Skip to content

Commit

Permalink
make internal-only provider, hide client
Browse files Browse the repository at this point in the history
  • Loading branch information
nbramblett committed Aug 17, 2023
1 parent 0bab27d commit 2c3aa30
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/chat-headless/docs/chat-headless.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

| Function | Description |
| --- | --- |
| [provideChatHeadless(config, chatClient)](./chat-headless.providechatheadless.md) | Provide an instance of [ChatHeadless](./chat-headless.chatheadless.md) with all functionality built in. |
| [provideChatHeadless(config)](./chat-headless.providechatheadless.md) | Provide an instance of [ChatHeadless](./chat-headless.chatheadless.md) with all functionality built in. |

## Interfaces

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ Provide an instance of [ChatHeadless](./chat-headless.chatheadless.md) with all
**Signature:**

```typescript
export declare function provideChatHeadless(config: HeadlessConfig, chatClient?: ChatClient): ChatHeadless;
export declare function provideChatHeadless(config: HeadlessConfig): ChatHeadless;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| config | [HeadlessConfig](./chat-headless.headlessconfig.md) | |
| chatClient | [ChatClient](./chat-headless.chatclient.md) | _(Optional)_ |

**Returns:**

Expand Down
2 changes: 1 addition & 1 deletion packages/chat-headless/etc/chat-headless.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export interface MetaState {
}

// @public
export function provideChatHeadless(config: HeadlessConfig, chatClient?: ChatClient): ChatHeadless;
export function provideChatHeadless(config: HeadlessConfig): ChatHeadless;

export { RawResponse }

Expand Down
20 changes: 16 additions & 4 deletions packages/chat-headless/src/HeadlessProvider.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import { InternalConfig, provideChatCoreInternal } from "@yext/chat-core";
import { ChatHeadless, ChatHeadlessImpl } from "./ChatHeadless";
import { HeadlessConfig, ChatClient } from "./models";
import { HeadlessConfig } from "./models";

/**
* Provide an instance of {@link ChatHeadless} with all functionality built in.
*
* @public
*/
export function provideChatHeadless(
export function provideChatHeadless(config: HeadlessConfig): ChatHeadless {
return new ChatHeadlessImpl(config);
}

/**
* Provide an instance of {@link ChatHeadless} with all functionality built in,
* including internal-only configuration.
*
* @internal
*/
export function provideChatHeadlessInternal(
config: HeadlessConfig,
chatClient?: ChatClient
internalConfig: InternalConfig
): ChatHeadless {
return new ChatHeadlessImpl(config, chatClient);
const internalCore = provideChatCoreInternal(config, internalConfig);
return new ChatHeadlessImpl(config, internalCore);
}

0 comments on commit 2c3aa30

Please sign in to comment.