Global

Members

(constant) DEFAULT_KEEP_UP_INTERVAL :Duration

The default interval for sending subscription keep up requests.
Type:
Source:

(constant) wellKnownParsers :Map.<string, ObjectParser>

The map of parsers for standard Protobuf types.
Type:
  • Map.<string, ObjectParser>
Source:

Methods

checkItemsNotNegative(itemsnon-null, messagenon-null)

Checks that each item in provided items is non-negative. An error is thrown otherwise.
Parameters:
Name Type Description
items Array.<number> an array of numbers to check
message String a message for when one of the items does not match the requirement
Source:

classFor(typeUrlnon-null) → (non-null) {Class}

Obtains JS class for the given Protobuf type URL.
Parameters:
Name Type Description
typeUrl string the type URL
Source:
Returns:
class of this Protobuf type
Type
Class

clear()

Removes all the types. The method is purposed for the testing.
Source:

convert(objectnon-null, typeUrlnon-null)

Converts the object to the corresponding Protobuf message. The input object is supposed to be a Protobuf message representation, i.e. all of its attributes should correspond to the fields of the specified message type.
Parameters:
Name Type Description
object Object an object to convert
typeUrl string a type URL of the corresponding Protobuf message
Source:

convertDateToTimestamp(datenon-null) → {Timestamp}

Converts a given JavaScript Date into the Timestamp Protobuf message.
Parameters:
Name Type Description
date Date a date to convert
Source:
Throws:
error when non-Date value is passed or it is invalid
Returns:
a timestamp message of the given date value
Type
Timestamp

enumValueOf(valuenon-null) → {EnumValue}

Wraps the passed enum value as Protobuf `EnumValue` so it can be correctly processed by the server. As enums in Protobuf JS are declared as plain `number`s, their values can be passed to this method as-is, for example: `enumValueOf(Task.Severity.HIGH)`.
Parameters:
Name Type Description
value number the enum value
Source:
Returns:
the `EnumValue` instance
Type
EnumValue

(abstract) fromObject(objectnon-null) → (non-null) {Message}

Converts an object to a message.
Parameters:
Name Type Description
object Object the object representing a Protobuf message
Source:
Returns:
the parsed Protobuf message
Type
Message

hasType(typeUrlnon-null)

Tells whether the specified type URL is present among known types.
Parameters:
Name Type Description
typeUrl string the type URL to check
Source:

init(options) → {Client}

The main entry point of the `spine-web` JS library. Serves for initialization of the `Client` instances to interact with Spine-based backend. To initialize a new instance of client that uses Firebase as a storage do the following: ``` import * as protobufs from './proto/index.js'; import * as spineWeb from 'spine-web'; const firebaseApp = Firebase.initializeApp({...Firebase options}); // The backend client will receive updates of the current actor through this instance const actorProvider = new ActorProvider(); const client = spineWeb.init({ protoIndexFiles: [protobufs], endpointUrl: 'http://example.appspot.com', firebaseDatabase: firebaseApp.database(), actorProvider: actorProvider }); ``` To substitute a custom implementation of `Client` for tests do the following: ``` // An instance of class extending `spineWeb.Client` const mockClientImpl = new MockClient(); const mockClient = spineWeb.init({ protoIndexFiles: [protobufs], implementation: mockClientImpl }); ``` Note, when using of custom `Client` implementation protobuf index files registration is still required.
Parameters:
Name Type Description
options ClientOptions | CompositeClientOptions
Source:
Returns:
Type
Client

isParser(object)

Checks if the parser extends ObjectParser.

The implementation doesn't use `instanceof` check and check on prototypes since they may fail if different versions of the file are used at the same time (e.g. bundled and the original one).

Parameters:
Name Type Description
object the object to check
Source:

isProtobufMessage(object)

Checks if the object extends Message.

The implementation doesn't use `instanceof` check and check on prototypes since they may fail if different versions of the file are used at the same time (e.g. bundled and the original one).

Parameters:
Name Type Description
object the object to check
Source:

map(observablenon-null, typeUrlnon-null) → {Observable.<Message>}

Convert the given observable of objects to the observable of the corresponding Protobuf messages.
Parameters:
Name Type Description
observable Observable.<Object> an observable to convert
typeUrl string a type URL of the corresponding Protobuf message
Source:
Returns:
an observable of converted Protobuf messages
Type
Observable.<Message>

parserFor(typeUrlnon-null) → (non-null) {ObjectParser}

Obtains a parser by the specified type URL.
Parameters:
Name Type Description
typeUrl string the type URL to get the parser
Source:
Returns:
the parser instance for the type
Type
ObjectParser

register(typenon-null, typeUrlnon-null)

Registers the type as a known type.
Parameters:
Name Type Description
type Class the class of a Protobuf message or enum
typeUrl string the URL of the type
Source:

register(parsernon-null, typeUrlnon-null)

