diff --git a/README.md b/README.md
index 0dd555d..5800c0f 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,7 @@
+
+
+
+
# Breinify’s React API Library
@@ -21,15 +25,15 @@ It is recommended to use signed messages when utilizing the react library. A sig
#### utakxp7sm6weo5gvk7cytw==
### Installing
-The library is available on [npm](https://www.npmjs.com/package/brein-react-api-library-react) and can be added using:
+The library is available on [npm](https://www.npmjs.com/package/breinify-react) and can be added using:
```bash
-npm i brein-react-api-library-react --save
+npm i breinify-react
```
### Configuring the Library
Whenever the library is used, it needs to be configured, i.e., the configuration defines which API key and which secret (if signed messages are enabled, i.e., `Verification Signature` is checked) to use. Please place `BreinifySetup` on the top most section of your application.
**Warning: Only call BreinSetup once in your application!**
```tsx
-import { BreinifySetup } from 'brein-api-library-react';
+import { BreinifySetup } from 'breinify-react';
const apiKey = '938D-3120-64DD-413F-BB55-6573-90CE-473A';
const secret = 'utakxp7sm6weo5gvk7cytw==';
diff --git a/docs/recommendations/recommendations.md b/docs/recommendations/recommendations.md
index ced64ed..d709911 100644
--- a/docs/recommendations/recommendations.md
+++ b/docs/recommendations/recommendations.md
@@ -54,7 +54,7 @@ getRecs({user, unixTimestamp, signature, recommendation, recommendations}: Recom
#### Example
```tsx
-import { useRecommendations } from "brein-api-library-react";
+import { useRecommendations } from "breinify-react";
export function TestContainer() {
const { getRecs, data, isInit, isLoading, isSuccess, isFailure, error } =
@@ -172,7 +172,7 @@ Our Carousel extends [react-slick](https://react-slick.neostack.com/docs/api).
#### Example
```tsx
import React from "react";
-import { Carousel } from "brein-api-library-react";
+import { Carousel } from "breinify-react";
export const CarouselTest = () => {
return (
diff --git a/package-lock.json b/package-lock.json
index 32e6a78..7c74aa4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,11 +1,11 @@
{
- "name": "brein-api-library-react",
+ "name": "breinify-react",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
- "name": "brein-api-library-react",
+ "name": "breinify-react",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
@@ -50,6 +50,7 @@
"react-dom": "^18.0.0",
"react-test-renderer": "^18.0.0",
"rollup": "^2.75.7",
+ "rollup-plugin-dts": "^4.2.2",
"rollup-plugin-import-css": "^3.0.3",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.2",
@@ -26708,6 +26709,40 @@
"fsevents": "~2.3.2"
}
},
+ "node_modules/rollup-plugin-dts": {
+ "version": "4.2.2",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-4.2.2.tgz",
+ "integrity": "sha512-A3g6Rogyko/PXeKoUlkjxkP++8UDVpgA7C+Tdl77Xj4fgEaIjPSnxRmR53EzvoYy97VMVwLAOcWJudaVAuxneQ==",
+ "dev": true,
+ "dependencies": {
+ "magic-string": "^0.26.1"
+ },
+ "engines": {
+ "node": ">=v12.22.11"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/Swatinem"
+ },
+ "optionalDependencies": {
+ "@babel/code-frame": "^7.16.7"
+ },
+ "peerDependencies": {
+ "rollup": "^2.55",
+ "typescript": "^4.1"
+ }
+ },
+ "node_modules/rollup-plugin-dts/node_modules/magic-string": {
+ "version": "0.26.2",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.2.tgz",
+ "integrity": "sha512-NzzlXpclt5zAbmo6h6jNc8zl2gNRGHvmsZW4IvZhTC4W7k4OlLP+S5YLussa/r3ixNT66KOQfNORlXHSOy/X4A==",
+ "dev": true,
+ "dependencies": {
+ "sourcemap-codec": "^1.4.8"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/rollup-plugin-import-css": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/rollup-plugin-import-css/-/rollup-plugin-import-css-3.0.3.tgz",
@@ -51402,6 +51437,27 @@
"fsevents": "~2.3.2"
}
},
+ "rollup-plugin-dts": {
+ "version": "4.2.2",
+ "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-4.2.2.tgz",
+ "integrity": "sha512-A3g6Rogyko/PXeKoUlkjxkP++8UDVpgA7C+Tdl77Xj4fgEaIjPSnxRmR53EzvoYy97VMVwLAOcWJudaVAuxneQ==",
+ "dev": true,
+ "requires": {
+ "@babel/code-frame": "^7.16.7",
+ "magic-string": "^0.26.1"
+ },
+ "dependencies": {
+ "magic-string": {
+ "version": "0.26.2",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.2.tgz",
+ "integrity": "sha512-NzzlXpclt5zAbmo6h6jNc8zl2gNRGHvmsZW4IvZhTC4W7k4OlLP+S5YLussa/r3ixNT66KOQfNORlXHSOy/X4A==",
+ "dev": true,
+ "requires": {
+ "sourcemap-codec": "^1.4.8"
+ }
+ }
+ }
+ },
"rollup-plugin-import-css": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/rollup-plugin-import-css/-/rollup-plugin-import-css-3.0.3.tgz",
diff --git a/package.json b/package.json
index b9fb652..21a709b 100644
--- a/package.json
+++ b/package.json
@@ -1,8 +1,9 @@
{
"name": "breinify-react",
- "version": "1.0.0",
+ "version": "1.0.1",
"description": "React Library for the Breinify API",
"main": "dist/cjs/index.js",
+ "types": "dist/index.d.ts",
"module": "dist/esm/index.js",
"scripts": {
"build": "rollup --config",
@@ -16,13 +17,16 @@
"type": "git",
"url": "git+https://github.com/Breinify/brein-api-library-react.git"
},
- "files": ["dist/*"],
+ "files": [
+ "dist/*",
+ "src"
+ ],
"keywords": [],
"authors": [
"Alvin Kwong ",
"Timothy Yue "
],
- "license": "ISC",
+ "license": "MIT",
"bugs": {
"url": "https://github.com/Breinify/brein-api-library-react/issues"
},
@@ -73,6 +77,7 @@
"react-dom": "^18.0.0",
"react-test-renderer": "^18.0.0",
"rollup": "^2.75.7",
+ "rollup-plugin-dts": "^4.2.2",
"rollup-plugin-import-css": "^3.0.3",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.2",
diff --git a/rollup.config.js b/rollup.config.js
index 383416d..69c9f1c 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -6,6 +6,7 @@ import { terser } from 'rollup-plugin-terser';
import external from 'rollup-plugin-peer-deps-external';
import visualizer from 'rollup-plugin-visualizer';
import postcss from 'rollup-plugin-postcss';
+import dts from 'rollup-plugin-dts';
const PLUGINS = [
external(),
@@ -19,21 +20,32 @@ const PLUGINS = [
const pkg = require('./package.json');
-export default {
- input: 'src/index.ts',
- output: [
- {
- file: pkg.main,
- format: 'cjs',
- sourcemap: true,
- name: 'react-lib',
- },
- {
- file: pkg.module,
+export default [
+ {
+ input: 'src/index.ts',
+ output: [
+ {
+ file: pkg.main,
+ format: 'cjs',
+ sourcemap: true,
+ name: 'react-lib',
+ },
+ {
+ file: pkg.module,
+ format: 'esm',
+ sourcemap: true,
+ },
+ ],
+ plugins: [...PLUGINS, terser()],
+ external: ['react', 'react-dom'],
+ },
+ {
+ input: 'dist/esm/types/index.d.ts',
+ output: {
+ file: pkg.types,
format: 'esm',
- sourcemap: true,
},
- ],
- plugins: [...PLUGINS, terser()],
- external: ['react', 'react-dom'],
-};
+ external: [/\.(scss|css)$/],
+ plugins: [dts()],
+ },
+];
diff --git a/src/index.ts b/src/index.ts
index d59ee59..ce5bf00 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -3,3 +3,4 @@ export * from './configs';
export * from './setup';
export * from './hooks';
export * from './components';
+export * from './types';
diff --git a/src/setup/setup.test.ts b/src/setup/setup.test.ts
index ca02167..0637ab0 100644
--- a/src/setup/setup.test.ts
+++ b/src/setup/setup.test.ts
@@ -72,13 +72,4 @@ describe('Setup functions', () => {
expect(() => Setup.BreinifySetup(ARRAY as any)).toThrow();
expect(() => Setup.BreinifySetup(NUMBER as any)).toThrow();
});
-
- test('should throw when trying to change BreinifyGlobalConfigs', () => {
- const Setup = require('./setup');
- const API_KEY = 'API_KEY';
- Setup.BreinifySetup({ apiKey: API_KEY });
-
- expect(() => (Setup.BreinifyGlobalConfigs.apiKey = 'apiKey')).toThrow();
- expect(() => (Setup.BreinifyGlobalConfigs.secret = 'secret')).toThrow();
- });
});
diff --git a/src/setup/setup.ts b/src/setup/setup.ts
index 81599dd..07d3e8f 100644
--- a/src/setup/setup.ts
+++ b/src/setup/setup.ts
@@ -16,7 +16,6 @@ export function BreinifySetup({ apiKey, secret }: SetupProps): void {
if (secret && !isString(secret)) throw 'Secret needs to be a string';
BreinifyGlobalConfigs.apiKey = apiKey;
BreinifyGlobalConfigs.secret = secret;
- Object.freeze(BreinifyGlobalConfigs);
}
// Checks if BreinifySetup is complete
diff --git a/tsconfig.json b/tsconfig.json
index af01c49..e5d9270 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -11,5 +11,8 @@
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"baseUrl": ".",
+ "declaration": true,
+ "outDir": "types",
+ "emitDeclarationOnly": true
}
}