Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

♻️ Migrate petal management API contracts https://github.com/siyuan-note/siyuan/issues/19378

Danielcbfe9e59d2b0
diff --git a/app/src/config/tabs/keymapUi.ts b/app/src/config/tabs/keymapUi.ts
index c8203d39e2..719cc61f10 100644
--- a/app/src/config/tabs/keymapUi.ts
+++ b/app/src/config/tabs/keymapUi.ts
@@ -297,7 +297,7 @@ const buildKeymapPluginCommandHtml = (item: Plugin) => {
const html: string[] = [];
for (const command of item.commands) {
html.push(genKeymapRowHtml(
- command.langText || (item.i18n ? item.i18n[command.langKey] : "") || command.langKey,
+ String(command.langText || (item.i18n ? item.i18n[command.langKey] : "") || command.langKey),
pluginKeyPrefix + command.langKey,
ensurePluginKeymap(item.name, command.langKey, command.hotkey),
));
diff --git a/app/src/plugin/commandAdapter.ts b/app/src/plugin/commandAdapter.ts
index 1ae9a7fd67..a600b29a0d 100644
--- a/app/src/plugin/commandAdapter.ts
+++ b/app/src/plugin/commandAdapter.ts
@@ -4,7 +4,7 @@ import type {ICommandContextSnapshot, ICommandDefinition, TCommandSource} from "
interface IPluginCommandOwner {
name: string;
displayName: string;
- i18n: Record<string, string>;
+ i18n: Record<string, import("../types/api").JSONValue>;
}
interface IPluginCommandRegistration {
diff --git a/app/src/plugin/index.ts b/app/src/plugin/index.ts
index 418ee0a307..be4e750def 100644
--- a/app/src/plugin/index.ts
+++ b/app/src/plugin/index.ts
@@ -57,7 +57,7 @@ const refreshPluginToolbars = () => {
export class Plugin {
private app: App;
- public i18n: Record<string, string>;
+ public i18n: Record<string, import("../types/api").JSONValue>;
public eventBus: EventBus;
public kernel: Kernel;
public data: any = {};
@@ -104,7 +104,7 @@ export class Plugin {
app: App,
name: string,
displayName: string,
- i18n: Record<string, string>
+ i18n: Record<string, import("../types/api").JSONValue>
}) {
this.app = options.app;
this.i18n = options.i18n;
diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.ts
index e6b0d47dcd..c8135d27ec 100644
--- a/app/src/plugin/loader.ts
+++ b/app/src/plugin/loader.ts
@@ -123,7 +123,7 @@ const getLifecycleManager = (app: App) => {
const createPluginDataLoader = () => {
let promise: Promise<IPluginData[]>;
return (name: string) => {
- promise ??= fetchSyncPost("/api/petal/loadPetals", {frontend: getFrontend()}).then(response => response.data);
+ promise ??= fetchSyncPost("/api/petal/loadPetals", {frontend: getFrontend()}).then(response => response.code === 0 && Array.isArray(response.data) ? response.data : []);
return promise.then(items => items.find(item => item.name === name));
};
};
@@ -141,7 +141,7 @@ export const loadPlugins = async (app: App, names?: string[], init = true) => {
} else {
const batch = manager.beginLoadBatch(!manager.isStarted());
const response = await fetchSyncPost("/api/petal/loadPetals", {frontend: getFrontend()});
- tasks = (response.data as IPluginData[]).map(item => manager.requestBatchLoad(item.name, item, batch));
+ tasks = (response.code === 0 && Array.isArray(response.data) ? response.data : []).map(item => manager.requestBatchLoad(item.name, item, batch));
shouldStart = manager.isLatestLoadBatch(batch);
}
if (shouldStart) {
diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts
index 2190fbc9a6..aba39cad84 100644
--- a/app/src/protyle/export/index.ts
+++ b/app/src/protyle/export/index.ts
@@ -21,7 +21,7 @@ const getPluginStyle = async () => {
const response = await fetchSyncPost("/api/petal/loadPetals", {frontend: getFrontend()});
let css = "";
// 为加快启动速度,不进行 await
- response.data.forEach((item: IPluginData) => {
+ (response.code === 0 && Array.isArray(response.data) ? response.data : []).forEach(item => {
css += item.css || "";
});
return css;
diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.ts
index cf86e5bb63..25c1481b0a 100644
--- a/app/src/types/api/index.d.ts
+++ b/app/src/types/api/index.d.ts
@@ -212,10 +212,14 @@ export type InsertBlockRequestInput = { "data": string; "dataType": string; "nex
export type JSONValue = null | boolean | number | string | Array<JSONValue> | { [key: string]: JSONValue };
+export type KernelPetal = { "existed": boolean; "incompatible": boolean; "js": string; };
+
export type ListNotebooksData = { "boxDocEnabled": boolean; "notebooks": Array<Notebook | null> | null; };
export type ListNotebooksRequestInput = { "flashcard"?: boolean | null; };
+export type LoadPetalsRequestInput = { "frontend": string; };
+
export type LockScreenRequestInput = { "lockScreenMode": number; };
export type MarkdownHTMLRequestInput = { "markdown": string; "mode"?: string | null; };
@@ -272,6 +276,8 @@ export type OutlineStorageRequestInput = { "docID": string; };
export type OutlineStorageSetRequestInput = { "docID": string; "val": { [key: string]: JSONValue }; };
+export type Petal = { "css": string; "disabledInPublish": boolean; "disallowInstall": boolean; "displayName": string; "enabled": boolean; "i18n": { [key: string]: JSONValue } | null; "incompatible": boolean; "js": string; "kernel": KernelPetal; "name": string; "userDisabledInPublish": boolean; "version": string; };
+
export type PinnedDoc = { "childrenSortMode": number | null; "icon": string; "id": string; "name": string; "notebook": string; "path": string; "subFileCount": number; "unavailable": boolean; };
export type PrependBlockRequestInput = { "data": string; "dataType": string; "parentID": string; };
@@ -340,6 +346,10 @@ export type SetNotebookConfRequestInput = { "conf"?: NotebookConfPatchInput | nu
export type SetNotebookIconRequestInput = { "icon": string; "notebook": string; };
+export type SetPetalEnabledRequestInput = { "app"?: string | null; "enabled": boolean; "packageName": string; };
+
+export type SetPetalPublishEnabledRequestInput = { "enabled": boolean; "packageName": string; };
+
export type SetSnapshotMemoRequestInput = { "id": string; "memo": string; };
export type SetSnippetRequestInput = { "snippets": Array<SnippetInput>; };
@@ -706,9 +716,6 @@ export type APILegacyPOSTPath =
"/api/network/echo/*path" |
"/api/network/forwardProxy" |
"/api/network/proxy" |
- "/api/petal/loadPetals" |
- "/api/petal/setPetalEnabled" |
- "/api/petal/setPetalPublishEnabled" |
"/api/plugin/getLoadedPlugin" |
"/api/plugin/listLoadedPlugins" |
"/api/plugin/rpc" |
@@ -1451,6 +1458,21 @@ export interface APIPOSTRoutes {
response: { "code": 0; "data": Array<SearchPath | null> | null; "msg": string; } | { "code": -1 | 1; "data": { "closeTimeout": number; } | null; "msg": string; };
body: "json";
};
+ "/api/petal/loadPetals": {
+ request: LoadPetalsRequestInput;
+ response: { "code": 0; "data": Array<Petal | null> | null; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
+ body: "json";
+ };
+ "/api/petal/setPetalEnabled": {
+ request: SetPetalEnabledRequestInput;
+ response: { "code": 0; "data": Petal | null; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
+ body: "json";
+ };
+ "/api/petal/setPetalPublishEnabled": {
+ request: SetPetalPublishEnabledRequestInput;
+ response: { "code": 0; "data": Petal | null; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
+ body: "json";
+ };
"/api/repo/checkSnapshot": {
request: EmptyRequestInput;
response: { "code": 0; "data": CheckSnapshotData; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 87b6b83f74..2ebf86c234 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -925,7 +925,7 @@ interface IPluginData {
name: string,
js: string,
css: string,
- i18n: Record<string, string>
+ i18n: Record<string, import("./api").JSONValue>
}
interface IPluginDockTab {
diff --git a/kernel/api/contract_petal.go b/kernel/api/contract_petal.go
new file mode 100644
index 0000000000..15bca54317
--- /dev/null
+++ b/kernel/api/contract_petal.go
@@ -0,0 +1,29 @@
+package api
+
+import (
+ "encoding/json"
+ "github.com/siyuan-note/siyuan/kernel/apicontract"
+ "github.com/siyuan-note/siyuan/kernel/model"
+)
+
+func petalContract(value *model.Petal) (*apicontract.Petal, error) {
+ if value == nil {
+ return nil, nil
+ }
+ // 插件自行定义语言包的键和值,保留嵌套 JSON 内容。
+ data, err := json.Marshal(value.I18n)
+ if err != nil {
+ return nil, err
+ }
+ var i18n map[string]apicontract.JSONValue
+ if err = json.Unmarshal(data, &i18n); err != nil {
+ return nil, err
+ }
+ return &apicontract.Petal{
+ Name: value.Name, DisplayName: value.DisplayName, Version: value.Version,
+ Enabled: value.Enabled, Incompatible: value.Incompatible, DisabledInPublish: value.DisabledInPublish,
+ UserDisabledInPublish: value.UserDisabledInPublish, DisallowInstall: value.DisallowInstall,
+ JS: value.JS, CSS: value.CSS, I18n: i18n,
+ Kernel: apicontract.KernelPetal{JS: value.Kernel.JS, Existed: value.Kernel.Existed, Incompatible: value.Kernel.Incompatible},
+ }, nil
+}
diff --git a/kernel/api/contract_petal_test.go b/kernel/api/contract_petal_test.go
new file mode 100644
index 0000000000..e077c8a6fb
--- /dev/null
+++ b/kernel/api/contract_petal_test.go
@@ -0,0 +1,39 @@
+package api
+
+import (
+ "encoding/json"
+ "github.com/gin-gonic/gin"
+ "github.com/siyuan-note/siyuan/kernel/model"
+ "net/http/httptest"
+ "strings"
+ "testing"
+)
+
+func TestAPIContractPetalConversion(t *testing.T) {
+ for _, value := range []*model.Petal{nil, {}, {Name: "plugin", Enabled: true, I18n: map[string]any{"nested": map[string]any{"label": "text"}, "array": []any{true, nil, 1.5}}, Kernel: model.KernelPetal{JS: "code", Existed: true}}} {
+ result, err := petalContract(value)
+ if err != nil {
+ t.Fatal(err)
+ }
+ before, _ := json.Marshal(value)
+ after, err := json.Marshal(result)
+ if err != nil || string(before) != string(after) {
+ t.Fatalf("plugin payload changed: %s != %s, %v", before, after, err)
+ }
+ }
+}
+
+func TestAPIContractPetalInvalidRequests(t *testing.T) {
+ engine := gin.New()
+ engine.POST("/api/petal/loadPetals", loadPetals)
+ engine.POST("/api/petal/setPetalEnabled", setPetalEnabled)
+ engine.POST("/api/petal/setPetalPublishEnabled", setPetalPublishEnabled)
+ for _, path := range []string{"/api/petal/loadPetals", "/api/petal/setPetalEnabled", "/api/petal/setPetalPublishEnabled"} {
+ recorder := httptest.NewRecorder()
+ engine.ServeHTTP(recorder, httptest.NewRequest("POST", path, strings.NewReader(`{}`)))
+ requireAPIContract(t, "POST", path, recorder)
+ if !strings.Contains(recorder.Body.String(), `"code":-1`) {
+ t.Fatalf("missing required field accepted: %s", recorder.Body.String())
+ }
+ }
+}
diff --git a/kernel/api/petal.go b/kernel/api/petal.go
index dba3395a46..5c97997244 100644
--- a/kernel/api/petal.go
+++ b/kernel/api/petal.go
@@ -17,94 +17,57 @@
package api
import (
- "net/http"
-
- "github.com/88250/gulu"
"github.com/emirpasic/gods/sets/hashset"
"github.com/gin-gonic/gin"
+ "github.com/siyuan-note/siyuan/kernel/apicontract"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/util"
)
-func loadPetals(c *gin.Context) {
- ret := gulu.Ret.NewResult()
- defer c.JSON(http.StatusOK, ret)
-
- arg, ok := util.JsonArg(c, ret)
- if !ok {
- return
+var loadPetals = contractHandler(apicontract.LoadPetals, func(c *gin.Context, request apicontract.LoadPetalsRequest) apicontract.Response[[]*apicontract.Petal] {
+ values := model.LoadPetals(request.Frontend, model.IsReadOnlyRoleContext(c))
+ var result []*apicontract.Petal
+ if values != nil {
+ result = make([]*apicontract.Petal, len(values))
}
-
- var frontend string
- if !util.ParseJsonArgs(arg, ret, util.BindJsonArg("frontend", &frontend, true, true)) {
- return
- }
- isPublish := model.IsReadOnlyRoleContext(c)
-
- ret.Data = model.LoadPetals(frontend, isPublish)
-}
-
-func setPetalEnabled(c *gin.Context) {
- ret := gulu.Ret.NewResult()
- defer c.JSON(http.StatusOK, ret)
-
- arg, ok := util.JsonArg(c, ret)
- if !ok {
- return
- }
-
- var packageName, app string
- var enabled bool
- if !util.ParseJsonArgs(arg, ret,
- util.BindJsonArg("packageName", &packageName, true, true),
- util.BindJsonArg("enabled", &enabled, true, false),
- util.BindJsonArg("app", &app, false, false),
- ) {
- return
+ for i, value := range values {
+ item, err := petalContract(value)
+ if err != nil {
+ return apicontract.Failure[[]*apicontract.Petal](-1, err.Error())
+ }
+ result[i] = item
}
+ return apicontract.Success(result)
+})
- data, err := model.SetPetalEnabled(packageName, enabled)
+var setPetalEnabled = contractHandler(apicontract.SetPetalEnabled, func(c *gin.Context, request apicontract.SetPetalEnabledRequest) apicontract.Response[*apicontract.Petal] {
+ data, err := model.SetPetalEnabled(request.PackageName, request.Enabled)
if err != nil {
- ret.Code = -1
- ret.Msg = err.Error()
- return
+ return apicontract.Failure[*apicontract.Petal](-1, err.Error())
}
-
- ret.Data = data
- if enabled {
- reloadPluginSet := hashset.New(packageName)
- model.PushReloadPlugin(nil, nil, reloadPluginSet, nil, app, "")
+ if request.Enabled {
+ reloadPluginSet := hashset.New(request.PackageName)
+ model.PushReloadPlugin(nil, nil, reloadPluginSet, nil, request.App, "")
} else {
- unloadPluginSet := hashset.New(packageName)
- model.PushReloadPlugin(nil, unloadPluginSet, nil, nil, app, "")
+ unloadPluginSet := hashset.New(request.PackageName)
+ model.PushReloadPlugin(nil, unloadPluginSet, nil, nil, request.App, "")
}
-}
-
-func setPetalPublishEnabled(c *gin.Context) {
- ret := gulu.Ret.NewResult()
- defer c.JSON(http.StatusOK, ret)
-
- arg, ok := util.JsonArg(c, ret)
- if !ok {
- return
- }
-
- var packageName string
- var enabled bool
- if !util.ParseJsonArgs(arg, ret,
- util.BindJsonArg("packageName", &packageName, true, true),
- util.BindJsonArg("enabled", &enabled, true, false),
- ) {
- return
+ result, err := petalContract(data)
+ if err != nil {
+ return apicontract.Failure[*apicontract.Petal](-1, err.Error())
}
+ return apicontract.Success(result)
+})
- data, err := model.SetPetalPublishEnabled(packageName, enabled)
+var setPetalPublishEnabled = contractHandler(apicontract.SetPetalPublishEnabled, func(c *gin.Context, request apicontract.SetPetalPublishEnabledRequest) apicontract.Response[*apicontract.Petal] {
+ data, err := model.SetPetalPublishEnabled(request.PackageName, request.Enabled)
if err != nil {
- ret.Code = -1
- ret.Msg = err.Error()
- return
+ return apicontract.Failure[*apicontract.Petal](-1, err.Error())
}
-
- ret.Data = data
util.ReloadPublishServiceSessions()
-}
+ result, err := petalContract(data)
+ if err != nil {
+ return apicontract.Failure[*apicontract.Petal](-1, err.Error())
+ }
+ return apicontract.Success(result)
+})
diff --git a/kernel/apicontract/contracts.go b/kernel/apicontract/contracts.go
index befa2cf14f..f682fed676 100644
--- a/kernel/apicontract/contracts.go
+++ b/kernel/apicontract/contracts.go
@@ -419,3 +419,9 @@ var SetWorkspaceAVPalette = define[WorkspaceAVPaletteRequest, *InlineStyles]("se
var HTML2BlockDOM = define[HTMLClipboardRequest, HTMLClipboardData]("html2BlockDOM", "/api/lute/html2BlockDOM", JSONBody, ResponseOptions{}, "POST")
var WPSPresentation2BlockDOM = define[WPSPresentationRequest, WPSPresentationData]("wpsPresentation2BlockDOM", "/api/lute/wpsPresentation2BlockDOM", JSONBody, ResponseOptions{DataOnError: true}, "POST")
+
+var LoadPetals = define[LoadPetalsRequest, []*Petal]("loadPetals", "/api/petal/loadPetals", JSONBody, ResponseOptions{}, "POST")
+
+var SetPetalEnabled = define[SetPetalEnabledRequest, *Petal]("setPetalEnabled", "/api/petal/setPetalEnabled", JSONBody, ResponseOptions{}, "POST")
+
+var SetPetalPublishEnabled = define[SetPetalPublishEnabledRequest, *Petal]("setPetalPublishEnabled", "/api/petal/setPetalPublishEnabled", JSONBody, ResponseOptions{}, "POST")
diff --git a/kernel/apicontract/legacy_routes.json b/kernel/apicontract/legacy_routes.json
index e0baef1d1a..dc1e2b0d99 100644
--- a/kernel/apicontract/legacy_routes.json
+++ b/kernel/apicontract/legacy_routes.json
@@ -278,9 +278,6 @@
{"method":"POST","path":"/api/inbox/getShorthands","handler":"getShorthands"},
{"method":"POST","path":"/api/inbox/removeShorthands","handler":"removeShorthands"},
{"method":"POST","path":"/api/network/forwardProxy","handler":"forwardProxy"},
- {"method":"POST","path":"/api/petal/loadPetals","handler":"loadPetals"},
- {"method":"POST","path":"/api/petal/setPetalEnabled","handler":"setPetalEnabled"},
- {"method":"POST","path":"/api/petal/setPetalPublishEnabled","handler":"setPetalPublishEnabled"},
{"method":"POST","path":"/api/plugin/getLoadedPlugin","handler":"getLoadedPlugin"},
{"method":"POST","path":"/api/plugin/listLoadedPlugins","handler":"listLoadedPlugins"},
{"method":"POST","path":"/api/plugin/rpc","handler":"pluginJsonRpcHttp"},
diff --git a/kernel/apicontract/petal.go b/kernel/apicontract/petal.go
new file mode 100644
index 0000000000..679f2eef52
--- /dev/null
+++ b/kernel/apicontract/petal.go
@@ -0,0 +1,37 @@
+package apicontract
+
+type LoadPetalsRequest struct {
+ Frontend string `json:"frontend" api:"trim"`
+}
+
+type SetPetalEnabledRequest struct {
+ PackageName string `json:"packageName" api:"trim"`
+ Enabled bool `json:"enabled"`
+ App string `json:"app" api:"optional,nullable"`
+}
+
+type SetPetalPublishEnabledRequest struct {
+ PackageName string `json:"packageName" api:"trim"`
+ Enabled bool `json:"enabled"`
+}
+
+type Petal struct {
+ Name string `json:"name"`
+ DisplayName string `json:"displayName"`
+ Version string `json:"version"`
+ Enabled bool `json:"enabled"`
+ Incompatible bool `json:"incompatible"`
+ DisabledInPublish bool `json:"disabledInPublish"`
+ UserDisabledInPublish bool `json:"userDisabledInPublish"`
+ DisallowInstall bool `json:"disallowInstall"`
+ JS string `json:"js"`
+ CSS string `json:"css"`
+ I18n map[string]JSONValue `json:"i18n"`
+ Kernel KernelPetal `json:"kernel"`
+}
+
+type KernelPetal struct {
+ JS string `json:"js"`
+ Existed bool `json:"existed"`
+ Incompatible bool `json:"incompatible"`
+}
diff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.json
index 52a207da57..15cbb233a7 100644
--- a/kernel/apicontract/schema.json
+++ b/kernel/apicontract/schema.json
@@ -4067,6 +4067,26 @@
}
]
},
+ "KernelPetal": {
+ "type": "object",
+ "properties": {
+ "existed": {
+ "type": "boolean"
+ },
+ "incompatible": {
+ "type": "boolean"
+ },
+ "js": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "existed",
+ "incompatible",
+ "js"
+ ],
+ "additionalProperties": false
+ },
"ListNotebooksData": {
"type": "object",
"properties": {
@@ -4116,6 +4136,18 @@
},
"additionalProperties": false
},
+ "LoadPetalsRequestInput": {
+ "type": "object",
+ "properties": {
+ "frontend": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "frontend"
+ ],
+ "additionalProperties": false
+ },
"LockScreenRequestInput": {
"type": "object",
"properties": {
@@ -4974,6 +5006,72 @@
],
"additionalProperties": false
},
+ "Petal": {
+ "type": "object",
+ "properties": {
+ "css": {
+ "type": "string"
+ },
+ "disabledInPublish": {
+ "type": "boolean"
+ },
+ "disallowInstall": {
+ "type": "boolean"
+ },
+ "displayName": {
+ "type": "string"
+ },
+ "enabled": {
+ "type": "boolean"
+ },
+ "i18n": {
+ "anyOf": [
+ {
+ "type": "object",
+ "additionalProperties": {
+ "$ref": "#/$defs/JSONValue"
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "incompatible": {
+ "type": "boolean"
+ },
+ "js": {
+ "type": "string"
+ },
+ "kernel": {
+ "$ref": "#/$defs/KernelPetal"
+ },
+ "name": {
+ "type": "string"
+ },
+ "userDisabledInPublish": {
+ "type": "boolean"
+ },
+ "version": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "css",
+ "disabledInPublish",
+ "disallowInstall",
+ "displayName",
+ "enabled",
+ "i18n",
+ "incompatible",
+ "js",
+ "kernel",
+ "name",
+ "userDisabledInPublish",
+ "version"
+ ],
+ "additionalProperties": false
+ },
"PinnedDoc": {
"type": "object",
"properties": {
@@ -6092,6 +6190,48 @@
],
"additionalProperties": false
},
+ "SetPetalEnabledRequestInput": {
+ "type": "object",
+ "properties": {
+ "app": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "enabled": {
+ "type": "boolean"
+ },
+ "packageName": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "enabled",
+ "packageName"
+ ],
+ "additionalProperties": false
+ },
+ "SetPetalPublishEnabledRequestInput": {
+ "type": "object",
+ "properties": {
+ "enabled": {
+ "type": "boolean"
+ },
+ "packageName": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "enabled",
+ "packageName"
+ ],
+ "additionalProperties": false
+ },
"SetSnapshotMemoRequestInput": {
"type": "object",
"properties": {
@@ -16343,6 +16483,262 @@
]
}
},
+ {
+ "method": "POST",
+ "path": "/api/petal/loadPetals",
+ "handler": "loadPetals",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/LoadPetalsRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/Petal"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
+ {
+ "method": "POST",
+ "path": "/api/petal/setPetalEnabled",
+ "handler": "setPetalEnabled",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/SetPetalEnabledRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/Petal"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
+ {
+ "method": "POST",
+ "path": "/api/petal/setPetalPublishEnabled",
+ "handler": "setPetalPublishEnabled",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/SetPetalPublishEnabledRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/Petal"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
{
"method": "POST",
"path": "/api/repo/checkSnapshot",