Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rapida-nodejs",
"version": "1.0.5",
"version": "1.0.10",
"description": "Enable to interact with rapida platform",
"main": "dist/index.cjs",
"module": "dist/index.js",
Expand Down
99 changes: 58 additions & 41 deletions src/connections/connection-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ export class ConnectionConfig {
* @returns
*/
static WithPersonalToken({
authorization,
userId,
projectId,
Authorization,
AuthId,
ProjectId,
}: {
authorization: string;
userId: string;
projectId: string;
Authorization: string;
AuthId: string;
ProjectId: string;
}): UserAuthInfo {
return {
authorization,
[HEADER_AUTH_ID]: userId,
[HEADER_PROJECT_ID]: projectId,
authorization: Authorization,
[HEADER_AUTH_ID]: AuthId,
[HEADER_PROJECT_ID]: ProjectId,
Client: {
[HEADER_SOURCE_KEY]: RapidaSource.SDK,
},
Expand All @@ -112,15 +112,15 @@ export class ConnectionConfig {
* @returns
*/
static WithWebpluginClient({
apiKey,
userId,
ApiKey,
UserId,
}: {
apiKey: string;
userId?: string;
ApiKey: string;
UserId?: string;
}): ClientAuthInfo {
return {
[HEADER_API_KEY]: apiKey,
[HEADER_AUTH_ID]: userId,
[HEADER_API_KEY]: ApiKey,
[HEADER_AUTH_ID]: UserId,
Client: {
[HEADER_SOURCE_KEY]: RapidaSource.WEB_PLUGIN,
},
Expand All @@ -132,15 +132,15 @@ export class ConnectionConfig {
* @returns
*/
static WithSDK({
apiKey,
userId,
ApiKey,
UserId,
}: {
apiKey: string;
userId?: string;
ApiKey: string;
UserId?: string;
}): ClientAuthInfo {
return {
[HEADER_API_KEY]: apiKey,
[HEADER_AUTH_ID]: userId,
[HEADER_API_KEY]: ApiKey,
[HEADER_AUTH_ID]: UserId,
Client: {
[HEADER_SOURCE_KEY]: RapidaSource.SDK,
},
Expand Down Expand Up @@ -179,107 +179,119 @@ export class ConnectionConfig {
}

get conversationClient(): TalkServiceClient {
return new TalkServiceClient(this._endpoint.web, this.getClientOptions());
return new TalkServiceClient(
this._endpoint.assistant,
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get assistantClient(): AssistantServiceClient {
return new AssistantServiceClient(
this._endpoint.web,
this.getClientOptions()
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get projectClient(): ProjectServiceClient {
return new ProjectServiceClient(
this._endpoint.web,
this.getClientOptions()
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get knowledgeClient(): KnowledgeServiceClient {
return new KnowledgeServiceClient(
this._endpoint.web,
this.getClientOptions()
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get deploymentClient(): DeploymentClient {
return new DeploymentClient(this._endpoint.web, this.getClientOptions());
return new DeploymentClient(
this._endpoint.web,
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get marketplaceClient(): MarketplaceServiceClient {
return new MarketplaceServiceClient(
this._endpoint.web,
this.getClientOptions()
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get documentClient(): DocumentServiceClient {
return new DocumentServiceClient(
this._endpoint.web,
this.getClientOptions()
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get vaultClient(): VaultServiceClient {
return new VaultServiceClient(this._endpoint.web, this.getClientOptions());
return new VaultServiceClient(
this._endpoint.web,
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get endpointClient(): EndpointServiceClient {
return new EndpointServiceClient(
this._endpoint.web,
this.getClientOptions()
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get auditLoggingClient(): AuditLoggingServiceClient {
return new AuditLoggingServiceClient(
this._endpoint.web,
this.getClientOptions()
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get assistantDeploymentClient(): AssistantDeploymentServiceClient {
return new AssistantDeploymentServiceClient(
this._endpoint.web,
this.getClientOptions()
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get organizationClient(): OrganizationServiceClient {
return new OrganizationServiceClient(
this._endpoint.web,
this.getClientOptions()
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get connectClient(): ConnectServiceClient {
return new ConnectServiceClient(
this._endpoint.web,
this.getClientOptions()
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get providerClient(): ProviderServiceClient {
return new ProviderServiceClient(
this._endpoint.web,
this.getClientOptions()
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

get authenticationClient(): AuthenticationServiceClient {
return new AuthenticationServiceClient(
this._endpoint.web,
this.getClientOptions()
this._debug ? credentials.createInsecure() : credentials.createSsl()
);
}

withLocal(): this {
return this.withCustomEndpoint({
assistant: LOCAL_ASSISTANT_API,
web: LOCAL_WEB_API,
endpoint: LOCAL_ENDPOINT_API,
});
return this.withCustomEndpoint(
{
assistant: LOCAL_ASSISTANT_API,
web: LOCAL_WEB_API,
endpoint: LOCAL_ENDPOINT_API,
},
true
);
}

get auth(): ClientAuthInfo | UserAuthInfo | undefined {
Expand Down Expand Up @@ -312,6 +324,11 @@ export class ConnectionConfig {
return this;
}

/**
*
* @param auth
* @returns
*/
static DefaultConnectionConfig(
auth: ClientAuthInfo | UserAuthInfo
): ConnectionConfig {
Expand Down
4 changes: 0 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { AssistantConversation, Error } from "./clients/protos/common_pb";
import { AssistantApiDeployment } from "./clients/protos/assistant-deployment_pb";
import { EndpointDefinition } from "./clients/protos/invoker-api_pb";
import { AssistantDefinition } from "./clients/protos/talk-api_pb";
import { Any } from "google-protobuf/google/protobuf/any_pb";
import {
StringToAny,
Expand Down