entkit

package module
v2.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

README

EntKit

A Comprehensive Solution for Building Data-Driven Applications with Ease and Efficiency

GitHub license GitHub stars GitHub release (latest by date) Go Report Card codecov

Documentation | GoDoc | Example project | Live demo

Live demo credentials

  • username: entuser
  • password: entuser

logo-color.svg

EntKit: Leveraging the Power of React, Refine, and AntDesign for Simplified UI Generation and Database Interaction

Introduction

Efficient tools play a vital role in the world of software development, streamlining workflows, and enhancing productivity. EntKit is a powerful framework designed to automatically generate UI components, server environments, and TypeScript definitions based on your database schema, simplifying UI creation and database interaction. With its integration with React, Refine, AntDesign, and Keycloak, EntKit delivers an end-to-end solution for building and deploying data-driven applications effortlessly.

EntKit: A React-Based Framework for Streamlined UI Development and Database Interaction

EntKit is an innovative framework that simplifies UI development by automatically generating React-based UI components, server environments, and TypeScript definitions using your database schema. EntKit utilizes the Refine framework, AntDesign components, and supports GraphQL API, providing a comprehensive solution for developers to build and deploy data-driven applications with ease.

Key Features of EntKit

  1. Auto-generation of UI Components and TypeScript Definitions EntKit's primary feature is the automatic generation of React-based UI components and TypeScript definitions based on a given database schema. The framework leverages the power of the Refine framework and AntDesign components, resulting in a functional and visually appealing user interface for your application.

  2. Based on Ent Framework and GraphQL API Support EntKit is built on top of the Ent framework and supports GraphQL API, ensuring a seamless and efficient interaction between the frontend and backend of your application.

  3. Authentication and Authorization with Keycloak EntKit provides robust authentication and authorization support by integrating with Keycloak. Support for other authentication providers like Casbin, Auth0, and more is expected to be added soon, offering developers more options for securing their applications.

  4. Generated Server for Development and Production Environments EntKit goes beyond UI generation by also generating servers for development and production environments. This feature simplifies the deployment process and helps developers maintain a consistent server configuration across various stages of their projects.

  5. Docker Image Generation for Applications EntKit supports generating Docker images for your applications, making it easier to manage and deploy your projects in containerized environments. This feature ensures consistent behavior across different platforms and allows for seamless scalability.

  6. Powerful CLI for Easy Development and Deployment EntKit's powerful Command Line Interface (CLI) streamlines the development and deployment process, enabling developers to efficiently manage their projects from start to finish. The CLI offers various commands to generate UI components, manage servers, and deploy applications.

Idea and target

EntKit is a groundbreaking framework that significantly simplifies UI development and database interaction by leveraging the power of React, Refine, AntDesign, and Keycloak. Its features, including the automatic generation of UI components, server environments, TypeScript definitions, and robust authentication support, provide developers with a comprehensive solution for building and deploying data-driven applications. By automating key aspects of the development process, EntKit allows developers to focus on more critical aspects of their projects, resulting in increased productivity and more efficient software development cycles.

Roadmap

  • Generates CRUD operations based on Ent definitions
  • Customizable views for each CRUD operation
  • Customizable fields for lists, forms, and show views using annotations
  • Custom actions for items
    • Actions on a list, show, or edit view that trigger a GraphQL mutation.
    • Bulk actions on lists
  • Relational view with nested lists and edges
  • Smart search component to find records by every attribute with a custom operator
  • Uses only a Graphql API with a custom Refine data-provider
  • Generates TypeScript types from Ent definitions
  • Column filters with customizable operators
  • Edges diagram graph view
  • Nested create/edit
    • Ability to create edges from form
    • Ability to edit edges from form
  • I18n support
  • Keycloak Authentication
  • Keycloak Authorization
  • Generate server with CLI
  • Generate multiple UIs with different configurations
  • Filter by edges
  • Sort by edges
  • Godoc: provide comprehensive documentation

Contacts

Linkedin: https://www.linkedin.com/in/aaron-yor/

Discord: aaron․yordanyan#7556

Phone: +374 98 471111

Documentation

Index

Constants

View Source
const AnnotationKey = "ENTKIT"

Variables

