diff --git a/README.md b/README.md index 9ce2182..1de38d4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@

- ## Features - Automatic parsing of proto definitions to render services and input messages @@ -16,7 +15,7 @@ - Selection of multiple services and methods - Configuration of TLS, including disabling TLS (plain text) - Input generation for all scalar types -- Input generation for nested messages +- Input generation for nested and looped messages - Input generation for enums, including nested - Input generation for repeated fields - Input generation for oneof and map fields @@ -47,7 +46,8 @@ Visit the [Releases](https://github.com/Forest33/warthog/releases) page for the ### MacOS -[Download](https://github.com/Forest33/warthog/releases) and open `Warthog*-darwin-x86-64.dmg`, drag `Warthog` to the `Applications` folder and run from `Applications`. +[Download](https://github.com/Forest33/warthog/releases) and open `Warthog*-darwin-x86-64.dmg`, drag `Warthog` to +the `Applications` folder and run from `Applications`. ### Windows diff --git a/adapter/database/gui.config.go b/adapter/database/gui.config.go index 9768829..cd808ce 100644 --- a/adapter/database/gui.config.go +++ b/adapter/database/gui.config.go @@ -8,12 +8,11 @@ import ( "github.com/forest33/warthog/business/entity" "github.com/forest33/warthog/pkg/database" - "github.com/forest33/warthog/pkg/database/types" ) const ( guiConfigTable = "gui_config" - guiConfigTableFields = "window_width, window_height, window_x, window_y, created_at, updated_at" + guiConfigTableFields = "window_width, window_height, window_x, window_y" ) // GUIConfigRepository object capable of interacting with GUIConfigRepository @@ -31,33 +30,19 @@ func NewGUIConfigRepository(ctx context.Context, db *database.Database) *GUIConf } type guiConfigDTO struct { - WindowWidth int `db:"window_width"` - WindowHeight int `db:"window_height"` - WindowX int `db:"window_x"` - WindowY int `db:"window_y"` - CreatedAt string `db:"created_at"` - UpdatedAt string `db:"updated_at"` + WindowWidth int `db:"window_width"` + WindowHeight int `db:"window_height"` + WindowX int `db:"window_x"` + WindowY int `db:"window_y"` } -func (dto *guiConfigDTO) entity() (*entity.GUIConfig, error) { - out := &entity.GUIConfig{ +func (dto *guiConfigDTO) entity() *entity.GUIConfig { + return &entity.GUIConfig{ WindowWidth: dto.WindowWidth, WindowHeight: dto.WindowHeight, WindowX: &dto.WindowX, WindowY: &dto.WindowY, } - - var err error - out.CreatedAt, err = types.StrToDateTime(dto.CreatedAt) - if err != nil { - return nil, err - } - out.UpdatedAt, err = types.StrToDateTime(dto.UpdatedAt) - if err != nil { - return nil, err - } - - return out, nil } // Get returns GUIConfig @@ -69,7 +54,7 @@ func (repo *GUIConfigRepository) Get() (*entity.GUIConfig, error) { return nil, err } - return dto.entity() + return dto.entity(), nil } // Update updates GUIConfig @@ -108,5 +93,5 @@ func (repo *GUIConfigRepository) Update(in *entity.GUIConfig) (*entity.GUIConfig return nil, err } - return dto.entity() + return dto.entity(), nil } diff --git a/adapter/database/workspace.go b/adapter/database/workspace.go index 4ad5b77..15e706d 100644 --- a/adapter/database/workspace.go +++ b/adapter/database/workspace.go @@ -19,7 +19,7 @@ import ( const ( workspaceTable = "workspace" - workspaceTableFields = "id, parent_id, has_child, type, title, data, sort, expanded, created_at, updated_at" + workspaceTableFields = "id, parent_id, has_child, type, title, data, sort, expanded" ) // WorkspaceRepository object capable of interacting with WorkspaceRepository @@ -37,16 +37,14 @@ func NewWorkspaceRepository(ctx context.Context, db *database.Database) *Workspa } type workspaceDTO struct { - ID int64 `db:"id"` - ParentID sql.NullInt64 `db:"parent_id"` - HasChild bool `db:"has_child"` - Type string `db:"type"` - Title string `db:"title"` - Data sql.NullString `db:"data"` - Sort int64 `db:"sort"` - Expanded bool `db:"expanded"` - CreatedAt string `db:"created_at"` - UpdatedAt string `db:"updated_at"` + ID int64 `db:"id"` + ParentID sql.NullInt64 `db:"parent_id"` + HasChild bool `db:"has_child"` + Type string `db:"type"` + Title string `db:"title"` + Data sql.NullString `db:"data"` + Sort int64 `db:"sort"` + Expanded bool `db:"expanded"` } func newWorkspaceDTO(in *entity.Workspace) (dto *workspaceDTO, err error) { @@ -77,7 +75,6 @@ func (dto *workspaceDTO) entity() (*entity.Workspace, error) { Expanded: &dto.Expanded, } - var err error if dto.Data.Valid { switch out.Type { case entity.WorkspaceTypeFolder: @@ -93,14 +90,6 @@ func (dto *workspaceDTO) entity() (*entity.Workspace, error) { return nil, err } } - out.CreatedAt, err = types.StrToDateTime(dto.CreatedAt) - if err != nil { - return nil, err - } - out.UpdatedAt, err = types.StrToDateTime(dto.UpdatedAt) - if err != nil { - return nil, err - } return out, nil } @@ -124,9 +113,10 @@ func (repo *WorkspaceRepository) GetByID(id int64) (*entity.Workspace, error) { if err != nil { return nil, err } + return dto.entity() } - return dto.entity() + return nil, entity.ErrWorkspaceNotExists } // GetByParentID returns workspace item by parent id diff --git a/bin/version b/bin/version index 52411b9..4209dba 100644 --- a/bin/version +++ b/bin/version @@ -1 +1 @@ -0.3.3.2 \ No newline at end of file +0.3.8 \ No newline at end of file diff --git a/business/entity/workspace.go b/business/entity/workspace.go index 5a1fb1b..c9f66a9 100644 --- a/business/entity/workspace.go +++ b/business/entity/workspace.go @@ -17,6 +17,11 @@ const ( WorkspaceTypeQuery WorkspaceType = "r" ) +var ( + // ErrWorkspaceNotExists error workspace not exists + ErrWorkspaceNotExists = errors.New("workspace not exists") +) + // Workspace workspace item type Workspace struct { ID int64 `json:"id"` diff --git a/go.mod b/go.mod index d3d085d..809a9a2 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( github.com/golang/protobuf v1.5.2 github.com/jhump/protoreflect v1.14.0 github.com/jmoiron/sqlx v1.3.5 - github.com/mattn/go-sqlite3 v1.14.15 github.com/mitchellh/mapstructure v1.5.0 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.28.0 @@ -28,6 +27,7 @@ require ( github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-sqlite3 v1.14.10 // indirect github.com/sam-kamerer/go-plister v1.2.0 // indirect go.uber.org/atomic v1.7.0 // indirect golang.org/x/sys v0.0.0-20220317061510-51cd9980dadf // indirect diff --git a/go.sum b/go.sum index 403ef75..b58742e 100644 --- a/go.sum +++ b/go.sum @@ -807,9 +807,8 @@ github.com/mattn/go-shellwords v1.0.6/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vq github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/Sfk= github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= -github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2/go.mod h1:eD9eIE7cdwcMi9rYluz88Jz2VyhSmden33/aXg4oVIY= diff --git a/resources/js/request.js b/resources/js/request.js index 9226d61..7cb6b07 100644 --- a/resources/js/request.js +++ b/resources/js/request.js @@ -77,7 +77,7 @@ function getRequestData(field, root, disableProtoFQN) { } switch (field.type) { - case protoTypeEnum: { + case protoTypeEnum: let enumValues = []; root.find('[data-field-fqn="' + field.fqn + '"]').each(function () { enumValues.push($(this).find(":selected").val()); @@ -90,8 +90,7 @@ function getRequestData(field, root, disableProtoFQN) { } } break; - } - case protoTypeBool: { + case protoTypeBool: let boolValues = []; root.find('[data-field-fqn="' + field.fqn + '"]').each(function () { boolValues.push($(this).is(":checked")); @@ -104,8 +103,7 @@ function getRequestData(field, root, disableProtoFQN) { } } break; - } - case protoTypeMessage: { + case protoTypeMessage: if (field.map !== undefined) { // todo validate dup keys if (field.map.fields === undefined) { @@ -176,8 +174,7 @@ function getRequestData(field, root, disableProtoFQN) { } } break; - } - default: { + default: let textValues = []; root.find('[data-field-fqn="' + field.fqn + '"]').each(function () { textValues.push($(this).val()); @@ -189,7 +186,6 @@ function getRequestData(field, root, disableProtoFQN) { data[field.fqn] = textValues; } } - } } return data; diff --git a/resources/js/server.js b/resources/js/server.js index 3ebeae3..c412187 100644 --- a/resources/js/server.js +++ b/resources/js/server.js @@ -263,7 +263,7 @@ function getFieldTemplate(field, attr, showOneOf) { } switch (field.type) { - case protoTypeEnum: { + case protoTypeEnum: if (!field.repeated) { tmpl = $(template["request-select-input"]); $(tmpl.find(".label-name")[0]).html(field.name); @@ -288,8 +288,7 @@ function getFieldTemplate(field, attr, showOneOf) { ); } break; - } - case protoTypeBool: { + case protoTypeBool: if (!field.repeated) { tmpl = $(template["request-bool-input"]); $(tmpl.find(".label-name")[0]).attr("for", field.fqn).html(field.name); @@ -304,8 +303,7 @@ function getFieldTemplate(field, attr, showOneOf) { ); } break; - } - case protoTypeMessage: { + case protoTypeMessage: let fieldType = field.type; if (field.map !== undefined) { fieldType = @@ -412,8 +410,7 @@ function getFieldTemplate(field, attr, showOneOf) { currentInputCount++; }); break; - } - default: { + default: if (!field.repeated) { tmpl = $(template["request-text-input"]); $(tmpl.find(".label-name")[0]).html(field.name); @@ -427,7 +424,6 @@ function getFieldTemplate(field, attr, showOneOf) { currentInputCount ); } - } } let fv = $(tmpl.find(".field-value")[0]);