Init
This commit is contained in:
commit
0029086b3f
148 changed files with 19047 additions and 0 deletions
3
shared/types/.eslintrc.js
Normal file
3
shared/types/.eslintrc.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
extends: ['../../.eslintrc.js'],
|
||||
};
|
33
shared/types/README.md
Normal file
33
shared/types/README.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Types
|
||||
|
||||
The types package is used for types that are used in multiple parts of the application. For example the API endpoint response type and the web front end that needs to handle the response type.
|
||||
|
||||
## Type Naming
|
||||
|
||||
Consider making names specific to their use case, such as including a response or endpoint name in the type names. E.g. `ApiNewUserResponse`.
|
||||
|
||||
## Working With Baseblocks
|
||||
|
||||
New types can be manually added to this folder. A Baseblock may also add new type files during its installation.
|
||||
|
||||
## Using Types in a Client
|
||||
|
||||
Add a new "include" to the client `tsconfig.json` (e.g. `packages/web/tsconfig.json`)
|
||||
|
||||
```
|
||||
"include": ["../../shared/types"]
|
||||
```
|
||||
|
||||
Add a new dependency to the client `package.json` (e.g. `packages/web/package.json`)
|
||||
|
||||
```
|
||||
"@baseline/types": "1.0.0",
|
||||
```
|
||||
|
||||
Referencing the type in code
|
||||
|
||||
```
|
||||
import { Admin } from '@baseline/types/admin';
|
||||
```
|
||||
|
||||
If you are having issues with your IDE showing this package as not existing attempt restarting your IDE TS Server and IDE ESLint Server.
|
4
shared/types/admin.d.ts
vendored
Normal file
4
shared/types/admin.d.ts
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
export interface Admin {
|
||||
userSub: string;
|
||||
userEmail: string;
|
||||
}
|
19
shared/types/chart.ts
Normal file
19
shared/types/chart.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import * as Yup from 'yup';
|
||||
|
||||
export interface Chart {
|
||||
chartId: string;
|
||||
md5: string;
|
||||
sha256: string;
|
||||
resourceUri?: string;
|
||||
parentChart?: string;
|
||||
name: string;
|
||||
comment?: string;
|
||||
}
|
||||
|
||||
export const chartSchema = Yup.object().shape({
|
||||
name: Yup.string().required(),
|
||||
md5: Yup.string().required(),
|
||||
sha256: Yup.string().required(),
|
||||
resourceUri: Yup.string(),
|
||||
comment: Yup.string(),
|
||||
});
|
12
shared/types/package.json
Normal file
12
shared/types/package.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "@baseline/types",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"lint": "npx eslint --config '.eslintrc.js' '**/*.{ts,tsx,js}'",
|
||||
"pretty": "npx prettier --write '*.{ts,tsx,d.ts,js,json,css,scss,md,yml,yaml,html}'"
|
||||
},
|
||||
"dependencies": {
|
||||
"yup": "^1.4.0"
|
||||
}
|
||||
}
|
10
shared/types/paging.d.ts
vendored
Normal file
10
shared/types/paging.d.ts
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
export interface PagedResponse<T> {
|
||||
data?: T[];
|
||||
pagination: {
|
||||
limit: number;
|
||||
totalRecords: number;
|
||||
nextFrom?: number;
|
||||
pages: number;
|
||||
currentPage: number;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue