Skip to main content

@actyx/os-sdk#

Table of contents#

Enumerations#

Interfaces#

Type aliases#

LogEntryDraft#

Ƭ LogEntryDraft: object

This data type specifies the content of a log entry that must/can be provided by your application. This is not exactly equivalent to the actual log entry stored by ActyxOS since the Console Service automatically adds additional data points such as the node's ID or display name. The Console Service also adds the timestamp unless you have specifically provided it.

The most basic LogEntryDraft would look as follows:

const minimalEntry: LogEntryDraft = {
logName: 'myLogger',
severity: LogSeverity.INFO,
producer: {
name: 'myapp',
version: '1.0.0',
},
message: 'my log message',
}

Type declaration:#

NameTypeDescription
additionalData?unknownAdditional data you would like to add to the log entry. Note: this is data that complements the log message (e.g. additional parsing errors).
labels?objectAny labels you would like to add to the log entry. Note that labels are always of type string: string.
logNamestringName of the log you want to post the entry to.
messagestringThe actual log message.
producerobjectDetails about who produced the log message. This should be your app's name and version number.
producer.namestring-
producer.versionstring-
severityLogSeveritySeverity of the log entry (debug, warn, info or error).
timestamp?DateTimestamp of the log entry. Note: ActyxOS automatically adds this, so you should almost never have to set this yourself.

LogOpts#

Ƭ LogOpts: object

Configuration of a request to post a log entry to the ActyxOS Console Service. Please refer to the individual properties for more information about what each of them do.

Type declaration:#

NameTypeDescription
entryLogEntryDraftThis property defines the draft log entry you want to post to the Console Service. The log entry has a number of required and a number of optional properties. Please refer to LogEntryDraft for more information and a couple of examples.
onError?OnErrorThis property allows you to provide a callback that will be called if an error occurs whilst the SDK tried to post the log entry. Note: this should not happen unless there are problems with the ActyxOS node so if anything you might throw an exception here.
onLogged?OnResult<void>This property allows you to provide a callback that will be called when the log entry has been successfully posted. Note: in most cases you can simply fire-and-forget and thus don't need to provide this callback.

OffsetsOpts#

Ƭ OffsetsOpts: object

Configuration of a request for offsets to the ActyxOS Event Service. Please refer to the individual properties for more information about what each of them do.

Type declaration:#

NameTypeDescription
onError?OnErrorThis is a callback that will be called if any errors occur whilst getting offsets from the Event Service.
onOffsetsOnResult<OffsetMap>This is a callback that will be called with the offsets once they have been received from the Event Service.

OnDone#

Ƭ OnDone: () => void

This is a callback function type that is used for notifying users that an operation has completed. This type of callback is used for operations that return results via other means (e.g. OnEvent).

Type declaration:#

▸ (): void

Returns: void


OnError#

Ƭ OnError: (error: string) => void

This is a callback function type that is used for notifying users that an error has occured.

Type declaration:#

▸ (error: string): void

Parameters:#

NameType
errorstring

Returns: void


OnEvent#

Ƭ OnEvent: (event: Event) => void

This is a callback function type that is used for subscribing to event streams or querying the ActyxOS Event Service (see SubscribeOpts or QueryOpts).

Type declaration:#

▸ (event: Event): void

Parameters:#

NameType
eventEvent

Returns: void


OnResult#

Ƭ OnResult<T>: (result: T) => void

This is a callback function type that is used for return the result of an asynchronous operation to the user.

Type parameters:#

NameDescription
Tthe type of the result that will be provided to the callback.

Type declaration:#

▸ (result: T): void

Parameters:#

NameType
resultT

Returns: void


PublishOpts#

Ƭ PublishOpts: object

Configuration of a publishing request to the ActyxOS Event Service. Please refer to the individual properties for more information about what each of them do.

Type declaration:#

NameTypeDescription
eventDraftsEventDraft | EventDraft[]The event drafts to be published (and thus turned into events).
onDone?OnDoneThis is a callback that will be called after the event(s) have been successfully published.
onError?OnErrorThis is a callback that will be called if any errors occur during the publication process.

PublishPromiseOpts#

Ƭ PublishPromiseOpts: Omit<PublishOpts, onDone | onError>

Configuration of a publishing request to the ActyxOS Event Service. Please refer to the individual properties for more information about what each of them do.


QueryOpts#

Ƭ QueryOpts: object

Configuration of a query to the ActyxOS Event Service. Please refer to the individual properties for more information about what each of them do.

Type declaration:#

