@demity/demity-common
v1.0.10
Published
A TypeScript library providing shared models, types, and utilities for the Demity platform. This library is designed to simplify type sharing between projects such as `buyer-mobile`, `seller-web`, `buyer-web`, and others, ensuring consistency and mainta
Readme
demity-common
A TypeScript library providing shared models, types, and utilities for the Demity platform.
This library is designed to simplify type sharing between projects such as buyer-mobile, seller-web, buyer-web,
and others, ensuring consistency and maintainability.
Here is the link to the Demity NPM package: https://www.npmjs.com/package/demity-common
Features
- Shared TypeScript models for sellers, products, claims, recalls, warranties, and more.
- Lightweight and reusable library designed for seamless integration across Demity projects.
- Published as an NPM package for easy consumption.
Local Setup
Prerequisites
- Node.js
v16+ - NPM
v8+or Yarn
Clone the Repository
git clone https://github.com/demity/demity-common.git
cd demity-commonInstall Dependencies
npm installRun the TypeScript Compiler
To ensure the code compiles correctly:
npm run buildThis will generate the compiled .js and .d.ts files in the dist/ directory.
Deployment
Automated Deployment via GitHub Actions
The library is configured for automated deployment using GitHub Actions. On every push to the main branch:
- The version is automatically incremented (patch-level).
- The library is built and published to NPM.
Using the Library in Another Project
Install the Library
Install the library in your project via NPM:
npm install demity-commonExample Usage
Import the models or types into your project as needed.
Example: Using in a React Component
import { Seller, Product } from 'demity-common';
const seller: Seller = {
id: "123",
name: "John Doe",
email: "[email protected]",
};
const product: Product = {
id: "456",
name: "Extended Warranty",
price: 99.99,
stock: 50,
};
export default function SellerInfo() {
return (
<div>
<h1>{seller.name}</h1>
<p>Email: {seller.email}</p>
<p>Product: {product.name}</p>
</div>
);
}Contributing
We welcome contributions to improve the demity-common library! Follow these steps to get started:
1. Fork the Repository
- Fork this repository to your GitHub account.
- Clone your forked repository:
git clone https://github.com/your-username/demity-common.git cd demity-common
2. Create a Feature Branch
git checkout -b feature/your-feature-name3. Make Your Changes
- Add or update types, models, or utilities in the
srcdirectory. - Write corresponding tests (if applicable).
4. Test Your Changes
- Build the library to ensure everything compiles correctly:
npm run build - Run any unit tests (if available):
npm test
5. Commit and Push
git add .
git commit -m "feat: add [your feature]"
git push origin feature/your-feature-name6. Create a Pull Request
- Open a pull request from your feature branch to the
mainbranch of the original repository. - Provide a clear description of your changes and their purpose.
This README provides detailed information for setting up, deploying, using, and contributing to the library. Let me know if you'd like to modify any section further!
