Documentation
¶
Index ¶
- Constants
- Variables
- func AddDaysWithCurrentDhakaTime(days int) string
- func AddDaysWithCurrentTime(days int) string
- func ApplicationCacheFromContext(ctx context.Context) (*models.ApplicationCache, bool)
- func ArrayContains(arr []string, str string) bool
- func ArrayContainsInterface(arr []interface{}, val interface{}) bool
- func BuildAsyncContext(ctx context.Context) (context.Context, context.CancelFunc)
- func BuildCRUDPermissions(modelName string, role *models.Role) (*models.APIPermission, error)
- func CamelFromAny(modelID string) string
- func CamelFromCanonical(canonical string) string
- func CanonicalSystemRelationFieldIdentifier(identifier string) string
- func CanonicalizeModelName(raw string) (string, error)
- func CaptureInternalServerError(err error, scopes map[string]interface{}) error
- func ConnectDisconnectParamBuilder(project *models.Project, uid string, connectionIds map[string]interface{}, ...) ([]*models.ConnectDisconnectParam, error)
- func ExpandPath(path string) (string, error)
- func ExtractActionName(name string) string
- func ExtractGraphQLOperationName(query string, schema *models.ProjectSchema, isSystemQuery bool) ([]*models.IncomingRequest, error)
- func ExtractModelNames(schema *models.ProjectSchema, queryDoc *ast.QueryDocument) ([]*models.IncomingRequest, bool, error)
- func ExtractRelationName(name string) string
- func ExtractResourceName(name string) string
- func FilterNumber(num string) (string, error)
- func FilterProjectArray(arr *[]*models.Project, key string) *models.Project
- func FilterUserArray(arr *[]*models.SystemUser, key string) *models.SystemUser
- func GenerateCombinedQuery(doc *ast.QueryDocument, fragments map[string]*ast.FragmentDefinition) string
- func GetCurrentDhakaTime() string
- func GetCurrentDhakaTimeDateOnly() string
- func GetCurrentDhakaTimeObject() time.Time
- func GetCurrentTime() string
- func GetCurrentTimeObject() time.Time
- func GetDhakaLocation() *time.Location
- func GetEnv(key, defaults string) string
- func GetGraphQLObject(object interface{}) (*graphql.Object, error)
- func GraphQLComposedTypeName(modelID string, suffix string) string
- func GraphQLTypeName(s string) string
- func GraphQLTypeNameForFilterArg(modelID string) string
- func HTMLToMarkdown(html string) string
- func HandlePayload(model *models.ModelType, data map[string]interface{})
- func HandleSubPayload(field *models.FieldInfo, data map[string]interface{})
- func HasMetaQuery(name string) bool
- func IntFormat(v interface{}) (int, error)
- func IsCanonicalModelID(s string) bool
- func IsInActionNameMap(key string) bool
- func IsValidIdentifier(identifier string) (*models.ValidIdentifier, error)
- func LegacyApplicationCache(ctx context.Context) (*models.ApplicationCache, bool)
- func LegacyRelationMeta(ctx context.Context) (map[string]interface{}, bool)
- func LegacySelectionSet(ctx context.Context) (ast.SelectionSet, bool)
- func LegacyStoredNameToCanonical(stored string) (string, error)
- func ListGraphQLTypeName(modelID string) string
- func LookupAPIPermission(role *models.Role, modelName string) (*models.APIPermission, bool)
- func MarkdownToHTML(markdown string) string
- func MarkdownToText(markdown string) string
- func MigrateProjectSchemaToNamingV2(project *models.Project) (bool, error)
- func ModelIDMatchesGraphQLField(storedModelID, graphqlLowerCamel string) bool
- func ModelSchemaBuilder(modelType *models.ModelType, update bool) *oas.Schema
- func MultiLineTextFormat(v interface{}) (map[string]interface{}, error)
- func MultipleResourceName(name string) string
- func NewRefreshTokenAuthenticator(cfg *models.Config, token string) (*models.JWTTokens, error)
- func OpenApiSpecGenerator(env string, loader *models.ApplicationCache) (interface{}, error)
- func PascalFromAnyModelID(modelID string) string
- func PascalFromCanonical(canonical string) string
- func ProcessMultilineField(input map[string]interface{}) map[string]interface{}
- func RandomNumberGenerator(min, max int) string
- func RandomStringGenerator(n int) string
- func RandomVariableGenerator(n int) string
- func RelationMetaFromContext(ctx context.Context) (map[string]interface{}, bool)
- func ResolveStoredModelID(knownIDs map[string]bool, graphqlSingular string) string
- func SanitizeMarkdown(markdown string) string
- func SelectionSetFromContext(ctx context.Context) (ast.SelectionSet, bool)
- func SetTokenClaimsToRouter(ctx echo.Context, tokenClaims *models.TokenClaims) error
- func SetTokenCookie(cfg *models.Config, name, token string, httpOnly bool, expire bool) *http.Cookie
- func SingularResourceName(name string) string
- func ValidatePermissions(vv map[string]interface{}) (*models.APIPermission, error)
- func ValidateScope(p string) (*string, bool)
- func WithApplicationCache(ctx context.Context, c *models.ApplicationCache) context.Context
- func WithRelationMeta(ctx context.Context, meta map[string]interface{}) context.Context
- func WithSelectionSet(ctx context.Context, sel ast.SelectionSet) context.Context
- type Authenticator
- type CRUDPermissions
- type GoroutineMonitor
- type MarkdownProcessor
- func (mp *MarkdownProcessor) HTMLToMarkdown(html string) string
- func (mp *MarkdownProcessor) MarkdownToHTML(markdown string) string
- func (mp *MarkdownProcessor) MarkdownToText(markdown string) string
- func (mp *MarkdownProcessor) ProcessMultilineField(input map[string]interface{}) map[string]interface{}
- func (mp *MarkdownProcessor) SanitizeMarkdown(markdown string) string
- func (mp *MarkdownProcessor) TextToMarkdown(text string) string
- type NamingV2ModelRenamePair
- type NamingV2PhysicalMigrator
- type RESTtoGraphResponse
Constants ¶
const ( NamingSchemaVersionLegacy = 0 NamingSchemaVersionV2 = 1 )
Naming schema version stored on ProjectSchema.NamingSchemaVersion.
const ( GOROUTINE_WARNING_THRESHOLD = 500 GOROUTINE_CRITICAL_THRESHOLD = 1000 GOROUTINE_CHECK_INTERVAL = 30 * time.Second )
Variables ¶
var ( // ErrRunOnModelName is returned when the input has no word-boundary signal // and looks like concatenated words (e.g. foodorder). Users must use // food_order, food-order, foodOrder, or "food order". ErrRunOnModelName = errors.New("model name needs a word boundary between words: use food_order, food-order, foodOrder, or \"food order\"") // ErrInvalidModelName is returned when the normalized id does not match canonical rules. ErrInvalidModelName = errors.New("invalid model name: use lowercase snake_case with letters, numbers, and underscores only") )
var DefaultMarkdownProcessor = NewMarkdownProcessor()
Global instance for easy access
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",
}
var SupportedLocals = []string{}/* 609 elements not displayed */
Functions ¶
func AddDaysWithCurrentTime ¶
func ApplicationCacheFromContext ¶ added in v1.6.0
func ApplicationCacheFromContext(ctx context.Context) (*models.ApplicationCache, bool)
ApplicationCacheFromContext returns the cache set by WithApplicationCache.
func ArrayContains ¶
func ArrayContainsInterface ¶
func ArrayContainsInterface(arr []interface{}, val interface{}) bool
func BuildAsyncContext ¶
func BuildCRUDPermissions ¶
func CamelFromAny ¶ added in v1.6.0
CamelFromAny converts stored model id (canonical snake_case or legacy lowerCamelCase) to lowerCamelCase.
func CamelFromCanonical ¶ added in v1.6.0
CamelFromCanonical converts canonical snake_case to lowerCamelCase (e.g. food_order -> foodOrder).
func CanonicalSystemRelationFieldIdentifier ¶ added in v1.6.0
CanonicalSystemRelationFieldIdentifier maps stored schema field ids to the same keys used in document data and connect/disconnect: system_<canonical_model_id>_id or system_<canonical_model_id>_as_<known_as>_id. Legacy schema rows may use mixed casing (e.g. system_foodCategory_id); this normalizes to system_food_category_id.
func CanonicalizeModelName ¶ added in v1.6.0
CanonicalizeModelName normalizes admin input into the canonical snake_case singular model id.
func ExpandPath ¶ added in v1.3.0
expandPath expands ~ to home directory and converts to absolute path. If the path starts with ./ or ../, it resolves relative to the current working directory.
func ExtractActionName ¶
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 ExtractResourceName ¶
separate update,delete,create from model name
func FilterNumber ¶
func FilterProjectArray ¶
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 GetCurrentTimeObject ¶
func GetGraphQLObject ¶
GetGraphQLObject Converts struct into graphql object
func GraphQLComposedTypeName ¶ added in v1.6.0
GraphQLComposedTypeName builds Tag_Update_Payload style names from model id + suffix (e.g. "Create_Payload", "List_Aggregate", "RawModel").
func GraphQLTypeName ¶ added in v1.6.0
GraphQLTypeName formats a name for GraphQL object/input types. It applies Unicode title case to each underscore-separated segment so compound names match conventional GraphQL PascalCase (e.g. tag_Update_Payload → Tag_Update_Payload). A plain cases.Title on the full string only capitalizes the first rune of the first “word”, which yields Tag_update_payload and breaks clients expecting Tag_Update_Payload.
func GraphQLTypeNameForFilterArg ¶ added in v1.6.0
GraphQLTypeNameForFilterArg is the PascalCase name passed to BuildFilterArgument (list query / count). It matches ListGraphQLTypeName for canonical and legacy ids.
func HTMLToMarkdown ¶ added in v1.1.2
func HandlePayload ¶
func HandleSubPayload ¶
func HasMetaQuery ¶
func IsCanonicalModelID ¶ added in v1.6.0
IsCanonicalModelID reports whether s is already stored canonical form (snake_case ASCII).
func IsInActionNameMap ¶
func IsValidIdentifier ¶ added in v1.1.4
func IsValidIdentifier(identifier string) (*models.ValidIdentifier, error)
func LegacyApplicationCache ¶ added in v1.6.0
func LegacyApplicationCache(ctx context.Context) (*models.ApplicationCache, bool)
LegacyApplicationCache returns cache from typed key or legacy string "cache".
func LegacyRelationMeta ¶ added in v1.6.0
LegacyRelationMeta returns relation metadata from typed key or legacy "relation_meta".
func LegacySelectionSet ¶ added in v1.6.0
func LegacySelectionSet(ctx context.Context) (ast.SelectionSet, bool)
LegacySelectionSet returns selection set from typed key or legacy "selectionSet".
func LegacyStoredNameToCanonical ¶ added in v1.6.0
LegacyStoredNameToCanonical converts a legacy stored model name (camelCase or run-on) to canonical snake_case for migration. Does not apply run-on rejection.
func ListGraphQLTypeName ¶ added in v1.6.0
ListGraphQLTypeName returns the PascalCase list wrapper type (e.g. FoodCategoryList).
func LookupAPIPermission ¶ added in v1.6.0
LookupAPIPermission returns role permissions for a model id (canonical snake or legacy camel key).
func MarkdownToHTML ¶ added in v1.1.2
func MarkdownToText ¶ added in v1.1.2
func MigrateProjectSchemaToNamingV2 ¶ added in v1.6.0
MigrateProjectSchemaToNamingV2 rewrites stored model names to canonical snake_case, updates connection references and role API permission keys, and sets NamingSchemaVersion. Returns (true, nil) when the project was modified and should be persisted.
func ModelIDMatchesGraphQLField ¶ added in v1.6.0
ModelIDMatchesGraphQLField reports whether a stored model id matches the lowerCamel resource id used in GraphQL field names.
func ModelSchemaBuilder ¶
func MultiLineTextFormat ¶
func MultipleResourceName ¶
func OpenApiSpecGenerator ¶
func OpenApiSpecGenerator(env string, loader *models.ApplicationCache) (interface{}, error)
func PascalFromAnyModelID ¶ added in v1.6.0
PascalFromAnyModelID builds GraphQL PascalCase type names from either canonical snake or legacy camel.
func PascalFromCanonical ¶ added in v1.6.0
PascalFromCanonical converts canonical snake_case to PascalCase without underscores (e.g. food_order -> FoodOrder).
func ProcessMultilineField ¶ added in v1.1.2
Convenience functions using the default processor
func RandomNumberGenerator ¶
func RandomStringGenerator ¶
func RandomVariableGenerator ¶
func RelationMetaFromContext ¶ added in v1.6.0
RelationMetaFromContext returns relation metadata from ctx.
func ResolveStoredModelID ¶ added in v1.6.0
ResolveStoredModelID maps a GraphQL singular base name (e.g. foodCategory from foodCategoryList, or food_category) to the project schema's stored model id (e.g. food_category). knownIDs keys are Model.Name values. Matches exact id or the same CamelFromAny identity.
func SanitizeMarkdown ¶ added in v1.1.2
func SelectionSetFromContext ¶ added in v1.6.0
func SelectionSetFromContext(ctx context.Context) (ast.SelectionSet, bool)
SelectionSetFromContext returns the selection set from ctx.
func SetTokenClaimsToRouter ¶
func SetTokenClaimsToRouter(ctx echo.Context, tokenClaims *models.TokenClaims) error
func SetTokenCookie ¶
func SingularResourceName ¶
SingularResourceName returns the lowerCamelCase singular resource id for GraphQL fields. It accepts canonical snake_case model ids, legacy camelCase ids, or field names ending in List / ListCount.
func ValidatePermissions ¶
func ValidatePermissions(vv map[string]interface{}) (*models.APIPermission, error)
func ValidateScope ¶
func WithApplicationCache ¶ added in v1.6.0
WithApplicationCache attaches the application cache to ctx.
func WithRelationMeta ¶ added in v1.6.0
WithRelationMeta attaches relation metadata for dataloaders (replaces string key "relation_meta").
func WithSelectionSet ¶ added in v1.6.0
WithSelectionSet attaches the root GraphQL selection set (for relation resolution).
Types ¶
type Authenticator ¶
func NewAuthenticator ¶
func NewAuthenticator(cfg *models.Config) (*Authenticator, error)
type CRUDPermissions ¶
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.2
type MarkdownProcessor struct {
// contains filtered or unexported fields
}
MarkdownProcessor handles markdown sanitization and conversion
func NewMarkdownProcessor ¶ added in v1.1.2
func NewMarkdownProcessor() *MarkdownProcessor
NewMarkdownProcessor creates a new markdown processor with proper sanitization
func (*MarkdownProcessor) HTMLToMarkdown ¶ added in v1.1.2
func (mp *MarkdownProcessor) HTMLToMarkdown(html string) string
HTMLToMarkdown converts HTML to markdown
func (*MarkdownProcessor) MarkdownToHTML ¶ added in v1.1.2
func (mp *MarkdownProcessor) MarkdownToHTML(markdown string) string
MarkdownToHTML converts markdown to sanitized HTML
func (*MarkdownProcessor) MarkdownToText ¶ added in v1.1.2
func (mp *MarkdownProcessor) MarkdownToText(markdown string) string
MarkdownToText converts markdown to plain text (removes all formatting)
func (*MarkdownProcessor) ProcessMultilineField ¶ added in v1.1.2
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.2
func (mp *MarkdownProcessor) SanitizeMarkdown(markdown string) string
SanitizeMarkdown removes potentially dangerous content from markdown
func (*MarkdownProcessor) TextToMarkdown ¶ added in v1.1.2
func (mp *MarkdownProcessor) TextToMarkdown(text string) string
TextToMarkdown converts plain text to basic markdown
type NamingV2ModelRenamePair ¶ added in v1.6.0
NamingV2ModelRenamePair is one model identifier change produced by naming schema V2 migration.
func ComputeNamingV2ModelRenamePairs ¶ added in v1.6.0
func ComputeNamingV2ModelRenamePairs(project *models.Project) ([]NamingV2ModelRenamePair, error)
ComputeNamingV2ModelRenamePairs returns rename pairs for a project still on legacy naming. When the project is already on naming V2, or has no schema, it returns (nil, nil).
type NamingV2PhysicalMigrator ¶ added in v1.6.0
type NamingV2PhysicalMigrator interface {
ApplyNamingV2PhysicalMigration(ctx context.Context, projectID string, pairs []NamingV2ModelRenamePair, perModelCollections bool, relationTenantModel string) error
}
NamingV2PhysicalMigrator is implemented by project database drivers that can rewrite persisted rows (for example Arango document `type` and collection names) before the in-memory schema is migrated. relationTenantModel is the SaaS tenant root model name (e.g. "restaurant"); when non-empty, relation edges that still carry root-level tenant_id are rewritten into ext (tenant_id, tenant_model).
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)
Source Files
¶
- apito_naming.go
- array.go
- claims_set.go
- connect_disconnect_builder.go
- context.go
- date.go
- english_title_word.go
- env.go
- fragment_query_merger.go
- generator.go
- goroutine_monitor.go
- graphql_context.go
- graphql_typename.go
- html_to_markdown.go
- id_check.go
- locals.go
- map_action_name.go
- map_validation.go
- markdown_utility.go
- model_extractor_from_query.go
- name_extractor.go
- naming_migration.go
- oauth.go
- open_api_spec_generator.go
- path.go
- permission_builder.go
- query_parser.go
- rest_to_graphql.go
- sentry.go
- set_token_cookie.go
- struct_to_graphql.go