1.14.4 • Published 10 months ago

@inploi/sdk v1.14.4

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

@inploi/sdk

This package contains the core functionality for the inploi SDK.

Installation

npm install @inploi/sdk

Usage

You can initialise the SDK by calling initialiseInploiSdk with the following options:

import { initialiseInploiSdk } from '@inploi/sdk';

const sdk = initialiseInploiSdk({
	publishableKey: 'your-publishable-key',
	env: 'sandbox',
});

Plugins

You can write custom plugins via the createPlugin function. The plugin will have two dependencies injected: a logger service and a an apiClient service, which can be used to make requests to the inploi API.

Example:

export const myCounterPlugin = createPlugin(({ logger, apiClient }) => {
	let count = 0;
	logger.info('myCounterPlugin initialised');

	return {
		add: () => {
			count++;
			logger.info(`count is now ${count}`);
		},
		getCount: () => count,
	};
});

External dependencies

If your plugin requires external dependencies, you may want to wrap the createPlugin function with whatever it takes, to then generate a function that returns a plugin:

import { createPlugin } from '@inploi/sdk';

type CounterExternalDeps = {onUpdate: (newCounter: number) => void};

export const myCounterPlugin = ({onUpdate}: CounterExternalDeps) =>
  createPlugin(({ logger, apiClient }) => {
    let count = 0;
    logger.info('myCounterPlugin initialised');

    return {
      add: () => {
        count++;
        logger.info(`count is now ${count}`);
        onUpdate(count);
      },
      getCount: () => count,
    };
  });

Using plugins

Users of the SDK may invoke sdk.registerPlugin with a plugin to register it. The plugin will be initialised with the dependencies it requires, and the returned object will be returned to the user.

const sdk = initialiseInploiSdk({
	publishableKey: 'your-publishable-key',
	env: 'sandbox',
});

const mySimplePlugin = sdk.registerPlugin(mySimplePlugin);

const myCounterPlugin = sdk.registerPlugin(myPluginWithDeps({ onUpdate: newCounter => console.log(newCounter) }));

myCounterPlugin.add();
1.14.1

10 months ago

1.14.0

11 months ago

1.14.4

10 months ago

1.14.3

10 months ago

1.14.2

10 months ago

1.13.5

11 months ago

1.13.4

11 months ago

1.12.3

1 year ago

1.12.4

1 year ago

1.13.2

12 months ago

1.13.1

12 months ago

1.13.0

1 year ago

1.13.3

11 months ago

1.12.2

1 year ago

1.12.1

1 year ago

1.12.0

1 year ago

1.11.4

1 year ago

1.11.3

1 year ago

1.11.2

1 year ago

1.11.1

1 year ago

1.11.0

1 year ago

1.10.0

1 year ago

1.8.0

1 year ago

1.9.0

1 year ago

1.7.6

1 year ago

1.7.5

1 year ago

1.7.4

2 years ago

1.7.3

2 years ago

1.7.2

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.6

2 years ago

1.4.5

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

1.2.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago