adamo-types
v2.0.73-fix.0
Published
A types library for API communication agreement
Keywords
Readme
ADAMO TYPES
Summary
This is a package used for type definitions and interfaces for cross service I/O agreement The main purpose is to ensure a front end and backend complience of types when consuming APIs
Tenents
Summary
This is where specific api consumption type definitions are defined
- sys03
- web
- admin
- common
Sys03
Summary
Describes sys03 specific interfaces
Web
Summary
Describes web specific interfaces
Admin
Summary
Describes admind specific interfaces
User Creation within SYS03/Infonova
Creation Request
interface UserCreationDTO {
name: string
email: string
language: string
givenName: string
familyName: string
workGroupName: string
password: string
role: string
channel: string[]
salesman: boolean
}Creation Response
Common
Summary
Describes common interfaces between the various tenents
Login
login request
export interface UserLoginDTO {
username: string
password: string
}login response
export interface UserLoginAccessToken {
username: string
access_token: string
}access_token - is a JWT consisting of metadata related to the user that signed in:
- channels
- roles
- tenentPermissions
- iat
each
access_tokenis valid (currently) for 24 hours
example
try {
import { LoginRequest, LoginResponse } from 'adamo-types/common/login'
const data: UserLoginDTO = {
username: 'username',
password: 'password'
}
const response = await fetch('/v1/api/sys03/user/login', {
method: 'POST',
data
})
const loginResponse: UserLoginDTO = response.data
} catch(e: unknown) {
// do something incase of error
}How to publish to npm
Use npm run push instead of git push
This will execute these cmds git push && git push --no-verify && git push --tags --no-verify
git push: will push changes to the repository and will executepre-pushtrigger. Trigger: local_branch_name="$(git rev-parse --abbrev-ref HEAD)"
if [ "$local_branch_name" = "master" ]; then npm version patch // will update package.json version and git tags -> they have to be pushed to repository npm publish // will publish package to npm registry fi
git push --no-verify: will pushpackage.jsonto repository without executing the triggergit push --tags --no-verify: will push git tags to repository without executing the trigger
Use yalc for local develoment
There are some issues when ussig class-transformer and class-validator with npm link or npm install file:../adamo-types.
See these GitHub issues:
https://github.com/typestack/class-transformer/issues/313#issuecomment-667728916
https://github.com/typestack/class-transformer/issues/384
In order to get rid of this, you can use yalc for local development. For more information about yalc see this link.
- Install
yalcglobally with:
npm i -g yalcIt has to be installed globally because it creates a global folder where all packages are stored.
- Run script
start:yalcwith:
npm run start:yalcThis will execute:
concurrently --kill-others \"npm run start\" \"npm run yalc:watch\"concurrently is a packege installed like a dev dependency which will execute both scripts: npm run start and npm run yalc:watch. For more information about concurrently see this link.
npm run start will execute this script: nest build --watch. This script will watch your code changes and will build the project with every change you make.
npm run yalc:watch will execute the script: nodemon -w ./dist/tsconfig.build.tsbuildinfo -x \"yalc push --changed --replace --private\". This script will watch the file ./dist/tsconfig.build.tsbuildinfo, that will change with every build, and will execute this yalc script: yalc push --changed --replace --private.
yalc push --changed --replace --private will propagate your changes to all projects where this package is installed.
- Install
adamo-typesin your project with:
yalc link adamo-typesyalc link will create a symbolic link in node_modules to yalc directory where adamo-types is pushed. Also this link won't update your package.json file.
- Update your project
.gitignorewith:
# Yalc
/.yalc
yalc-build
yalc.lock