utility

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2025 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GOROUTINE_WARNING_THRESHOLD  = 500
	GOROUTINE_CRITICAL_THRESHOLD = 1000
	GOROUTINE_CHECK_INTERVAL     = 30 * time.Second
)

Variables

View Source
var DefaultMarkdownProcessor = NewMarkdownProcessor()

Global instance for easy access

View Source
var MapActionName = map[string]string{
	"UpdateProfileResolverFn":        "update user profile",
	"UpsertPluginResolverFn":         "plugin modification",
	"GenerateApiTokenResolverFn":     "generated api token",
	"DeleteApiTokenResolverFn":       "deleted api token",
	"CreateWebHookResolverFn":        "created a webhook",
	"DeleteWebHookResolverFn":        "deleted a webhook",
	"UpdateProjectResolverFn":        "updated a project information",
	"AddModelToProjectResolverFn":    "added a model to a project",
	"UpdateModelResolverFn":          "updated a model",
	"UpsertRoleToProjectResolverFn":  "added or modified a role to a project",
	"DeleteRoleResolverFn":           "deleted a role",
	"UpsertFieldToModelResolverFn":   "added or modified a field to a model",
	"DeleteFieldTypeResolverFn":      "deleted a field",
	"ModelFieldOperationResolverFn":  "modified a field of a model",
	"CreateConnectionTypeResolverFn": "created a connection between models",
	"UpsertModelDataFnFn":            "added or modified data of a model",
	"DeleteModelDataFnFn":            "deleted data of a model",
}
View Source
var SupportedLocals = []string{}/* 609 elements not displayed */

Functions

func AddDaysWithCurrentDhakaTime

func AddDaysWithCurrentDhakaTime(days int) string

func AddDaysWithCurrentTime

func AddDaysWithCurrentTime(days int) string

func ArrayContains

func ArrayContains(arr []string, str string) bool

func ArrayContainsInterface

func ArrayContainsInterface(arr []interface{}, val interface{}) bool

func BuildAsyncContext

func BuildAsyncContext(ctx context.Context) (context.Context, context.CancelFunc)

func BuildCRUDPermissions

func BuildCRUDPermissions(modelName string, role *models.Role) (*models.APIPermission, error)

func CaptureInternalServerError

func CaptureInternalServerError(err error, scopes map[string]interface{}) error

func ConnectDisconnectParamBuilder

func ConnectDisconnectParamBuilder(project *models.Project, uid string, connectionIds map[string]interface{}, modelType *models.ModelType) ([]*models.ConnectDisconnectParam, error)

func ExtractActionName

func ExtractActionName(name string) string

func ExtractGraphQLOperationName

func ExtractGraphQLOperationName(query string, schema *models.ProjectSchema, isSystemQuery bool) ([]*models.IncomingRequest, error)

func ExtractModelNames

func ExtractModelNames(schema *models.ProjectSchema, queryDoc *ast.QueryDocument) ([]*models.IncomingRequest, bool, error)

func ExtractRelationName

func ExtractRelationName(name string) string

func ExtractResourceName

func ExtractResourceName(name string) string

separate update,delete,create from model name

func FilterNumber

func FilterNumber(num string) (string, error)

func FilterProjectArray

func FilterProjectArray(arr *[]*models.Project, key string) *models.Project

FilterProjectArray filters the array by a key and removes the found item from the array

func FilterUserArray

func FilterUserArray(arr *[]*models.SystemUser, key string) *models.SystemUser

FilterUserArray filters the array by a key and removes the found item from the array

func GenerateCombinedQuery

func GenerateCombinedQuery(doc *ast.QueryDocument, fragments map[string]*ast.FragmentDefinition) string

New function to generate the combined output as a single string

func GetCurrentDhakaTime

func GetCurrentDhakaTime() string

func GetCurrentDhakaTimeDateOnly

func GetCurrentDhakaTimeDateOnly() string

func GetCurrentDhakaTimeObject

func GetCurrentDhakaTimeObject() time.Time

func GetCurrentTime

func GetCurrentTime() string

UTC time functions

func GetCurrentTimeObject

func GetCurrentTimeObject() time.Time

func GetDhakaLocation

func GetDhakaLocation() *time.Location

Dhaka time functions

func GetEnv

func GetEnv(key, defaults string) string

func GetGraphQLObject

func GetGraphQLObject(object interface{}) (*graphql.Object, error)

GetGraphQLObject Converts struct into graphql object

func HTMLToMarkdown added in v1.1.3

func HTMLToMarkdown(html string) string

func HandlePayload

func HandlePayload(model *models.ModelType, data map[string]interface{})

func HandleSubPayload

func HandleSubPayload(field *models.FieldInfo, data map[string]interface{})

func HasMetaQuery

func HasMetaQuery(name string) bool

func IntFormat

func IntFormat(v interface{}) (int, error)

func IsInActionNameMap

func IsInActionNameMap(key string) bool

func IsValidIdentifier added in v1.1.4

