Skip to content

Commit

Permalink
Update sator client to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
sesposito committed Sep 20, 2024
1 parent 11ec670 commit fe2026e
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 2 deletions.
68 changes: 67 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5014,6 +5014,11 @@ declare namespace nkruntime {
recompute?: boolean
}

export interface AuthPropertiesUpdate {
default?: {[key: string]: string}
custom?: {[key: string]: string}
}

export interface SatoriEvent {
name: string
id: string
Expand All @@ -5039,6 +5044,32 @@ declare namespace nkruntime {
value: string
activeStartTime: number
activeEndTime: number
id: string
startTime: number
endTime: number
duration: number
resetCron: string
}

export interface SatoriMessagesList {
messages: SatoriMessage[]
nextCursor: string
prevCursor: string
cacheableCursor: string
}

export interface SatoriMessage {
scheduleId: string
sendTime: number
metadata: {[key: string]: string}
createTime: number
updateTime: number
readTime: number
consumeTime: number
text: string
id: string
title: string
imageUrl: string
}

/**
Expand All @@ -5049,10 +5080,11 @@ declare namespace nkruntime {
* Create identity.
*
* @param id - Identity identifier.
* @param properties - Opt. Properties to update.
* @param ipAddress - Opt. Client IP address to pass on to Satori for geo-IP lookup.
* @throws {TypeError, GoError}
*/
authenticate(id: string, ipAddress?: string): void
authenticate(id: string, properties?: AuthPropertiesUpdate, ipAddress?: string): void

/**
* Get identity properties.
Expand Down Expand Up @@ -5086,6 +5118,7 @@ declare namespace nkruntime {
*
* @param id - Identity identifier.
* @param names - Opt. List of experiment names.
* @returns a list of experiments.
* @throws {TypeError, GoError}
*/
experimentsList(id: string, names?: string[]): Experiment[]
Expand All @@ -5095,6 +5128,7 @@ declare namespace nkruntime {
*
* @param id - Identity identifier.
* @param names - Opt. List of flag names.
* @returns a List of flags.
* @throws {TypeError, GoError}
*/
flagsList(id: string, names?: string[]): Flag[]
Expand All @@ -5104,8 +5138,40 @@ declare namespace nkruntime {
*
* @param id - Identity identifier.
* @param names - Opt. List of live event names.
* @returns a list of live-events.
* @throws {TypeError, GoError}
*/
liveEventsList(id: string, names?: string[]): LiveEvent[]

/**
* List messages.
*
* @param id - Identity identifier.
* @param limit - Opt. The max number of messages to return.
* @param forward - Opt. True if listing should be older messages to newer, false if reverse.
* @param cursor - Opt. A pagination cursor, if any.
* @returns A list of messages.
* @throws {TypeError, GoError}
*/
messagesList(id: string, limit?: number, forward?: boolean, cursor?: string): SatoriMessagesList[]

/**
* Update a message.
*
* @param id - Identity identifier.
* @param readTime - The time the message was read at the client.
* @param consumeTime - Opt. The time the message was consumed by the identity.
* @throws {TypeError, GoError}
*/
messageUpdate(id: string, messageId: string, readTime: number, consumeTime?: number)

/**
* Delete a message.
*
* @param id - Identity identifier.
* @param messageId - The identifier of the message.
* @throws {TypeError, GoError}
*/
messageDelete(id: string, messageId: string)
}
}
36 changes: 35 additions & 1 deletion runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -1311,13 +1311,16 @@ type FleetManagerInitializer interface {
Satori runtime integration definitions.
*/
type Satori interface {
Authenticate(ctx context.Context, id string, ipAddress ...string) error
Authenticate(ctx context.Context, id string, defaultProperties, customProperties map[string]string, ipAddress ...string) error
PropertiesGet(ctx context.Context, id string) (*Properties, error)
PropertiesUpdate(ctx context.Context, id string, properties *PropertiesUpdate) error
EventsPublish(ctx context.Context, id string, events []*Event) error
ExperimentsList(ctx context.Context, id string, names ...string) (*ExperimentList, error)
FlagsList(ctx context.Context, id string, names ...string) (*FlagList, error)
LiveEventsList(ctx context.Context, id string, names ...string) (*LiveEventList, error)
MessagesList(ctx context.Context, id string, limit int, forward bool, cursor string) (*SatoriMessageList, error)
MessageUpdate(ctx context.Context, id, messageId string, readTime, consumeTime int64) error
MessageDelete(ctx context.Context, id, messageId string) error
}

type Properties struct {
Expand Down Expand Up @@ -1373,4 +1376,35 @@ type LiveEvent struct {
Value string `json:"value,omitempty"`
ActiveStartTimeSec int64 `json:"active_start_time_sec,string,omitempty"`
ActiveEndTimeSec int64 `json:"active_end_time_sec,string,omitempty"`
Id string `json:"id,omitempty"`
StartTimeSec int64 `json:"start_time_sec,omitempty"`
EndTimeSec int64 `json:"end_time_sec,omitempty"`
DurationSec int64 `json:"duration_sec,omitempty"`
ResetCronExpr string `json:"reset_cron,omitempty"`
}

type SatoriMessageList struct {
SatoriMessages []*SatoriMessage `json:"messages,omitempty"`
NextCursor string `json:"next_cursor,omitempty"`
PrevCursor string `json:"prev_cursor,omitempty"`
CacheableCursor string `json:"cacheable_cursor,omitempty"`
}

type SatoriMessage struct {
ScheduleId string `json:"schedule_id,omitempty"`
SendTime int64 `json:"send_time,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
CreateTime int64 `json:"create_time,omitempty"`
UpdateTime int64 `json:"update_time,omitempty"`
ReadTime int64 `json:"read_time,omitempty"`
ConsumeTime int64 `json:"consume_time,omitempty"`
Text string `json:"text,omitempty"`
Id string `json:"id,omitempty"`
Title string `json:"title,omitempty"`
ImageUrl string `json:"image_url,omitempty"`
}

type SatoriMessageUpdate struct {
ReadTime int64 `json:"read_time,omitempty"`
ConsumeTime int64 `json:"consume_time,omitempty"`
}

0 comments on commit fe2026e

Please sign in to comment.