mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-04 10:13:53 +08:00
发布流程优化
This commit is contained in:
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.4 KiB |
@@ -1 +1,2 @@
|
||||
<image xmlns="http://www.w3.org/2000/svg" id="image0" width="22" height="22" x="0" y="0" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAMAAADzapwJAAAAIGNIUk0AAHomAACAhAAA+gAAAIDo AAB1MAAA6mAAADqYAAAXcJy6UTwAAAI0UExURQAAAABP/yx3/wAA/wAe/zZ9/x5t/wBa/xZo/zqA /zd9/wBO/wBR/yh0/zN7/xJm/xBk/whf/x5u/xxs/zuA/yRx/y94/zp//////6rI/9fl/9rn/yFv /2Sb/0OF/0CD/0uL/0iJ/6jH/1OQ/yp2/wAY/wAT/8PY/7HM/7XP/9zo/wAR/wAx/xhp/4mz/y54 /xpr/xtr/xts/93p/xhq/wBA/wA7/wA8/wBY/9fk/y95/yVy/x5t/xVn/xRn/wth/yFv/0OF/zR7 /x5u/w9k/x1t/63L/wFb/xNm/zh+/x5u/xNn/xFl/xxs/0yM/x1t/yp1/xFl/zh//xVo/wVd/wJc /wNc/wJb/wdf/yx2/zl//y13/zl//xNn/wJb/wVd/yBv/wJc/wVd/yFv/w1j/yFw/yFv/yBv/yVy /zyB/xJm/////////////////xBk/wRd/xRn/zyB/xNm/zB5/0CE/2yg/xNn/26h/1OP/1CO/02M /0qK/0qK/1WR/xRn/0KF/xFl/wth/wth/xts/y13/yx2/yx2/zl//6fG/2Oa/1SQ/1SR/16X/yJw /wJc/zuA/yVy/+Pt/6jH/6rI/6/M/4Ov/yJw/w5j/w5j/w9j/wth/zuB/wZe/yVy/3yq/xVn/3yr /xVo/xBk/36s/xlq/wNc/wRd/wRd/xRn/4mz/y54/xtr/xxs/yh0/zyB/yVy/0OF/xBk/wph/wph /y13/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J4yFIdXh+vuWvXvuLdFjp/TXet07+EpDS/vg77685/QOAim73/XUDkQAAAT1J REFUGNNjYEADjEzMViysDAxs7BycXAhhbmsbWzseBgZeewdHPn4BGBB0cnZxdWNgEHL38PTy9oED Xz//AGGQcGBQcEhoGBSER0RGRYuAhWNi47bBQXyCqKgYVDgRIZyUzAayGiackpoGAukZmeLIwlnZ ObkgkJMngSycnycpBQbS0iBhmYLComKQcI6snDwEKADVK5aUlpWDhCUqKquqqmtqamrr8hiUZJVV eOtBwqoNjU3NLa1tbe0deQydXd09vX39QGG1Cdt37Jg4afKUKVMlGKZNnzFz1uydIOE5c7dtm5et rqGhKcEwf8GOHTtA3oAJa4EDcuGiHRDfLdZGFl6ydNlyEFixUgdZeNXqNWvBYJ0usrCevoEhGPAa rd+1bdsGqDACiG7ctHnL1hxjNGEeE1MzcwsJSxAbAKHenZfZhLKNAAAAJXRFWHRkYXRlOmNyZWF0 ZQAyMDI0LTEwLTEwVDEwOjE3OjA2KzAwOjAwb3EVAgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNC0x MC0xMFQxMDoxNzowNiswMDowMB4srb4AAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjQtMTAtMTBU MTA6MTc6MDYrMDA6MDBJOYxhAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAA AABJRU5ErkJggg=="/>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" width="200px" height="200px" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve"> <image id="image0" width="200" height="200" x="0" y="0" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAIGNIUk0AAHomAACAhAAA+gAAAIDo AAB1MAAA6mAAADqYAAAXcJy6UTwAAAF0UExURf///7vU/yRx/1qU/6fH/wBa/yp1/7DN/z+D/7bQ /0G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dGUA MjAyNC0xMC0xMFQxMDoxNjozNSswMDowMD/UY0IAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjQtMTAt MTBUMTA6MTY6MzUrMDA6MDBOidv+AAAAKHRFWHRkYXRlOnRpbWVzdGFtcAAyMDI0LTEwLTEwVDEw OjE2OjM1KzAwOjAwGZz6IQAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAA SUVORK5CYII="/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
@@ -39,11 +39,7 @@ func (c *imlPublishController) ReleaseDo(ctx *gin.Context, serviceId string, inp
|
||||
c.releaseModule.Delete(ctx, serviceId, newReleaseId)
|
||||
return nil, err
|
||||
}
|
||||
//err = c.publishModule.Publish(ctx, serviceId, apply.Id)
|
||||
//if err != nil {
|
||||
// c.releaseModule.Delete(ctx, serviceId, newReleaseId)
|
||||
// return nil, err
|
||||
//}
|
||||
|
||||
err = c.publishModule.Publish(ctx, serviceId, apply.Id)
|
||||
if err != nil {
|
||||
c.releaseModule.Delete(ctx, serviceId, newReleaseId)
|
||||
|
||||
+78
-20
@@ -3,10 +3,19 @@ package service
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/APIParkLab/APIPark/model/plugin_model"
|
||||
"github.com/APIParkLab/APIPark/service/api"
|
||||
|
||||
router_dto "github.com/APIParkLab/APIPark/module/router/dto"
|
||||
|
||||
model_runtime "github.com/APIParkLab/APIPark/ai-provider/model-runtime"
|
||||
"github.com/APIParkLab/APIPark/module/ai"
|
||||
ai_api "github.com/APIParkLab/APIPark/module/ai-api"
|
||||
ai_api_dto "github.com/APIParkLab/APIPark/module/ai-api/dto"
|
||||
"github.com/APIParkLab/APIPark/module/router"
|
||||
"github.com/APIParkLab/APIPark/module/service"
|
||||
service_dto "github.com/APIParkLab/APIPark/module/service/dto"
|
||||
"github.com/APIParkLab/APIPark/module/upstream"
|
||||
@@ -14,7 +23,6 @@ import (
|
||||
"github.com/eolinker/go-common/store"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -27,6 +35,7 @@ type imlServiceController struct {
|
||||
module service.IServiceModule `autowired:""`
|
||||
docModule service.IServiceDocModule `autowired:""`
|
||||
aiAPIModule ai_api.IAPIModule `autowired:""`
|
||||
routerModule router.IRouterModule `autowired:""`
|
||||
providerModule ai.IProviderModule `autowired:""`
|
||||
upstreamModule upstream.IUpstreamModule `autowired:""`
|
||||
transaction store.ITransaction `autowired:""`
|
||||
@@ -110,32 +119,81 @@ func (i *imlServiceController) CreateAIService(ctx *gin.Context, teamID string,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
path := fmt.Sprintf("/%s/demo_translation_api", strings.Trim(input.Prefix, "/"))
|
||||
timeout := 300000
|
||||
retry := 0
|
||||
aiPrompt := &ai_api_dto.AiPrompt{
|
||||
Variables: []*ai_api_dto.AiPromptVariable{
|
||||
{
|
||||
Key: "source_lang",
|
||||
Description: "",
|
||||
Require: true,
|
||||
},
|
||||
{
|
||||
Key: "target_lang",
|
||||
Description: "",
|
||||
Require: true,
|
||||
},
|
||||
{
|
||||
Key: "text",
|
||||
Description: "",
|
||||
Require: true,
|
||||
},
|
||||
},
|
||||
Prompt: "You need to translate {{source_lang}} into {{target_lang}}, and the following is the content that needs to be translated.\n---\n{{text}}",
|
||||
}
|
||||
aiModel := &ai_api_dto.AiModel{
|
||||
Id: pv.DefaultLLM,
|
||||
Config: pv.DefaultLLMConfig,
|
||||
}
|
||||
name := "Demo Translation API"
|
||||
description := "A demo that shows you how to use a prompt to create a Translation API."
|
||||
err = i.aiAPIModule.Create(
|
||||
ctx,
|
||||
info.Id,
|
||||
&ai_api_dto.CreateAPI{
|
||||
Name: "Default API",
|
||||
Path: fmt.Sprintf("/%s", strings.Trim(input.Prefix, "/")),
|
||||
Description: "Default API for service",
|
||||
Name: name,
|
||||
Path: path,
|
||||
Description: description,
|
||||
Disable: false,
|
||||
AiPrompt: &ai_api_dto.AiPrompt{
|
||||
Variables: []*ai_api_dto.AiPromptVariable{
|
||||
{
|
||||
Key: "Query",
|
||||
Description: "",
|
||||
Require: true,
|
||||
},
|
||||
},
|
||||
Prompt: "{{Query}}",
|
||||
},
|
||||
AiModel: &ai_api_dto.AiModel{
|
||||
Id: pv.DefaultLLM,
|
||||
Config: pv.DefaultLLMConfig,
|
||||
},
|
||||
Timeout: 300000,
|
||||
Retry: 0,
|
||||
AiPrompt: aiPrompt,
|
||||
AiModel: aiModel,
|
||||
Timeout: timeout,
|
||||
Retry: retry,
|
||||
},
|
||||
)
|
||||
plugins := make(map[string]api.PluginSetting)
|
||||
plugins["ai_prompt"] = api.PluginSetting{
|
||||
Config: plugin_model.ConfigType{
|
||||
"prompt": aiPrompt.Prompt,
|
||||
"variables": aiPrompt.Variables,
|
||||
},
|
||||
}
|
||||
plugins["ai_formatter"] = api.PluginSetting{
|
||||
Config: plugin_model.ConfigType{
|
||||
"model": aiModel.Id,
|
||||
"provider": fmt.Sprintf("%s@ai-provider", info.Provider.Id),
|
||||
"config": aiModel.Config,
|
||||
},
|
||||
}
|
||||
_, err = i.routerModule.Create(ctx, info.Id, &router_dto.Create{
|
||||
Id: input.Id,
|
||||
Name: name,
|
||||
Path: path,
|
||||
Methods: []string{
|
||||
http.MethodPost,
|
||||
},
|
||||
Description: description,
|
||||
Protocols: []string{"http", "https"},
|
||||
MatchRules: nil,
|
||||
Proxy: &router_dto.InputProxy{
|
||||
Path: path,
|
||||
Timeout: timeout,
|
||||
Retry: retry,
|
||||
Plugins: plugins,
|
||||
},
|
||||
Disable: false,
|
||||
})
|
||||
_, err = i.upstreamModule.Save(ctx, info.Id, newAIUpstream(info.Id, *input.Provider, p.URI()))
|
||||
return err
|
||||
})
|
||||
|
||||
+10
-1
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
api_doc "github.com/APIParkLab/APIPark/service/api-doc"
|
||||
service_doc "github.com/APIParkLab/APIPark/service/service-doc"
|
||||
|
||||
@@ -136,13 +137,21 @@ func (m *imlReleaseModule) Create(ctx context.Context, serviceId string, input *
|
||||
}
|
||||
serviceDoc, err := m.serviceDocService.Get(ctx, serviceId)
|
||||
if err != nil {
|
||||
return err
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
}
|
||||
serviceDoc = &service_doc.Doc{
|
||||
Doc: "",
|
||||
}
|
||||
}
|
||||
err = m.serviceDocService.CommitDoc(ctx, serviceId, serviceDoc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
serviceDocCommit, err := m.serviceDocService.LatestDocCommit(ctx, serviceId)
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
if !m.releaseService.Completeness(utils.SliceToSlice(clusters, func(s *cluster.Cluster) string {
|
||||
return s.Uuid
|
||||
}), apiUUIDS, requestCommits, apiProxy, upstreams) {
|
||||
|
||||
@@ -3,9 +3,10 @@ package router_dto
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/eolinker/go-common/utils"
|
||||
"strings"
|
||||
|
||||
"github.com/eolinker/go-common/utils"
|
||||
|
||||
"github.com/APIParkLab/APIPark/service/api"
|
||||
)
|
||||
|
||||
@@ -21,6 +22,7 @@ var validMethods = map[string]struct{}{
|
||||
|
||||
type Create struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
Methods []string `json:"methods"`
|
||||
Description string `json:"description"`
|
||||
|
||||
@@ -5,9 +5,10 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/APIParkLab/APIPark/service/universally/commit"
|
||||
"strings"
|
||||
|
||||
"github.com/APIParkLab/APIPark/service/universally/commit"
|
||||
|
||||
"github.com/APIParkLab/APIPark/service/service"
|
||||
"github.com/APIParkLab/APIPark/service/upstream"
|
||||
|
||||
@@ -253,10 +254,14 @@ func (i *imlRouterModule) Create(ctx context.Context, serviceId string, dto *rou
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name := dto.Name
|
||||
if name == "" {
|
||||
name = dto.Id
|
||||
}
|
||||
match, _ := json.Marshal(dto.MatchRules)
|
||||
return i.apiService.Create(ctx, &api.Create{
|
||||
UUID: dto.Id,
|
||||
Name: name,
|
||||
Description: dto.Description,
|
||||
Service: serviceId,
|
||||
Team: info.Team,
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/APIParkLab/APIPark/service/api"
|
||||
api_doc "github.com/APIParkLab/APIPark/service/api-doc"
|
||||
"github.com/APIParkLab/APIPark/service/cluster"
|
||||
@@ -95,6 +96,7 @@ func (m *imlServiceDiff) DiffForLatest(ctx context.Context, serviceId string, ba
|
||||
Target: apiInfo.UUID,
|
||||
Key: "request",
|
||||
Data: &api.Request{
|
||||
Name: apiInfo.Name,
|
||||
Path: apiInfo.Path,
|
||||
Methods: apiInfo.Methods,
|
||||
Protocols: apiInfo.Protocols,
|
||||
@@ -221,6 +223,7 @@ func (m *imlServiceDiff) diff(partitions []string, base, target *projectInfo) *s
|
||||
for _, rc := range target.apiRequestCommits {
|
||||
apiId := rc.Target
|
||||
a := &service_diff.ApiDiff{
|
||||
Name: rc.Data.Name,
|
||||
APi: rc.Target,
|
||||
Method: rc.Data.Methods,
|
||||
Protocol: rc.Data.Protocols,
|
||||
@@ -266,6 +269,7 @@ func (m *imlServiceDiff) diff(partitions []string, base, target *projectInfo) *s
|
||||
apiInfo := rc.Data
|
||||
if baseApis.Has(rc.Target) {
|
||||
out.Apis = append(out.Apis, &service_diff.ApiDiff{
|
||||
Name: apiInfo.Name,
|
||||
APi: rc.Target,
|
||||
Method: apiInfo.Methods,
|
||||
Protocol: apiInfo.Protocols,
|
||||
@@ -328,6 +332,7 @@ func (m *imlServiceDiff) Out(ctx context.Context, diff *service_diff.Diff) (*Dif
|
||||
out := &DiffOut{}
|
||||
out.Routers = utils.SliceToSlice(diff.Apis, func(i *service_diff.ApiDiff) *RouterDiffOut {
|
||||
return &RouterDiffOut{
|
||||
Name: i.Name,
|
||||
Methods: i.Method,
|
||||
Path: i.Path,
|
||||
Change: i.Change,
|
||||
|
||||
@@ -14,6 +14,7 @@ type DiffOut struct {
|
||||
}
|
||||
|
||||
type RouterDiffOut struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Methods []string `json:"methods,omitempty"`
|
||||
Protocols []string `json:"protocols,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
|
||||
+5
-23
@@ -37,31 +37,10 @@ type imlAPIService struct {
|
||||
apiInfoStore api.IAPIInfoStore `autowired:""`
|
||||
requestCommitService commit.ICommitWithKeyService[Request] `autowired:""`
|
||||
proxyCommitService commit.ICommitWithKeyService[Proxy] `autowired:""`
|
||||
//pluginCommitService commit.ICommitWithKeyService[Plugin] `autowired:""`
|
||||
universally.IServiceGet[API]
|
||||
universally.IServiceDelete
|
||||
}
|
||||
|
||||
//func (i *imlAPIService) ListLatestCommitPlugin(ctx context.Context, aid ...string) ([]*commit.Commit[Plugin], error) {
|
||||
// return i.pluginCommitService.ListLatest(ctx, aid...)
|
||||
//}
|
||||
//
|
||||
//func (i *imlAPIService) GetPluginCommit(ctx context.Context, commitId string) (*commit.Commit[Plugin], error) {
|
||||
// return i.pluginCommitService.Get(ctx, commitId)
|
||||
//}
|
||||
//
|
||||
//func (i *imlAPIService) ListPluginCommit(ctx context.Context, commitId ...string) ([]*commit.Commit[Plugin], error) {
|
||||
// return i.pluginCommitService.List(ctx, commitId...)
|
||||
//}
|
||||
//
|
||||
//func (i *imlAPIService) SavePlugin(ctx context.Context, aid string, data *Plugin) error {
|
||||
// return i.pluginCommitService.Save(ctx, aid, data)
|
||||
//}
|
||||
//
|
||||
//func (i *imlAPIService) LatestPlugin(ctx context.Context, aid string) (*commit.Commit[Plugin], error) {
|
||||
// return i.pluginCommitService.Latest(ctx, aid)
|
||||
//}
|
||||
|
||||
func (i *imlAPIService) ListLatestCommitRequest(ctx context.Context, aid ...string) ([]*commit.Commit[Request], error) {
|
||||
return i.requestCommitService.ListLatest(ctx, aid...)
|
||||
}
|
||||
@@ -137,6 +116,9 @@ func (i *imlAPIService) Save(ctx context.Context, id string, model *Edit) error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if model.Name != nil {
|
||||
ev.Name = *model.Name
|
||||
}
|
||||
|
||||
if model.Description != nil {
|
||||
ev.Description = *model.Description
|
||||
@@ -186,7 +168,7 @@ func (i *imlAPIService) Create(ctx context.Context, input *Create) (err error) {
|
||||
|
||||
ne := api.API{
|
||||
UUID: input.UUID,
|
||||
Name: input.UUID,
|
||||
Name: input.Name,
|
||||
Service: input.Service,
|
||||
Team: input.Team,
|
||||
Creator: operater,
|
||||
@@ -201,7 +183,7 @@ func (i *imlAPIService) Create(ctx context.Context, input *Create) (err error) {
|
||||
ev := &api.Info{
|
||||
Id: ne.Id,
|
||||
UUID: ne.UUID,
|
||||
Name: ne.UUID,
|
||||
Name: ne.Name,
|
||||
Description: input.Description,
|
||||
Updater: operater,
|
||||
UpdateAt: time.Now(),
|
||||
|
||||
@@ -9,7 +9,8 @@ import (
|
||||
)
|
||||
|
||||
type API struct {
|
||||
UUID string
|
||||
UUID string
|
||||
|
||||
Service string
|
||||
Team string
|
||||
Creator string
|
||||
@@ -75,6 +76,7 @@ type Kind string
|
||||
|
||||
type Create struct {
|
||||
UUID string
|
||||
Name string
|
||||
Description string
|
||||
Service string
|
||||
Team string
|
||||
@@ -86,6 +88,7 @@ type Create struct {
|
||||
}
|
||||
|
||||
type Edit struct {
|
||||
Name *string
|
||||
Description *string
|
||||
Methods *[]string
|
||||
Protocols *[]string
|
||||
@@ -108,6 +111,7 @@ type PluginSetting struct {
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
Methods []string `json:"methods"`
|
||||
Protocols []string `json:"protocols"`
|
||||
|
||||
@@ -19,9 +19,8 @@ type Status struct {
|
||||
}
|
||||
|
||||
type ApiDiff struct {
|
||||
APi string `json:"api,omitempty"`
|
||||
//Upstream string `json:"upstream,omitempty"`
|
||||
//Name string `json:"name,omitempty"`
|
||||
APi string `json:"api,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Method []string `json:"method,omitempty"`
|
||||
Protocol []string `json:"protocol,omitempty"`
|
||||
Disable bool `json:"disable,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user