func IsValidIdentifier(identifier string) (*models.ValidIdentifier, error)

func MarkdownToHTML added in v1.1.3

func MarkdownToHTML(markdown string) string

func MarkdownToText added in v1.1.3

func MarkdownToText(markdown string) string

func ModelSchemaBuilder

func ModelSchemaBuilder(modelType *models.ModelType, update bool) *oas.Schema

func MultiLineTextFormat

func MultiLineTextFormat(v interface{}) (map[string]interface{}, error)

func MultipleResourceName

func MultipleResourceName(name string) string

func NewRefreshTokenAuthenticator

func NewRefreshTokenAuthenticator(cfg *models.Config, token string) (*models.JWTTokens, error)

func OpenApiSpecGenerator

func OpenApiSpecGenerator(env string, loader *models.ApplicationCache) (interface{}, error)

func ProcessMultilineField added in v1.1.3

func ProcessMultilineField(input map[string]interface{}) map[string]interface{}

Convenience functions using the default processor

func RandomNumberGenerator

func RandomNumberGenerator(min, max int) string

func RandomStringGenerator

func RandomStringGenerator(n int) string

func RandomVariableGenerator

func RandomVariableGenerator(n int) string

func SanitizeMarkdown added in v1.1.3

func SanitizeMarkdown(markdown string) string

func SetTokenClaimsToRouter

func SetTokenClaimsToRouter(ctx echo.Context, tokenClaims *models.TokenClaims) error

func SetTokenCookie

func SetTokenCookie(cfg *models.Config, name, token string, httpOnly bool, expire bool) *http.Cookie

func SingularResourceName

func SingularResourceName(name string) string

func ValidatePermissions

func ValidatePermissions(vv map[string]interface{}) (*models.APIPermission, error)

func ValidateScope

func ValidateScope(p string) (*string, bool)

Types

type Authenticator

type Authenticator struct {
	Provider *oidc.Provider
	Config   oauth2.Config
	Ctx      context.Context
}

func NewAuthenticator

func NewAuthenticator(cfg *models.Config) (*Authenticator, error)

type CRUDPermissions

type CRUDPermissions struct {
	Create bool
	Read   bool
	Update bool
	Delete bool
}

type GoroutineMonitor added in v1.1.0

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

func NewGoroutineMonitor added in v1.1.0

func NewGoroutineMonitor() *GoroutineMonitor

func (*GoroutineMonitor) GetCurrentCount added in v1.1.0

func (gm *GoroutineMonitor) GetCurrentCount() int

func (*GoroutineMonitor) StartMonitoring added in v1.1.0

func (gm *GoroutineMonitor) StartMonitoring(ctx context.Context)

func (*GoroutineMonitor) StopMonitoring added in v1.1.0

func (gm *GoroutineMonitor) StopMonitoring()

type MarkdownProcessor added in v1.1.3

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

MarkdownProcessor handles markdown sanitization and conversion

func NewMarkdownProcessor added in v1.1.3

func NewMarkdownProcessor() *MarkdownProcessor

NewMarkdownProcessor creates a new markdown processor with proper sanitization

func (*MarkdownProcessor) HTMLToMarkdown added in v1.1.3

func (mp *MarkdownProcessor) HTMLToMarkdown(html string) string

HTMLToMarkdown converts HTML to markdown

func (*MarkdownProcessor) MarkdownToHTML added in v1.1.3

func (mp *MarkdownProcessor) MarkdownToHTML(markdown string) string

MarkdownToHTML converts markdown to sanitized HTML

func (*MarkdownProcessor) MarkdownToText added in v1.1.3

func (mp *MarkdownProcessor) MarkdownToText(markdown string) string

MarkdownToText converts markdown to plain text (removes all formatting)

func (*MarkdownProcessor) ProcessMultilineField added in v1.1.3

func (mp *MarkdownProcessor) ProcessMultilineField(input map[string]interface{}) map[string]interface{}

ProcessMultilineField processes a multiline field with markdown as the source of truth

func (*MarkdownProcessor) SanitizeMarkdown added in v1.1.3

func (mp *MarkdownProcessor) SanitizeMarkdown(markdown string) string

SanitizeMarkdown removes potentially dangerous content from markdown

func (*MarkdownProcessor) TextToMarkdown added in v1.1.3

func (mp *MarkdownProcessor) TextToMarkdown(text string) string

TextToMarkdown converts plain text to basic markdown

type RESTtoGraphResponse

type RESTtoGraphResponse struct {
	Query         string `json:"query"`
	QueryName     string `json:"query_name"`
	OperationName string `json:"operation_name"`
}

func HandleFunctionGraphqlBase

func HandleFunctionGraphqlBase(c echo.Context, schema *models.ProjectSchema, functionName string) (*RESTtoGraphResponse, error)

func RESTtoGraphQL

func RESTtoGraphQL(c echo.Context, schema *models.ProjectSchema, rootModel string, rest url.Values, skipQueryDef bool) (*RESTtoGraphResponse, error)

Jump to

Keyboard shortcuts

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