This commit is contained in:
Dax Raad
2025-05-29 11:17:34 -04:00
parent 33a831d2be
commit 42c1cd6a85
8 changed files with 116 additions and 22 deletions

View File

@@ -10,7 +10,9 @@ import (
)
var EventMap = map[string]any{
"storage.write": EventStorageWrite{},
"storage.write": EventStorageWrite{},
"session.updated": EventSessionUpdated{},
"message.updated": EventMessageUpdated{},
}
type EventMessage struct {

View File

@@ -29,6 +29,32 @@
"serverID",
"path"
]
},
"event.message.updated": {
"type": "object",
"properties": {
"sessionID": {
"type": "string"
},
"messageID": {
"type": "string"
}
},
"required": [
"sessionID",
"messageID"
]
},
"event.session.updated": {
"type": "object",
"properties": {
"sessionID": {
"type": "string"
}
},
"required": [
"sessionID"
]
}
}
}

View File

@@ -34,6 +34,58 @@ func (j *EventLspClientDiagnostics) UnmarshalJSON(value []byte) error {
return nil
}
type EventMessageUpdated struct {
// MessageID corresponds to the JSON schema field "messageID".
MessageID string `json:"messageID" yaml:"messageID" mapstructure:"messageID"`
// SessionID corresponds to the JSON schema field "sessionID".
SessionID string `json:"sessionID" yaml:"sessionID" mapstructure:"sessionID"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *EventMessageUpdated) UnmarshalJSON(value []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(value, &raw); err != nil {
return err
}
if _, ok := raw["messageID"]; raw != nil && !ok {
return fmt.Errorf("field messageID in EventMessageUpdated: required")
}
if _, ok := raw["sessionID"]; raw != nil && !ok {
return fmt.Errorf("field sessionID in EventMessageUpdated: required")
}
type Plain EventMessageUpdated
var plain Plain
if err := json.Unmarshal(value, &plain); err != nil {
return err
}
*j = EventMessageUpdated(plain)
return nil
}
type EventSessionUpdated struct {
// SessionID corresponds to the JSON schema field "sessionID".
SessionID string `json:"sessionID" yaml:"sessionID" mapstructure:"sessionID"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *EventSessionUpdated) UnmarshalJSON(value []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(value, &raw); err != nil {
return err
}
if _, ok := raw["sessionID"]; raw != nil && !ok {
return fmt.Errorf("field sessionID in EventSessionUpdated: required")
}
type Plain EventSessionUpdated
var plain Plain
if err := json.Unmarshal(value, &plain); err != nil {
return err
}
*j = EventSessionUpdated(plain)
return nil
}
type EventStorageWrite struct {
// Content corresponds to the JSON schema field "content".
Content interface{} `json:"content" yaml:"content" mapstructure:"content"`