Skip to content

Commit

Permalink
fix version (#25)
Browse files Browse the repository at this point in the history
Error out with version as number:
<img width="607" alt="Screenshot 2023-10-10 at 4 47 55 PM" src="https://github.com/yext/chat-core/assets/36055303/0c939f9e-b16d-4e14-a63a-2a1ad02d29c8">

J=CLIP-693

see that it works with version = '51' and not version 52
  • Loading branch information
yen-tt authored Oct 10, 2023
1 parent b720fa6 commit 5b0d76b
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/chat-core.chatconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ export interface ChatConfig
| [endpoints?](./chat-core.chatconfig.endpoints.md) | | [Endpoints](./chat-core.endpoints.md) | _(Optional)_ Overrides for the URLs which are used when making requests to the Chat API. |
| [env?](./chat-core.chatconfig.env.md) | | [EnumOrLiteral](./chat-core.enumorliteral.md)<!-- -->&lt;[Environment](./chat-core.environment.md)<!-- -->&gt; | _(Optional)_ Defines the environment of the API domains. |
| [region?](./chat-core.chatconfig.region.md) | | [EnumOrLiteral](./chat-core.enumorliteral.md)<!-- -->&lt;[Region](./chat-core.region.md)<!-- -->&gt; | _(Optional)_ The region to send the requests to. |
| [version?](./chat-core.chatconfig.version.md) | | "STAGING" \| "PRODUCTION" \| number | _(Optional)_ The version of the chat bot configuration. |
| [version?](./chat-core.chatconfig.version.md) | | string | _(Optional)_ The version of the chat bot configuration. |

6 changes: 3 additions & 3 deletions docs/chat-core.chatconfig.version.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ The version of the chat bot configuration.
**Signature:**

```typescript
version?: "STAGING" | "PRODUCTION" | number;
version?: string;
```

## Remarks

May be a configuration label (string) or a configuration version (number). Default to 'STAGING' in Chat API
Default to 'STAGING' in Chat API

## Example

Examples: 'STAGING', 42
Examples: 'STAGING', 'PRODUCTION', '42'

2 changes: 1 addition & 1 deletion etc/chat-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface ChatConfig {
endpoints?: Endpoints;
env?: EnumOrLiteral<Environment>;
region?: EnumOrLiteral<Region>;
version?: "STAGING" | "PRODUCTION" | number;
version?: string;
}

// @public
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yext/chat-core",
"version": "0.7.1",
"version": "0.7.2",
"description": "Typescript Networking Library for the Yext Chat API",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.mjs",
Expand Down
5 changes: 2 additions & 3 deletions src/models/ChatConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ export interface ChatConfig {
* The version of the chat bot configuration.
*
* @remarks
* May be a configuration label (string) or a configuration version (number).
* Default to 'STAGING' in Chat API
*
* @example
* Examples: 'STAGING', 42
* Examples: 'STAGING', 'PRODUCTION', '42'
*/
version?: "STAGING" | "PRODUCTION" | number;
version?: string;
/**
* Defines the environment of the API domains.
*
Expand Down
2 changes: 1 addition & 1 deletion src/models/endpoints/MessageRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface ApiMessageRequest {
/** {@inheritdoc MessageRequest.conversationId} */
conversationId?: string;
/** {@inheritDoc ChatConfig.version} */
version?: "STAGING" | "PRODUCTION" | number;
version?: string;
/** {@inheritDoc MessageRequest.messages} */
messages: Message[];
/** {@inheritDoc MessageNotes} */
Expand Down
2 changes: 1 addition & 1 deletion test-browser-esm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test-node-cjs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/ChatCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe("URL and http request construction", () => {

const configWithVersion: ChatConfig = {
...defaultConfig,
version: 42,
version: '42',
};

it("sets custom version when specified for Chat API", async () => {
Expand All @@ -167,7 +167,7 @@ describe("URL and http request construction", () => {
"https://liveapi.yext.com/v2/accounts/me/chat/my-bot/message",
{ v: defaultApiVersion },
{
version: 42,
version: '42',
conversationId: "my-id",
context: {
foo: "bar",
Expand All @@ -186,7 +186,7 @@ describe("URL and http request construction", () => {
"https://liveapi.yext.com/v2/accounts/me/chat/my-bot/message/streaming",
{ v: defaultApiVersion },
{
version: 42,
version: '42',
conversationId: "my-id",
context: {
foo: "bar",
Expand Down

0 comments on commit 5b0d76b

Please sign in to comment.