Skip to content

Commit

Permalink
renaming env to match analytics repo (#17)
Browse files Browse the repository at this point in the history
renaming env to match analytics repo #17
  • Loading branch information
yen-tt authored Jun 28, 2023
1 parent da7021d commit e894d49
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/chat-core.chatconfig.env.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ env?: EnumOrLiteral<Environment>;

## Remarks

Default to PROD.
Default to PRODUCTION.

4 changes: 2 additions & 2 deletions docs/chat-core.environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export declare enum Environment

| Member | Value | Description |
| --- | --- | --- |
| PROD | <code>&quot;prod&quot;</code> | |
| SANDBOX | <code>&quot;sbx&quot;</code> | |
| PRODUCTION | <code>&quot;PRODUCTION&quot;</code> | |
| SANDBOX | <code>&quot;SANDBOX&quot;</code> | |

4 changes: 2 additions & 2 deletions etc/chat-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export type EnumOrLiteral<T extends string> = T | `${T}`;
// @public
export enum Environment {
// (undocumented)
PROD = "prod",
PRODUCTION = "PRODUCTION",
// (undocumented)
SANDBOX = "sbx"
SANDBOX = "SANDBOX"
}

// @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.5.0",
"version": "0.5.1",
"description": "Typescript Networking Library for the Yext Chat API",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
Expand Down
13 changes: 8 additions & 5 deletions src/infra/EndpointsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ import { Environment } from "../models/endpoints/Environment";
*/
export class EndpointsFactory {
private static getDomain(endpointConfig: EndpointConfig): string {
const { region = Region.US, env = Environment.PROD } = endpointConfig;
const { region = Region.US, env = Environment.PRODUCTION } = endpointConfig;
switch (region) {
case Region.US:
return env === Environment.PROD
? "liveapi.yext.com"
: `liveapi-${env}.yext.com`;
switch (env) {
case Environment.SANDBOX:
return "liveapi-sbx.yext.com";
default:
return "liveapi.yext.com";
}
case Region.EU:
if (env === Environment.PROD) {
if (env === Environment.PRODUCTION) {
return "cdn.eu.yextapis.com";
}
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion src/models/ChatConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface ChatConfig {
* Defines the environment of the API domains.
*
* @remarks
* Default to PROD.
* Default to PRODUCTION.
*/
env?: EnumOrLiteral<Environment>;
/**
Expand Down
4 changes: 2 additions & 2 deletions src/models/endpoints/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* @public
*/
export enum Environment {
PROD = "prod",
SANDBOX = "sbx",
PRODUCTION = "PRODUCTION",
SANDBOX = "SANDBOX",
}
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/infra/EndPointFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ it("provides proper endpoint for default env, region, and businessId", () => {
it("provides proper endpoint for custom env", () => {
const endpoints = EndpointsFactory.getEndpoints({
botId: "my-bot",
env: "sbx",
env: "SANDBOX",
});
expect(endpoints).toEqual({
chat: `https://liveapi-sbx.yext.com/v2/accounts/me/chat/my-bot/message`,
Expand Down Expand Up @@ -48,7 +48,7 @@ it("throws error on invalid region + env", () => {
EndpointsFactory.getEndpoints({
botId: "my-bot",
region: "eu",
env: "sbx",
env: "SANDBOX",
})
).toThrow('Unsupported domain: invalid environment "sbx" for region EU');
).toThrow('Unsupported domain: invalid environment "SANDBOX" for region EU');
});

0 comments on commit e894d49

Please sign in to comment.