From bed7e040de212a8f4ab4e1179a4d19e2afe24adb Mon Sep 17 00:00:00 2001 From: Jay D Date: Tue, 25 Apr 2023 18:44:47 +0800 Subject: [PATCH] feat: add server-side support for neon action --- pkg/action/factory.go | 3 ++- pkg/action/service.go | 9 +++++---- pkg/app/service.go | 4 ++-- pkg/resource/factory.go | 3 ++- pkg/resource/service.go | 9 +++++---- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pkg/action/factory.go b/pkg/action/factory.go index bb22a177..e42f4388 100644 --- a/pkg/action/factory.go +++ b/pkg/action/factory.go @@ -63,6 +63,7 @@ var ( ORACLE_ACTION = "oracle" APPWRITE_ACTION = "appwrite" GOOGLESHEETS_ACTION = "googlesheets" + NEON_ACTION = "neon" ) type AbstractActionFactory interface { @@ -81,7 +82,7 @@ func (f *Factory) Build() common.DataConnector { case MYSQL_ACTION, MARIADB_ACTION, TIDB_ACTION: sqlAction := &mysql.MySQLConnector{} return sqlAction - case POSTGRESQL_ACTION, SUPABASEDB_ACTION: + case POSTGRESQL_ACTION, SUPABASEDB_ACTION, NEON_ACTION: pgsAction := &postgresql.Connector{} return pgsAction case REDIS_ACTION: diff --git a/pkg/action/service.go b/pkg/action/service.go index 30025470..9a4eb9c6 100644 --- a/pkg/action/service.go +++ b/pkg/action/service.go @@ -25,9 +25,9 @@ import ( "go.uber.org/zap" ) -var type_array = [24]string{"transformer", "restapi", "graphql", "redis", "mysql", "mariadb", "postgresql", "mongodb", +var type_array = [25]string{"transformer", "restapi", "graphql", "redis", "mysql", "mariadb", "postgresql", "mongodb", "tidb", "elasticsearch", "s3", "smtp", "supabasedb", "firebase", "clickhouse", "mssql", "huggingface", "dynamodb", - "snowflake", "couchdb", "hfendpoint", "oracle", "appwrite", "googlesheets"} + "snowflake", "couchdb", "hfendpoint", "oracle", "appwrite", "googlesheets", "neon"} var type_map = map[string]int{ "transformer": 0, "restapi": 1, @@ -53,6 +53,7 @@ var type_map = map[string]int{ "oracle": 21, "appwrite": 22, "googlesheets": 23, + "neon": 24, } type ActionService interface { @@ -75,7 +76,7 @@ type ActionDto struct { Version int `json:"-"` Resource int `json:"resourceId,omitempty"` DisplayName string `json:"displayName" validate:"required"` - Type string `json:"actionType" validate:"oneof=transformer restapi graphql redis mysql mariadb postgresql mongodb tidb elasticsearch s3 smtp supabasedb firebase clickhouse mssql huggingface dynamodb snowflake couchdb hfendpoint oracle appwrite googlesheets"` + Type string `json:"actionType" validate:"oneof=transformer restapi graphql redis mysql mariadb postgresql mongodb tidb elasticsearch s3 smtp supabasedb firebase clickhouse mssql huggingface dynamodb snowflake couchdb hfendpoint oracle appwrite googlesheets neon"` Template map[string]interface{} `json:"content" validate:"required"` Transformer map[string]interface{} `json:"transformer" validate:"required"` TriggerMode string `json:"triggerMode" validate:"oneof=manually automate"` @@ -94,7 +95,7 @@ type ActionDtoForExport struct { Version int `json:"-"` Resource string `json:"resourceId,omitempty"` DisplayName string `json:"displayName" validate:"required"` - Type string `json:"actionType" validate:"oneof=transformer restapi graphql redis mysql mariadb postgresql mongodb tidb elasticsearch s3 smtp supabasedb firebase clickhouse mssql huggingface dynamodb snowflake couchdb hfendpoint oracle appwrite"` + Type string `json:"actionType" validate:"oneof=transformer restapi graphql redis mysql mariadb postgresql mongodb tidb elasticsearch s3 smtp supabasedb firebase clickhouse mssql huggingface dynamodb snowflake couchdb hfendpoint oracle appwrite googlesheets neon"` Template map[string]interface{} `json:"content" validate:"required"` Transformer map[string]interface{} `json:"transformer" validate:"required"` TriggerMode string `json:"triggerMode" validate:"oneof=manually automate"` diff --git a/pkg/app/service.go b/pkg/app/service.go index 98d51a63..f2a93660 100644 --- a/pkg/app/service.go +++ b/pkg/app/service.go @@ -49,9 +49,9 @@ type AppServiceImpl struct { actionRepository repository.ActionRepository } -var type_array = [24]string{"transformer", "restapi", "graphql", "redis", "mysql", "mariadb", "postgresql", "mongodb", +var type_array = [25]string{"transformer", "restapi", "graphql", "redis", "mysql", "mariadb", "postgresql", "mongodb", "tidb", "elasticsearch", "s3", "smtp", "supabasedb", "firebase", "clickhouse", "mssql", "huggingface", "dynamodb", - "snowflake", "couchdb", "hfendpoint", "oracle", "appwrite", "googlesheets"} + "snowflake", "couchdb", "hfendpoint", "oracle", "appwrite", "googlesheets", "neon"} type AppDto struct { ID int `json:"appId"` // generated by database primary key serial diff --git a/pkg/resource/factory.go b/pkg/resource/factory.go index cc3d408c..141a6f4c 100644 --- a/pkg/resource/factory.go +++ b/pkg/resource/factory.go @@ -62,6 +62,7 @@ var ( ORACLE_RESOURCE = "oracle" APPWRITE_RESOURCE = "appwrite" GOOGLESHEETS_RESOURCE = "googlesheets" + NEON_RESOURCE = "neon" ) type AbstractResourceFactory interface { @@ -80,7 +81,7 @@ func (f *Factory) Generate() common.DataConnector { case MYSQL_RESOURCE, MARIADB_RESOURCE, TIDB_RESOURCE: sqlRsc := &mysql.MySQLConnector{} return sqlRsc - case POSTGRES_RESOURCE, SUPABASEDB_RESOURCE: + case POSTGRES_RESOURCE, SUPABASEDB_RESOURCE, NEON_RESOURCE: pgsRsc := &postgresql.Connector{} return pgsRsc case REDIS_RESOURCE: diff --git a/pkg/resource/service.go b/pkg/resource/service.go index d20a5487..941d42af 100644 --- a/pkg/resource/service.go +++ b/pkg/resource/service.go @@ -25,9 +25,9 @@ import ( "go.uber.org/zap" ) -var type_array = [23]string{"restapi", "graphql", "redis", "mysql", "mariadb", "postgresql", "mongodb", "tidb", +var type_array = [24]string{"restapi", "graphql", "redis", "mysql", "mariadb", "postgresql", "mongodb", "tidb", "elasticsearch", "s3", "smtp", "supabasedb", "firebase", "clickhouse", "mssql", "huggingface", "dynamodb", "snowflake", - "couchdb", "hfendpoint", "oracle", "appwrite", "googlesheets"} + "couchdb", "hfendpoint", "oracle", "appwrite", "googlesheets", "neon"} var type_map = map[string]int{ "restapi": 1, "graphql": 2, @@ -52,6 +52,7 @@ var type_map = map[string]int{ "oracle": 21, "appwrite": 22, "googlesheets": 23, + "neon": 24, } type ResourceService interface { @@ -70,7 +71,7 @@ type ResourceDto struct { UID uuid.UUID `json:"uid"` TeamID int `json:"teamID"` Name string `json:"resourceName" validate:"required,min=1,max=128"` - Type string `json:"resourceType" validate:"oneof=restapi graphql redis mysql mariadb postgresql mongodb tidb elasticsearch s3 smtp supabasedb firebase clickhouse mssql huggingface dynamodb snowflake couchdb hfendpoint oracle appwrite googlesheets"` + Type string `json:"resourceType" validate:"oneof=restapi graphql redis mysql mariadb postgresql mongodb tidb elasticsearch s3 smtp supabasedb firebase clickhouse mssql huggingface dynamodb snowflake couchdb hfendpoint oracle appwrite googlesheets neon"` Options map[string]interface{} `json:"content" validate:"required"` CreatedAt time.Time `json:"createdAt,omitempty"` CreatedBy int `json:"createdBy,omitempty"` @@ -83,7 +84,7 @@ type ResourceDtoForExport struct { UID uuid.UUID `json:"uid"` TeamID string `json:"teamID"` Name string `json:"resourceName" validate:"required"` - Type string `json:"resourceType" validate:"oneof=restapi graphql redis mysql mariadb postgresql mongodb tidb elasticsearch s3 smtp supabasedb firebase clickhouse mssql huggingface dynamodb snowflake couchdb hfendpoint oracle appwrite googlesheets"` + Type string `json:"resourceType" validate:"oneof=restapi graphql redis mysql mariadb postgresql mongodb tidb elasticsearch s3 smtp supabasedb firebase clickhouse mssql huggingface dynamodb snowflake couchdb hfendpoint oracle appwrite googlesheets neon"` Options map[string]interface{} `json:"content" validate:"required"` CreatedAt time.Time `json:"createdAt,omitempty"` CreatedBy string `json:"createdBy,omitempty"`