Registers the parser for a type.
Parameters:
Name Type Description
parser ObjectParser the parser instance to register
typeUrl string the URL of the type to register the parser for
Source:

registerWellKnownParsers()

Register parsers for standard Protobuf types.
Source:

typeUrlFor(messageClassnon-null) → (non-null) {string}

Obtains the type URL for the Protobuf type.
Parameters:
Name Type Description
messageClass Class the class of a Protobuf message or enum
Source:
Returns:
the type URL
Type
string

Type Definitions

AckCallback

Properties:
Name Type Description
onOk parameterlessCallback the callback to run when the command is handled properly
onError consumerCallback.<Error> the callback to run when the command cannot be handled due to a technical error
onImmediateRejection consumerCallback.<Message> the callback to run when the command is denied execution due to a business rejection
Source:

ClientOptions

a type of object for initialization of Spine client
Type:
  • Object
Properties:
Name Type Attributes Description
protoIndexFiles Array.<Object> the list of the `index.js` files generated by the Protobuf plugin for JS
endpointUrl string <nullable>
the URL of the Spine-based backend endpoint
httpClient HttpClient <nullable>
custom implementation of HTTP client to use; defaults to HttpClient.
httpResponseHandler HttpResponseHandler <nullable>
custom implementation of HTTP response handler; defaults to HttpResponseHandler
firebaseDatabase firebase.database.Database <nullable>
the Firebase Database that will be used to retrieve data from
actorProvider ActorProvider <nullable>
the provider of the user interacting with Spine
implementation Client <nullable>
the custom implementation of `Client`
routing Routing <nullable>
custom configuration of HTTP endpoints
tenantProvider TenantProvider <nullable>
the provider of an active tenant ID, if not specified, the application is considered single-tenant
subscriptionKeepUpInterval Duration <nullable>
the custom interval for sending requests to keep up subscriptions
Source:

CompositeClientOptions

is a configuration of a composite client, which allows different client implementations to be used for different client requests.
Type:
  • Object
Properties:
Name Type Description
protoIndexFiles Array.<Object> the list of the `index.js` files generated by the Protobuf plugin for JS
forQueries ClientOptions options of the client used for queries
forSubscriptions ClientOptions options of the client used for subscriptions
forCommands ClientOptions options of the client used for commands
Source:

DurationValue

Type:
  • Object
Properties:
Name Type Description
seconds number
minutes number
Source:

EntitySubscriptionObject

An object representing the result of a subscription to entity state changes.
Type:
  • Object
Properties:
Name Type Description
itemAdded Observable.<T> emits new items matching the subscription topic
itemChanged Observable.<T> emits updated items matching the subscription topic
itemRemoved Observable.<T> emits removed items matching the subscription topic
unsubscribe parameterlessCallback a method to be called to cancel the subscription, stopping the subscribers from receiving new entities
Source:

EventSubscriptionCallbacks

Properties:
Name Type Description
subscribe consumerCallback.<eventConsumer> the callback which allows to setup an event consumer to use for the subscription
unsubscribe parameterlessCallback the callback which allows to cancel the subscription
Source:

EventSubscriptionObject

An object which represents the result of a subscription to events of a certain type.
Type:
  • Object
Properties:
Name Type Description
> eventEmitted emits new items when the new events matching the subscription topic occur in the system
unsubscribe parameterlessCallback a method to be called to cancel the subscription, stopping the subscribers from receiving new entities
Source:

FieldValue

Represents all types acceptable as a value for filtering.
Type:
  • string | number | boolean | Date | TypedMessage.<T> | Message
Source:

Routing

Type:
  • Object
Properties:
Name Type Description
query string the name of the query endpoint; defaults to "/query"
command string the name of the command endpoint; defaults to "/command"
subscription SubscriptionRouting the config of the subscription endpoints
Source:

SubscriptionRouting

Type:
  • Object
Properties:
Name Type Description
create string the name of the subscription creation endpoint; defaults to "/subscription/create"
keepUp string the name of the subscription keep up endpoint; defaults to "/subscription/keep-up"
keepUpAll string the name of the subscription bulk keep up endpoint; defaults to "/subscription/keep-up-all"
cancel string the name of the subscription cancellation endpoint; defaults to "/subscription/cancel"
cancelAll string the name of the subscription bulk cancellation endpoint; defaults to "/subscription/cancel-all"
Source:

_NewBuilderFn() → {AbstractTargetBuilder}

Parameters:
Type Description
ActorRequestFactory
Source:
Returns:
Type
AbstractTargetBuilder

consumerCallback(the)

The callback that accepts single parameter.
Parameters:
Name Type Description
the T value the callback function accepts
Source:

eventConsumer(the)

The callback that accepts a single `Event` as a parameter.
Parameters:
Name Type Description
the spine.core.Event event that is accepted by the callback
Source:

parameterlessCallback()

The callback that doesn't accept any parameters.
Source: