memori-api-client
TypeScript client to integrate with Memori API.
Installation
yarn add @memori.ai/memori-api-client
npm install @memori.ai/memori-api-client
Usage
Every method has JSDoc annotations with usage and description and typings information.
See examples for Node (TypeScript) and React.
import memoriApiClient from '@memori.ai/memori-api-client';
const memori = memoriApiClient('https://backend.memori.ai');
(async () => {
const { sessionID, currentState, ...response } = await memori.initSession(
'768b9654-e781-4c3c-81fa-ae1529d1bfbe'
);
const {
currentState: dialogState,
...resp
} = await memori.postTextEnteredEvent(sessionID, 'Ciao, Memori!');
})();
For the specification of the APIs, see the typings or the documentation from the dashboard if you are allowed to see it.
Constants
import memoriApiClient from '@memori.ai/memori-api-client';
const memori = memoriApiClient('https://backend.memori.ai');
memori.constants.allowedMediaTypes;
memori.constants.anonTag;
Asset
There is a helper method parsing media urls from the DB, handling different cases
const memori = memoriApiClient('https://backend.memori.ai');
memori.asset.getResourceUrl({
type: 'avatar',
resourceURI: '768b9654-e781-4c3c-81fa-ae1529d1bfbe.png',
mediaType: 'image/png',
sessionId: 'be2e4a44-890b-483b-a26a-f6e122f36e2b',
});
Development
To run TSDX, use:
npm start
This builds to /dist
and runs the project in watch mode so any edits you save inside src
causes a rebuild to /dist
.
To do a one-off build, use npm run build
or yarn build
.
To run tests, use npm test
or yarn test
.
Formatting and linting
Code quality is set up with prettier
, husky
, and lint-staged
.
You can run prettier with npm format
or yarn format
.
You can run linter with npm lint
or yarn lint
.
You can run type checking with npm typecheck
or yarn typecheck
.
Jest
Jest tests are set up to run with npm test
or yarn test
.
Bundle Analysis
size-limit
is set up to calculate the real cost of your library with npm run size
and visualize the bundle with npm run analyze
.
Rollup
TSDX uses Rollup as a bundler and generates multiple rollup configs for various module formats and build settings. See Optimizations for details.
TypeScript
tsconfig.json
is set up to interpret dom
and esnext
types, as well as react
for jsx
.
You can run type checking with npm typecheck
or yarn typecheck
.
Continuous Integration
GitHub Actions
Two actions are added by default:
main
which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrixsize
which comments cost comparison of your library on every pull request using size-limit
Optimizations
Please see the main tsdx
optimizations docs. In particular, know that you can take advantage of development-only optimizations:
declare var __DEV__: boolean;
if (__DEV__) {
console.log('foo');
}
You can also choose to install and use invariant and warning functions.
Module Formats
CJS, ESModules, and UMD module formats are supported.
The appropriate paths are configured in package.json
and dist/index.js
accordingly. Please report if any issues are found.
Commitlint
We use commmitlint for commit message validation based on Conventional Commits.
Release
Changelog and release management with release-it, using convential changelog.