Skip to content

PURISTA API / Modules / @purista/dapr-sdk

Module: @purista/dapr-sdk

SDK and helper to run PURISTA services in Kubernetes.

This package provides the Dapr event bridge and adapters for secret, state and config stores provided by Dapr.

Here is a full example, how the index file might look like, if you want to deploy a service to Kubernetes.

Example

typescript
import { DaprConfigStore, DaprEventBridge, DaprSecretStore, DaprStateStore } from '@purista/dapr-sdk'
const eventBridge = new DaprEventBridge({
   spanProcessor,
   logger,
   serve,
 })

const secretStore = new DaprSecretStore({ logger, secretStoreName: 'local-secret-store' })
const stateStore = new DaprStateStore({ logger, stateStoreName: 'local-state-store' })
const configStore = new DaprConfigStore({ logger, configStoreName: 'local-config-store' })

// start the services ...

await eventBridge.start()

Table of contents

Enumerations

Classes

Type Aliases

Variables

Functions

Event bridge

Type Aliases

BulkSubscribeConfig

Ƭ BulkSubscribeConfig: Object

BulkSubscribeConfig defines the configuration for a bulk subscription

Type declaration

NameType
enabledboolean
maxAwaitDurationMs?number
maxMessagesCount?number

Defined in

dapr-sdk/src/types/pubsub/BulkSubscribeConfig.type.ts:19


BulkSubscribeOptions

Ƭ BulkSubscribeOptions: Object

BulkSubscribeOptions enlists the options for bulk subscribe

Type declaration

NameType
maxAwaitDurationMs?number
maxMessagesCount?number
metadata?KeyValueType
route?string | DaprPubSubRouteType

Defined in

dapr-sdk/src/types/pubsub/BulkSubscribeOptions.type.ts:20


BulkSubscribeResponse

Ƭ BulkSubscribeResponse: Object

BulkSubscribeResponse is the response for a bulk subscribe request

Type declaration

NameType
statusesBulkSubscribeResponseEntry[]

Defined in

dapr-sdk/src/types/pubsub/BulkSubscribeResponse.type.ts:19


BulkSubscribeResponseEntry

Ƭ BulkSubscribeResponseEntry: Object

BulkSubscribeResponseEntry is the response entry for a bulk subscribe request

Type declaration

NameType
entryIdstring
statusDaprPubSubStatusEnum

Defined in

dapr-sdk/src/types/pubsub/BulkSubscribeResponseEntry.type.ts:19


DaprClientConfig

Ƭ DaprClientConfig: Object

Type declaration

NameTypeDescription
appPrefix?stringThe prefix to generate the app-ID of other services. Default app-
daprApiToken?stringAPI token to authenticate with Dapr. See https://docs.dapr.io/operations/security/api-token/.
daprApiVersionstringThe Dapr api version Default ts v1.0
daprHost?stringHost location of the Dapr sidecar. Default ts 127.0.0.1
daprPort?stringPort of the Dapr sidecar. Default ts 3500.
isKeepAlive?booleanIf set to false, the HTTP client will not reuse the same connection for multiple requests. Default ts true
pubSubName?stringThe PubSub to be used for event messages Default ts pubsub

Defined in

dapr-sdk/src/DaprClient/types/DaprClientConfig.ts:1


DaprConfigStoreConfig

Ƭ DaprConfigStoreConfig: Object

Dapr config store configuration

Type declaration

NameTypeDescription
clientConfig?DaprClientConfigThe Dapr client config to interact with Dapr sidecar
configStoreName?stringThe name of the config store

Defined in

dapr-sdk/src/DaprConfigStore/types/DaprConfigStoreConfig.ts:6


DaprEventBridgeConfig

Ƭ DaprEventBridgeConfig: Prettify<HttpEventBridgeConfig & { clientConfig?: DaprClientConfig }>

Defined in

dapr-sdk/src/DaprEventBridge/types/DaprEventBridgeConfig.ts:6


DaprPubSubRouteType

Ƭ DaprPubSubRouteType: Object

DaprPubSubRouteType Defines the rules for a route

Type declaration

NameType
default?string
rules?DaprPubSubRuleType[]

Defined in

dapr-sdk/src/types/pubsub/DaprPubSubRouteType.type.ts:20


DaprPubSubRuleType

