MCPcopy Create free account
hub / github.com/QuantumNous/new-api / GetTaskPlugin

Function GetTaskPlugin

controller/task_plugin.go:280–308  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

278}
279
280func GetTaskPlugin(c *gin.Context) {
281 key := c.Param("key")
282 version := c.Query("version")
283 plugin, err := model.GetTaskPluginVersion(key, version)
284 if err == nil {
285 loaded, compileErr := jsplugin.NewRegistry().Register(plugin.Source, jsplugin.Options{Key: plugin.Key, Version: plugin.Version})
286 if compileErr != nil {
287 common.ApiErrorMsg(c, compileErr.Error())
288 return
289 }
290 common.ApiSuccess(c, taskPluginDetail{Plugin: plugin, Meta: loaded.Meta, Source: plugin.Source, Layer: "override"})
291 return
292 }
293 if !errors.Is(err, gorm.ErrRecordNotFound) || version != "" {
294 common.ApiError(c, err)
295 return
296 }
297 source, err := plugins.Source(key)
298 if err != nil {
299 common.ApiErrorMsg(c, "task plugin not found")
300 return
301 }
302 loaded, err := jsplugin.NewRegistry().RegisterFactory(source, jsplugin.Options{Key: key})
303 if err != nil {
304 common.ApiError(c, err)
305 return
306 }
307 common.ApiSuccess(c, taskPluginDetail{Meta: loaded.Meta, Source: source, Layer: "factory"})
308}
309
310type taskPluginDryRunRequest struct {
311 Hook string `json:"hook" binding:"required"`

Callers

nothing calls this directly

Calls 10

GetTaskPluginVersionFunction · 0.92
NewRegistryFunction · 0.92
ApiErrorMsgFunction · 0.92
ApiSuccessFunction · 0.92
ApiErrorFunction · 0.92
SourceFunction · 0.92
QueryMethod · 0.80
RegisterFactoryMethod · 0.80
RegisterMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected