123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package models
- import (
- "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities"
- "github.com/langgenius/dify-plugin-daemon/internal/utils/parser"
- )
- type Plugin struct {
- Model
- // PluginUniqueIdentifier is a unique identifier for the plugin, it contains version and checksum
- PluginUniqueIdentifier string `json:"plugin_unique_identifier" gorm:"index;size:127"`
- // PluginID is the id of the plugin, only plugin name is considered
- PluginID string `json:"id" gorm:"index;size:127"`
- Refers int `json:"refers" gorm:"default:0"`
- InstallType plugin_entities.PluginRuntimeType `json:"install_type" gorm:"size:127;index"`
- ManifestType plugin_entities.DifyManifestType `json:"manifest_type" gorm:"size:127"`
- Declaration string `json:"declaration" gorm:"type:text;size:65535"`
- }
- func (p *Plugin) GetDeclaration() (*plugin_entities.PluginDeclaration, error) {
- declaration, err := parser.UnmarshalJson[plugin_entities.PluginDeclaration](p.Declaration)
- if err != nil {
- return nil, err
- }
- return &declaration, nil
- }
- type ServerlessRuntimeType string
- const (
- SERVERLESS_RUNTIME_TYPE_AWS_LAMBDA ServerlessRuntimeType = "aws_lambda"
- )
- type ServerlessRuntime struct {
- Model
- PluginUniqueIdentifier string `json:"plugin_unique_identifier" gorm:"size:127;unique"`
- FunctionURL string `json:"function_url" gorm:"size:255"`
- FunctionName string `json:"function_name" gorm:"size:127"`
- Type ServerlessRuntimeType `json:"type" gorm:"size:127"`
- Declaration string `json:"declaration" gorm:"type:text;size:65535"`
- Checksum string `json:"checksum" gorm:"size:127;index"`
- }
- func (p *ServerlessRuntime) GetDeclaration() (*plugin_entities.PluginDeclaration, error) {
- declaration, err := parser.UnmarshalJson[plugin_entities.PluginDeclaration](p.Declaration)
- if err != nil {
- return nil, err
- }
- return &declaration, nil
- }
- func (p *ServerlessRuntime) SetDeclaration(declaration *plugin_entities.PluginDeclaration) {
- p.Declaration = parser.MarshalJson(declaration)
- }
|