-
Notifications
You must be signed in to change notification settings - Fork 18
/
types.ts
180 lines (133 loc) · 4.74 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import { RateLimitConfig, Validator } from '@voiceflow/backend-utils';
import { BaseRequest, BaseTrace } from '@voiceflow/base-types';
import * as Express from 'express';
import http from 'http';
import { RuntimeRequest } from '@/lib/services/runtime/types';
import CacheDataAPI from '@/lib/services/state/cacheDataAPI';
import * as Runtime from './runtime';
export interface Config extends RateLimitConfig {
NODE_ENV: string;
PORT: string;
PORT_METRICS: string | null;
ERROR_RESPONSE_MS: number;
CLOUD_ENV: string;
DEPLOY_ENV: string;
IS_PRIVATE_CLOUD: boolean;
AWS_ACCESS_KEY_ID: string | null;
AWS_SECRET_ACCESS_KEY: string | null;
AWS_REGION: string | null;
AWS_ENDPOINT: string | null;
DYNAMO_ENDPOINT: string | null;
S3_ACCESS_KEY_ID: string | null;
S3_SECRET_ACCESS_KEY: string | null;
S3_TLS_BUCKET: string | null;
S3_ENDPOINT: string | null;
CODE_HANDLER_ENDPOINT: string | null;
INTEGRATIONS_HANDLER_ENDPOINT: string;
API_REQUEST_TIMEOUT_MS: number | null;
API_MAX_CONTENT_LENGTH_BYTES: number | null;
API_MAX_BODY_LENGTH_BYTES: number | null;
// Release information
GIT_SHA: string | null;
BUILD_NUM: string | null;
SEM_VER: string | null;
BUILD_URL: string | null;
GENERAL_SERVICE_ENDPOINT: string | null;
KNOWLEDGE_BASE_LAMBDA_ENDPOINT: string | null;
FUNCTION_API_PROXY: boolean | null;
FUNCTION_LAMBDA_ARN: string | null;
FUNCTION_LAMBDA_ACCESS_KEY_ID: string | null;
FUNCTION_LAMBDA_SECRET_ACCESS_KEY: string | null;
KL_RETRIEVER_SERVICE_URI: string | null;
KL_RETRIEVER_SERVICE_PORT: string | null;
AUTH_API_SERVICE_URI: string | null;
AUTH_API_SERVICE_PORT_APP: string | null;
ANALYTICS_API_SERVICE_URI: string | null;
ANALYTICS_API_SERVICE_PORT_APP: string | null;
NLU_GATEWAY_SERVICE_URI: string | null;
NLU_GATEWAY_SERVICE_PORT_APP: string | null;
IDENTITY_API_SERVICE_URI: string | null;
IDENTITY_API_SERVICE_PORT_APP: string | null;
BILLING_API_SERVICE_URI: string | null;
BILLING_API_SERVICE_PORT_APP: string | null;
ML_GATEWAY_SERVICE_URI: string | null;
ML_GATEWAY_SERVICE_PORT_APP: string | null;
CREATOR_API_ENDPOINT: string | null;
CREATOR_API_AUTHORIZATION: string | null;
CREATOR_APP_ORIGIN: string | null;
DISABLE_ORIGIN_CHECK: boolean;
// Logging
LOG_LEVEL: string | null;
MIDDLEWARE_VERBOSITY: string | null;
PROJECT_SOURCE: string | null;
REDIS_CLUSTER_HOST: string | null;
REDIS_CLUSTER_PORT: number | null;
SESSIONS_SOURCE: string;
MONGO_URI: string | null;
MONGO_DB: string | null;
ANALYTICS_ENDPOINT: string | null;
ANALYTICS_WRITE_KEY: string | null;
INGEST_V2_WEBHOOK_ENDPOINT: string | null;
// OpenAI LLM keys
AZURE_OPENAI_API_KEY: string | null;
AZURE_ENDPOINT: string | null;
AZURE_GPT3_DEPLOYMENTS: string | null;
AZURE_GPT35_DEPLOYMENTS: string | null;
OPENAI_API_KEY: string | null;
OPENAI_API_ENDPOINT: string | null;
ANTHROPIC_API_KEY: string | null;
// AI Configuration
AI_GENERATION_TIMEOUT: number;
// Unleash
UNLEASH_URL: string | null;
UNLEASH_API_KEY: string | null;
ALLOWED_PUBLIC_ORIGINS: string | null;
RATE_LIMITER_DURATION_LLM: number;
RATE_LIMITER_POINTS_LLM: number;
RATE_LIMITER_DURATION_INFERENCE: number;
RATE_LIMITER_POINTS_INFERENCE: number;
}
export interface Request<
P extends Record<string, any> = Record<string, any>,
B = any,
H extends Record<string, any> = Record<string, any>,
Q = any,
RB = any
> extends Express.Request<P, RB, B, Q> {
headers: http.IncomingHttpHeaders & H;
}
export type Response = Express.Response;
export type Next = (err?: any) => void;
export interface Route<Params extends Record<string, any> = Record<string, any>, T = void> {
(req: Request<Params>): Promise<T>;
validations?: Validator.ValidationChain[];
callback?: boolean;
route?: unknown;
}
export type Controller = Record<string, Route>;
export type Middleware = (req: Request, res: Response, next: Next) => Promise<void>;
export type MiddlewareGroup = Record<string, Middleware>;
export interface Class<T, A extends any[]> {
new (...args: A): T;
}
export type AnyClass = Class<any, any[]>;
export enum VersionTag {
DEVELOPMENT = 'development',
PRODUCTION = 'production',
}
export const isVersionTag = (value: unknown): value is VersionTag =>
value === VersionTag.DEVELOPMENT || value === VersionTag.PRODUCTION;
export interface ContextData {
api: CacheDataAPI;
locale?: string;
config?: BaseRequest.RequestConfig;
reqHeaders?: {
origin?: string;
platform?: string;
sessionid?: string;
authorization?: string;
};
}
export type Context = Runtime.Context<RuntimeRequest, BaseTrace.AnyTrace, ContextData>;
export type ContextHandler = Runtime.ContextHandler<Context>;
export type InitContextHandler = Runtime.InitContextHandler<Context>;