View Source
var (
	// ListAction standard list action
	ListAction = NewAction(
		"list",
		ActionAsGeneral(),
		ActionWithLabel("List"),
		ActionWithScope(ActionReadScope),
		ActionWithIcon("AntdIcons.UnorderedListOutlined"),
		ActionDisplayOn("show", "edgesDiagram"),
		ActionWithRoute(NewRoute("/", "List.{name}List", RouteAsIndex())),
	)
	// EditAction standard edit action
	EditAction = NewAction(
		"edit",
		ActionWithLabel("Edit"),
		ActionWithScope(ActionUpdateScope),
		ActionWithRoute(NewRoute("edit/:id", "Edit.{name}Edit")),
		ActionWithIcon("AntdIcons.EditOutlined"),
		ActionDisplayOn("list", "show", "edgesDiagram"),
	)
	// CreateAction standard create action
	CreateAction = NewAction(
		"create",
		ActionAsGeneral(),
		ActionWithLabel("Create"),
		ActionWithScope(ActionCreateScope),
		ActionWithIcon("AntdIcons.PlusCircleOutlined"),
		ActionWithRoute(NewRoute("create", "Create.{name}Create")),
		ActionDisplayOn("list"),
	)
	// ShowAction standard show action
	ShowAction = NewAction(
		"show",
		ActionWithLabel("Show"),
		ActionWithScope(ActionReadScope),
		ActionWithIcon("AntdIcons.EyeOutlined"),
		ActionWithRoute(NewRoute("show/:id", "Show.{name}MainShow")),
		ActionDisplayOn("list", "edit", "edgesDiagram"),
	)
	// DeleteAction standard delete action
	DeleteAction = NewAction(
		"delete",
		ActionWithLabel("Delete"),
		ActionWithScope(ActionDeleteScope),
		ActionWithIcon("AntdIcons.DeleteOutlined"),
		ActionWithProps(map[string]any{
			"danger": true,
		}),
		ActionDisplayOn("list", "show", "edgesDiagram"),
		ActionWithOperation(NewOperation(
			"delete",
			OperationAsBulk(),
			OperationAsMutation(),
		)),
	)
	// EdgesDiagramAction edges diagram action (optional)
	EdgesDiagramAction = NewAction(
		"edgesDiagram",
		ActionWithLabel("Edges Diagram"),
		ActionWithScope(ActionReadScope),
		ActionWithIcon("AntdIcons.ClusterOutlined"),
		ActionWithRoute(NewRoute("edges/:id", "EdgesDiagram.{name}EdgesDiagram")),
		ActionDisplayOn("show", "edit"),
	)
	DefaultActions = []*Action{
		ShowAction, ListAction, CreateAction, EditAction, DeleteAction,
	}
)
View Source
var (
	ActionReadScope     = "Read"
	ActionCreateScope   = "Create"
	ActionUpdateScope   = "Update"
	ActionDeleteScope   = "Delete"
	DefaultActionScopes = []string{
		ActionReadScope,
		ActionCreateScope,
		ActionUpdateScope,
		ActionDeleteScope,
	}
)
View Source
var AuthContextKey = "entkit_auth_context"
View Source
var DefaultEnvironmentAdapter = EnvironmentAdapter{}

DefaultEnvironmentAdapter main struct

View Source
var DefaultRefineAdapter = Refine{}
View Source
var DefaultServerAdapter = ServerAdapter{}
View Source
var DefaultTypescriptAdapter = TypescriptAdapter{}

Functions

func BoolP

func BoolP(value bool) *bool

BoolP returns a pointer of a boolean variable

func Contains

func Contains[T comparable](s []T, e T) bool

Contains checks if slice contains element

func GenerateAuthResourcesHook

func GenerateAuthResourcesHook(ex *Extension) gen.Hook

func GeneratorHook

func GeneratorHook(ex *Extension) gen.Hook

func Int32P

func Int32P(value int32) *int32

Int32P returns a pointer of an int32 variable

func Int64P

func Int64P(value int64) *int64

Int64P returns a pointer of an int64 variable

func IntP

func IntP(value int) *int

IntP returns a pointer of an integer variable

func NewEntgqlExtension

func NewEntgqlExtension(opts ...entgql.ExtensionOption) (*entgql.Extension, error)

func PBool

func PBool(value *bool) bool

PBool returns a boolean value from a pointer

func PInt

func PInt(value *int) int

PInt returns an integer value from a pointer

func PInt32

func PInt32(value *int32) int32

PInt32 returns an int32 value from a pointer

func PInt64

func PInt64(value *int64) int64

PInt64 returns an int64 value from a pointer

func PString

func PString(value *string) string

PString returns a string value from a pointer

func StringP

func StringP(value string) *string

