Documentation
¶
Index ¶
- Constants
- func BuildFilter(filterJSON string, queryCSV string) (any, string, error)
- func BuildRuleParam(eventKey string, opts RuleOptions) (ruleType string, ruleParam map[string]any, err error)
- func CanonicalJSON(v any) (string, error)
- func IdempotencyKey(identity Identity, eventKey, ruleType string, ruleParam map[string]any, ...) string
- func IsPublic(eventKey string) bool
- func IsSchemaPending(err error) bool
- func ProjectOutput(ev transport.Event) (any, error)
- func PublicAvailabilityError(eventKey string) error
- func RemoveRunStates(workDir string, subscribeIDs []string) error
- func SupportsMessageFilter(eventKey string) bool
- func UpsertRunState(workDir string, st RunState) error
- type APIError
- type Client
- func (c *Client) CreateSubscription(ctx context.Context, req CreateSubscriptionRequest) (*Subscription, error)
- func (c *Client) DeleteSubscription(ctx context.Context, subscribeID string) error
- func (c *Client) GetSubscription(ctx context.Context, subscribeID string) (*Subscription, error)
- func (c *Client) ListSubscriptions(ctx context.Context, opts ListOptions) ([]Subscription, error)
- type CreateSubscriptionRequest
- type Definition
- type GroupLifecycleEventOutput
- type GroupMemberEventMember
- type GroupMemberEventOutput
- type Identity
- type ListOptions
- type MessageEventContext
- type MessageEventOutput
- type ParameterConstraints
- type ReactionEventOutput
- type ReadEventOutput
- type RecallEventOutput
- type RuleOptions
- type RunState
- type SchemaDocument
- type SchemaPendingError
- type Subscription
Constants ¶
const ( EventMention = "user_im_message_receive_at" EventSingleChat = "user_im_message_receive_o2o" EventInChat = "user_im_message_receive_group" EventFromUser = "user_im_message_receive_user" EventAllSingleChat = "user_im_message_receive_o2o_all" EventAllGroupChat = "user_im_message_receive_group_all" EventReadO2O = "user_im_message_read_o2o" EventReadGroup = "user_im_message_read_group" EventRecallO2O = "user_im_message_recall_o2o" EventRecallGroup = "user_im_message_recall_group" EventReactionO2O = "user_im_message_reaction_o2o" EventReactionGroup = "user_im_message_reaction_group" EventGroupUpdated = "user_im_group_updated" EventGroupMemberAdded = "user_im_group_member_added" EventGroupMemberExited = "user_im_group_member_exited" EventGroupDisbanded = "user_im_group_disbanded" )
const ( StatusEnabled = "enabled" StatusPending = "pending" )
const ( StateFileName = "personal_subscriptions.json" StateLockFileName = "personal_subscriptions.lock" )
const DefaultBasePath = "/dws"
Variables ¶
This section is empty.
Functions ¶
func BuildRuleParam ¶
func CanonicalJSON ¶
func IdempotencyKey ¶
func IsSchemaPending ¶
func ProjectOutput ¶ added in v1.0.54
ProjectOutput converts the transport envelope into the stable personal event output. On malformed Data it returns the original envelope together with an error; the formatter logs the warning and still emits that envelope.
func PublicAvailabilityError ¶
func RemoveRunStates ¶
func SupportsMessageFilter ¶ added in v1.0.55
SupportsMessageFilter reports whether --query/--filter-json describe a stable message payload for this event. Action and group lifecycle events do not expose the same filter fields.
func UpsertRunState ¶
Types ¶
type APIError ¶
type Client ¶
type Client struct {
BaseURL string
HTTPClient *http.Client
Identity Identity
AccessTokenProvider func(context.Context) (string, error)
}
func (*Client) CreateSubscription ¶
func (c *Client) CreateSubscription(ctx context.Context, req CreateSubscriptionRequest) (*Subscription, error)
func (*Client) DeleteSubscription ¶
func (*Client) GetSubscription ¶
func (*Client) ListSubscriptions ¶
func (c *Client) ListSubscriptions(ctx context.Context, opts ListOptions) ([]Subscription, error)
type CreateSubscriptionRequest ¶
type CreateSubscriptionRequest struct {
EventKey string `json:"event_key"`
RuleType string `json:"rule_type"`
Name string `json:"name,omitempty"`
RuleParam map[string]any `json:"rule_param"`
Filter any `json:"filter,omitempty"`
Delivery map[string]any `json:"delivery"`
TTLSeconds int64 `json:"ttl_seconds,omitempty"`
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
type Definition ¶
type Definition struct {
EventKey string `json:"event_key"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Category string `json:"category"`
RuleType string `json:"rule_type"`
Status string `json:"status"`
RequiredParams []string `json:"required_params"`
Constraints *ParameterConstraints `json:"constraints,omitempty"`
Auth map[string]any `json:"auth,omitempty"`
Public bool `json:"-"`
}
func Catalog ¶
func Catalog(category string, enabledOnly, includePending bool) []Definition
func Definitions ¶
func Definitions() []Definition
func Lookup ¶
func Lookup(eventKey string) (Definition, bool)
type GroupLifecycleEventOutput ¶ added in v1.0.55
type GroupLifecycleEventOutput struct {
Type string `json:"type" description:"事件类型,固定为当前 event_key"`
EventID string `json:"event_id" description:"事件 ID,可用于去重"`
Timestamp int64 `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
SubscribeID string `json:"subscribe_id" description:"订阅 ID"`
Payload map[string]any `` /* 130-byte string literal not displayed */
}
GroupLifecycleEventOutput is intentionally conservative until stable group event payload samples are available. Payload keeps unknown business fields while transport identity and routing metadata remain available only in raw output.
type GroupMemberEventMember ¶ added in v1.0.55
type GroupMemberEventOutput ¶ added in v1.0.55
type GroupMemberEventOutput struct {
Type string `json:"type" description:"事件类型,固定为当前 event_key"`
EventID string `json:"event_id" description:"事件 ID,可用于去重"`
Timestamp int64 `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
SubscribeID string `json:"subscribe_id" description:"订阅 ID"`
ConversationID string `json:"conversation_id" description:"发生成员变更的群会话 ID" format:"open_conversation_id"`
Operator string `json:"operator" description:"执行成员变更操作的用户展示名,系统操作或成员自行退出时可能为空"`
OperatorOpenDingTalkID string `` /* 166-byte string literal not displayed */
Members []GroupMemberEventMember `json:"members" description:"本次加入或退出的成员列表"`
EventTime int64 `json:"event_time" description:"群成员变更事件时间戳" format:"timestamp_ms"`
}
type Identity ¶
type ListOptions ¶
type MessageEventContext ¶ added in v1.0.55
type MessageEventContext struct {
MessageID string `json:"message_id" description:"内部消息的开放消息 ID" format:"open_message_id"`
ConversationID string `json:"conversation_id" description:"内部消息原来所在的会话 ID" format:"open_conversation_id"`
Sender string `json:"sender" description:"内部消息发送人展示名;服务端未提供时可能为空或为 null 字符串"`
SenderOpenDingTalkID string `` /* 131-byte string literal not displayed */
Content string `json:"content" description:"内部消息正文;媒体消息可能包含 mediaId 等下载定位信息"`
CreateTime string `json:"create_time" description:"内部消息创建时间"`
}
MessageEventContext preserves the business context nested under a quoted reply or merged-forward message. Keep these fields structured instead of parsing the localized outer content summary.
type MessageEventOutput ¶ added in v1.0.54
type MessageEventOutput struct {
Type string `json:"type" description:"事件类型,固定为当前 event_key"`
EventID string `json:"event_id" description:"事件 ID,可用于去重"`
Timestamp int64 `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
SubscribeID string `json:"subscribe_id" description:"订阅 ID"`
MessageID string `json:"message_id" description:"开放消息 ID" format:"open_message_id"`
ConversationID string `json:"conversation_id" description:"会话 ID" format:"open_conversation_id"`
Sender string `json:"sender" description:"发送人展示名"`
SenderOpenDingTalkID string `json:"sender_open_dingtalk_id" description:"发送人开放 ID" format:"open_dingtalk_id"`
Content string `json:"content" description:"消息正文"`
CreateTime string `json:"create_time" description:"消息创建时间"`
EventTime int64 `json:"event_time" description:"消息事件时间戳" format:"timestamp_ms"`
QuotedMessage *MessageEventContext `json:"quoted_message,omitempty" description:"引用回复所引用的原消息;非引用回复时不输出"`
ForwardMessages []MessageEventContext `json:"forward_messages,omitempty" description:"合并转发包含的原消息列表;非合并转发时不输出"`
}
MessageEventOutput is the stable business-facing output for personal message receive events. Schema output is generated from these tags so the documented fields cannot drift from the values written by consume.
type ParameterConstraints ¶ added in v1.0.54
type ReactionEventOutput ¶ added in v1.0.54
type ReactionEventOutput struct {
Type string `json:"type" description:"事件类型,固定为当前 event_key"`
EventID string `json:"event_id" description:"事件 ID,可用于去重"`
Timestamp int64 `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
SubscribeID string `json:"subscribe_id" description:"订阅 ID"`
MessageID string `json:"message_id" description:"收到表情回应的开放消息 ID" format:"open_message_id"`
ConversationID string `json:"conversation_id" description:"会话 ID" format:"open_conversation_id"`
Operator string `json:"operator" description:"执行表情回应操作的用户展示名"`
OperatorOpenDingTalkID string `json:"operator_open_dingtalk_id" description:"执行表情回应操作的用户开放 ID" format:"open_dingtalk_id"`
ReactionName string `json:"reaction_name" description:"表情回应名称"`
ReactionText string `json:"reaction_text" description:"表情回应文本"`
OperationType string `json:"operation_type" description:"表情回应操作类型"`
OperationTime string `json:"operation_time" description:"表情回应操作时间"`
Sender string `json:"sender" description:"原消息发送人展示名"`
SenderOpenDingTalkID string `json:"sender_open_dingtalk_id" description:"原消息发送人开放 ID" format:"open_dingtalk_id"`
EventTime int64 `json:"event_time" description:"消息事件时间戳" format:"timestamp_ms"`
}
type ReadEventOutput ¶ added in v1.0.54
type ReadEventOutput struct {
Type string `json:"type" description:"事件类型,固定为当前 event_key"`
EventID string `json:"event_id" description:"事件 ID,可用于去重"`
Timestamp int64 `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
SubscribeID string `json:"subscribe_id" description:"订阅 ID"`
MessageID string `json:"message_id" description:"被读取消息的开放消息 ID" format:"open_message_id"`
ConversationID string `json:"conversation_id" description:"会话 ID" format:"open_conversation_id"`
Reader string `json:"reader" description:"读取消息的用户展示名"`
ReaderOpenDingTalkID string `json:"reader_open_dingtalk_id" description:"读取消息的用户开放 ID" format:"open_dingtalk_id"`
Sender string `json:"sender" description:"原消息发送人展示名"`
SenderOpenDingTalkID string `json:"sender_open_dingtalk_id" description:"原消息发送人开放 ID" format:"open_dingtalk_id"`
ReadTime string `json:"read_time" description:"消息读取时间"`
EventTime int64 `json:"event_time" description:"消息事件时间戳" format:"timestamp_ms"`
}
type RecallEventOutput ¶ added in v1.0.54
type RecallEventOutput struct {
Type string `json:"type" description:"事件类型,固定为当前 event_key"`
EventID string `json:"event_id" description:"事件 ID,可用于去重"`
Timestamp int64 `json:"timestamp" description:"事件发生时间戳" format:"timestamp_ms"`
SubscribeID string `json:"subscribe_id" description:"订阅 ID"`
MessageID string `json:"message_id" description:"被撤回消息的开放消息 ID" format:"open_message_id"`
ConversationID string `json:"conversation_id" description:"会话 ID" format:"open_conversation_id"`
Recaller string `json:"recaller" description:"撤回消息的用户展示名"`
RecallerOpenDingTalkID string `json:"recaller_open_dingtalk_id" description:"撤回消息的用户开放 ID" format:"open_dingtalk_id"`
Sender string `json:"sender" description:"原消息发送人展示名"`
SenderOpenDingTalkID string `json:"sender_open_dingtalk_id" description:"原消息发送人开放 ID" format:"open_dingtalk_id"`
RecallTime string `json:"recall_time" description:"消息撤回时间"`
EventTime int64 `json:"event_time" description:"消息事件时间戳" format:"timestamp_ms"`
}
type RuleOptions ¶
type RunState ¶
type RunState struct {
SubscribeID string `json:"subscribe_id"`
EventKey string `json:"event_key,omitempty"`
RuleType string `json:"rule_type,omitempty"`
ClientID string `json:"client_id,omitempty"`
SourceID string `json:"source_id,omitempty"`
IdentityHash string `json:"identity_hash,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
func LoadRunStates ¶
type SchemaDocument ¶
type SchemaDocument struct {
EventKey string `json:"event_key"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Category string `json:"category"`
RuleType string `json:"rule_type"`
RequiredParams []string `json:"required_params"`
Constraints *ParameterConstraints `json:"constraints,omitempty"`
JQRootPath string `json:"jq_root_path"`
Schema map[string]any `json:"schema"`
}
func BuildSchemaDocument ¶
func BuildSchemaDocument(def Definition) SchemaDocument
func BuildSchemaDocumentForMode ¶ added in v1.0.54
func BuildSchemaDocumentForMode(def Definition, flatten bool) SchemaDocument
type SchemaPendingError ¶
type SchemaPendingError struct {
EventKey string
}
func (*SchemaPendingError) Error ¶
func (e *SchemaPendingError) Error() string
type Subscription ¶
type Subscription struct {
SubscribeID string `json:"subscribe_id"`
EventKey string `json:"event_key,omitempty"`
RuleType string `json:"rule_type,omitempty"`
Status string `json:"status,omitempty"`
SourceID string `json:"source_id,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}