Ƭ DaprPubSubRuleType: Object

DaprPubSubRuleType defines a rule set

Type declaration

NameType
matchstring
pathstring

Defined in

dapr-sdk/src/types/pubsub/DaprPubSubRuleType.type.ts:19


DaprPubSubType

Ƭ DaprPubSubType: Object

DaprPubSubType is the Type used by the Dapr API to interface with its PubSub component

Type declaration

NameType
bulkSubscribe?BulkSubscribeConfig
deadLetterTopic?string
metadata?KeyValueType
pubsubnamestring
route?string
routes?DaprPubSubRouteType
topicstring

Defined in

dapr-sdk/src/types/pubsub/DaprPubSub.type.ts:22


DaprSecretStoreConfig

Ƭ DaprSecretStoreConfig: Object

Dapr secret store configuration

Type declaration

NameTypeDescription
clientConfig?DaprClientConfigThe Dapr client config to interact with Dapr sidecar
metadata?{ namespace?: string }Dapr secret store metadata
metadata.namespace?stringIn case of deploying into namespace other than default, the namespace (e.g. production) must be set
secretStoreName?stringThe name of the secret store

Defined in

dapr-sdk/src/DaprSecretStore/types/DaprSecretStoreConfig.ts:6


DaprStateStoreConfig

Ƭ DaprStateStoreConfig: Object

Dapr state store configuration

Type declaration

NameTypeDescription
clientConfig?DaprClientConfigThe Dapr client config to interact with Dapr sidecar
stateStoreName?stringThe name of the state store

Defined in

dapr-sdk/src/DaprStateStore/types/DaprStateStoreConfig.ts:6


KeyValueType

Ƭ KeyValueType: Object

Index signature

▪ [key: string]: unknown

Defined in

dapr-sdk/src/types/pubsub/KeyValue.type.ts:14


PubSubBulkPublishApiResponse

Ƭ PubSubBulkPublishApiResponse: Object

Response from a bulk publish API request.

Type declaration

NameType
failedEntriesPubSubBulkPublishApiResponseStatus[]

Defined in

dapr-sdk/src/types/pubsub/PubSubBulkPublishApiResponse.type.ts:22


PubSubBulkPublishEntry

Ƭ PubSubBulkPublishEntry: Object

PubSubBulkPublishEntry defines an entry in a bulk publish request.

Type declaration

NameType
contentTypestring
entryIDstring
eventobject | string
metadataKeyValueType

Defined in

dapr-sdk/src/types/pubsub/PubSubBulkPublishEntry.type.ts:19


PubSubBulkPublishMessage

Ƭ PubSubBulkPublishMessage: PubSubBulkPublishMessageExplicit | object | string

PubSubBulkPublishMessage is a message in a bulk publish request.

Defined in

dapr-sdk/src/types/pubsub/PubSubBulkPublishMessage.type.ts:26


PubSubBulkPublishResponse

Ƭ PubSubBulkPublishResponse: Object

PubSubBulkPublishResponse defines the response from a bulk publish request.

Type declaration

NameType
failedMessagesPubSubBulkPublishResponseFailedEntry[]

Defined in

dapr-sdk/src/types/pubsub/PubSubBulkPublishResponse.type.ts:24


PubSubPublishOptions

Ƭ PubSubPublishOptions: Object

Type declaration

NameTypeDescription
contentType?stringThe content type of the message. This is optional and will be inferred from the payload if not provided.
metadata?KeyValueTypeMetadata to be passed to the publish operation.

Defined in

dapr-sdk/src/types/pubsub/PubSubPublishOptions.type.ts:16


PubSubPublishResponseType

Ƭ PubSubPublishResponseType: Object

PubSubPublishResponseType defines the response from a publish.

Type declaration

NameType
error?Error

Defined in

dapr-sdk/src/types/pubsub/PubSubPublishResponse.type.ts:17


PubSubSubscriptionOptionsType

Ƭ PubSubSubscriptionOptionsType: Object

PubSubSubscriptionOptionsType defines the options we can pass while subscribing

Type declaration

NameType
bulkSubscribe?BulkSubscribeConfig
callback?TypeDaprPubSubCallback
deadLetterCallback?TypeDaprPubSubCallback
deadLetterTopic?string
metadata?KeyValueType
route?string | DaprPubSubRouteType