StringP returns a pointer of a string variable

Types

type Action

type Action struct {
	Name            *string         `json:"Name,omitempty"`            // Name of action (Required)
	General         *bool           `json:"General,omitempty"`         // Mark action as general (independent of record) (e.g. create, list)
	Scope           *string         `json:"Scope,omitempty"`           // Scope of resource authorization
	Props           *map[string]any `json:"Props,omitempty"`           // Props are directly passing to react component
	CustomComponent *string         `json:"CustomComponent,omitempty"` // Custom component TODO: custom component
	Description     *string         `json:"Description,omitempty"`     // Description of action
	Label           *string         `json:"Label,omitempty"`           // Label of button
	Icon            *string         `json:"Icon,omitempty"`            // Icon of button
	OnList          *bool           `json:"OnList,omitempty"`          // Display on list
	OnShow          *bool           `json:"OnShow,omitempty"`          // Display on show
	OnEdit          *bool           `json:"OnEdit,omitempty"`          // Display on edit
	OnCreate        *bool           `json:"OnCreate,omitempty"`        // Display on edit
	DisplayOn       []string        `json:"DisplayOn,omitempty"`
	Route           *Route          `json:"Route,omitempty"`     // Route of action
	Operation       *Operation      `json:"Operation,omitempty"` // Operation of action
}

Action item related action

func NewAction

func NewAction(name string, options ...ActionOption) *Action

type ActionOption

type ActionOption = func(*Action) error

func ActionAsGeneral

func ActionAsGeneral() ActionOption

func ActionDisplayOn

func ActionDisplayOn(actionNames ...string) ActionOption

func ActionWithIcon

func ActionWithIcon(icon string) ActionOption

func ActionWithLabel

func ActionWithLabel(label string) ActionOption

func ActionWithOperation

func ActionWithOperation(operation *Operation) ActionOption

func ActionWithProps

func ActionWithProps(props map[string]any) ActionOption

func ActionWithRoute

func ActionWithRoute(route *Route) ActionOption

func ActionWithScope

func ActionWithScope(scope string) ActionOption

func WithCustomComponent

func WithCustomComponent(component string) ActionOption

func WithDescription

func WithDescription(description string) ActionOption

type Annotation

type Annotation struct {
	TitleField     *bool             `json:"TitleField,omitempty"`     // Mark field as title of entity
	ImageField     *bool             `json:"ImageField,omitempty"`     // Mark field as image
	MainImageField *bool             `json:"MainImageField,omitempty"` // Mark field as main image of entity
	CodeField      *CodeFieldOptions `json:"CodeField,omitempty"`      // Mark field as code field
	URLField       *bool             `json:"URLField,omitempty"`       // Mark field as url field
	RichTextField  *bool             `json:"RichTextField,omitempty"`  // Mark field as rich text field
	HideOnList     *bool             `json:"HideOnList,omitempty"`     // Hide field on list
	HideOnShow     *bool             `json:"HideOnShow,omitempty"`     // Hide field on show
	HideOnForm     *bool             `json:"HideOnForm,omitempty"`     // Hide field on all forms
	HideOnCreate   *bool             `json:"HideOnCreate,omitempty"`   // Hide field on create form
	HideOnUpdate   *bool             `json:"HideOnUpdate,omitempty"`   // Hide field on update form
	FilterOperator *string           `json:"FilterOperator,omitempty"` // Set filter operator for field `gen.Op`
	Icon           *string           `json:"Icon,omitempty"`           // Set entity or field icon
	Label          *string           `json:"Label,omitempty"`          // Set label for entity or field
	Description    *string           `json:"Description,omitempty"`    // Set description for entity or field
	Prefix         *string           `json:"Prefix,omitempty"`         // Set prefix on field: TODO
	Suffix         *string           `json:"Suffix,omitempty"`         // Set suffix on field: TODO
	Actions        []*Action         `json:"Actions,omitempty"`        // Set entity related actions
	View           *string           `json:"View,omitempty"`           // Set view for field
	Route          *string           `json:"Route,omitempty"`          // Set root Route for entity
	IndexRoute     *bool             `json:"IndexRoute,omitempty"`     // Mark entity as index route
	ViewOnShow     *string           `json:"ViewOnShow,omitempty"`     // Set a view of entity on show
	ViewOnList     *string           `json:"ViewOnList,omitempty"`     // Set a view of entity on list
	ViewOnForm     *string           `json:"ViewOnForm,omitempty"`     // Set a view on entity on form
	Badge          *string           `json:"Badge,omitempty"`          // Set a badge view

	EdgesDiagram *string `json:"EdgesDiagram,omitempty"`
}

