From 457e7e376b61c6fc7e8e4de6698e658a3d2485d5 Mon Sep 17 00:00:00 2001 From: Prashant Srivastav Date: Sat, 30 Aug 2025 21:46:42 +0800 Subject: [PATCH] feat: tested and validated the create-phone-call --- package.json | 2 +- src/connections/connection-config.ts | 99 ++++++++++++++++------------ src/index.ts | 4 -- 3 files changed, 59 insertions(+), 46 deletions(-) diff --git a/package.json b/package.json index b43fabd..47a3459 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/connections/connection-config.ts b/src/connections/connection-config.ts index ee35532..100c016 100644 --- a/src/connections/connection-config.ts +++ b/src/connections/connection-config.ts @@ -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, }, @@ -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, }, @@ -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, }, @@ -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 { @@ -312,6 +324,11 @@ export class ConnectionConfig { return this; } + /** + * + * @param auth + * @returns + */ static DefaultConnectionConfig( auth: ClientAuthInfo | UserAuthInfo ): ConnectionConfig { diff --git a/src/index.ts b/src/index.ts index acede6f..367d61d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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,