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

@huz-com/subscription-sdk

v1.0.16

Published

Subscription microservices can connect to huz api

Downloads

8

Readme

Huz.com / Subscription SDK

Subscription microservices can connect to huz api

Standards

  • Language: TS
  • Eslint: Yes
  • Static Code Analysis: Yes IntelliJ Code Inspections
  • DDD - Document Driven: Yes
  • EDD - Exception Driven: Yes
  • TDD - Test Driven: Yes go to simulate page
  • Standards Complied: Huz Standards

Commands

  • npm run clear // clears "dist" folder
  • npm run lint // runs eslint for static code analysis
  • npm run test // runs test files in "test" folder
  • npm run build // builds JS files at "dist" folder
  • npm publish or npm run publix // publishes "dist" folder to npm

Install

npm i @huz-com/subscription-sdk

Usage

Sample

import {connector, orderService, planService, profileService, projectService, subscriptionService, userService} from "@huz-com/subscription-sdk";


// Init system
await connector.initAsync({
    auth0Domain: 'auth0.com - domain',
    auth0Audience: 'auth0.com - audience',
    auth0ClientId: 'auth0.com - client-id',
    auth0ClientSecret: 'auth0.com - secret',
    apiInterval: 60 * 10, // as seconds, refresh token interval
    apiUrl: 'huz-api-url'
});

let projectDoc;

// get project by id
projectDoc = await projectService.getByIdAsync(req, 'project-id');


// get project by code
projectDoc = await projectService.getByCodeAsync(req, 'project-code');

let planDoc, planDocs;

// list assigned plans by project
planDocs = await planService.listAsync(req, 'project-id');

// get plan by id
planDoc = await planService.getByIdAsync(req, 'plan-id', 'project-id');

// get plan by code
planDoc = await planService.getByCodeAsync(req, 'plan-code', 'project-id');

let userDoc;

// get user by iam id
userDoc = await userService.getByIamId(req, 'iam-id');

// upsert user with iam-id and project id
userDoc = await userService.upsertAsync(req, 'iam-id', 'project-id', 'email-address');

// get user by id
userDoc = await userService.getByIdAsync(req, 'user-id');

let profileDoc;

// get profile by user and project
profileDoc = await profileService.getByUserAsync(req, 'user-id', 'project-id');

// upsert profile with user and project
profileDoc = await profileService.upsertAsync(req, 'user-id', 'project-id');

// get profile by id and project
profileDoc = await profileService.getByIdAsync(req, 'profile-id', 'project-id');

// log login history
profileDoc = await profileService.loginAsync(req, 'profile-id', 'reason');

// log logout history
profileDoc = await profileService.logoutAsync(req, 'profile-id', 'reason');

// subscribe to a subscription
profileDoc = await profileService.subscribeAsync(req, 'profile-id', 'subscription-id', 'reason');

// cancel current subscription of profile
profileDoc = await profileService.cancelSubscriptionAsync(req, 'profile-id', 'reason');

// unsubscribe from current subscription of profile
profileDoc = await profileService.unsubscribeAsync(req, 'profile-id', 'status', 'reason');

let subscriptionDoc, subscriptionDetailDoc, subscriptionDocs;

// get subscription of profile
subscriptionDoc = await subscriptionService.getByProfileAsync(req, 'profile-id');

// get subscription details of profile
subscriptionDetailDoc = await subscriptionService.getDetailedByProfileAsync(req, 'profile-id');

// get subscription by id
subscriptionDoc = await subscriptionService.getByIdAsync(req, 'subscription-id');

// create subscription
subscriptionDoc = await subscriptionService.createAsync(req, 'profile-id', 'plan-id', 'order-id', 'started-at');

// lists subscriptions of profile
subscriptionDocs = await subscriptionService.listAsync(req, 'profile-id');

// lists subscription history of profile
const historyItems = await subscriptionService.historyAsync(req, 'profile-id');

let orderDoc;

// create an order
orderDoc = await orderService.createAsync(req, 'profile-id', 'plan-id', {key1: 'value-1'});

// Assign a subscription to an order
orderDoc = await orderService.updateSubscriptionAsync(req, 'order-id', 'subscription-id', {key1: 'value-1'});

// Set order state as active
orderDoc = await orderService.setStatusActiveAsync(req, 'order-id', {key1: 'value-1'});

// Set order state as cancelled
orderDoc = await orderService.setStatusCancelAsync(req, 'order-id', {key1: 'value-1'});

// Set order state as idle
orderDoc = await orderService.setStatusIdleAsync(req, 'order-id', {key1: 'value-1'});

// Set order state as timeout
orderDoc = await orderService.setStatusTimeoutAsync(req, 'order-id', {key1: 'value-1'});

// Set order state as error
orderDoc = await orderService.setStatusErrorAsync(req, 'order-id', {key1: 'value-1'});

// Get order by id
orderDoc = await orderService.getByIdAsync(req, 'order-id');