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
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
- BulkSubscribeConfig
- BulkSubscribeOptions
- BulkSubscribeResponse
- BulkSubscribeResponseEntry
- DaprClientConfig
- DaprConfigStoreConfig
- DaprEventBridgeConfig
- DaprPubSubRouteType
- DaprPubSubRuleType
- DaprPubSubType
- DaprSecretStoreConfig
- DaprStateStoreConfig
- KeyValueType
- PubSubBulkPublishApiResponse
- PubSubBulkPublishEntry
- PubSubBulkPublishMessage
- PubSubBulkPublishResponse
- PubSubPublishOptions
- PubSubPublishResponseType
- PubSubSubscriptionOptionsType
- PubSubSubscriptionTopicRouteType
- PubSubSubscriptionTopicRoutesType
- PubSubSubscriptionTopicType
- PubSubSubscriptionType
- PubSubSubscriptionsType
- TypeDaprPubSubCallback
Variables
Functions
Event bridge
Type Aliases
BulkSubscribeConfig
Ƭ BulkSubscribeConfig: Object
BulkSubscribeConfig defines the configuration for a bulk subscription
Type declaration
Name | Type |
---|---|
enabled | boolean |
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
Name | Type |
---|---|
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
Name | Type |
---|---|
statuses | BulkSubscribeResponseEntry [] |
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
Name | Type |
---|---|
entryId | string |
status | DaprPubSubStatusEnum |
Defined in
dapr-sdk/src/types/pubsub/BulkSubscribeResponseEntry.type.ts:19
DaprClientConfig
Ƭ DaprClientConfig: Object
Type declaration
Name | Type | Description |
---|---|---|
appPrefix? | string | The prefix to generate the app-ID of other services. Default app- |
daprApiToken? | string | API token to authenticate with Dapr. See https://docs.dapr.io/operations/security/api-token/. |
daprApiVersion | string | The Dapr api version Default ts v1.0 |
daprHost? | string | Host location of the Dapr sidecar. Default ts 127.0.0.1 |
daprPort? | string | Port of the Dapr sidecar. Default ts 3500. |
isKeepAlive? | boolean | If set to false, the HTTP client will not reuse the same connection for multiple requests. Default ts true |
pubSubName? | string | The 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
Name | Type | Description |
---|---|---|
clientConfig? | DaprClientConfig | The Dapr client config to interact with Dapr sidecar |
configStoreName? | string | The 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
Name | Type |
---|---|
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
Name | Type |
---|---|
match | string |
path | string |
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
Name | Type |
---|---|
bulkSubscribe? | BulkSubscribeConfig |
deadLetterTopic? | string |
metadata? | KeyValueType |
pubsubname | string |
route? | string |
routes? | DaprPubSubRouteType |
topic | string |
Defined in
dapr-sdk/src/types/pubsub/DaprPubSub.type.ts:22
DaprSecretStoreConfig
Ƭ DaprSecretStoreConfig: Object
Dapr secret store configuration
Type declaration
Name | Type | Description |
---|---|---|
clientConfig? | DaprClientConfig | The Dapr client config to interact with Dapr sidecar |
metadata? | { namespace? : string } | Dapr secret store metadata |
metadata.namespace? | string | In case of deploying into namespace other than default, the namespace (e.g. production) must be set |
secretStoreName? | string | The name of the secret store |
Defined in
dapr-sdk/src/DaprSecretStore/types/DaprSecretStoreConfig.ts:6
DaprStateStoreConfig
Ƭ DaprStateStoreConfig: Object
Dapr state store configuration
Type declaration
Name | Type | Description |
---|---|---|
clientConfig? | DaprClientConfig | The Dapr client config to interact with Dapr sidecar |
stateStoreName? | string | The 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
Name | Type |
---|---|
failedEntries | PubSubBulkPublishApiResponseStatus [] |
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
Name | Type |
---|---|
contentType | string |
entryID | string |
event | object | string |
metadata | KeyValueType |
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
Name | Type |
---|---|
failedMessages | PubSubBulkPublishResponseFailedEntry [] |
Defined in
dapr-sdk/src/types/pubsub/PubSubBulkPublishResponse.type.ts:24
PubSubPublishOptions
Ƭ PubSubPublishOptions: Object
Type declaration
Name | Type | Description |
---|---|---|
contentType? | string | The content type of the message. This is optional and will be inferred from the payload if not provided. |
metadata? | KeyValueType | Metadata 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
Name | Type |
---|---|
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
Name | Type |
---|---|
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
Name | Type |
---|---|
eventHandlers | TypeDaprPubSubCallback [] |
path | string |
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
Name | Type |
---|---|
dapr | DaprPubSubType |
routes | PubSubSubscriptionTopicRoutesType |
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
Name | Type |
---|---|
data | any |
headers | object |
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
Functions
configRoute
▸ configRoute(this
, c
): Promise
<Response
>
Parameters
Name | Type |
---|---|
this | HttpEventBridge <HttpEventBridgeConfig > |
c | Context <any , any , {}> |
Returns
Promise
<Response
>
Defined in
dapr-sdk/src/DaprEventBridge/routes/config.impl.ts:3
getDefaultClientConfig
▸ getDefaultClientConfig(): Object
Returns
Object
Name | Type |
---|---|
appPrefix | string |
daprApiToken | undefined |
daprApiVersion | string |
daprHost | string |
daprPort | string |
isKeepAlive | boolean |
pubSubName | string |
Defined in
dapr-sdk/src/DaprClient/getDefaultClientConfig.impl.ts:3
getDefaultConfig
▸ getDefaultConfig(): Object
Returns
Object
Name | Type |
---|---|
apiPrefix | string |
clientConfig | { appPrefix : string = 'app-'; daprApiToken : undefined = undefined; daprApiVersion : string = DAPR_API_VERSION; daprHost : string ; daprPort : string ; isKeepAlive : boolean = true; pubSubName : string = 'pubsub' } |
clientConfig.appPrefix | string |
clientConfig.daprApiToken | undefined |
clientConfig.daprApiVersion | string |
clientConfig.daprHost | string |
clientConfig.daprPort | string |
clientConfig.isKeepAlive | boolean |
clientConfig.pubSubName | string |
commandPayloadAsCloudEvent | boolean |
enableRestApiExpose | boolean |
name | string |
pathPrefix | string |
serverHost | string |
serverPort | number |
subscriptionPayloadAsCloudEvent | boolean |