@@ -7,9 +7,13 @@ import (
77 "github.com/omniviewdev/plugin-sdk/pkg/types"
88)
99
10- // Client is a thin wrapper that exposes only the Service interface for Wails binding.
11- // The controller has lifecycle methods (OnPluginStart, etc.) that must not be exposed
12- // to the frontend — this is a Wails constraint, not a design choice.
10+ // NOTE: Client intentionally does NOT implement Service. It is the Wails-bound
11+ // frontend API layer that converts between SDK types (json.RawMessage) and
12+ // frontend-friendly types (interface{} → "any" in TypeScript).
13+
14+ // Client is a thin Wails-bound wrapper around the Controller.
15+ // It converts SDK types (json.RawMessage) to frontend-friendly types (interface{})
16+ // so that Wails generates "any" in TypeScript instead of "number[]".
1317type Client struct {
1418 controller Controller
1519}
@@ -18,37 +22,69 @@ func NewClient(controller Controller) *Client {
1822 return & Client {controller : controller }
1923}
2024
21- // compile-time assertion
22- var _ Service = ( * Client )( nil )
25+ // Client no longer satisfies Service — it uses frontend-facing types
26+ // (interface{} instead of json.RawMessage) so Wails generates correct TS.
2327
2428func (c * Client ) ListPlugins () ([]string , error ) {
2529 return c .controller .ListPlugins ()
2630}
2731
28- // CRUD
32+ // CRUD — converts between SDK types and frontend-facing types
2933
30- func (c * Client ) Get (pluginID , connectionID , key string , input resource.GetInput ) (* resource.GetResult , error ) {
31- return c .controller .Get (pluginID , connectionID , key , input )
34+ func (c * Client ) Get (pluginID , connectionID , key string , input resource.GetInput ) (* ClientResult , error ) {
35+ result , err := c .controller .Get (pluginID , connectionID , key , input )
36+ if err != nil {
37+ return nil , err
38+ }
39+ return toClientResult (result ), nil
3240}
3341
34- func (c * Client ) List (pluginID , connectionID , key string , input resource.ListInput ) (* resource.ListResult , error ) {
35- return c .controller .List (pluginID , connectionID , key , input )
42+ func (c * Client ) List (pluginID , connectionID , key string , input resource.ListInput ) (* ClientListResult , error ) {
43+ result , err := c .controller .List (pluginID , connectionID , key , input )
44+ if err != nil {
45+ return nil , err
46+ }
47+ return toClientListResult (result ), nil
3648}
3749
38- func (c * Client ) Find (pluginID , connectionID , key string , input resource.FindInput ) (* resource.FindResult , error ) {
39- return c .controller .Find (pluginID , connectionID , key , input )
50+ func (c * Client ) Find (pluginID , connectionID , key string , input resource.FindInput ) (* ClientListResult , error ) {
51+ result , err := c .controller .Find (pluginID , connectionID , key , input )
52+ if err != nil {
53+ return nil , err
54+ }
55+ return findToClientListResult (result ), nil
4056}
4157
42- func (c * Client ) Create (pluginID , connectionID , key string , input resource.CreateInput ) (* resource.CreateResult , error ) {
43- return c .controller .Create (pluginID , connectionID , key , input )
58+ func (c * Client ) Create (pluginID , connectionID , key string , input ClientCreateInput ) (* ClientResult , error ) {
59+ sdkInput , err := toSDKCreateInput (input )
60+ if err != nil {
61+ return nil , err
62+ }
63+ result , err := c .controller .Create (pluginID , connectionID , key , sdkInput )
64+ if err != nil {
65+ return nil , err
66+ }
67+ return createToClientResult (result ), nil
4468}
4569
46- func (c * Client ) Update (pluginID , connectionID , key string , input resource.UpdateInput ) (* resource.UpdateResult , error ) {
47- return c .controller .Update (pluginID , connectionID , key , input )
70+ func (c * Client ) Update (pluginID , connectionID , key string , input ClientUpdateInput ) (* ClientResult , error ) {
71+ sdkInput , err := toSDKUpdateInput (input )
72+ if err != nil {
73+ return nil , err
74+ }
75+ result , err := c .controller .Update (pluginID , connectionID , key , sdkInput )
76+ if err != nil {
77+ return nil , err
78+ }
79+ return updateToClientResult (result ), nil
4880}
4981
50- func (c * Client ) Delete (pluginID , connectionID , key string , input resource.DeleteInput ) (* resource.DeleteResult , error ) {
51- return c .controller .Delete (pluginID , connectionID , key , input )
82+ func (c * Client ) Delete (pluginID , connectionID , key string , input resource.DeleteInput ) (* ClientResult , error ) {
83+ result , err := c .controller .Delete (pluginID , connectionID , key , input )
84+ if err != nil {
85+ return nil , err
86+ }
87+ return deleteToClientResult (result ), nil
5288}
5389
5490// Connection lifecycle
@@ -171,8 +207,12 @@ func (c *Client) GetFilterFields(pluginID, connectionID, key string) ([]resource
171207 return c .controller .GetFilterFields (pluginID , connectionID , key )
172208}
173209
174- func (c * Client ) GetResourceSchema (pluginID , connectionID , key string ) (json.RawMessage , error ) {
175- return c .controller .GetResourceSchema (pluginID , connectionID , key )
210+ func (c * Client ) GetResourceSchema (pluginID , connectionID , key string ) (interface {}, error ) {
211+ raw , err := c .controller .GetResourceSchema (pluginID , connectionID , key )
212+ if err != nil {
213+ return nil , err
214+ }
215+ return interface {}(raw ), nil
176216}
177217
178218// Actions
@@ -207,8 +247,12 @@ func (c *Client) ResolveRelationships(pluginID, connectionID, key, id, namespace
207247
208248// Health
209249
210- func (c * Client ) GetHealth (pluginID , connectionID , key string , data json.RawMessage ) (* resource.ResourceHealth , error ) {
211- return c .controller .GetHealth (pluginID , connectionID , key , data )
250+ func (c * Client ) GetHealth (pluginID , connectionID , key string , data interface {}) (* resource.ResourceHealth , error ) {
251+ raw , err := json .Marshal (data )
252+ if err != nil {
253+ return nil , err
254+ }
255+ return c .controller .GetHealth (pluginID , connectionID , key , json .RawMessage (raw ))
212256}
213257
214258func (c * Client ) GetResourceEvents (pluginID , connectionID , key , id , namespace string , limit int32 ) ([]resource.ResourceEvent , error ) {
0 commit comments