refactor(plugins): update request/response types to use private naming conventions

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan 2025-12-30 13:47:49 -05:00
parent 810ee687fa
commit 3d14349b99
30 changed files with 169 additions and 516 deletions

View File

@ -319,9 +319,9 @@ type ServiceB interface {
Expect(contentStr).To(ContainSubstring("//go:wasmimport extism:host/user comprehensive_noparams"))
Expect(contentStr).To(ContainSubstring("//go:wasmimport extism:host/user comprehensive_noparamsnoreturns"))
// Should have response types for methods with complex returns
Expect(contentStr).To(ContainSubstring("type ComprehensiveSimpleParamsResponse struct"))
Expect(contentStr).To(ContainSubstring("type ComprehensiveMultipleReturnsResponse struct"))
// Should have response types for methods with complex returns (private types in client code)
Expect(contentStr).To(ContainSubstring("type comprehensiveSimpleParamsResponse struct"))
Expect(contentStr).To(ContainSubstring("type comprehensiveMultipleReturnsResponse struct"))
// Should have wrapper functions
Expect(contentStr).To(ContainSubstring("func ComprehensiveSimpleParams("))

View File

@ -23,13 +23,14 @@ func hostFuncMap(svc Service) template.FuncMap {
}
// clientFuncMap returns the template functions for client code generation.
// Uses private (lowercase) type names for request/response structs.
func clientFuncMap(svc Service) template.FuncMap {
return template.FuncMap{
"lower": strings.ToLower,
"title": strings.Title,
"exportName": func(m Method) string { return m.FunctionName(svc.ExportPrefix()) },
"requestType": func(m Method) string { return m.RequestTypeName(svc.Name) },
"responseType": func(m Method) string { return m.ResponseTypeName(svc.Name) },
"requestType": func(m Method) string { return m.ClientRequestTypeName(svc.Name) },
"responseType": func(m Method) string { return m.ClientResponseTypeName(svc.Name) },
"formatDoc": formatDoc,
}
}

View File

@ -627,8 +627,9 @@ var _ = Describe("Generator", func() {
// Check for panic in function body
Expect(codeStr).To(ContainSubstring(`panic("ndpdk: CacheGet is only available in WASM plugins")`))
// Check that types are defined (needed for IDE support)
Expect(codeStr).To(ContainSubstring("type CacheGetResponse struct"))
// Stub files should NOT have request/response types (they're not needed)
Expect(codeStr).NotTo(ContainSubstring("Request struct"))
Expect(codeStr).NotTo(ContainSubstring("Response struct"))
})
})

View File

@ -273,8 +273,12 @@ type TestService interface {
It("should generate correct type names", func() {
m := Method{Name: "Call"}
// Host-side types are public
Expect(m.RequestTypeName("SubsonicAPI")).To(Equal("SubsonicAPICallRequest"))
Expect(m.ResponseTypeName("SubsonicAPI")).To(Equal("SubsonicAPICallResponse"))
// Client/PDK types are private
Expect(m.ClientRequestTypeName("SubsonicAPI")).To(Equal("subsonicAPICallRequest"))
Expect(m.ClientResponseTypeName("SubsonicAPI")).To(Equal("subsonicAPICallResponse"))
})
})

View File

@ -37,11 +37,10 @@ type {{.Name}} struct {
func {{exportName .}}(uint64) uint64
{{- end}}
{{- /* Generate request/response types for all methods */ -}}
{{- /* Generate request/response types for all methods (private) */ -}}
{{range .Service.Methods}}
{{- if .HasParams}}
// {{requestType .}} is the request type for {{$.Service.Name}}.{{.Name}}.
type {{requestType .}} struct {
{{- range .Params}}
{{title .Name}} {{.Type}} `json:"{{.JSONName}}"`
@ -50,7 +49,6 @@ type {{requestType .}} struct {
{{- end}}
{{- if not .IsErrorOnly}}
// {{responseType .}} is the response type for {{$.Service.Name}}.{{.Name}}.
type {{responseType .}} struct {
{{- range .Returns}}
{{title .Name}} {{.Type}} `json:"{{.JSONName}},omitempty"`

View File

@ -8,7 +8,7 @@
package {{.Package}}
{{- /* Generate struct definitions (same as main file, needed for type references) */ -}}
{{- /* Generate struct definitions (same as main file, needed for type references in function signatures) */ -}}
{{- range .Service.Structs}}
// {{.Name}} represents the {{.Name}} data structure.
@ -22,29 +22,6 @@ type {{.Name}} struct {
}
{{- end}}
{{- /* Generate request/response types (same as main file) */ -}}
{{range .Service.Methods}}
{{- if .HasParams}}
// {{requestType .}} is the request type for {{$.Service.Name}}.{{.Name}}.
type {{requestType .}} struct {
{{- range .Params}}
{{title .Name}} {{.Type}} `json:"{{.JSONName}}"`
{{- end}}
}
{{- end}}
{{- if not .IsErrorOnly}}
// {{responseType .}} is the response type for {{$.Service.Name}}.{{.Name}}.
type {{responseType .}} struct {
{{- range .Returns}}
{{title .Name}} {{.Type}} `json:"{{.JSONName}},omitempty"`
{{- end}}
Error string `json:"error,omitempty"`
}
{{- end}}
{{- end}}
{{- /* Generate stub wrapper functions that panic */ -}}
{{range .Service.Methods}}

View File

@ -181,16 +181,36 @@ func (m Method) FunctionName(servicePrefix string) string {
return servicePrefix + "_" + strings.ToLower(m.Name)
}
// RequestTypeName returns the generated request type name.
// RequestTypeName returns the generated request type name (public, for host-side code).
func (m Method) RequestTypeName(serviceName string) string {
return serviceName + m.Name + "Request"
}
// ResponseTypeName returns the generated response type name.
// ResponseTypeName returns the generated response type name (public, for host-side code).
func (m Method) ResponseTypeName(serviceName string) string {
return serviceName + m.Name + "Response"
}
// ClientRequestTypeName returns the generated request type name (private, for client/PDK code).
func (m Method) ClientRequestTypeName(serviceName string) string {
return lowerFirst(serviceName) + m.Name + "Request"
}
// ClientResponseTypeName returns the generated response type name (private, for client/PDK code).
func (m Method) ClientResponseTypeName(serviceName string) string {
return lowerFirst(serviceName) + m.Name + "Response"
}
// lowerFirst returns the string with the first letter lowercased.
func lowerFirst(s string) string {
if s == "" {
return s
}
r := []rune(s)
r[0] = unicode.ToLower(r[0])
return string(r)
}
// HasParams returns true if the method has input parameters.
func (m Method) HasParams() bool {
return len(m.Params) > 0

View File

@ -19,13 +19,11 @@ import (
//go:wasmimport extism:host/user codec_encode
func codec_encode(uint64) uint64
// CodecEncodeRequest is the request type for Codec.Encode.
type CodecEncodeRequest struct {
type codecEncodeRequest struct {
Data []byte `json:"data"`
}
// CodecEncodeResponse is the response type for Codec.Encode.
type CodecEncodeResponse struct {
type codecEncodeResponse struct {
Result []byte `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
@ -33,7 +31,7 @@ type CodecEncodeResponse struct {
// CodecEncode calls the codec_encode host function.
func CodecEncode(data []byte) ([]byte, error) {
// Marshal request to JSON
req := CodecEncodeRequest{
req := codecEncodeRequest{
Data: data,
}
reqBytes, err := json.Marshal(req)
@ -51,7 +49,7 @@ func CodecEncode(data []byte) ([]byte, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response CodecEncodeResponse
var response codecEncodeResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return nil, err
}

View File

@ -19,13 +19,11 @@ import (
//go:wasmimport extism:host/user counter_count
func counter_count(uint64) uint64
// CounterCountRequest is the request type for Counter.Count.
type CounterCountRequest struct {
type counterCountRequest struct {
Name string `json:"name"`
}
// CounterCountResponse is the response type for Counter.Count.
type CounterCountResponse struct {
type counterCountResponse struct {
Value int32 `json:"value,omitempty"`
Error string `json:"error,omitempty"`
}
@ -33,7 +31,7 @@ type CounterCountResponse struct {
// CounterCount calls the counter_count host function.
func CounterCount(name string) int32 {
// Marshal request to JSON
req := CounterCountRequest{
req := counterCountRequest{
Name: name,
}
reqBytes, err := json.Marshal(req)
@ -51,7 +49,7 @@ func CounterCount(name string) int32 {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response CounterCountResponse
var response counterCountResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return 0
}

View File

@ -19,13 +19,11 @@ import (
//go:wasmimport extism:host/user echo_echo
func echo_echo(uint64) uint64
// EchoEchoRequest is the request type for Echo.Echo.
type EchoEchoRequest struct {
type echoEchoRequest struct {
Message string `json:"message"`
}
// EchoEchoResponse is the response type for Echo.Echo.
type EchoEchoResponse struct {
type echoEchoResponse struct {
Reply string `json:"reply,omitempty"`
Error string `json:"error,omitempty"`
}
@ -33,7 +31,7 @@ type EchoEchoResponse struct {
// EchoEcho calls the echo_echo host function.
func EchoEcho(message string) (string, error) {
// Marshal request to JSON
req := EchoEchoRequest{
req := echoEchoRequest{
Message: message,
}
reqBytes, err := json.Marshal(req)
@ -51,7 +49,7 @@ func EchoEcho(message string) (string, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response EchoEchoResponse
var response echoEchoResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return "", err
}

View File

@ -24,14 +24,12 @@ type Filter struct {
//go:wasmimport extism:host/user list_items
func list_items(uint64) uint64
// ListItemsRequest is the request type for List.Items.
type ListItemsRequest struct {
type listItemsRequest struct {
Name string `json:"name"`
Filter Filter `json:"filter"`
}
// ListItemsResponse is the response type for List.Items.
type ListItemsResponse struct {
type listItemsResponse struct {
Count int32 `json:"count,omitempty"`
Error string `json:"error,omitempty"`
}
@ -39,7 +37,7 @@ type ListItemsResponse struct {
// ListItems calls the list_items host function.
func ListItems(name string, filter Filter) (int32, error) {
// Marshal request to JSON
req := ListItemsRequest{
req := listItemsRequest{
Name: name,
Filter: filter,
}
@ -58,7 +56,7 @@ func ListItems(name string, filter Filter) (int32, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response ListItemsResponse
var response listItemsResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return 0, err
}

View File

@ -19,14 +19,12 @@ import (
//go:wasmimport extism:host/user math_add
func math_add(uint64) uint64
// MathAddRequest is the request type for Math.Add.
type MathAddRequest struct {
type mathAddRequest struct {
A int32 `json:"a"`
B int32 `json:"b"`
}
// MathAddResponse is the response type for Math.Add.
type MathAddResponse struct {
type mathAddResponse struct {
Result int32 `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
@ -34,7 +32,7 @@ type MathAddResponse struct {
// MathAdd calls the math_add host function.
func MathAdd(a int32, b int32) (int32, error) {
// Marshal request to JSON
req := MathAddRequest{
req := mathAddRequest{
A: a,
B: b,
}
@ -53,7 +51,7 @@ func MathAdd(a int32, b int32) (int32, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response MathAddResponse
var response mathAddResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return 0, err
}

View File

@ -24,26 +24,23 @@ func meta_get(uint64) uint64
//go:wasmimport extism:host/user meta_set
func meta_set(uint64) uint64
// MetaGetRequest is the request type for Meta.Get.
type MetaGetRequest struct {
type metaGetRequest struct {
Key string `json:"key"`
}
// MetaGetResponse is the response type for Meta.Get.
type MetaGetResponse struct {
type metaGetResponse struct {
Value any `json:"value,omitempty"`
Error string `json:"error,omitempty"`
}
// MetaSetRequest is the request type for Meta.Set.
type MetaSetRequest struct {
type metaSetRequest struct {
Data map[string]any `json:"data"`
}
// MetaGet calls the meta_get host function.
func MetaGet(key string) (any, error) {
// Marshal request to JSON
req := MetaGetRequest{
req := metaGetRequest{
Key: key,
}
reqBytes, err := json.Marshal(req)
@ -61,7 +58,7 @@ func MetaGet(key string) (any, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response MetaGetResponse
var response metaGetResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return nil, err
}
@ -77,7 +74,7 @@ func MetaGet(key string) (any, error) {
// MetaSet calls the meta_set host function.
func MetaSet(data map[string]any) error {
// Marshal request to JSON
req := MetaSetRequest{
req := metaSetRequest{
Data: data,
}
reqBytes, err := json.Marshal(req)

View File

@ -24,13 +24,11 @@ type Result struct {
//go:wasmimport extism:host/user search_find
func search_find(uint64) uint64
// SearchFindRequest is the request type for Search.Find.
type SearchFindRequest struct {
type searchFindRequest struct {
Query string `json:"query"`
}
// SearchFindResponse is the response type for Search.Find.
type SearchFindResponse struct {
type searchFindResponse struct {
Results []Result `json:"results,omitempty"`
Total int32 `json:"total,omitempty"`
Error string `json:"error,omitempty"`
@ -39,7 +37,7 @@ type SearchFindResponse struct {
// SearchFind calls the search_find host function.
func SearchFind(query string) ([]Result, int32, error) {
// Marshal request to JSON
req := SearchFindRequest{
req := searchFindRequest{
Query: query,
}
reqBytes, err := json.Marshal(req)
@ -57,7 +55,7 @@ func SearchFind(query string) ([]Result, int32, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response SearchFindResponse
var response searchFindResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return nil, 0, err
}

View File

@ -25,13 +25,11 @@ type Item struct {
//go:wasmimport extism:host/user store_save
func store_save(uint64) uint64
// StoreSaveRequest is the request type for Store.Save.
type StoreSaveRequest struct {
type storeSaveRequest struct {
Item Item `json:"item"`
}
// StoreSaveResponse is the response type for Store.Save.
type StoreSaveResponse struct {
type storeSaveResponse struct {
Id string `json:"id,omitempty"`
Error string `json:"error,omitempty"`
}
@ -39,7 +37,7 @@ type StoreSaveResponse struct {
// StoreSave calls the store_save host function.
func StoreSave(item Item) (string, error) {
// Marshal request to JSON
req := StoreSaveRequest{
req := storeSaveRequest{
Item: item,
}
reqBytes, err := json.Marshal(req)
@ -57,7 +55,7 @@ func StoreSave(item Item) (string, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response StoreSaveResponse
var response storeSaveResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return "", err
}

View File

@ -25,14 +25,12 @@ type User struct {
//go:wasmimport extism:host/user users_get
func users_get(uint64) uint64
// UsersGetRequest is the request type for Users.Get.
type UsersGetRequest struct {
type usersGetRequest struct {
Id *string `json:"id"`
Filter *User `json:"filter"`
}
// UsersGetResponse is the response type for Users.Get.
type UsersGetResponse struct {
type usersGetResponse struct {
Result *User `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
@ -40,7 +38,7 @@ type UsersGetResponse struct {
// UsersGet calls the users_get host function.
func UsersGet(id *string, filter *User) (*User, error) {
// Marshal request to JSON
req := UsersGetRequest{
req := usersGetRequest{
Id: id,
Filter: filter,
}
@ -59,7 +57,7 @@ func UsersGet(id *string, filter *User) (*User, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response UsersGetResponse
var response usersGetResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return nil, err
}

View File

@ -34,50 +34,42 @@ func artwork_gettrackurl(uint64) uint64
//go:wasmimport extism:host/user artwork_getplaylisturl
func artwork_getplaylisturl(uint64) uint64
// ArtworkGetArtistUrlRequest is the request type for Artwork.GetArtistUrl.
type ArtworkGetArtistUrlRequest struct {
type artworkGetArtistUrlRequest struct {
Id string `json:"id"`
Size int32 `json:"size"`
}
// ArtworkGetArtistUrlResponse is the response type for Artwork.GetArtistUrl.
type ArtworkGetArtistUrlResponse struct {
type artworkGetArtistUrlResponse struct {
Url string `json:"url,omitempty"`
Error string `json:"error,omitempty"`
}
// ArtworkGetAlbumUrlRequest is the request type for Artwork.GetAlbumUrl.
type ArtworkGetAlbumUrlRequest struct {
type artworkGetAlbumUrlRequest struct {
Id string `json:"id"`
Size int32 `json:"size"`
}
// ArtworkGetAlbumUrlResponse is the response type for Artwork.GetAlbumUrl.
type ArtworkGetAlbumUrlResponse struct {
type artworkGetAlbumUrlResponse struct {
Url string `json:"url,omitempty"`
Error string `json:"error,omitempty"`
}
// ArtworkGetTrackUrlRequest is the request type for Artwork.GetTrackUrl.
type ArtworkGetTrackUrlRequest struct {
type artworkGetTrackUrlRequest struct {
Id string `json:"id"`
Size int32 `json:"size"`
}
// ArtworkGetTrackUrlResponse is the response type for Artwork.GetTrackUrl.
type ArtworkGetTrackUrlResponse struct {
type artworkGetTrackUrlResponse struct {
Url string `json:"url,omitempty"`
Error string `json:"error,omitempty"`
}
// ArtworkGetPlaylistUrlRequest is the request type for Artwork.GetPlaylistUrl.
type ArtworkGetPlaylistUrlRequest struct {
type artworkGetPlaylistUrlRequest struct {
Id string `json:"id"`
Size int32 `json:"size"`
}
// ArtworkGetPlaylistUrlResponse is the response type for Artwork.GetPlaylistUrl.
type ArtworkGetPlaylistUrlResponse struct {
type artworkGetPlaylistUrlResponse struct {
Url string `json:"url,omitempty"`
Error string `json:"error,omitempty"`
}
@ -92,7 +84,7 @@ type ArtworkGetPlaylistUrlResponse struct {
// Returns the public URL for the artwork, or an error if generation fails.
func ArtworkGetArtistUrl(id string, size int32) (string, error) {
// Marshal request to JSON
req := ArtworkGetArtistUrlRequest{
req := artworkGetArtistUrlRequest{
Id: id,
Size: size,
}
@ -111,7 +103,7 @@ func ArtworkGetArtistUrl(id string, size int32) (string, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response ArtworkGetArtistUrlResponse
var response artworkGetArtistUrlResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return "", err
}
@ -134,7 +126,7 @@ func ArtworkGetArtistUrl(id string, size int32) (string, error) {
// Returns the public URL for the artwork, or an error if generation fails.
func ArtworkGetAlbumUrl(id string, size int32) (string, error) {
// Marshal request to JSON
req := ArtworkGetAlbumUrlRequest{
req := artworkGetAlbumUrlRequest{
Id: id,
Size: size,
}
@ -153,7 +145,7 @@ func ArtworkGetAlbumUrl(id string, size int32) (string, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response ArtworkGetAlbumUrlResponse
var response artworkGetAlbumUrlResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return "", err
}
@ -176,7 +168,7 @@ func ArtworkGetAlbumUrl(id string, size int32) (string, error) {
// Returns the public URL for the artwork, or an error if generation fails.
func ArtworkGetTrackUrl(id string, size int32) (string, error) {
// Marshal request to JSON
req := ArtworkGetTrackUrlRequest{
req := artworkGetTrackUrlRequest{
Id: id,
Size: size,
}
@ -195,7 +187,7 @@ func ArtworkGetTrackUrl(id string, size int32) (string, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response ArtworkGetTrackUrlResponse
var response artworkGetTrackUrlResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return "", err
}
@ -218,7 +210,7 @@ func ArtworkGetTrackUrl(id string, size int32) (string, error) {
// Returns the public URL for the artwork, or an error if generation fails.
func ArtworkGetPlaylistUrl(id string, size int32) (string, error) {
// Marshal request to JSON
req := ArtworkGetPlaylistUrlRequest{
req := artworkGetPlaylistUrlRequest{
Id: id,
Size: size,
}
@ -237,7 +229,7 @@ func ArtworkGetPlaylistUrl(id string, size int32) (string, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response ArtworkGetPlaylistUrlResponse
var response artworkGetPlaylistUrlResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return "", err
}

View File

@ -8,54 +8,6 @@
package host
// ArtworkGetArtistUrlRequest is the request type for Artwork.GetArtistUrl.
type ArtworkGetArtistUrlRequest struct {
Id string `json:"id"`
Size int32 `json:"size"`
}
// ArtworkGetArtistUrlResponse is the response type for Artwork.GetArtistUrl.
type ArtworkGetArtistUrlResponse struct {
Url string `json:"url,omitempty"`
Error string `json:"error,omitempty"`
}
// ArtworkGetAlbumUrlRequest is the request type for Artwork.GetAlbumUrl.
type ArtworkGetAlbumUrlRequest struct {
Id string `json:"id"`
Size int32 `json:"size"`
}
// ArtworkGetAlbumUrlResponse is the response type for Artwork.GetAlbumUrl.
type ArtworkGetAlbumUrlResponse struct {
Url string `json:"url,omitempty"`
Error string `json:"error,omitempty"`
}
// ArtworkGetTrackUrlRequest is the request type for Artwork.GetTrackUrl.
type ArtworkGetTrackUrlRequest struct {
Id string `json:"id"`
Size int32 `json:"size"`
}
// ArtworkGetTrackUrlResponse is the response type for Artwork.GetTrackUrl.
type ArtworkGetTrackUrlResponse struct {
Url string `json:"url,omitempty"`
Error string `json:"error,omitempty"`
}
// ArtworkGetPlaylistUrlRequest is the request type for Artwork.GetPlaylistUrl.
type ArtworkGetPlaylistUrlRequest struct {
Id string `json:"id"`
Size int32 `json:"size"`
}
// ArtworkGetPlaylistUrlResponse is the response type for Artwork.GetPlaylistUrl.
type ArtworkGetPlaylistUrlResponse struct {
Url string `json:"url,omitempty"`
Error string `json:"error,omitempty"`
}
// ArtworkGetArtistUrl is a stub that panics on non-WASM platforms.
// GetArtistUrl generates a public URL for an artist's artwork.
//

View File

@ -64,95 +64,80 @@ func cache_has(uint64) uint64
//go:wasmimport extism:host/user cache_remove
func cache_remove(uint64) uint64
// CacheSetStringRequest is the request type for Cache.SetString.
type CacheSetStringRequest struct {
type cacheSetStringRequest struct {
Key string `json:"key"`
Value string `json:"value"`
TtlSeconds int64 `json:"ttlSeconds"`
}
// CacheGetStringRequest is the request type for Cache.GetString.
type CacheGetStringRequest struct {
type cacheGetStringRequest struct {
Key string `json:"key"`
}
// CacheGetStringResponse is the response type for Cache.GetString.
type CacheGetStringResponse struct {
type cacheGetStringResponse struct {
Value string `json:"value,omitempty"`
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// CacheSetIntRequest is the request type for Cache.SetInt.
type CacheSetIntRequest struct {
type cacheSetIntRequest struct {
Key string `json:"key"`
Value int64 `json:"value"`
TtlSeconds int64 `json:"ttlSeconds"`
}
// CacheGetIntRequest is the request type for Cache.GetInt.
type CacheGetIntRequest struct {
type cacheGetIntRequest struct {
Key string `json:"key"`
}
// CacheGetIntResponse is the response type for Cache.GetInt.
type CacheGetIntResponse struct {
type cacheGetIntResponse struct {
Value int64 `json:"value,omitempty"`
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// CacheSetFloatRequest is the request type for Cache.SetFloat.
type CacheSetFloatRequest struct {
type cacheSetFloatRequest struct {
Key string `json:"key"`
Value float64 `json:"value"`
TtlSeconds int64 `json:"ttlSeconds"`
}
// CacheGetFloatRequest is the request type for Cache.GetFloat.
type CacheGetFloatRequest struct {
type cacheGetFloatRequest struct {
Key string `json:"key"`
}
// CacheGetFloatResponse is the response type for Cache.GetFloat.
type CacheGetFloatResponse struct {
type cacheGetFloatResponse struct {
Value float64 `json:"value,omitempty"`
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// CacheSetBytesRequest is the request type for Cache.SetBytes.
type CacheSetBytesRequest struct {
type cacheSetBytesRequest struct {
Key string `json:"key"`
Value []byte `json:"value"`
TtlSeconds int64 `json:"ttlSeconds"`
}
// CacheGetBytesRequest is the request type for Cache.GetBytes.
type CacheGetBytesRequest struct {
type cacheGetBytesRequest struct {
Key string `json:"key"`
}
// CacheGetBytesResponse is the response type for Cache.GetBytes.
type CacheGetBytesResponse struct {
type cacheGetBytesResponse struct {
Value []byte `json:"value,omitempty"`
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// CacheHasRequest is the request type for Cache.Has.
type CacheHasRequest struct {
type cacheHasRequest struct {
Key string `json:"key"`
}
// CacheHasResponse is the response type for Cache.Has.
type CacheHasResponse struct {
type cacheHasResponse struct {
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// CacheRemoveRequest is the request type for Cache.Remove.
type CacheRemoveRequest struct {
type cacheRemoveRequest struct {
Key string `json:"key"`
}
@ -167,7 +152,7 @@ type CacheRemoveRequest struct {
// Returns an error if the operation fails.
func CacheSetString(key string, value string, ttlSeconds int64) error {
// Marshal request to JSON
req := CacheSetStringRequest{
req := cacheSetStringRequest{
Key: key,
Value: value,
TtlSeconds: ttlSeconds,
@ -209,7 +194,7 @@ func CacheSetString(key string, value string, ttlSeconds int64) error {
// or the stored value is not a string, exists will be false.
func CacheGetString(key string) (string, bool, error) {
// Marshal request to JSON
req := CacheGetStringRequest{
req := cacheGetStringRequest{
Key: key,
}
reqBytes, err := json.Marshal(req)
@ -227,7 +212,7 @@ func CacheGetString(key string) (string, bool, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response CacheGetStringResponse
var response cacheGetStringResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return "", false, err
}
@ -251,7 +236,7 @@ func CacheGetString(key string) (string, bool, error) {
// Returns an error if the operation fails.
func CacheSetInt(key string, value int64, ttlSeconds int64) error {
// Marshal request to JSON
req := CacheSetIntRequest{
req := cacheSetIntRequest{
Key: key,
Value: value,
TtlSeconds: ttlSeconds,
@ -293,7 +278,7 @@ func CacheSetInt(key string, value int64, ttlSeconds int64) error {
// or the stored value is not an integer, exists will be false.
func CacheGetInt(key string) (int64, bool, error) {
// Marshal request to JSON
req := CacheGetIntRequest{
req := cacheGetIntRequest{
Key: key,
}
reqBytes, err := json.Marshal(req)
@ -311,7 +296,7 @@ func CacheGetInt(key string) (int64, bool, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response CacheGetIntResponse
var response cacheGetIntResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return 0, false, err
}
@ -335,7 +320,7 @@ func CacheGetInt(key string) (int64, bool, error) {
// Returns an error if the operation fails.
func CacheSetFloat(key string, value float64, ttlSeconds int64) error {
// Marshal request to JSON
req := CacheSetFloatRequest{
req := cacheSetFloatRequest{
Key: key,
Value: value,
TtlSeconds: ttlSeconds,
@ -377,7 +362,7 @@ func CacheSetFloat(key string, value float64, ttlSeconds int64) error {
// or the stored value is not a float, exists will be false.
func CacheGetFloat(key string) (float64, bool, error) {
// Marshal request to JSON
req := CacheGetFloatRequest{
req := cacheGetFloatRequest{
Key: key,
}
reqBytes, err := json.Marshal(req)
@ -395,7 +380,7 @@ func CacheGetFloat(key string) (float64, bool, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response CacheGetFloatResponse
var response cacheGetFloatResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return 0, false, err
}
@ -419,7 +404,7 @@ func CacheGetFloat(key string) (float64, bool, error) {
// Returns an error if the operation fails.
func CacheSetBytes(key string, value []byte, ttlSeconds int64) error {
// Marshal request to JSON
req := CacheSetBytesRequest{
req := cacheSetBytesRequest{
Key: key,
Value: value,
TtlSeconds: ttlSeconds,
@ -461,7 +446,7 @@ func CacheSetBytes(key string, value []byte, ttlSeconds int64) error {
// or the stored value is not a byte slice, exists will be false.
func CacheGetBytes(key string) ([]byte, bool, error) {
// Marshal request to JSON
req := CacheGetBytesRequest{
req := cacheGetBytesRequest{
Key: key,
}
reqBytes, err := json.Marshal(req)
@ -479,7 +464,7 @@ func CacheGetBytes(key string) ([]byte, bool, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response CacheGetBytesResponse
var response cacheGetBytesResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return nil, false, err
}
@ -501,7 +486,7 @@ func CacheGetBytes(key string) ([]byte, bool, error) {
// Returns true if the key exists and has not expired.
func CacheHas(key string) (bool, error) {
// Marshal request to JSON
req := CacheHasRequest{
req := cacheHasRequest{
Key: key,
}
reqBytes, err := json.Marshal(req)
@ -519,7 +504,7 @@ func CacheHas(key string) (bool, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response CacheHasResponse
var response cacheHasResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return false, err
}
@ -541,7 +526,7 @@ func CacheHas(key string) (bool, error) {
// Returns an error if the operation fails. Does not return an error if the key doesn't exist.
func CacheRemove(key string) error {
// Marshal request to JSON
req := CacheRemoveRequest{
req := cacheRemoveRequest{
Key: key,
}
reqBytes, err := json.Marshal(req)

View File

@ -8,98 +8,6 @@
package host
// CacheSetStringRequest is the request type for Cache.SetString.
type CacheSetStringRequest struct {
Key string `json:"key"`
Value string `json:"value"`
TtlSeconds int64 `json:"ttlSeconds"`
}
// CacheGetStringRequest is the request type for Cache.GetString.
type CacheGetStringRequest struct {
Key string `json:"key"`
}
// CacheGetStringResponse is the response type for Cache.GetString.
type CacheGetStringResponse struct {
Value string `json:"value,omitempty"`
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// CacheSetIntRequest is the request type for Cache.SetInt.
type CacheSetIntRequest struct {
Key string `json:"key"`
Value int64 `json:"value"`
TtlSeconds int64 `json:"ttlSeconds"`
}
// CacheGetIntRequest is the request type for Cache.GetInt.
type CacheGetIntRequest struct {
Key string `json:"key"`
}
// CacheGetIntResponse is the response type for Cache.GetInt.
type CacheGetIntResponse struct {
Value int64 `json:"value,omitempty"`
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// CacheSetFloatRequest is the request type for Cache.SetFloat.
type CacheSetFloatRequest struct {
Key string `json:"key"`
Value float64 `json:"value"`
TtlSeconds int64 `json:"ttlSeconds"`
}
// CacheGetFloatRequest is the request type for Cache.GetFloat.
type CacheGetFloatRequest struct {
Key string `json:"key"`
}
// CacheGetFloatResponse is the response type for Cache.GetFloat.
type CacheGetFloatResponse struct {
Value float64 `json:"value,omitempty"`
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// CacheSetBytesRequest is the request type for Cache.SetBytes.
type CacheSetBytesRequest struct {
Key string `json:"key"`
Value []byte `json:"value"`
TtlSeconds int64 `json:"ttlSeconds"`
}
// CacheGetBytesRequest is the request type for Cache.GetBytes.
type CacheGetBytesRequest struct {
Key string `json:"key"`
}
// CacheGetBytesResponse is the response type for Cache.GetBytes.
type CacheGetBytesResponse struct {
Value []byte `json:"value,omitempty"`
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// CacheHasRequest is the request type for Cache.Has.
type CacheHasRequest struct {
Key string `json:"key"`
}
// CacheHasResponse is the response type for Cache.Has.
type CacheHasResponse struct {
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// CacheRemoveRequest is the request type for Cache.Remove.
type CacheRemoveRequest struct {
Key string `json:"key"`
}
// CacheSetString is a stub that panics on non-WASM platforms.
// SetString stores a string value in the cache.
//

View File

@ -44,53 +44,44 @@ func kvstore_list(uint64) uint64
//go:wasmimport extism:host/user kvstore_getstorageused
func kvstore_getstorageused(uint64) uint64
// KVStoreSetRequest is the request type for KVStore.Set.
type KVStoreSetRequest struct {
type kVStoreSetRequest struct {
Key string `json:"key"`
Value []byte `json:"value"`
}
// KVStoreGetRequest is the request type for KVStore.Get.
type KVStoreGetRequest struct {
type kVStoreGetRequest struct {
Key string `json:"key"`
}
// KVStoreGetResponse is the response type for KVStore.Get.
type KVStoreGetResponse struct {
type kVStoreGetResponse struct {
Value []byte `json:"value,omitempty"`
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// KVStoreDeleteRequest is the request type for KVStore.Delete.
type KVStoreDeleteRequest struct {
type kVStoreDeleteRequest struct {
Key string `json:"key"`
}
// KVStoreHasRequest is the request type for KVStore.Has.
type KVStoreHasRequest struct {
type kVStoreHasRequest struct {
Key string `json:"key"`
}
// KVStoreHasResponse is the response type for KVStore.Has.
type KVStoreHasResponse struct {
type kVStoreHasResponse struct {
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// KVStoreListRequest is the request type for KVStore.List.
type KVStoreListRequest struct {
type kVStoreListRequest struct {
Prefix string `json:"prefix"`
}
// KVStoreListResponse is the response type for KVStore.List.
type KVStoreListResponse struct {
type kVStoreListResponse struct {
Keys []string `json:"keys,omitempty"`
Error string `json:"error,omitempty"`
}
// KVStoreGetStorageUsedResponse is the response type for KVStore.GetStorageUsed.
type KVStoreGetStorageUsedResponse struct {
type kVStoreGetStorageUsedResponse struct {
Bytes int64 `json:"bytes,omitempty"`
Error string `json:"error,omitempty"`
}
@ -105,7 +96,7 @@ type KVStoreGetStorageUsedResponse struct {
// Returns an error if the storage limit would be exceeded or the operation fails.
func KVStoreSet(key string, value []byte) error {
// Marshal request to JSON
req := KVStoreSetRequest{
req := kVStoreSetRequest{
Key: key,
Value: value,
}
@ -145,7 +136,7 @@ func KVStoreSet(key string, value []byte) error {
// Returns the value and whether the key exists.
func KVStoreGet(key string) ([]byte, bool, error) {
// Marshal request to JSON
req := KVStoreGetRequest{
req := kVStoreGetRequest{
Key: key,
}
reqBytes, err := json.Marshal(req)
@ -163,7 +154,7 @@ func KVStoreGet(key string) ([]byte, bool, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response KVStoreGetResponse
var response kVStoreGetResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return nil, false, err
}
@ -185,7 +176,7 @@ func KVStoreGet(key string) ([]byte, bool, error) {
// Returns an error if the operation fails. Does not return an error if the key doesn't exist.
func KVStoreDelete(key string) error {
// Marshal request to JSON
req := KVStoreDeleteRequest{
req := kVStoreDeleteRequest{
Key: key,
}
reqBytes, err := json.Marshal(req)
@ -224,7 +215,7 @@ func KVStoreDelete(key string) error {
// Returns true if the key exists.
func KVStoreHas(key string) (bool, error) {
// Marshal request to JSON
req := KVStoreHasRequest{
req := kVStoreHasRequest{
Key: key,
}
reqBytes, err := json.Marshal(req)
@ -242,7 +233,7 @@ func KVStoreHas(key string) (bool, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response KVStoreHasResponse
var response kVStoreHasResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return false, err
}
@ -264,7 +255,7 @@ func KVStoreHas(key string) (bool, error) {
// Returns a slice of matching keys.
func KVStoreList(prefix string) ([]string, error) {
// Marshal request to JSON
req := KVStoreListRequest{
req := kVStoreListRequest{
Prefix: prefix,
}
reqBytes, err := json.Marshal(req)
@ -282,7 +273,7 @@ func KVStoreList(prefix string) ([]string, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response KVStoreListResponse
var response kVStoreListResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return nil, err
}
@ -310,7 +301,7 @@ func KVStoreGetStorageUsed() (int64, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response KVStoreGetStorageUsedResponse
var response kVStoreGetStorageUsedResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return 0, err
}

View File

@ -8,57 +8,6 @@
package host
// KVStoreSetRequest is the request type for KVStore.Set.
type KVStoreSetRequest struct {
Key string `json:"key"`
Value []byte `json:"value"`
}
// KVStoreGetRequest is the request type for KVStore.Get.
type KVStoreGetRequest struct {
Key string `json:"key"`
}
// KVStoreGetResponse is the response type for KVStore.Get.
type KVStoreGetResponse struct {
Value []byte `json:"value,omitempty"`
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// KVStoreDeleteRequest is the request type for KVStore.Delete.
type KVStoreDeleteRequest struct {
Key string `json:"key"`
}
// KVStoreHasRequest is the request type for KVStore.Has.
type KVStoreHasRequest struct {
Key string `json:"key"`
}
// KVStoreHasResponse is the response type for KVStore.Has.
type KVStoreHasResponse struct {
Exists bool `json:"exists,omitempty"`
Error string `json:"error,omitempty"`
}
// KVStoreListRequest is the request type for KVStore.List.
type KVStoreListRequest struct {
Prefix string `json:"prefix"`
}
// KVStoreListResponse is the response type for KVStore.List.
type KVStoreListResponse struct {
Keys []string `json:"keys,omitempty"`
Error string `json:"error,omitempty"`
}
// KVStoreGetStorageUsedResponse is the response type for KVStore.GetStorageUsed.
type KVStoreGetStorageUsedResponse struct {
Bytes int64 `json:"bytes,omitempty"`
Error string `json:"error,omitempty"`
}
// KVStoreSet is a stub that panics on non-WASM platforms.
// Set stores a byte value with the given key.
//

View File

@ -39,19 +39,16 @@ func library_getlibrary(uint64) uint64
//go:wasmimport extism:host/user library_getalllibraries
func library_getalllibraries(uint64) uint64
// LibraryGetLibraryRequest is the request type for Library.GetLibrary.
type LibraryGetLibraryRequest struct {
type libraryGetLibraryRequest struct {
Id int32 `json:"id"`
}
// LibraryGetLibraryResponse is the response type for Library.GetLibrary.
type LibraryGetLibraryResponse struct {
type libraryGetLibraryResponse struct {
Result *Library `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
// LibraryGetAllLibrariesResponse is the response type for Library.GetAllLibraries.
type LibraryGetAllLibrariesResponse struct {
type libraryGetAllLibrariesResponse struct {
Result []Library `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
@ -65,7 +62,7 @@ type LibraryGetAllLibrariesResponse struct {
// Returns the library metadata, or an error if the library is not found.
func LibraryGetLibrary(id int32) (*Library, error) {
// Marshal request to JSON
req := LibraryGetLibraryRequest{
req := libraryGetLibraryRequest{
Id: id,
}
reqBytes, err := json.Marshal(req)
@ -83,7 +80,7 @@ func LibraryGetLibrary(id int32) (*Library, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response LibraryGetLibraryResponse
var response libraryGetLibraryResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return nil, err
}
@ -113,7 +110,7 @@ func LibraryGetAllLibraries() ([]Library, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response LibraryGetAllLibrariesResponse
var response libraryGetAllLibrariesResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return nil, err
}

View File

@ -23,23 +23,6 @@ type Library struct {
TotalDuration float64 `json:"totalDuration"`
}
// LibraryGetLibraryRequest is the request type for Library.GetLibrary.
type LibraryGetLibraryRequest struct {
Id int32 `json:"id"`
}
// LibraryGetLibraryResponse is the response type for Library.GetLibrary.
type LibraryGetLibraryResponse struct {
Result *Library `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
// LibraryGetAllLibrariesResponse is the response type for Library.GetAllLibraries.
type LibraryGetAllLibrariesResponse struct {
Result []Library `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
// LibraryGetLibrary is a stub that panics on non-WASM platforms.
// GetLibrary retrieves metadata for a specific library by ID.
//

View File

@ -29,34 +29,29 @@ func scheduler_schedulerecurring(uint64) uint64
//go:wasmimport extism:host/user scheduler_cancelschedule
func scheduler_cancelschedule(uint64) uint64
// SchedulerScheduleOneTimeRequest is the request type for Scheduler.ScheduleOneTime.
type SchedulerScheduleOneTimeRequest struct {
type schedulerScheduleOneTimeRequest struct {
DelaySeconds int32 `json:"delaySeconds"`
Payload string `json:"payload"`
ScheduleID string `json:"scheduleId"`
}
// SchedulerScheduleOneTimeResponse is the response type for Scheduler.ScheduleOneTime.
type SchedulerScheduleOneTimeResponse struct {
type schedulerScheduleOneTimeResponse struct {
NewScheduleID string `json:"newScheduleId,omitempty"`
Error string `json:"error,omitempty"`
}
// SchedulerScheduleRecurringRequest is the request type for Scheduler.ScheduleRecurring.
type SchedulerScheduleRecurringRequest struct {
type schedulerScheduleRecurringRequest struct {
CronExpression string `json:"cronExpression"`
Payload string `json:"payload"`
ScheduleID string `json:"scheduleId"`
}
// SchedulerScheduleRecurringResponse is the response type for Scheduler.ScheduleRecurring.
type SchedulerScheduleRecurringResponse struct {
type schedulerScheduleRecurringResponse struct {
NewScheduleID string `json:"newScheduleId,omitempty"`
Error string `json:"error,omitempty"`
}
// SchedulerCancelScheduleRequest is the request type for Scheduler.CancelSchedule.
type SchedulerCancelScheduleRequest struct {
type schedulerCancelScheduleRequest struct {
ScheduleID string `json:"scheduleId"`
}
@ -72,7 +67,7 @@ type SchedulerCancelScheduleRequest struct {
// Returns the schedule ID that can be used to cancel the job, or an error if scheduling fails.
func SchedulerScheduleOneTime(delaySeconds int32, payload string, scheduleID string) (string, error) {
// Marshal request to JSON
req := SchedulerScheduleOneTimeRequest{
req := schedulerScheduleOneTimeRequest{
DelaySeconds: delaySeconds,
Payload: payload,
ScheduleID: scheduleID,
@ -92,7 +87,7 @@ func SchedulerScheduleOneTime(delaySeconds int32, payload string, scheduleID str
responseBytes := responseMem.ReadBytes()
// Parse the response
var response SchedulerScheduleOneTimeResponse
var response schedulerScheduleOneTimeResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return "", err
}
@ -117,7 +112,7 @@ func SchedulerScheduleOneTime(delaySeconds int32, payload string, scheduleID str
// Returns the schedule ID that can be used to cancel the job, or an error if scheduling fails.
func SchedulerScheduleRecurring(cronExpression string, payload string, scheduleID string) (string, error) {
// Marshal request to JSON
req := SchedulerScheduleRecurringRequest{
req := schedulerScheduleRecurringRequest{
CronExpression: cronExpression,
Payload: payload,
ScheduleID: scheduleID,
@ -137,7 +132,7 @@ func SchedulerScheduleRecurring(cronExpression string, payload string, scheduleI
responseBytes := responseMem.ReadBytes()
// Parse the response
var response SchedulerScheduleRecurringResponse
var response schedulerScheduleRecurringResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return "", err
}
@ -159,7 +154,7 @@ func SchedulerScheduleRecurring(cronExpression string, payload string, scheduleI
// Returns an error if the schedule ID is not found or if cancellation fails.
func SchedulerCancelSchedule(scheduleID string) error {
// Marshal request to JSON
req := SchedulerCancelScheduleRequest{
req := schedulerCancelScheduleRequest{
ScheduleID: scheduleID,
}
reqBytes, err := json.Marshal(req)

View File

@ -8,37 +8,6 @@
package host
// SchedulerScheduleOneTimeRequest is the request type for Scheduler.ScheduleOneTime.
type SchedulerScheduleOneTimeRequest struct {
DelaySeconds int32 `json:"delaySeconds"`
Payload string `json:"payload"`
ScheduleID string `json:"scheduleId"`
}
// SchedulerScheduleOneTimeResponse is the response type for Scheduler.ScheduleOneTime.
type SchedulerScheduleOneTimeResponse struct {
NewScheduleID string `json:"newScheduleId,omitempty"`
Error string `json:"error,omitempty"`
}
// SchedulerScheduleRecurringRequest is the request type for Scheduler.ScheduleRecurring.
type SchedulerScheduleRecurringRequest struct {
CronExpression string `json:"cronExpression"`
Payload string `json:"payload"`
ScheduleID string `json:"scheduleId"`
}
// SchedulerScheduleRecurringResponse is the response type for Scheduler.ScheduleRecurring.
type SchedulerScheduleRecurringResponse struct {
NewScheduleID string `json:"newScheduleId,omitempty"`
Error string `json:"error,omitempty"`
}
// SchedulerCancelScheduleRequest is the request type for Scheduler.CancelSchedule.
type SchedulerCancelScheduleRequest struct {
ScheduleID string `json:"scheduleId"`
}
// SchedulerScheduleOneTime is a stub that panics on non-WASM platforms.
// ScheduleOneTime schedules a one-time event to be triggered after the specified delay.
// Plugins that use this function must also implement the SchedulerCallback capability

View File

@ -19,13 +19,11 @@ import (
//go:wasmimport extism:host/user subsonicapi_call
func subsonicapi_call(uint64) uint64
// SubsonicAPICallRequest is the request type for SubsonicAPI.Call.
type SubsonicAPICallRequest struct {
type subsonicAPICallRequest struct {
Uri string `json:"uri"`
}
// SubsonicAPICallResponse is the response type for SubsonicAPI.Call.
type SubsonicAPICallResponse struct {
type subsonicAPICallResponse struct {
ResponseJSON string `json:"responseJson,omitempty"`
Error string `json:"error,omitempty"`
}
@ -37,7 +35,7 @@ type SubsonicAPICallResponse struct {
// e.g., "getAlbumList2?type=random&size=10". The response is returned as raw JSON.
func SubsonicAPICall(uri string) (string, error) {
// Marshal request to JSON
req := SubsonicAPICallRequest{
req := subsonicAPICallRequest{
Uri: uri,
}
reqBytes, err := json.Marshal(req)
@ -55,7 +53,7 @@ func SubsonicAPICall(uri string) (string, error) {
responseBytes := responseMem.ReadBytes()
// Parse the response
var response SubsonicAPICallResponse
var response subsonicAPICallResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return "", err
}

View File

@ -8,17 +8,6 @@
package host
// SubsonicAPICallRequest is the request type for SubsonicAPI.Call.
type SubsonicAPICallRequest struct {
Uri string `json:"uri"`
}
// SubsonicAPICallResponse is the response type for SubsonicAPI.Call.
type SubsonicAPICallResponse struct {
ResponseJSON string `json:"responseJson,omitempty"`
Error string `json:"error,omitempty"`
}
// SubsonicAPICall is a stub that panics on non-WASM platforms.
// Call executes a Subsonic API request and returns the JSON response.
//

View File

@ -34,33 +34,28 @@ func websocket_sendbinary(uint64) uint64
//go:wasmimport extism:host/user websocket_closeconnection
func websocket_closeconnection(uint64) uint64
// WebSocketConnectRequest is the request type for WebSocket.Connect.
type WebSocketConnectRequest struct {
type webSocketConnectRequest struct {
Url string `json:"url"`
Headers map[string]string `json:"headers"`
ConnectionID string `json:"connectionId"`
}
// WebSocketConnectResponse is the response type for WebSocket.Connect.
type WebSocketConnectResponse struct {
type webSocketConnectResponse struct {
NewConnectionID string `json:"newConnectionId,omitempty"`
Error string `json:"error,omitempty"`
}
// WebSocketSendTextRequest is the request type for WebSocket.SendText.
type WebSocketSendTextRequest struct {
type webSocketSendTextRequest struct {
ConnectionID string `json:"connectionId"`
Message string `json:"message"`
}
// WebSocketSendBinaryRequest is the request type for WebSocket.SendBinary.
type WebSocketSendBinaryRequest struct {
type webSocketSendBinaryRequest struct {
ConnectionID string `json:"connectionId"`
Data []byte `json:"data"`
}
// WebSocketCloseConnectionRequest is the request type for WebSocket.CloseConnection.
type WebSocketCloseConnectionRequest struct {
type webSocketCloseConnectionRequest struct {
ConnectionID string `json:"connectionId"`
Code int32 `json:"code"`
Reason string `json:"reason"`
@ -81,7 +76,7 @@ type WebSocketCloseConnectionRequest struct {
// or an error if the connection fails.
func WebSocketConnect(url string, headers map[string]string, connectionID string) (string, error) {
// Marshal request to JSON
req := WebSocketConnectRequest{
req := webSocketConnectRequest{
Url: url,
Headers: headers,
ConnectionID: connectionID,
@ -101,7 +96,7 @@ func WebSocketConnect(url string, headers map[string]string, connectionID string
responseBytes := responseMem.ReadBytes()
// Parse the response
var response WebSocketConnectResponse
var response webSocketConnectResponse
if err := json.Unmarshal(responseBytes, &response); err != nil {
return "", err
}
@ -124,7 +119,7 @@ func WebSocketConnect(url string, headers map[string]string, connectionID string
// Returns an error if the connection is not found or if sending fails.
func WebSocketSendText(connectionID string, message string) error {
// Marshal request to JSON
req := WebSocketSendTextRequest{
req := webSocketSendTextRequest{
ConnectionID: connectionID,
Message: message,
}
@ -165,7 +160,7 @@ func WebSocketSendText(connectionID string, message string) error {
// Returns an error if the connection is not found or if sending fails.
func WebSocketSendBinary(connectionID string, data []byte) error {
// Marshal request to JSON
req := WebSocketSendBinaryRequest{
req := webSocketSendBinaryRequest{
ConnectionID: connectionID,
Data: data,
}
@ -207,7 +202,7 @@ func WebSocketSendBinary(connectionID string, data []byte) error {
// Returns an error if the connection is not found or if closing fails.
func WebSocketCloseConnection(connectionID string, code int32, reason string) error {
// Marshal request to JSON
req := WebSocketCloseConnectionRequest{
req := webSocketCloseConnectionRequest{
ConnectionID: connectionID,
Code: code,
Reason: reason,

View File

@ -8,38 +8,6 @@
package host
// WebSocketConnectRequest is the request type for WebSocket.Connect.
type WebSocketConnectRequest struct {
Url string `json:"url"`
Headers map[string]string `json:"headers"`
ConnectionID string `json:"connectionId"`
}
// WebSocketConnectResponse is the response type for WebSocket.Connect.
type WebSocketConnectResponse struct {
NewConnectionID string `json:"newConnectionId,omitempty"`
Error string `json:"error,omitempty"`
}
// WebSocketSendTextRequest is the request type for WebSocket.SendText.
type WebSocketSendTextRequest struct {
ConnectionID string `json:"connectionId"`
Message string `json:"message"`
}
// WebSocketSendBinaryRequest is the request type for WebSocket.SendBinary.
type WebSocketSendBinaryRequest struct {
ConnectionID string `json:"connectionId"`
Data []byte `json:"data"`
}
// WebSocketCloseConnectionRequest is the request type for WebSocket.CloseConnection.
type WebSocketCloseConnectionRequest struct {
ConnectionID string `json:"connectionId"`
Code int32 `json:"code"`
Reason string `json:"reason"`
}
// WebSocketConnect is a stub that panics on non-WASM platforms.
// Connect establishes a WebSocket connection to the specified URL.
//