mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-18 21:16:31 +00:00
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/hay-kot/content/backend/internal/types"
|
|
"github.com/hay-kot/content/backend/pkgs/automapper"
|
|
"github.com/tkrajina/typescriptify-golang-structs/typescriptify"
|
|
)
|
|
|
|
// generateMappers serialized the config file into a list of automapper struct
|
|
func generateMappers() []automapper.AutoMapper {
|
|
return []automapper.AutoMapper{}
|
|
}
|
|
|
|
func generateTypeScript() {
|
|
// Configuration
|
|
converter := typescriptify.New()
|
|
converter.CreateInterface = true
|
|
converter.ManageType(uuid.UUID{}, typescriptify.TypeOptions{TSType: "string"})
|
|
converter.ManageType(time.Time{}, typescriptify.TypeOptions{TSType: "Date", TSTransform: "new Date(__VALUE__)"})
|
|
|
|
// General
|
|
public := []any{
|
|
// Base Types
|
|
types.ApiSummary{},
|
|
|
|
// User Types
|
|
types.UserCreate{},
|
|
types.UserIn{},
|
|
types.UserUpdate{},
|
|
|
|
// Auth Types
|
|
types.LoginForm{},
|
|
types.TokenResponse{},
|
|
}
|
|
|
|
for i := 0; i < len(public); i++ {
|
|
converter.Add(public[i])
|
|
}
|
|
|
|
// Creation
|
|
converter.ConvertToFile("./generated-types.ts")
|
|
|
|
}
|
|
|
|
func main() {
|
|
automappers := generateMappers()
|
|
conf := automapper.DefaultConf()
|
|
|
|
automapper.Generate(automappers, conf)
|
|
|
|
generateTypeScript()
|
|
}
|