Annotation struct container of all annotations

func Actions

func Actions(actions ...*Action) Annotation

Actions actions/buttons on list items

func Badge

func Badge(name string) Annotation

Badge define entity badge view

func CodeField

func CodeField(config *CodeFieldOptions) Annotation

CodeField mark field as a code field

func Description

func Description(description string) Annotation

Description define description of field/entity todo: implement generator

func FilterOperator

func FilterOperator(operator gen.Op) Annotation

FilterOperator define entity field filter operator

func HideOnCreate

func HideOnCreate() Annotation

HideOnCreate hide field on form

func HideOnForm

func HideOnForm() Annotation

HideOnForm hide field on form

func HideOnList

func HideOnList() Annotation

HideOnList hide field on list

func HideOnShow

func HideOnShow() Annotation

HideOnShow hide field on show page

func HideOnUpdate

func HideOnUpdate() Annotation

HideOnUpdate hide field on form

func Icon

func Icon(icon string) Annotation

Icon define icon of entity that will be shown on navigations, breadcrumbs etc.

func ImageField

func ImageField() Annotation

ImageField mark field as an image field

func IndexRoute

func IndexRoute() Annotation

IndexRoute make entity route as index route

func Label

func Label(label string) Annotation

Label define label of field todo: implement generator

func MainImageField

func MainImageField() Annotation

MainImageField mark field as a main image field

func OnlyOnForm

func OnlyOnForm() Annotation

OnlyOnForm show field only on form

func OnlyOnList

func OnlyOnList() Annotation

OnlyOnList show field only on list

func OnlyOnShow

func OnlyOnShow() Annotation

OnlyOnShow show field only on show page

func Prefix

func Prefix(prefix string) Annotation

Prefix add prefix to value of field todo: implement generator

func RichTextField

func RichTextField() Annotation

RichTextField mark field as a rich text field (wysiwyg editor)

func RoutePath

func RoutePath(path string) Annotation

RoutePath define entity route for url.

func Suffix

func Suffix(suffix string) Annotation

Suffix add suffix to value of field

func TitleField

func TitleField() Annotation

TitleField mark field as a title field

func URLField

func URLField() Annotation

URLField mark field as an url field

func View

func View(name string) Annotation

View define field views on list and show

func ViewOnForm

func ViewOnForm(name string) Annotation

ViewOnForm define field view on form

func ViewOnList

func ViewOnList(name string) Annotation

ViewOnList define field view on list

func ViewOnShow

func ViewOnShow(name string) Annotation

ViewOnShow define field view on show page

func (Annotation) Merge

func (at Annotation) Merge(other schema.Annotation) schema.Annotation

Merge implements the schema.Merger interface.

func (Annotation) Name

func (at Annotation) Name() string

Name annotation

type Annotations

type Annotations struct {
	Prefix string
	Auth   *Auth
}

Annotations Define Ent annotations

func (Annotations) Name

func (Annotations) Name() string

Name of the annotation. Used by the codegen templates.

type Auth

type Auth struct {
	Extension *Extension `json:"Extension,omitempty"`
	Enabled   *bool      `json:"Enabled,omitempty"`
	Keycloak  *Keycloak  `json:"Keycloak,omitempty"`
}

func NewAuth

func NewAuth(ex *Extension, options ...AuthOption) *Auth

func (*Auth) GetEnvironmentConfig

func (at *Auth) GetEnvironmentConfig() *AuthEnvironment

type AuthContext

type AuthContext struct {
	Roles       []string // Not supporting yet. TODO: create support
	Permissions []*Permission
}

type AuthEnvironment

type AuthEnvironment struct {
	Keycloak *KeycloakEnvironment `json:"keycloak,omitempty"`
}

type AuthOption

type AuthOption = func(auth *Auth) error

func AuthWithKeycloak

func AuthWithKeycloak(keycloakOption ...KeycloakOption) AuthOption

AuthWithKeycloak configure authentication and authorization

type CodeFieldOptions

type CodeFieldOptions struct {
	Language string `json:"Language,omitempty"`
}

CodeFieldOptions code field is configurable

**Example**

```go

CodeFieldOptions{
	Language: "javascript"
}

```

type Environment

