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

@affixapi/connect-sdk

v1.0.8

Published

[![codecov](https://codecov.io/gh/affixapi/connect-sdk/branch/master/graph/badge.svg?token=JJjrZxvxlU)](https://codecov.io/gh/affixapi/connect-sdk) [![NPM](https://img.shields.io/npm/v/@affixapi/connect-sdk.svg)](https://www.npmjs.com/package/@affixapi/co

Downloads

47

Readme

connect-sdk

codecov NPM

Install

npm install --save @affixapi/connect-sdk

Usage

typescript

import React, { useState } from 'react';
import { useConnect } from '@affixapi/connect-sdk';

const App = () => {
  const [authorizationCode, setAuthorizationCode] = useState<string | null>(
    null
  );
  const [state, setState] = useState<string | null>();

  const onSuccess = ({
    authorizationCode,
    state,
  }: {
    authorizationCode: string;
    state?: string;
  }): void => {
    setAuthorizationCode(authorizationCode);
    if (state) setState(state);
  };
  const onError = ({ errorMessage }: { errorMessage: string }) =>
    console.error({ errorMessage });
  const onClose = () => console.log('User exited Connect');

  const { open } = useConnect({
    clientId: '<your-client-id>',
    scopes: [
      // remove any you don't need
      '/2023-03-01/xhr/company',
      '/2023-03-01/xhr/employee',
      '/2023-03-01/xhr/employees',
      '/2023-03-01/xhr/groups',
      '/2023-03-01/xhr/identity',
      '/2023-03-01/xhr/payruns',
      '/2023-03-01/xhr/payruns/:payrun_id',
      '/2023-03-01/xhr/time-off-balances',
      '/2023-03-01/xhr/time-off-entries',
      '/2023-03-01/xhr/timesheets',
      '/2023-03-01/xhr/work-locations',
    ],
    mode: 'xhr',
    // provider: 'bamboohr', // optional param, will skip the provider selector page if set
    // sandbox: true, // if this flag is enabled, `provider` needs to be `provider: sandbox` above
    // state: '00000000-0000-0000-0000-000000000000', // optional - usually your internal identifier of a customer
    onSuccess,
    onError,
    onClose,
  });

  return (
    <div>
      <header>
        <p>Authorization Code: {authorizationCode}</p>
        <p>State (optional): {state}</p>
        <button type="button" onClick={() => open()}>
          open connect
        </button>
      </header>
    </div>
  );
};

javascript

import React, { useState } from 'react';
import { useConnect } from '@affixapi/connect-sdk';

const App = () => {
  const [authorizationCode, setAuthorizationCode] = useState(null);
  const [state, setState] = useState();

  const onSuccess = ({ authorizationCode, state }: {
    authorizationCode: string,
    state?: string
  }): void => {
    setAuthorizationCode(authorizationCode);
    if (state) setState(state);
  }
  const onError = ({ errorMessage }) => console.error(errorMessage);
  const onClose = () => console.log('User exited Connect');

  const { open } = useConnect({
    clientId: '<your-client-id>',
    scopes: [
      // remove any you don't need
      '/2023-03-01/xhr/company',
      '/2023-03-01/xhr/employee',
      '/2023-03-01/xhr/employees',
      '/2023-03-01/xhr/groups',
      '/2023-03-01/xhr/identity',
      '/2023-03-01/xhr/payruns',
      '/2023-03-01/xhr/payruns/:payrun_id',
      '/2023-03-01/xhr/time-off-balances',
      '/2023-03-01/xhr/time-off-entries',
      '/2023-03-01/xhr/timesheets',
      '/2023-03-01/xhr/work-locations',
    ],
    mode: 'xhr',
    // provider: 'bamboohr', // optional param, will skip the provider selector page if set
    // sandbox: true, // if this flag is enabled, `provider` needs to be `provider: sandbox` above
    // state: '00000000-0000-0000-0000-000000000000', // optional - usually your internal identifier of a customer
    onSuccess,
    onError,
    onClose,
  });

  return (
    <div>
      <header>
        <p>Authorization Code: {authorizationCode}</p>
        <p>State (optional): {state}</p>
        <button type="button" onClick={() => open()}>
          open affixapi connect
        </button>
      </header>
    </div>
  );
};

create the sdk

for affixapi engineer's reference only

in project root,

npm start

for local development,

example/index.tsx:

import { createRoot } from 'react-dom/client';
import React, { useState } from 'react';
// import { useConnect } from '@affixapi/connect-sdk'; <<< comment

import { useConnect } from '../src/index'; // for local testing <<< uncomment

in seperate shell,

cd example
npm start

server is now running on http://localhost:1234

troubleshooting:

  • make sure to restart the vite server after making the comment change