@enable-tech/enable-shared-types
v1.0.7
Published
This package represents the single source of truth of the Types being used in the codebase (front-end and back-end) of enable.tech, It is an organization-scoped package. So, all the development teams belonging to it can participate to enhance it.
Downloads
5
Readme
enable-shared-types
This package represents the single source of truth of the Types being used in the codebase (front-end and back-end) of enable.tech, It is an organization-scoped package. So, all the development teams belonging to it can participate to enhance it.
Installation
npm i @enable-tech/enable-shared-types
Usage
Right now the package contains the types of front-end apps (5 apps) exported as { CallCenterApp, CentralizedApp, EnableApp, OperationsManagementApp, PublicPagesApp } in "src/index.ts" so if we are working in the centralized app we are going to import CentralizedApp ony from it & access all the exported modules from it { FormModules, ApiModules } in "src/Types/CentralizedApp/index.ts"
Check the screenshot to see an example of how to use it
as you can see if you don't remember what is being exported in the CentralizedApp you can easily see what it included by dot notation & the autocomplete for TypeScript will result in 2 results so you can choose which one to use & proceed with destructing what you want to use from it In this example, I logged 2 values of the enum one of them is correct & the other is not just for testing
You can the code snippet directly if you want:
import { CentralizedApp } from '@enable-tech/enable-shared-types';
const {
FormModules: { Mode },
} = CentralizedApp;
console.log('Mode Enum', Mode.Add); // Correct Enum value
After a new version of the package is published you need to update it through the following command
npm update @enable-tech/enable-shared-types
Contributing
All the development team can contribute you would need to do the following steps
Clone the repo
git clone https://github.com/EButler-QA/enable-shared-types.git
Install the dependencies
npm install
If there is a new project we want to add the types of it, it shall be added to This directory 'src/Types' example: All the types of the centralized app (front-end app) are added to this directory 'src/Types/CentralizedApp' and all I want to export from it are included at 'src/Types/CentralizedApp/index.ts' Don't forget to export your new module at this file 'src/index.ts' as it represents the index to the package
Note: The back-end team & front-end teams are free to propose another architecture for exporting the modules if needed feel free to suggest any new ideas to enhance the package
After adding the new updates to the package you can use the scripts in the package.json file to make sure that everything is working fine before publishing
Run the following command to build the project
npm run prepare
Run the following command to make sure that there are no ESlint across the project (If there are any new errors fix them before publishing)
npm run prepublish
Note:
- The rules of ESlint are provided in this file '.eslintrc.cjs' so if you want to add any extra config feel free to do so
- In the '.eslintrc.cjs' file The following rule
is only added because there are explicit 'any' for some of the types that supposed to be typed by the schema of DTOs so once the back-end adds them we are going to remove this rule & follow strict types without 'any'rules: { '@typescript-eslint/no-explicit-any': ['off'], },
Run the following command to format all files using Prettier & add them to be committed
npm run version
Provide a new version
npm version <update_type>
The version of the package mainly would be represented as major.minor.patch so replace <update_type> with the equivalent example updating the patch would be
npm version patch
Finally, Publish it 🥳
npm publish
Author
Mayar Elabbasy