Classes · @purista/dapr-sdk

DaprClient

HTTP client for Dapr sidecar APIs used by the Dapr event bridge.

Signature

DaprClient.ts typescript
class DaprClient

Constructors

1 entry

constructor

Constructor

constructor.ts typescript
new constructor(config: { apiPrefix: string; baseUrl: string; basicAuth: { password: string; username: string }; bearerToken: string; clientConfig: DaprClientConfig; commandPayloadAsCloudEvent: boolean; ... })

Properties

8 entries

auth

Property

auth.ts typescript
auth: AuthCredentials

baseUrl

Property

baseUrl.ts typescript
baseUrl: URL | undefined

Parsed base URL, when configured.

config

Property

config.ts typescript
config: { apiPrefix: string; baseUrl: string; basicAuth: { password: string; username: string }; bearerToken: string; clientConfig: DaprClientConfig; commandPayloadAsCloudEvent: boolean; ... }

Resolved client configuration.

logger

Property

logger.ts typescript
logger: Logger

Logger scoped to this client.

name

Property

name.ts typescript
name: string

Client name used in logs, spans, and metrics.

spanProcessor

Property

spanProcessor.ts typescript
spanProcessor: SpanProcessor | undefined

Optional OpenTelemetry span processor configured for this client.

timeout

Property

timeout.ts typescript
timeout: number

Default request timeout in milliseconds.

traceProvider

Property

traceProvider.ts typescript
traceProvider: NodeTracerProvider

Node tracer provider owned by this client instance.

Methods

16 entries

delete

Method

delete.ts typescript
delete<T>(path: string, options?: HttpClientRequestOptions, payload?: unknown): Promise<T>

DELETE request.

execute

Method

execute.ts typescript
execute(method: string, path: string, options?: HttpClientRequestOptions, payload?: unknown): Promise<any>

Helper method

get

Method

get.ts typescript
get<T>(path: string, options?: HttpClientRequestOptions): Promise<T>

GET request.

getApiPathForCommand

Method

Source
getApiPathForCommand.ts typescript
getApiPathForCommand(addess: EBMessageAddress, metadata: { expose: { contentEncodingRequest: string; contentEncodingResponse: string; contentTypeRequest: string; contentTypeResponse: string; deprecated: boolean; inputPayload: SchemaObject; ... } & { http: { method: unknown | unknown | unknown | unknown | unknown; mode: unknown | unknown; openApi: { additionalStatusCodes: unknown; description: unknown; isSecure: unknown; operationId: unknown; query: unknown; summary: unknown; ... }; path: string; stream: { documentationUrl: unknown; mode: unknown; protocol: unknown } } } }): string

Returns the public REST projection path for an HTTP-exposed command.

getInternalPathForCommand

Method

Source
getInternalPathForCommand.ts typescript
getInternalPathForCommand(address: EBMessageAddress): string

Returns the internal route Dapr calls for a PURISTA command.

getInternalPathForSubscription

Method

Source
getInternalPathForSubscription.ts typescript
getInternalPathForSubscription(address: EBMessageAddress): string

Returns the internal route Dapr calls for a PURISTA subscription.

getTracer

Method

getTracer.ts typescript
getTracer(): Tracer

Returns OpenTelemetry tracer of this client.

getUrlAndHeader

Method

getUrlAndHeader.ts typescript
getUrlAndHeader(path: string, options?: HttpClientRequestOptions): { headers: Record<string, string>; url: URL }

invoke

Method

Source
invoke.ts typescript
invoke(command: { contentEncoding: string; contentType: string; correlationId: string; eventName: string; id: string; messageType: Command; ... }, headers?: Record<string, string>, timeout?: number): Promise<CommandResponse>

Invokes a remote PURISTA command through Dapr service invocation.

isSidecarAvailable

Method

Source
isSidecarAvailable.ts typescript
isSidecarAvailable(): Promise<boolean>

Checks whether the local Dapr sidecar metadata endpoint is reachable.

patch

Method

patch.ts typescript
patch<T>(path: string, payload: unknown, options?: HttpClientRequestOptions): Promise<T>

PATCH request with an optional JSON payload.

post

Method

post.ts typescript
post<T>(path: string, payload: unknown, options?: HttpClientRequestOptions): Promise<T>

POST request with an optional JSON payload.

put

Method

put.ts typescript
put<T>(path: string, payload: unknown, options?: HttpClientRequestOptions): Promise<T>

PUT request with an optional JSON payload.

sendEvent

Method

Source
sendEvent.ts typescript
sendEvent(message: EBMessage, headers?: Record<string, string>): Promise<void>

Publishes a PURISTA event message to the configured Dapr Pub/Sub component.

setBearerToken

Method

setBearerToken.ts typescript
setBearerToken(token: string | undefined): void

Set the bearer token for all following requests.

startActiveSpan

Method

startActiveSpan.ts typescript
startActiveSpan<F>(name: string, opts: SpanOptions, context: Context | undefined, fn: (span: Span) => Promise<F>): Promise<F>

Start a child span for OpenTelemetry tracking.