Skip to content

Commit f47b9a5

Browse files
committed
baseURL, log types context, log types scripts
1 parent 434a5fb commit f47b9a5

File tree

9 files changed

+14900
-6
lines changed

9 files changed

+14900
-6
lines changed

apps/web/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
ANTHROPIC_API_KEY=
1+
ANTHROPIC_API_KEY=
2+
NEXT_PUBLIC_VERCEL_URL=

apps/web/src/app/api/chat/route.ts

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,101 @@ import { z } from 'zod';
66
// Allow streaming responses up to 30 seconds
77
export const maxDuration = 30;
88

9+
const event_type_context = `
10+
tool,event_type,description
11+
auth0,api_limit,"The maximum number of requests to the Authentication or Management APIs in given time was reached"
12+
auth0,appi,"API Peak Performance Rate is initiated"
13+
auth0,cls,"Passwordless Login Code/Link Sent"
14+
auth0,cs,"Passwordless Login Code Sent"
15+
auth0,depnote,"Deprecation Notice"
16+
auth0,f,"Failed Login This is only emitted if the error is not covered by the 'fp' or 'fu' log types"
17+
auth0,fce,"Failed to change user email"
18+
auth0,fco,"Failed due to CORS. Is the origin in the Allowed Origins list for the specified application?"
19+
auth0,fcoa,"Failed Cross-Origin Authentication"
20+
auth0,fcp,"Failed Change Password"
21+
auth0,fcph,"Failed Post Change Password Hook"
22+
auth0,fcpn,"Failed Change Phone Number"
23+
auth0,fcpr,"Failed Change Password Request"
24+
auth0,fcpro,"Failed to provision a AD/LDAP connector"
25+
auth0,fcu,"Failed to change username"
26+
auth0,fd,"Failed to generate delegation token"
27+
auth0,fdeac,"Failed Device Confirmation - Device Activation Failure"
28+
auth0,fdeaz,"Failed Device Confirmation - Request Failure"
29+
auth0,fdecc,"Failed Device Confirmation - User Canceled"
30+
auth0,fdu,"Failed User Deletion"
31+
auth0,feacft,"Failed to Exchange Authorization Code for Access Token"
32+
auth0,feccft,"Failed exchange of Access Token for a Client Credentials Grant"
33+
auth0,fede,"Failed to exchange Device Code for Access Token"
34+
auth0,fens,"Failed exchange for Native Social Login"
35+
auth0,feoobft,"Failed exchange of Password and OOB Challenge for Access Token"
36+
auth0,feotpft,"Failed exchange of Password and OTP Challenge for Access Token"
37+
auth0,fepft,"Failed exchange of Password for Access Token"
38+
auth0,fepotpft,"Failed exchange of Passwordless OTP for Access Token"
39+
auth0,fercft,"Failed Exchange of Password and MFA Recovery Code for Access Token"
40+
auth0,ferrt,"Failed Exchange of Rotating Refresh Token. This could occur when reuse is detected."
41+
auth0,fertft,"Failed Exchange of Refresh Token for Access Token. This could occur if the refresh token is revoked or expired."
42+
auth0,fi,"Failed to accept a user invitation. This could happen if the user accepts an invitation using a different email address than provided in the invitation; or due to a system failure while provisioning the invitation."
43+
auth0,flo,"Failed Logout"
44+
auth0,fn,"Failed Notification"
45+
auth0,fp,"Failed login due to invalid password"
46+
auth0,fpar,"Failed Push Authorization Request"
47+
auth0,fpurh,"Failed Post User Registration Hook"
48+
auth0,fs,"Failed Signup"
49+
auth0,fsa,"Failed Silent Auth"
50+
auth0,fu,"Failed login due to invalid username"
51+
auth0,fv,"Failed to send verification email"
52+
auth0,fvr,"Failed to proces verification email request"
53+
auth0,gd_auth_failed,"Multi-factor authentication failed. This could happen due to a wrong code entered for SMS/Voice/Email/TOTP factors; or a system failure."
54+
auth0,gd_auth_rejected,"User rejected a multi-factor authentication request via push-notification"
55+
auth0,gd_enrollment_complete,"A first time MFA user has successfully enrolled using one of the factors"
56+
auth0,gd_otp_rate_limit_exceed,"A user; during enrollment or authentication; enters an incorrect code more than the maximum allowed number of times. Ex: A user enrolling in SMS enters the 6-digit code wrong more than 10 times in a row."
57+
auth0,gd_recovery_failed,"A user entered a wrong Recovery Code when attempting to authenticate"
58+
auth0,gd_send_pn,"Push notification for MFA sent successfully sent"
59+
auth0,gd_send_pn_failure,"Push notification for MFA failed"
60+
auth0,limit_delegation,"A user is temporarily prevented from logging in because of too many delegation requests"
61+
auth0,limit_mu,"An IP address is blocked because it attempted too many failed logins without a successful login. Or an IP address is blocked because it attempted too many sign-ups; whether successful or failed."
62+
auth0,limit_sul,"A user is temporarily prevented from logging in because they reached the maximum logins per time period from the same IP address"
63+
auth0,limit_wc,"An IP address is blocked because it reached the maximum failed login attempts into a single account."
64+
auth0,mfar,"A user has been prompted for multi-factor authentication (MFA). When using Adaptive MFA; Auth0 includes details about the risk assessment"
65+
auth0,mgmt_api_read,"Successful GET request on the management API. This event will only be emitted if a secret is returned."
66+
auth0,pla,"Generated before a login and helps in monitoring the behavior of bot detection without having to enable it."
67+
auth0,pwd_leak,"Someone behind the IP address ip attempted to login with a leaked password"
68+
auth0,refresh_tokens_revoked_by_session,"Successfully revoked a refresh token"
69+
auth0,resource_cleanup,"Emitted when resources exceeding defined limits were removed. Normally related to refresh tokens"
70+
auth0,s,"Successful Login"
71+
auth0,sapi,"Successful API Operation Only emitted by the Management API on POST; DELETE; PATCH; and PUT"
72+
auth0,sce,"Successful Change Email"
73+
auth0,scoa,"Successful Cross-Origin Authentication"
74+
auth0,scp,"Successful Change Password"
75+
auth0,scph,"Successful Post Change Password Hook"
76+
auth0,scpn,"Successful Change Phone Number"
77+
auth0,scpr,"Successful Change Password Request"
78+
auth0,scu,"Successful Change Username"
79+
auth0,sd,"Successful Delegation"
80+
auth0,sdu,"Successful User Deletion"
81+
auth0,seacft,"Successful Exchange of Authorization Code for Access Token"
82+
auth0,seccft,"Successful Exchange of Access Token for a Client Credentials Grant"
83+
auth0,sede,"Successful Exchange of Device Code for Access Token"
84+
auth0,sens,"Successful Exchange - Native Social Login"
85+
auth0,seoobft,"Successful Exchange of Password and OOB Challenge for Access Token"
86+
auth0,seotpft,"Successful Exchange of Password and OTP Challenge for Access Token"
87+
auth0,sepft,"Successful Exchange of Password for Access Token"
88+
auth0,sercft,"Successful Exchange of Password and MFA Recovery Codeode for Access Token"
89+
auth0,sertft,"Successful Exchange of Refresh Token for Access Token"
90+
auth0,session_revoked,"Successfully revoked a session"
91+
auth0,si,"Successfully accepted a user invitation"
92+
auth0,slo,"Successful Logout"
93+
auth0,srrt,"Successfully revoked a refresh token"
94+
auth0,ss,"Successful Signup"
95+
auth0,ssa,"Successful Silent Auth"
96+
auth0,sui,"Successful Users Import"
97+
auth0,sv,"Successfully consumed email verification link"
98+
auth0,svr,"Successfully called verification email endpoint. Verification email has been queued for sending."
99+
auth0,ublkdu,"User block setup by anomaly detection has been released"
100+
auth0,w,"A warning has happened during a login flow"
101+
`
102+
103+
9104
export async function POST(req: Request) {
10105
const token = req.headers.get('token') ?? '';
11106
const { messages } = await req.json();
@@ -42,7 +137,8 @@ export async function POST(req: Request) {
42137
'6. The query must end with the text FORMAT JSON' +
43138
'7. The query must not contains new lines' +
44139
'The schema of all data sources is as follows: event_time DATETIME, event_type STRING, event JSON.' +
45-
'The event column contains a JSON object using the ClickHouse JSON type. The fields should be accessed using dot notation, e.g. event.data.field_name.',
140+
'The event column contains a JSON object using the ClickHouse JSON type. The fields should be accessed using dot notation, e.g. event.data.field_name.' +
141+
'The event_type column contains the types of events. Here is a list of event types and their descriptions for every tool: \n' + event_type_context,
46142
parameters: z.object({
47143
// token: z.string().describe('Tinybird Admin Token used to authenticate calls to the Tinybird API'),
48144
query: z.string().describe('The SQL query to execute'),

apps/web/src/lib/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import dynamic from 'next/dynamic';
22

3+
export const baseURL = process.env.NEXT_PUBLIC_VERCEL_URL
4+
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
5+
: 'http://localhost:3000';
6+
37
export type ToolState = 'available' | 'installed' | 'configured';
48

59
export interface AppGridItem {

apps/web/src/lib/tinybird.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22

3-
import { type ToolState } from './constants';
3+
import { type ToolState, baseURL } from './constants';
44

55
export class InvalidTokenError extends Error {
66
constructor() {
@@ -19,7 +19,7 @@ export interface TinybirdDataSource {
1919
}
2020

2121
export async function listDataSources(token: string): Promise<TinybirdDataSource[]> {
22-
const response = await fetch(`http://localhost:3000/api/datasources?token=${token}`);
22+
const response = await fetch(`${baseURL}/api/datasources?token=${token}`);
2323

2424
if (!response.ok) {
2525
if (response.status === 401 || response.status === 403) {
@@ -47,7 +47,7 @@ export interface QueryResult {
4747
}
4848

4949
export async function query(token: string, sql: string): Promise<QueryResult> {
50-
const response = await fetch(`http://localhost:3000/api/query?token=${token}&query=${encodeURIComponent(sql)}`);
50+
const response = await fetch(`${baseURL}/api/query?token=${token}&query=${encodeURIComponent(sql)}`);
5151

5252
if (!response.ok) {
5353
if (response.status === 401 || response.status === 403) {
@@ -123,7 +123,7 @@ export async function pipe<T = QueryResult>(
123123
});
124124
}
125125

126-
const response = await fetch(`http://localhost:3000/api/pipes?${searchParams}`);
126+
const response = await fetch(`${baseURL}/api/pipes?${searchParams}`);
127127

128128
if (!response.ok) {
129129
if (response.status === 401 || response.status === 403) {

log_types/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
types.csv

0 commit comments

Comments
 (0)