Documentation
¶
Overview ¶
Package interfaces defines the contracts for all components in the Apito Engine. This allows for dependency injection and modular architecture between core and pro versions.
Index ¶
- type ApitoSystemDB
- type CacheDBInterface
- type DatabaseDriverFactory
- type GraphQLExecutorInterface
- type GraphQLServerFactory
- type GraphQLServerInterface
- type HashiCorpPluginInterface
- type KeyValueServiceInterface
- type ProjectDBInterface
- type PubSubServiceInterface
- type QueryBuilderInformation
- type SharedDBInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApitoSystemDB ¶
type ApitoSystemDB interface { // RunMigration runs the database migrations RunMigration(ctx context.Context) error // Project-related functions CreateProject creates a new project CreateProject(ctx context.Context, userId string, project *models.Project) (*models.Project, error) // UpdateProject updates a project UpdateProject(ctx context.Context, project *models.Project, replace bool) error // GetProjects retrieves multiple projects by their IDs GetProjects(ctx context.Context, keys []string) ([]*models.Project, error) // GetProject retrieves a project by its ID GetProject(ctx context.Context, id string) (*models.Project, error) // CheckProjectName checks if a project name already exists CheckProjectName(ctx context.Context, name string) error // SearchProjects lists all the projects for a given user SearchProjects(ctx context.Context, param *models.CommonSystemParams) (*models.SearchResponse[models.Project], error) // FindUserProjects lists all the projects for a given user FindUserProjects(ctx context.Context, userId string) ([]*models.Project, error) // FindUserProjectsWithRoles lists all the projects for a given user with their roles FindUserProjectsWithRoles(ctx context.Context, userId string) ([]*models.ProjectWithRoles, error) // DeleteProjectFromSystem deletes a project from the system DeleteProjectFromSystem(ctx context.Context, projectId string) error // AddATeamMemberToProject adds a team member to a project AddATeamMemberToProject(ctx context.Context, req *models.TeamMemberAddRequest) error // RemoveATeamMemberFromProject removes a team member from a project RemoveATeamMemberFromProject(ctx context.Context, projectId string, userId string) error // SearchFunctions lists all the cloud functions for a given project SearchFunctions(ctx context.Context, param *models.CommonSystemParams) (*models.SearchResponse[models.ApitoFunction], error) // User-related functions // GetSystemUser retrieves a system user by their ID GetSystemUser(ctx context.Context, id string) (*models.SystemUser, error) // GetSystemUserByEmail retrieves a system user by their email GetSystemUserByEmail(ctx context.Context, email string) (*models.SystemUser, error) // GetSystemUsers retrieves multiple system users by their IDs GetSystemUsers(ctx context.Context, keys []string) ([]*models.SystemUser, error) // CreateSystemUser creates a new system user CreateSystemUser(ctx context.Context, user *models.SystemUser) (*models.SystemUser, error) // UpdateSystemUser updates a system user's profile UpdateSystemUser(ctx context.Context, user *models.SystemUser, replace bool) error // SearchUsers searches for system users based on a filter SearchUsers(ctx context.Context, param *models.CommonSystemParams) (*models.SearchResponse[models.SystemUser], error) // CheckProjectWithRoles checks if a user belongs to a project CheckProjectWithRoles(ctx context.Context, userId, projectId string) (*models.ProjectWithRoles, error) // AddSystemUserMetaInfo adds metadata to a system user // this is deprecated, and replaced by dataloader resolver // AddSystemUserMetaInfo(ctx context.Context, doc *types.DefaultDocumentStructure) (*types.DefaultDocumentStructure, error) // SearchResource searches for system users based on a filter SearchResource(ctx context.Context, param *models.CommonSystemParams) (*models.SearchResponse[any], error) // Organization-related functions GetTeams(ctx context.Context, userId string) ([]*models.Team, error) // GetOrganizations retrieves multiple user organizations by their IDs GetOrganizations(ctx context.Context, userId string) (*models.SearchResponse[models.Organization], error) // FindOrganizationAdmin retrieves an organization admin by their ID FindOrganizationAdmin(ctx context.Context, orgId string) (*models.SystemUser, error) // FindUserOrganizations retrieves all the organizations for a given user FindUserOrganizations(ctx context.Context, userId string) ([]*models.Organization, error) // CreateOrganization creates a new organization CreateOrganization(ctx context.Context, org *models.Organization) (*models.Organization, error) // AssignTeamToOrganization adds a team to an organization AssignTeamToOrganization(ctx context.Context, orgId, userId, teamId string) error // RemoveATeamFromOrganization removes a team from an organization RemoveATeamFromOrganization(ctx context.Context, orgId, userId, teamId string) error // AssignProjectToOrganization assigns a project to an organization AssignProjectToOrganization(ctx context.Context, orgId, userId, projectId string) error // RemoveProjectFromOrganization removes a project from an organization RemoveProjectFromOrganization(ctx context.Context, orgId, userId, projectId string) error // Team-related functions // GetProjectTeams retrieves a team member from a project GetProjectTeams(ctx context.Context, projectId string) (*models.Team, error) // FindUserTeams retrieves all the teams for a given user GetTeamsMembers(ctx context.Context, projectId string) ([]*models.SystemUser, error) // CreateTeam creates a new team CreateTeam(ctx context.Context, team *models.Team) (*models.Team, error) // AddTeamMetaInfo adds metadata to a team AddTeamMetaInfo(ctx context.Context, docs []*models.SystemUser) ([]*models.SystemUser, error) // Audit log-related functions // SaveAuditLog saves an audit log SaveAuditLog(ctx context.Context, auditLog *models.AuditLogs) error // SearchAuditLogs retrieves audit logs based on a filter SearchAuditLogs(ctx context.Context, param *models.CommonSystemParams) (*models.SearchResponse[models.AuditLogs], error) // Webhook-related functions // SearchWebHooks lists all the webhooks for a given project SearchWebHooks(ctx context.Context, param *models.CommonSystemParams) (*models.SearchResponse[models.Webhook], error) // GetWebHook retrieves a webhook by its ID for a given project GetWebHook(ctx context.Context, projectId, hookId string) (*models.Webhook, error) // DeleteWebhook deletes a webhook by its ID for a given project DeleteWebhook(ctx context.Context, projectId, hookId string) error // AddWebhookToProject adds a webhook to a project AddWebhookToProject(ctx context.Context, doc *models.Webhook) (*models.Webhook, error) // Raw data-related functions // SaveRawData saves raw data related to payments SaveRawData(ctx context.Context, collection string, data map[string]interface{}) error // Token-related functions // CheckTokenBlacklisted checks if a token is blacklisted CheckTokenBlacklisted(ctx context.Context, tokenId string) error // BlacklistAToken blacklists a token BlacklistAToken(ctx context.Context, token map[string]interface{}) error }
ApitoSystemDB is the main interface for the system database operations
type CacheDBInterface ¶
type CacheDBInterface interface { GetProject(ctx context.Context, projectID string) (*models.Project, error) SaveProject(ctx context.Context, project *models.Project) (*models.Project, error) ListKeys(ctx context.Context) ([]string, error) PutAppCache(ctx context.Context, projectID string, cache *models.ApplicationCache) error GetAppCache(ctx context.Context, projectID string) (*models.ApplicationCache, error) Expire(ctx context.Context, id string) error Put(ctx context.Context, id string, cache interface{}) error Get(ctx context.Context, id string) (interface{}, error) }
type DatabaseDriverFactory ¶
type DatabaseDriverFactory interface { // CreateSystemDriver creates a system database driver CreateSystemDriver(conf *models.Config, engineConfig *models.DriverCredentials) (ApitoSystemDB, error) // CreateProjectDriver creates a project database driver CreateProjectDriver(conf *models.Config, engineConfig *models.DriverCredentials) (ProjectDBInterface, error) // SupportsEngine returns true if this factory can create drivers for the given engine SupportsEngine(engine string) bool }
DatabaseDriverFactory interface for creating database drivers This allows pro version to inject its own drivers while keeping core intact
type GraphQLExecutorInterface ¶
type GraphQLExecutorInterface interface { Init(ctx context.Context, _driver *models.InitParams) error GetExecutorVersion(ctx context.Context) (string, error) SetApplicationCache(ctx context.Context, cache *models.ApplicationCache) error GetApplicationCache(ctx context.Context) (*models.ApplicationCache, error) GetProjectDriver(ctx context.Context) (ProjectDBInterface, error) SetProjectDriverCredential(ctx context.Context, driverCredentials *models.DriverCredentials) error GetDataLoaders(ctx context.Context) (*models.DataLoaders, error) DataLoaderHandler(ctx context.Context, keys []string) []*dataloader.Result[interface{}] SolvePublicQuery(ctx context.Context, model string, _args interface{}, selectionSet *ast.SelectionSet, cache *models.ApplicationCache) ([]byte, error) SolvePublicQueryCount(ctx context.Context, model string, _args interface{}, cache *models.ApplicationCache) ([]byte, error) SolvePublicMutation(ctx context.Context, resolverName string, _id *string, _ids []*string, status *string, local *string, userInputPayload interface{}, connect interface{}, disconnect interface{}, cache *models.ApplicationCache) ([]byte, error) //ConnectDisconnectParamBuilder(ctx context.Context, project *models.Project, uid string, connectionIds map[string]interface{}, modelType *models.ModelType) ([]*shared.ConnectDisconnectParam, error) HandlePayloadFormatting(ctx context.Context, param *models.CommonSystemParams, local string, fields []*models.FieldInfo, inputPayload map[string]interface{}, dbPayload map[string]interface{}, deltaUpdate bool) (map[string]interface{}, error) }
type GraphQLServerFactory ¶ added in v1.1.7
type GraphQLServerFactory interface { // SupportsVersion returns true if this factory can create servers for the given version/edition SupportsVersion(version string) bool // CreateGraphQLServer creates a GraphQL server instance CreateGraphQLServer(ctx context.Context, cfg *models.Config, extensionRouter *echo.Group, mainEcho *echo.Echo) (GraphQLServerInterface, error) }
GraphQLServerFactory interface for creating GraphQL servers This allows pro version to inject its own enhanced GraphQL server while keeping core intact
type GraphQLServerInterface ¶ added in v1.1.7
type GraphQLServerInterface interface { // Authentication middleware Authorize() echo.MiddlewareFunc PublicFunctionRouteAuthorize() echo.MiddlewareFunc // Application cache and project management GetApplicationCache(router echo.Context) (*models.ApplicationCache, error) LoadProjectCache(ctx context.Context, projectID string) (*models.Project, error) UpdateApplicationCache(ctx context.Context, projectID string) // GraphQL field caching GetCacheGraphQLFieldsGeneration(ctx context.Context, projectID string, modelName string) (*QueryBuilderInformation, error) CacheGraphQLFieldsGeneration(ctx context.Context, projectID string, modelName string, val interface{}) error ExpireGraphQLFieldCache(ctx context.Context, projectID string, modelName string) error ExpireGraphQLProjectCache(ctx context.Context, projectID string) error // System messaging and subscriptions PublishSystemMessage(ctx context.Context, userID string, data *models.SubscriptionEvent) error // Provider management GetFunctionProvider() ([]string, error) GetStorageProvider() ([]string, error) // File handling GatherFileInfo(image []byte) (*models.FileDetails, error) PrepareFileInfo(router echo.Context, projectID string) (*models.FileDetails, *bytes.Buffer, error) // Plugin management LoadPlugins(ctx context.Context) error WaitForPluginsToLoad() PrintAllPluginRoutes() // System parameters BuildSystemParam(i echo.Context, project *models.Project) (*models.CommonSystemParams, error) NewParam(_param *models.CommonSystemParams) *models.CommonSystemParams // Schema and query building BuildServerQueriesAndMutations() LoadProjectSpecificPlugins(ctx context.Context, cache *models.ApplicationCache) error // Plugin monitoring (needed by router) GetHashiCorpPluginIDs() []string SetPluginMonitor(monitor interface{}) GetConcreteServer() interface{} // For controller compatibility }
GraphQLServerInterface defines the contract for GraphQL server implementations This allows pro version to extend core functionality while maintaining compatibility
type HashiCorpPluginInterface ¶
type HashiCorpPluginInterface interface { // Init This functions runs when any extension runs Init(ctx context.Context, env []*protobuff.EnvVariable) error // Migration If your extension has any migration script you can put it here Migration(ctx context.Context) error // SchemaRegister Define the GraphQL Schema That Will be Added If this extension registers SchemaRegister(ctx context.Context) (*protobuff.ThirdPartyGraphQLSchemas, error) // RESTApiRegister Define the REST api that will be added to the existing list RESTApiRegister(ctx context.Context) ([]*protobuff.ThirdPartyRESTApi, error) // Execute calls when the function is called Execute(ctx context.Context, request interface{}) (interface{}, error) }
HashiCorpPluginInterface interface functions for HashiCorp go-plugin system
type KeyValueServiceInterface ¶
type KeyValueServiceInterface interface { // AddToSortedSets adds a key to a sorted set with a given TTL (Time To Live) in seconds. AddToSortedSets(ctx context.Context, setName string, key string, exp time.Duration) error // GetFromSortedSets retrieves a key from a sorted set. GetFromSortedSets(ctx context.Context, setName string, key string) (float64, error) // SetToHashMap sets a key-value pair in a hash. SetToHashMap(ctx context.Context, hash, key string, value string) error // GetFromHashMap retrieves a value from a hash using a key. GetFromHashMap(ctx context.Context, hash, key string) (string, error) // CheckKeyHashMap checks if a key exists in a hash. CheckKeyHashMap(ctx context.Context, hash, key string) bool // DelValue deletes a value using a key. DelValue(ctx context.Context, key string) error // SetValue sets a value with a key with a given expiration time. SetValue(ctx context.Context, key string, value string, expiration time.Duration) error // SetJSONObject sets a JSON object with a key with a given expiration time. SetJSONObject(ctx context.Context, key string, value interface{}, expiration time.Duration) error // GetJSONObject retrieves a JSON object using a key. GetJSONObject(ctx context.Context, key string) (interface{}, error) // CheckRedisKey checks if one or more keys exist. CheckRedisKey(ctx context.Context, keys ...string) (bool, error) // GetValue retrieves a value using a key. GetValue(ctx context.Context, key string) (string, error) // AddToSets adds a value to a set. AddToSets(ctx context.Context, key string, value string) error // RemoveSets removes a value from a set. RemoveSets(ctx context.Context, key string, value string) error }
KeyValueServiceInterface is an interface that defines the methods for interacting with Redis.
type ProjectDBInterface ¶
type ProjectDBInterface interface { // Project-related functions // DeleteProject deletes a project by its ID. DeleteProject(ctx context.Context, projectID string) error // TransferProject transfers a project from one user to another. TransferProject(ctx context.Context, userId, from, to string) error // Collection-related functions // CheckCollectionExists checks if a collection exists in the project. CheckCollectionExists(ctx context.Context, param *models.CommonSystemParams, isRelationCollection bool) (bool, error) // AddCollection adds a new collection to the project. AddCollection(ctx context.Context, param *models.CommonSystemParams, isRelationCollection bool) error // Model-related functions // AddModel adds a new model to the project. AddModel(ctx context.Context, project *models.Project, model *models.ModelType) (*models.ProjectSchema, error) // AddFieldToModel adds a new field to an existing model in the project. AddFieldToModel(ctx context.Context, param *models.CommonSystemParams, isUpdate bool, parent_field string) (*models.ModelType, error) // RenameModel renames a model in the project. RenameModel(ctx context.Context, project *models.Project, modelName, newName string) error // ConvertModel converts a model in the project. ConvertModel(ctx context.Context, project *models.Project, modelName string) error // DropModel drops a model from the project. DropModel(ctx context.Context, project *models.Project, modelName string) error // Index-related functions // CreateIndex creates an index for a model in the project. CreateIndex(ctx context.Context, param *models.CommonSystemParams, fieldName string, parent_field string) error // DropIndex drops an index from a model in the project. DropIndex(ctx context.Context, param *models.CommonSystemParams, indexName string) error // Relation-related functions // AddRelationFields creates a relation field (has one or has many) between models. AddRelationFields(ctx context.Context, from *models.ConnectionType, to *models.ConnectionType) error // DeleteRelationDocuments drops pivot tables, relation keys, or collection tables and all documents within them. DeleteRelationDocuments(ctx context.Context, projectId string, from *models.ConnectionType, to *models.ConnectionType) error // GetRelationDocument retrieves a relation document by ID. GetRelationDocument(ctx context.Context, param *models.ConnectDisconnectParam) (*models.EdgeRelation, error) // CreateRelation creates a relation in the project. CreateRelation(ctx context.Context, projectId string, relation *models.EdgeRelation) error // DeleteRelation deletes a relation in the project. DeleteRelation(ctx context.Context, param *models.ConnectDisconnectParam, id string) error // NewInsertableRelations retrieves new insertable relations in the project. NewInsertableRelations(ctx context.Context, param *models.ConnectDisconnectParam) ([]string, error) // CheckOneToOneRelationExists checks if a one-to-one relation exists in the project. CheckOneToOneRelationExists(ctx context.Context, param *models.ConnectDisconnectParam) (bool, error) // GetRelationIds retrieves the IDs of every document related to a document. GetRelationIds(ctx context.Context, param *models.ConnectDisconnectParam) ([]string, error) // Builder-related functions // ConnectBuilder connects a builder to the project. ConnectBuilder(ctx context.Context, param *models.CommonSystemParams) error // DisconnectBuilder disconnects a builder from the project. DisconnectBuilder(ctx context.Context, param *models.CommonSystemParams) error // User-related functions // GetProjectUser retrieves a user profile by phone, email, and project ID. GetProjectUser(ctx context.Context, phone, email, projectId string) (*types.DefaultDocumentStructure, error) // GetLoggedInProjectUser retrieves the logged-in user profile for the project. GetLoggedInProjectUser(ctx context.Context, param *models.CommonSystemParams) (*types.DefaultDocumentStructure, error) // GetProjectUsers retrieves metadata for multiple users in the project. GetProjectUsers(ctx context.Context, projectId string, keys []string) (map[string]*types.DefaultDocumentStructure, error) // Get a Relation Data of a single document by id, it could be object or array // GetAllRelationDocumentsOfSingleDocument retrieves all relation data of a single document by ID. GetAllRelationDocumentsOfSingleDocument(ctx context.Context, from string, arg *models.CommonSystemParams) (interface{}, error) // Document-related functions // GetSingleProjectDocumentBytes retrieves a single project document by ID as bytes. GetSingleProjectDocumentBytes(ctx context.Context, param *models.CommonSystemParams) ([]byte, error) // GetSingleProjectDocument retrieves a single project document by ID. GetSingleProjectDocument(ctx context.Context, param *models.CommonSystemParams) (*types.DefaultDocumentStructure, error) // GetSingleProjectDocumentRevisions retrieves the revision history of a single project document by ID. GetSingleProjectDocumentRevisions(ctx context.Context, param *models.CommonSystemParams) ([]*models.DocumentRevisionHistory, error) // GetSingleRawDocumentFromProject retrieves a single raw document from the project. GetSingleRawDocumentFromProject(ctx context.Context, param *models.CommonSystemParams) (interface{}, error) // QueryMultiDocumentOfProjectBytes queries multiple documents in the project and returns the result as bytes. QueryMultiDocumentOfProjectBytes(ctx context.Context, param *models.CommonSystemParams) ([]byte, error) // QueryMultiDocumentOfProject queries multiple documents in the project and returns the result as a slice of DefaultDocumentStructure. QueryMultiDocumentOfProject(ctx context.Context, param *models.CommonSystemParams) ([]*types.DefaultDocumentStructure, error) // AddDocumentToProject adds a new document to the project. AddDocumentToProject(ctx context.Context, param *models.CommonSystemParams, doc *types.DefaultDocumentStructure) (interface{}, error) // UpdateDocumentOfProject updates a particular document in the project. UpdateDocumentOfProject(ctx context.Context, param *models.CommonSystemParams, doc *types.DefaultDocumentStructure, replace bool) error // DeleteDocumentFromProject deletes a document from the project. DeleteDocumentFromProject(ctx context.Context, param *models.CommonSystemParams) error // DeleteDocumentsFromProject deletes multiple documents from the project. DeleteDocumentsFromProject(ctx context.Context, param *models.CommonSystemParams) error // DeleteDocumentRelation deletes all relations or data in pivot tables from the project. DeleteDocumentRelation(ctx context.Context, param *models.CommonSystemParams) error // Metadata-related functions // AddTeamMetaInfo adds metadata information for a team in the project. AddTeamMetaInfo(ctx context.Context, docs []*models.SystemUser) ([]*models.SystemUser, error) // Raw data-related functions // RelationshipDataLoader loads relationship data for the project. RelationshipDataLoader(ctx context.Context, param *models.CommonSystemParams, connection map[string]interface{}) (interface{}, error) // RelationshipDataLoaderBytes loads relationship data for the project and returns it as bytes. RelationshipDataLoaderBytes(ctx context.Context, param *models.CommonSystemParams, connection map[string]interface{}) ([]byte, error) // Counting documents-related functions // CountDocOfProject counts the documents in the project. CountDocOfProject(ctx context.Context, param *models.CommonSystemParams) (interface{}, error) // CountDocOfProjectBytes counts the documents in the project and returns the result as bytes. CountDocOfProjectBytes(ctx context.Context, param *models.CommonSystemParams) ([]byte, error) // CountMultiDocumentOfProject counts multiple documents in the project. CountMultiDocumentOfProject(ctx context.Context, param *models.CommonSystemParams, previewModel bool) (int, error) // Aggregate-related functions // AggregateDocOfProject aggregates the documents in the project. AggregateDocOfProject(ctx context.Context, param *models.CommonSystemParams) (interface{}, error) // AggregateDocOfProjectBytes aggregates the documents in the project and returns the result as bytes. AggregateDocOfProjectBytes(ctx context.Context, param *models.CommonSystemParams) ([]byte, error) // Field-related functions // DropField drops/deletes a field and its data from the project. DropField(ctx context.Context, param *models.CommonSystemParams) error // RenameField renames a field in a model along with its data key. RenameField(ctx context.Context, oldFieldName string, repeatedFieldGroup string, param *models.CommonSystemParams) error }
type PubSubServiceInterface ¶
type PubSubServiceInterface interface { // Subscribe method subscribes to a Redis channel and returns a pointer to a PubSub object. Subscribe(ctx context.Context, chanel string) *redis.PubSub // Publish method publishes data to a Redis channel and returns an error if the operation fails. Publish(ctx context.Context, chanel string, data interface{}) error // AddSubscriber method adds a subscriber to the Pub/Sub service and returns a pointer to the Subscriber object and an error if the operation fails. AddSubscriber(ctx context.Context, userID string) (*models.Subscriber, error) // RemoveSubscriber method removes a subscriber from the Pub/Sub service and returns an error if the operation fails. RemoveSubscriber(ctx context.Context, userID string) error // GetSubscriber method retrieves a subscriber from the Pub/Sub service and returns a pointer to the Subscriber object and an error if the operation fails. GetSubscriber(ctx context.Context, userID string) (*models.Subscriber, error) }
PubSubServiceInterface is an interface that defines the methods for interacting with a Pub/Sub service.
type QueryBuilderInformation ¶ added in v1.1.7
type QueryBuilderInformation struct { DataObjects graphql.Fields AggregateObjects graphql.Fields WhereParamObjects graphql.InputObjectConfigFieldMap SortParamObjects graphql.InputObjectConfigFieldMap }
type SharedDBInterface ¶
type SharedDBInterface interface {}