Init
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "@telemt/shared",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"files": ["dist", "package.json"],
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsup src/index.ts --format esm --dts",
|
||||
"dev": "tsup src/index.ts --format esm --dts --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"zod": "^3.25.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsup": "^8.5.0",
|
||||
"typescript": "^5.9.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const PANEL_MODES = ['standalone', 'fleet'] as const
|
||||
export type PanelMode = (typeof PANEL_MODES)[number]
|
||||
|
||||
export const loginRequestSchema = z.object({
|
||||
username: z.string().min(1),
|
||||
password: z.string().min(1),
|
||||
})
|
||||
|
||||
export const loginResponseSchema = z.object({
|
||||
accessToken: z.string(),
|
||||
operator: z.object({
|
||||
id: z.string(),
|
||||
username: z.string(),
|
||||
role: z.string(),
|
||||
}),
|
||||
panelMode: z.enum(PANEL_MODES),
|
||||
})
|
||||
|
||||
export type LoginRequest = z.infer<typeof loginRequestSchema>
|
||||
export type LoginResponse = z.infer<typeof loginResponseSchema>
|
||||
|
||||
export const telemtProxyRequestSchema = z.object({
|
||||
method: z.enum(['GET', 'POST', 'PATCH', 'DELETE']).default('GET'),
|
||||
path: z.string().min(1),
|
||||
body: z.unknown().optional(),
|
||||
ifMatch: z.string().optional(),
|
||||
})
|
||||
|
||||
export type TelemtProxyRequest = z.infer<typeof telemtProxyRequestSchema>
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"noEmit": false,
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": false,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
Reference in New Issue
Block a user