NameTypeDescription
lowerBound?OffsetMapYou can provide an OffsetMap specifying the lower bound of your query. Please refer to the ActyxOS Event Service documentation for more information about how the API handles lower and upper bounds. Note: not providing a lower bound means that you will receive all events known to the ActyxOS node's since it was first created.
onDone?OnDoneThis is a callback that will be called after the query has ended.
onError?OnErrorThis is a callback that will be called if an error occurs during the query. Note that a query is immediately destroyed if an error occurs.
onEventOnEventThis is a callback that will be called for each event returned by the query.
orderingOrderingThe order in which you want the query to return results. Please refer to the ActyxOS Event Service API documentation for more details.
subscriptionsSubscription | Subscription[]This property defines the stream subscriptions to be made as part of this query. You can query not only one ActyxOS event stream, but many streams at the same time. You can do this by providing multiple subscriptions at a time and by using constructors defined in Subscription. Here are a couple of examples. Create a subscription to everything typescript const subscription = Subscription.everything() Create a subscription for all events with a certain semantic typescript const subscription = Subscription.wildcard('temperatureValue') Create a subscription for all events related to a distributed state typescript const subscription = Subscription.distributed('machineState', 'machine1') Creating multiple subscriptions typescript const subscriptions = [ Subscription.wildcard('temperatureValue') Subscription.distributed('machineState', 'machine1'), ]
upperBoundOffsetMapYou must provide an OffsetMap specifying the upper bound of your subscription. Please refer to the ActyxOS Event Service documentation for more information about how the API handles lower and upper bounds.

QueryStreamOpts#

Ƭ QueryStreamOpts: Omit<QueryOpts, onEvent | onDone | onError>


SimpleLoggerOpts#

Ƭ SimpleLoggerOpts: object

Configuration parameters for creating a SimpleLogger. You must specify the producer name and version (e.g. myapp and 1.0.0) and a name for the log you want to post to (e.g. myLogger). You may also add a default error callback that will be called whenever an error occurs whilst trying to post a log entry.

Type declaration:#

NameType
logNamestring
onError?(error: string) => void
producerNamestring
producerVersionstring

SubscribeOpts#

Ƭ SubscribeOpts: object

Configuration of a subscription to the ActyxOS Event Service. Please refer to the individual properties for more information about what each of them do.

Type declaration:#

NameTypeDescription
lowerBound?OffsetMapYou can provide an OffsetMap specifying the lower bound of your subscription. Please refer to the ActyxOS Event Service documentation for more information about how the API handles lower and upper bounds.
onDone?OnDoneThis is a callback that will be called after the subscription has ended. Since subscriptions don't naturally end, this only happens if the subscription is aborted using the provided callback (see EventServiceClient.subscribe).
onError?OnErrorThis is a callback that will be called if an error occurs during the subscription. Note that a subscription is immediately destroyed if an error occurs.
onEventOnEventThis is a callback that will be called for each event returned by the subscription.
subscriptionsSubscription | Subscription[]This property defines the stream subscriptions to be made as part of this subscription. You can subscribe to not only one ActyxOS event stream, but to many streams at the same time. You can do this by providing multiple subscriptions at a time and by using constructors defined in Subscription. Here are a couple of examples. Create a subscription to everything typescript const subscription = Subscription.everything() Create a subscription for all events with a certain semantic typescript const subscription = Subscription.wildcard('temperatureValue') Create a subscription for all events related to a distributed state typescript const subscription = Subscription.distributed('machineState', 'machine1') Creating multiple subscriptions typescript const subscriptions = [ Subscription.wildcard('temperatureValue') Subscription.distributed('machineState', 'machine1'), ]

SubscribeStreamOpts#

Ƭ SubscribeStreamOpts: Omit<SubscribeOpts, onEvent | onDone | onError>


Subscription#

Ƭ Subscription: object

Describes a subscription

Type declaration:#

NameType
source?string
streamName?string
streamSemantics?string

Variables#

EventDraft#

EventDraft: object

Type declaration:#

NameType
make(streamSemantics: string, streamName: string, payload: unknown) => EventDraft

Subscription#

Subscription: object

This object provides useful constructors for creating subscription definitions.

Type declaration:#

NameType
distributed(streamSemantics: string, streamName: string) => Subscription
everything() => Subscription
local(streamSemantics: string, streamName: string, source: string) => Subscription
wildcard(streamSemantics: string) => Subscription

Functions#

Client#

ConstClient(opts?: ApiClientOpts): ApiClient

This function allows you to create a client. In almost all cases you do not need to provide options since the defaults will work.

Example

import { Client } from '@actyx/os-sdk'
const ActyxOS = Client()

In the rare case that you might in fact have to override clients options you could do so as follows:

import { DefaultClientOpts } from '@actyx/os-sdk'
const customClient = Client({
...DefaultClientOpts,
Ports: {
EventService: 5555
}
})

Parameters:#

NameType
optsApiClientOpts

Returns: ApiClient


DefaultClientOpts#

ConstDefaultClientOpts(): ApiClientOpts

This function returns the default client options

Returns: ApiClientOpts