type Environment = struct {
	Meta       map[string]any   `json:"meta,omitempty"`
	GraphqlURL string           `json:"graphqlUrl,omitempty"`
	AppPath    string           `json:"appPath,omitempty"`
	Auth       *AuthEnvironment `json:"auth,omitempty"`
}

Environment main struct

type EnvironmentAdapter

type EnvironmentAdapter struct{}

EnvironmentAdapter main struct

func (EnvironmentAdapter) GetFS

func (r EnvironmentAdapter) GetFS() fs.FS

GetFS returns fs of adapter

func (EnvironmentAdapter) GetName

func (r EnvironmentAdapter) GetName() string

GetName returns name of adapter

func (EnvironmentAdapter) GetTemplates

func (r EnvironmentAdapter) GetTemplates() []string

GetTemplates returns templates of adapter

type Extension

type Extension struct {
	entc.DefaultExtension
	IgnoreUncommittedChanges *bool   // Ignore uncommitted changes warning message
	GraphqlURL               *string // Graphql URL
	Prefix                   *string // General prefix for all generated resources

	GoJs                GoJSOptions         // TODO: must be moved
	ForceGraph2D        ForceGraph2DOptions // TODO: must be moved
	DefaultEdgesDiagram string              // TODO: must be moved

	Auth        *Auth
	Generators  []*Generator
	Environment *Environment
	Meta        map[string]any // Meta to share with frontend application

	FileHeader *string
	// contains filtered or unexported fields
}

Extension main struct

func NewExtension

func NewExtension(opts ...ExtensionOption) (*Extension, error)

NewExtension initialize extension

func (*Extension) Annotations

func (ex *Extension) Annotations() []entc.Annotation

Annotations Define Ent annotations

func (*Extension) Camel

func (ex *Extension) Camel(s string) string

Camel returns camel case string

func (*Extension) FieldTSType

func (ex *Extension) FieldTSType(field *gen.Field) string

FieldTSType returns typescript type for field

func (*Extension) GetActionByName

func (ex *Extension) GetActionByName(node *gen.Type, name string) *Action

GetActionByName returns action by name

func (*Extension) GetEdgeAnnotations

func (ex *Extension) GetEdgeAnnotations(field *gen.Edge) *Annotation

GetEdgeAnnotations returns edge annotations

func (*Extension) GetFieldAnnotations

func (ex *Extension) GetFieldAnnotations(field *gen.Field) *Annotation

GetFieldAnnotations returns field annotations

func (*Extension) GetNodeAction

func (ex *Extension) GetNodeAction(node *gen.Type, name string) *Action

GetNodeAction returns action by name

func (*Extension) GetNodeAnnotations

func (ex *Extension) GetNodeAnnotations(node *gen.Type) *Annotation

GetNodeAnnotations returns node annotations

func (*Extension) Hooks

func (ex *Extension) Hooks() []gen.Hook

Hooks Define Ent hooks

func (*Extension) IndexNode

func (ex *Extension) IndexNode(graph *gen.Graph) *gen.Type

IndexNode returns index node

func (*Extension) LcFirst

func (ex *Extension) LcFirst(str string) string

LcFirst converts first letter to lower case

func (*Extension) MainImageField

func (ex *Extension) MainImageField(node *gen.Type) *gen.Field

MainImageField returns main image field

func (*Extension) NodeActionRoutePattern

func (ex *Extension) NodeActionRoutePattern(node *gen.Type, actionName string) *string

NodeActionRoutePattern returns route pattern for node action

func (*Extension) Pascal

func (ex *Extension) Pascal(s string) string

Pascal returns pascal case string

func (*Extension) PrepareName

func (ex *Extension) PrepareName(name string) string

PrepareName returns prepared name

func (*Extension) Replace

func (ex *Extension) Replace(old string, new string, s string) string

Replace replaces old with new in string

func (*Extension) Snake

func (ex *Extension) Snake(s string) string

Snake returns snake case string

func (*Extension) Templates

func (ex *Extension) Templates() []*gen.Template

Templates Define Ent templates

func (*Extension) TitleField

func (ex *Extension) TitleField(node *gen.Type) *gen.Field

TitleField returns title field

func (*Extension) ToLabel

func (ex *Extension) ToLabel(str string) string

ToLabel converts string to label

func (*Extension) TsType

func (ex *Extension) TsType(gotype string, prefix string) string

TsType returns typescript type

func (*Extension) UcFirst

func (ex *Extension) UcFirst(str string) string

UcFirst converts first letter to upper case

type ExtensionOption

type ExtensionOption = func(*Extension) error

