Skip to content

Commit

Permalink
Release: v1.7.2(#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
naj1n authored Jan 14, 2023
2 parents 1bf3e07 + 66dba65 commit 2689cb2
Show file tree
Hide file tree
Showing 18 changed files with 732 additions and 212 deletions.
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ require (
github.com/aws/aws-sdk-go-v2 v1.17.3
github.com/aws/aws-sdk-go-v2/config v1.18.7
github.com/aws/aws-sdk-go-v2/credentials v1.13.7
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.9
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.18.0
github.com/aws/aws-sdk-go-v2/service/s3 v1.29.6
github.com/caarlos0/env v3.5.0+incompatible
github.com/elastic/go-elasticsearch/v8 v8.5.0
Expand Down Expand Up @@ -53,8 +55,10 @@ require (
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.21 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.28 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.18 // indirect
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.14.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.22 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.21 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.21 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.21 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.11.28 // indirect
Expand Down Expand Up @@ -88,6 +92,7 @@ require (
github.com/jackc/pgx/v4 v4.17.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.4 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
Expand Down
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ github.com/aws/aws-sdk-go-v2/config v1.18.7 h1:V94lTcix6jouwmAsgQMAEBozVAGJMFhVj
github.com/aws/aws-sdk-go-v2/config v1.18.7/go.mod h1:OZYsyHFL5PB9UpyS78NElgKs11qI/B5KJau2XOJDXHA=
github.com/aws/aws-sdk-go-v2/credentials v1.13.7 h1:qUUcNS5Z1092XBFT66IJM7mYkMwgZ8fcC8YDIbEwXck=
github.com/aws/aws-sdk-go-v2/credentials v1.13.7/go.mod h1:AdCcbZXHQCjJh6NaH3pFaw8LUeBFn5+88BZGMVGuBT8=
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.9 h1:G3QwassSng2rJVtSZOcLMOKxvb3U4CAflNqJlqqiAvw=
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.9/go.mod h1:+gnfJHVarZmY3pmAX9DnkL6lcGQtQ9Z1Rsj2Z1dsS4c=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.21 h1:j9wi1kQ8b+e0FBVHxCqCGo4kxDU175hoDHcWAi0sauU=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.21/go.mod h1:ugwW57Z5Z48bpvUyZuaPy4Kv+vEfJWnIrky7RmkBvJg=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.27 h1:I3cakv2Uy1vNmmhRQmFptYDxOvBnwCdNwyw63N0RaRU=
Expand All @@ -49,10 +51,16 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.3.28 h1:KeTxcGdNnQudb46oOl4d90f2I33
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.28/go.mod h1:yRZVr/iT0AqyHeep00SZ4YfBAKojXz08w3XMBscdi0c=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.18 h1:H/mF2LNWwX00lD6FlYfKpLLZgUW7oIzCBkig78x4Xok=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.18/go.mod h1:T2Ku+STrYQ1zIkL1wMvj8P3wWQaaCMKNdz70MT2FLfE=
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.18.0 h1:ytPUxPttkqtX8ducnFlimxa75RTwWfox+y8FwhIzMQE=
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.18.0/go.mod h1:uP2wpt43//qh6NqMFslaRu53A2YbnFStkV4Wn1Ldels=
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.14.0 h1:cctNlfjDl1xXPCFvwr/hUcBN6suAni8Mo1mcg4jNmQ4=
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.14.0/go.mod h1:zGScIYqnuTec46Rma2T0iSRUllvdebmzmvieAz0FyPo=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 h1:y2+VQzC6Zh2ojtV2LoC0MNwHWc6qXv/j2vrQtlftkdA=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11/go.mod h1:iV4q2hsqtNECrfmlXyord9u4zyuFEJX9eLgLpSPzWA8=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.22 h1:kv5vRAl00tozRxSnI0IszPWGXsJOyA7hmEUHFYqsyvw=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.22/go.mod h1:Od+GU5+Yx41gryN/ZGZzAJMZ9R1yn6lgA0fD5Lo5SkQ=
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.21 h1:UYhcXvg66FBsZKRpXtNc4w+2rwaTHzST/zhpQBxzhPo=
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.21/go.mod h1:NXJls8x8f9zVSaf+EKKoonqaahWK69MUWm6w6ob0FHs=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.21 h1:5C6XgTViSb0bunmU57b3CT+MhxULqHH2721FVA+/kDM=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.21/go.mod h1:lRToEJsn+DRA9lW4O9L9+/3hjTkUzlzyzHqn8MTds5k=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.21 h1:vY5siRXvW5TrOKm2qKEf9tliBfdLxdfy0i02LOcmqUo=
Expand Down Expand Up @@ -250,7 +258,9 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
Expand Down Expand Up @@ -551,6 +561,7 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
4 changes: 4 additions & 0 deletions internal/websocket/cooperate.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func (iru *InRoomUsers) LeaveRoom(userID int) {
delete(iru.AllUsers, userID)
}

func (iru *InRoomUsers) Count() int {
return len(iru.AllUsers)
}

func (iru *InRoomUsers) AttachComponent(userID int, componentDisplayNames []string) {
fuser, hit := iru.AllUsers[userID]
if !hit { // invalied user input, just ignore
Expand Down
9 changes: 8 additions & 1 deletion internal/websocket/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/illacloud/builder-backend/pkg/resource"
"github.com/illacloud/builder-backend/pkg/state"
"github.com/illacloud/builder-backend/pkg/user"

uuid "github.com/satori/go.uuid"
)

Expand Down Expand Up @@ -97,6 +96,14 @@ func (hub *Hub) GetInRoomUsersByRoomID(roomID int) *InRoomUsers {
return inRoomUsers
}

func (hub *Hub) CleanRoom(roomID int) {
inRoomUsers, hit := hub.InRoomUsersMap[roomID]
if inRoomUsers.Count() != 0 || !hit {
return
}
delete(hub.InRoomUsersMap, roomID)
}

func (hub *Hub) BroadcastToOtherClients(message *Message, currentClient *Client) {
if !message.NeedBroadcast {
return
Expand Down
5 changes: 5 additions & 0 deletions pkg/action/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package action
import (
"github.com/illacloud/builder-backend/pkg/plugins/clickhouse"
"github.com/illacloud/builder-backend/pkg/plugins/common"
"github.com/illacloud/builder-backend/pkg/plugins/dynamodb"
"github.com/illacloud/builder-backend/pkg/plugins/elasticsearch"
"github.com/illacloud/builder-backend/pkg/plugins/firebase"
"github.com/illacloud/builder-backend/pkg/plugins/graphql"
Expand Down Expand Up @@ -49,6 +50,7 @@ var (
GRAPHQL_ACTION = "graphql"
MSSQL_ACTION = "mssql"
HUGGINGFACE_ACTION = "huggingface"
DYNAMODB_ACTION = "dynamodb"
)

type AbstractActionFactory interface {
Expand Down Expand Up @@ -100,6 +102,9 @@ func (f *Factory) Build() common.DataConnector {
case HUGGINGFACE_ACTION:
hfAction := &huggingface.Connector{}
return hfAction
case DYNAMODB_ACTION:
dynamodbAction := &dynamodb.Connector{}
return dynamodbAction
default:
return nil
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/action/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"go.uber.org/zap"
)

var type_array = [17]string{"transformer", "restapi", "graphql", "redis", "mysql", "mariadb", "postgresql", "mongodb",
"tidb", "elasticsearch", "s3", "smtp", "supabasedb", "firebase", "clickhouse", "mssql", "huggingface"}
var type_array = [18]string{"transformer", "restapi", "graphql", "redis", "mysql", "mariadb", "postgresql", "mongodb",
"tidb", "elasticsearch", "s3", "smtp", "supabasedb", "firebase", "clickhouse", "mssql", "huggingface", "dynamodb"}
var type_map = map[string]int{
"transformer": 0,
"restapi": 1,
Expand All @@ -43,6 +43,7 @@ var type_map = map[string]int{
"clickhouse": 14,
"mssql": 15,
"huggingface": 16,
"dynamodb": 17,
}

type ActionService interface {
Expand All @@ -61,7 +62,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"`
Type string `json:"actionType" validate:"oneof=transformer restapi graphql redis mysql mariadb postgresql mongodb tidb elasticsearch s3 smtp supabasedb firebase clickhouse mssql huggingface dynamodb"`
Template map[string]interface{} `json:"content" validate:"required"`
Transformer map[string]interface{} `json:"transformer" validate:"required"`
TriggerMode string `json:"triggerMode" validate:"oneof=manually automate"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ type AppServiceImpl struct {
actionRepository repository.ActionRepository
}

var type_array = [17]string{"transformer", "restapi", "graphql", "redis", "mysql", "mariadb", "postgresql", "mongodb",
"tidb", "elasticsearch", "s3", "smtp", "supabasedb", "firebase", "clickhouse", "mssql", "huggingface"}
var type_array = [18]string{"transformer", "restapi", "graphql", "redis", "mysql", "mariadb", "postgresql", "mongodb",
"tidb", "elasticsearch", "s3", "smtp", "supabasedb", "firebase", "clickhouse", "mssql", "huggingface", "dynamodb"}

type AppDto struct {
ID int `json:"appId"` // generated by database primary key serial
Expand Down
53 changes: 53 additions & 0 deletions pkg/plugins/dynamodb/base.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2023 Illa Soft, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package dynamodb

import (
"context"

"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/mitchellh/mapstructure"
)

const (
QUERY_METHOD = "query"
SCAN_METHOD = "scan"
PUT_ITEM_METHOD = "putItem"
GET_ITEM_METHOD = "getItem"
UPDATE_ITEM_METHOD = "updateItem"
DELETE_ITEM_METHOD = "deleteItem"
)

func (d *Connector) getClientWithOptions(resourceOptions map[string]interface{}) (*dynamodb.Client, error) {
// format resource options
if err := mapstructure.Decode(resourceOptions, &d.ResourceOpts); err != nil {
return nil, err
}

// format the parameters for the session you want to create.
creds := credentials.NewStaticCredentialsProvider(d.ResourceOpts.AccessKeyID, d.ResourceOpts.SecretAccessKey, "")

cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion(d.ResourceOpts.Region), config.WithCredentialsProvider(creds))
if err != nil {
return nil, err
}

// Using the Config value, create the DynamoDB client
client := dynamodb.NewFromConfig(cfg)

return client, nil
}
Loading

0 comments on commit 2689cb2

Please sign in to comment.