Defined in

dapr-sdk/src/types/pubsub/PubSubSubscriptionOptions.type.ts:22


PubSubSubscriptionTopicRouteType

Ƭ PubSubSubscriptionTopicRouteType: Object

This defines the routeName object

Type declaration

NameType
eventHandlersTypeDaprPubSubCallback[]
pathstring

Defined in

dapr-sdk/src/types/pubsub/PubSubSubscriptionTopicRoute.type.ts:19


PubSubSubscriptionTopicRoutesType

Ƭ PubSubSubscriptionTopicRoutesType: Object

This defines the routes object

Index signature

▪ [key: string]: PubSubSubscriptionTopicRouteType

Defined in

dapr-sdk/src/types/pubsub/PubSubSubscriptionTopicRoutes.type.ts:19


PubSubSubscriptionTopicType

Ƭ PubSubSubscriptionTopicType: Object

This defines the topicName object

Type declaration

NameType
daprDaprPubSubType
routesPubSubSubscriptionTopicRoutesType

Defined in

dapr-sdk/src/types/pubsub/PubSubSubscriptionTopic.type.ts:20


PubSubSubscriptionType

Ƭ PubSubSubscriptionType: Object

This defines the pubsubName object

Index signature

▪ [key: string]: PubSubSubscriptionTopicType

Defined in

dapr-sdk/src/types/pubsub/PubSubSubscription.type.ts:19


PubSubSubscriptionsType

Ƭ PubSubSubscriptionsType: Object

This defines the entire object containing pubsubNames

Index signature

▪ [key: string]: PubSubSubscriptionType

Defined in

dapr-sdk/src/types/pubsub/PubSubSubscriptions.type.ts:19


TypeDaprPubSubCallback

Ƭ TypeDaprPubSubCallback: (data: any, headers: object) => Promise<any | void>

Type declaration

▸ (data, headers): Promise<any | void>

Parameters
NameType
dataany
headersobject
Returns

Promise<any | void>

Defined in

dapr-sdk/src/types/pubsub/DaprPubSubCallback.type.ts:14

Variables

DAPR_API_VERSION

Const DAPR_API_VERSION: "v1.0"

Defined in

dapr-sdk/src/types/constants.ts:4


DEFAULT_DAPR_HOST

Const DEFAULT_DAPR_HOST: "http://127.0.0.1"

Defined in

dapr-sdk/src/types/constants.ts:2


DEFAULT_DAPR_PORT

Const DEFAULT_DAPR_PORT: "3500"

Defined in

dapr-sdk/src/types/constants.ts:1


puristaVersion

Const puristaVersion: "1.11.0"

Defined in

dapr-sdk/src/version.ts:1

Functions

configRoute

configRoute(this, c): Promise<Response>

Parameters

NameType
thisHttpEventBridge<HttpEventBridgeConfig>
cContext<any, any, {}>

Returns

Promise<Response>

Defined in

dapr-sdk/src/DaprEventBridge/routes/config.impl.ts:3


getDefaultClientConfig

getDefaultClientConfig(): Object

Returns

Object

NameType
appPrefixstring
daprApiTokenundefined
daprApiVersionstring
daprHoststring
daprPortstring
isKeepAliveboolean
pubSubNamestring

Defined in

dapr-sdk/src/DaprClient/getDefaultClientConfig.impl.ts:3


getDefaultConfig

getDefaultConfig(): Object

Returns

Object

NameType
apiPrefixstring
clientConfig{ appPrefix: string = 'app-'; daprApiToken: undefined = undefined; daprApiVersion: string = DAPR_API_VERSION; daprHost: string ; daprPort: string ; isKeepAlive: boolean = true; pubSubName: string = 'pubsub' }
clientConfig.appPrefixstring
clientConfig.daprApiTokenundefined
clientConfig.daprApiVersionstring
clientConfig.daprHoststring
clientConfig.daprPortstring
clientConfig.isKeepAliveboolean
clientConfig.pubSubNamestring
commandPayloadAsCloudEventboolean
enableRestApiExposeboolean
namestring
pathPrefixstring
serverHoststring
serverPortnumber
subscriptionPayloadAsCloudEventboolean

Defined in

dapr-sdk/src/DaprEventBridge/getDefaultConfig.impl.ts:3