ExtensionOption is a functional option for Extension

func IgnoreUncommittedChanges

func IgnoreUncommittedChanges() ExtensionOption

IgnoreUncommittedChanges ignore uncommitted changes warning message

func WithAuth

func WithAuth(options ...AuthOption) ExtensionOption

WithAuth configure authentication and authorization

func WithDefaultEdgesDiagram

func WithDefaultEdgesDiagram(name string) ExtensionOption

WithDefaultEdgesDiagram set default edges graph/diagram view component name

func WithForceGraph2D

func WithForceGraph2D(options ForceGraph2DOptions) ExtensionOption

WithForceGraph2D use react-force-graph-2d for edges diagrams

func WithGenerator

func WithGenerator(name string, adapter GeneratorAdapter, options ...GeneratorOption) ExtensionOption

WithGenerator add generator to extension

func WithGoJs

func WithGoJs(options GoJSOptions) ExtensionOption

WithGoJs use gojs for edges diagrams

func WithGraphqlURL

func WithGraphqlURL(url string) ExtensionOption

WithGraphqlURL define graphql server url

func WithMeta

func WithMeta(key string, value any) ExtensionOption

WithMeta add metadata to `{AppPath}/entkit.json`

func WithPrefix

func WithPrefix(prefix string) ExtensionOption

WithPrefix define typescript types/vars prefix

type ForceGraph2DOptions

type ForceGraph2DOptions struct {
	Enabled bool `json:"Enabled,omitempty"`
}

type Generator

type Generator struct {
	Name          *string    `json:"Name,omitempty"`
	Extension     *Extension `json:"Extension,omitempty"`
	SkipGoModTidy *bool      `json:"SkipGoModTidy,omitempty"`

	Adapter GeneratorAdapter
	Path    *string `json:"Path,omitempty"`
	Enabled *bool   `json:"Enabled,omitempty"`
	Serve   *bool   `json:"Serve,omitempty"`

	Graph     *gen.Graph
	SkipModes SkipModes
	Ops       []gen.Op

	CWD    *string `json:"CWD,omitempty"` // base directory of gen.go file or running `go generate` command CWD
	RelCWD *string `json:"RelCWD"`        // relative directory of CWD and current generator path
}

Generator main struct

func NewGenerator

func NewGenerator(extension *Extension, name string, adapter GeneratorAdapter, options ...GeneratorOption) *Generator

func (*Generator) DefaultActions

func (gr *Generator) DefaultActions() []*Action

func (*Generator) Generate

func (gr *Generator) Generate(graph *gen.Graph)

Generate generates code from adapter

func (*Generator) ServableAdapter

func (gr *Generator) ServableAdapter() ServableAdapter

type GeneratorAdapter

type GeneratorAdapter interface {
	GetName() string
}

GeneratorAdapter interface

type GeneratorAdapterWithAfter

type GeneratorAdapterWithAfter interface {
	AfterGen(generator *Generator) error
}

GeneratorAdapterWithAfter interface

type GeneratorAdapterWithAfterCommand

type GeneratorAdapterWithAfterCommand interface {
	CommandAfterGen(generator *Generator) string
}

GeneratorAdapterWithAfterCommand interface

type GeneratorAdapterWithBefore

type GeneratorAdapterWithBefore interface {
	BeforeGen(generator *Generator) error
}

GeneratorAdapterWithBefore interface

type GeneratorAdapterWithBeforeCommand

type GeneratorAdapterWithBeforeCommand interface {
	CommandBeforeGen(generator *Generator) string
}

GeneratorAdapterWithBeforeCommand interface

type GeneratorAdapterWithDependencies

type GeneratorAdapterWithDependencies interface {
	GetDependencies() []GeneratorAdapter
}

GeneratorAdapterWithDependencies interface

type GeneratorAdapterWithFS

type GeneratorAdapterWithFS interface {
	GetFS() fs.FS
}

GeneratorAdapterWithFS interface

type GeneratorAdapterWithStaticTemplates

type GeneratorAdapterWithStaticTemplates interface {
	GeneratorAdapterWithFS
	GetStaticTemplates() []string
}

GeneratorAdapterWithStaticTemplates interface

type GeneratorAdapterWithTemplates

type GeneratorAdapterWithTemplates interface {
	GeneratorAdapterWithFS
	GetTemplates() []string
}

GeneratorAdapterWithTemplates interface

type GeneratorOption

type GeneratorOption = func(*Generator) error

func SkipGoModTidy

func SkipGoModTidy() GeneratorOption

func TargetPath

func TargetPath(path string) GeneratorOption

type GoJSOptions

type GoJSOptions struct {
	Enabled    bool   `json:"Enabled,omitempty"`
	LicenseKey string `json:"LicenseKey,omitempty"`
}

type Keycloak

type Keycloak struct {
	Auth                *Auth   `json:"Auth,omitempty"`
	Enabled             *bool   `json:"Enabled,omitempty"`
	Host                *string `json:"Host,omitempty"`
	Realm               *string `json:"Realm,omitempty"`
	MasterAdminUsername *string `json:"MasterAdminUsername,omitempty"`
	MasterAdminPassword *string `json:"MasterAdminPassword,omitempty"`
	MasterRealm         *string `json:"MasterRealm,omitempty"`

	AdminUsername        *string         `json:"AdminUsername,omitempty"`
	AdminPassword        *string         `json:"AdminPassword,omitempty"`
	BackendClientConfig  *gocloak.Client `json:"BackendClientConfig,omitempty"`
	FrontendClientConfig *gocloak.Client `json:"FrontendClientConfig,omitempty"`

	GoCloak *gocloak.GoCloak `json:"GoCloak,omitempty"`
}

Keycloak is a struct that contains keycloak configuration

func NewBackendKeycloak

func NewBackendKeycloak(host string, realm string, clientId string, secret string) *Keycloak

NewBackendKeycloak returns new backend keycloak instance

func NewKeycloak

func NewKeycloak(
	auth *Auth,
	options ...KeycloakOption,
) *Keycloak

NewKeycloak returns new keycloak instance

func (*Keycloak) GenerateKeycloakResources

func (kc *Keycloak) GenerateKeycloakResources(g *gen.Graph)

GenerateKeycloakResources generates keycloak resources

func (*Keycloak) GetEnvironmentConfig

func (kc *Keycloak) GetEnvironmentConfig() *KeycloakEnvironment

GetEnvironmentConfig returns keycloak environment configuration

func (*Keycloak) MiddlewareReqHandlerFunc

func (kc *Keycloak) MiddlewareReqHandlerFunc(w http.ResponseWriter, r *http.Request) (*http.Request, error)

MiddlewareReqHandlerFunc is a middleware that checks if the request is authorized

type KeycloakEnvironment

type KeycloakEnvironment struct {
	URL             string `json:"url,omitempty"`
	Realm           string `json:"realm,omitempty"`
	ClientID        string `json:"clientId,omitempty"`
	BackendClientID string `json:"backendClientId,omitempty"`
}

KeycloakEnvironment is a struct that contains keycloak environment configuration

type KeycloakOption

type KeycloakOption = func(keycloak *Keycloak) error

KeycloakOption is a function that configure keycloak

func KeycloakBackendClientConfig

func KeycloakBackendClientConfig(clientConfig gocloak.Client) KeycloakOption

KeycloakBackendClientConfig set keycloak backend client config

func KeycloakFrontendClientConfig

func KeycloakFrontendClientConfig(clientConfig gocloak.Client) KeycloakOption

KeycloakFrontendClientConfig set keycloak frontend client config

func KeycloakGeneratedAdminCredentials

func KeycloakGeneratedAdminCredentials(username string, password string) KeycloakOption

KeycloakGeneratedAdminCredentials set keycloak generated admin credentials

func KeycloakHost

func KeycloakHost(host string) KeycloakOption

KeycloakHost set keycloak host

func KeycloakMasterAdminCredentials

func KeycloakMasterAdminCredentials(username string, password string) KeycloakOption

KeycloakMasterAdminCredentials set keycloak master admin credentials

func KeycloakMasterRealm

func KeycloakMasterRealm(realm string) KeycloakOption

KeycloakMasterRealm set keycloak master realm

func KeycloakRealm

func KeycloakRealm(realm string) KeycloakOption

KeycloakRealm set keycloak realm

type Mutation

type Mutation struct {
	// contains filtered or unexported fields
}

func NewMutation

func NewMutation(description string, isCreate bool) Mutation

func (Mutation) Description

func (v Mutation) Description(desc string) entgql.MutationOption

func (Mutation) GetDescription

func (v Mutation) GetDescription() string

func (Mutation) IsCreate

func (v Mutation) IsCreate() bool

type Operation

type Operation struct {
	Mutation       *bool     `json:"Mutation,omitempty"`       // Mark operation as mutation
	Query          *bool     `json:"Query,omitempty"`          // Mark operation as query
	Name           *string   `json:"Name,omitempty"`           // Operation of graphql
	Fields         *[]string `json:"Fields,omitempty"`         // Fields to take after operation
	Single         *bool     `json:"Single,omitempty"`         // Show on single item
	Bulk           *bool     `json:"Bulk,omitempty"`           // Show on bulk selected items
	SuccessMessage *string   `json:"SuccessMessage,omitempty"` // Message on success
	FailMessage    *string   `json:"FailMessage,omitempty"`    // Message on fail
}

Operation struct

func NewOperation

func NewOperation(name string, options ...OperationOption) *Operation

NewOperation creates new operation

type OperationOption

type OperationOption = func(operation *Operation) error

func OperationAsBulk

func OperationAsBulk() OperationOption

OperationAsBulk marks operation as bulk

func OperationAsMutation

func OperationAsMutation() OperationOption

OperationAsMutation marks operation as mutation

func OperationAsQuery

func OperationAsQuery() OperationOption

OperationAsQuery marks operation as query

func OperationAsSingle

func OperationAsSingle() OperationOption

OperationAsSingle marks operation as single

func OperationWithFailMessage

func OperationWithFailMessage(message string) OperationOption

OperationWithFailMessage sets fail message

func OperationWithFields

func OperationWithFields(fields ...string) OperationOption

OperationWithFields sets fields

func OperationWithSuccessMessage

func OperationWithSuccessMessage(message string) OperationOption

OperationWithSuccessMessage sets success message

type Permission

type Permission struct {
	Resource string
	Scopes   []string
}

type Refine

type Refine struct{}

func (Refine) BuildPath

func (r Refine) BuildPath() string

func (Refine) CommandAfterGen

func (r Refine) CommandAfterGen(generator *Generator) string

func (Refine) GetDependencies

func (r Refine) GetDependencies() []GeneratorAdapter

func (Refine) GetFS

func (r Refine) GetFS() fs.FS

func (Refine) GetName

func (r Refine) GetName() string

func (Refine) GetStaticTemplates

func (r Refine) GetStaticTemplates() []string

func (Refine) GetTemplates

func (r Refine) GetTemplates() []string

func (Refine) RewritePath

func (r Refine) RewritePath() string

func (Refine) StaticPaths

func (r Refine) StaticPaths() []string

type Route

type Route struct {
	Path    *string `json:"Path,omitempty"`    // Route of action
	Index   *bool   `json:"Index,omitempty"`   // Mark action as index route
	Element *string `json:"Element,omitempty"` // Element that should be rendered
}

func NewRoute

func NewRoute(path string, element string, options ...RouteOption) *Route

type RouteOption

type RouteOption = func(route *Route) error

func RouteAsIndex

func RouteAsIndex() RouteOption

type ServableAdapter

type ServableAdapter interface {
	BuildPath() string
	RewritePath() string
	StaticPaths() []string
}

type ServerAdapter

type ServerAdapter struct{}

func (ServerAdapter) BeforeGen

func (r ServerAdapter) BeforeGen(generator *Generator) error

func (ServerAdapter) CommandAfterGen

func (r ServerAdapter) CommandAfterGen(generator *Generator) string

func (ServerAdapter) GetFS

func (r ServerAdapter) GetFS() fs.FS

func (ServerAdapter) GetName

func (r ServerAdapter) GetName() string

func (ServerAdapter) GetStaticTemplates

func (r ServerAdapter) GetStaticTemplates() []string

func (ServerAdapter) GetTemplates

func (r ServerAdapter) GetTemplates() []string

type SkipModes

type SkipModes struct {
	SkipAll                 int
	SkipEnumField           entgql.SkipMode
	SkipMutationCreateInput entgql.SkipMode
	SkipMutationUpdateInput entgql.SkipMode
	SkipOrderField          entgql.SkipMode
	SkipWhereInput          entgql.SkipMode
}

func (*SkipModes) Cast

func (sm *SkipModes) Cast(value int) entgql.SkipMode

Cast converts int to entgql.SkipMode

type TypescriptAdapter

type TypescriptAdapter struct{}

func (TypescriptAdapter) GetFS

func (r TypescriptAdapter) GetFS() fs.FS

func (TypescriptAdapter) GetName

func (r TypescriptAdapter) GetName() string

func (TypescriptAdapter) GetTemplates

func (r TypescriptAdapter) GetTemplates() []string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL