Skip to content

Commit d96f384

Browse files
authored
♻️ Migrate from got to ky (baptisteArno#1416)
Closes baptisteArno#1415
1 parent ccc7101 commit d96f384

File tree

59 files changed

+979
-617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+979
-617
lines changed

.eslintignore

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

apps/builder/next.config.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const injectViewerUrlIfVercelPreview = (val) => {
2121
process.env.VERCEL_BUILDER_PROJECT_NAME,
2222
process.env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME
2323
)
24-
if (process.env.NEXT_PUBLIC_CHAT_API_URL.includes('{{pr_id}}'))
24+
if (process.env.NEXT_PUBLIC_CHAT_API_URL?.includes('{{pr_id}}'))
2525
process.env.NEXT_PUBLIC_CHAT_API_URL =
2626
process.env.NEXT_PUBLIC_CHAT_API_URL.replace(
2727
'{{pr_id}}',
@@ -56,12 +56,14 @@ const nextConfig = {
5656
if (nextRuntime === 'edge') {
5757
config.resolve.alias['minio'] = false
5858
config.resolve.alias['got'] = false
59+
config.resolve.alias['qrcode'] = false
5960
return config
6061
}
6162
// These packages are imports from the integrations definition files that can be ignored for the client.
6263
config.resolve.alias['minio'] = false
6364
config.resolve.alias['got'] = false
6465
config.resolve.alias['openai'] = false
66+
config.resolve.alias['qrcode'] = false
6567
return config
6668
},
6769
headers: async () => {

apps/builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"framer-motion": "10.3.0",
6868
"google-auth-library": "8.9.0",
6969
"google-spreadsheet": "4.1.1",
70-
"got": "12.6.0",
70+
"ky": "1.2.3",
7171
"immer": "10.0.2",
7272
"jsonwebtoken": "9.0.1",
7373
"libphonenumber-js": "1.10.37",

apps/builder/src/features/blocks/integrations/webhook/api/getResultExample.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const getResultExample = authenticatedProcedure
3232
})
3333
)
3434
.query(async ({ input: { typebotId, blockId }, ctx: { user } }) => {
35-
console.log('user', user)
3635
const typebot = (await prisma.typebot.findFirst({
3736
where: canReadTypebots(typebotId, user),
3837
select: {

apps/builder/src/features/blocks/integrations/webhook/helpers/convertVariablesForTestToVariables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const convertVariablesForTestToVariables = (
1717
) as Variable
1818
return { ...variable, value: parseVariableValue(variableForTest.value) }
1919
}, {}),
20-
]
20+
].filter((v) => v.value)
2121
}
2222

2323
const parseVariableValue = (value: string | undefined): string | string[] => {

apps/builder/src/features/blocks/integrations/webhook/queries/executeWebhookQuery.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { Variable, HttpResponse } from '@typebot.io/schemas'
22
import { sendRequest } from '@typebot.io/lib'
3-
import { env } from '@typebot.io/env'
43

54
export const executeWebhook = (
65
typebotId: string,
76
variables: Variable[],
87
{ blockId }: { blockId: string }
98
) =>
109
sendRequest<HttpResponse>({
11-
url: `${env.NEXT_PUBLIC_VIEWER_URL[0]}/api/typebots/${typebotId}/blocks/${blockId}/executeWebhook`,
10+
url: `/api/typebots/${typebotId}/blocks/${blockId}/testWebhook`,
1211
method: 'POST',
1312
body: {
1413
variables,

apps/builder/src/features/blocks/integrations/zemanticAi/api/listProjects.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { z } from 'zod'
55
import { isReadWorkspaceFobidden } from '@/features/workspace/helpers/isReadWorkspaceFobidden'
66
import { decrypt } from '@typebot.io/lib/api/encryption/decrypt'
77
import { ZemanticAiCredentials } from '@typebot.io/schemas/features/blocks/integrations/zemanticAi'
8-
import got from 'got'
8+
import ky from 'ky'
99

1010
export const listProjects = authenticatedProcedure
1111
.input(
@@ -58,7 +58,7 @@ export const listProjects = authenticatedProcedure
5858
const url = 'https://api.zemantic.ai/v1/projects'
5959

6060
try {
61-
const response = await got
61+
const response = await ky
6262
.get(url, {
6363
headers: {
6464
Authorization: `Bearer ${data.apiKey}`,

apps/builder/src/features/customDomains/api/createCustomDomain.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { authenticatedProcedure } from '@/helpers/server/trpc'
33
import { TRPCError } from '@trpc/server'
44
import { z } from 'zod'
55
import { customDomainSchema } from '@typebot.io/schemas/features/customDomains'
6-
import got, { HTTPError } from 'got'
6+
import ky, { HTTPError } from 'ky'
77
import { env } from '@typebot.io/env'
88
import { isWriteWorkspaceForbidden } from '@/features/workspace/helpers/isWriteWorkspaceForbidden'
99
import { trackEvents } from '@typebot.io/telemetry/trackEvents'
@@ -61,12 +61,12 @@ export const createCustomDomain = authenticatedProcedure
6161
try {
6262
await createDomainOnVercel(name)
6363
} catch (err) {
64-
console.log(err)
65-
if (err instanceof HTTPError && err.response.statusCode !== 409)
64+
if (err instanceof HTTPError && err.response.status !== 409) {
6665
throw new TRPCError({
6766
code: 'INTERNAL_SERVER_ERROR',
6867
message: 'Failed to create custom ___domain on Vercel',
6968
})
69+
}
7070
}
7171

7272
const customDomain = await prisma.customDomain.create({
@@ -91,8 +91,12 @@ export const createCustomDomain = authenticatedProcedure
9191
})
9292

9393
const createDomainOnVercel = (name: string) =>
94-
got.post({
95-
url: `https://api.vercel.com/v10/projects/${env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME}/domains?teamId=${env.VERCEL_TEAM_ID}`,
96-
headers: { Authorization: `Bearer ${env.VERCEL_TOKEN}` },
97-
json: { name },
98-
})
94+
ky.post(
95+
`https://api.vercel.com/v10/projects/${env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME}/domains?teamId=${env.VERCEL_TEAM_ID}`,
96+
{
97+
headers: {
98+
authorization: `Bearer ${env.VERCEL_TOKEN}`,
99+
},
100+
json: { name },
101+
}
102+
)

apps/builder/src/features/customDomains/api/deleteCustomDomain.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import prisma from '@typebot.io/lib/prisma'
22
import { authenticatedProcedure } from '@/helpers/server/trpc'
33
import { TRPCError } from '@trpc/server'
44
import { z } from 'zod'
5-
import got from 'got'
5+
import ky from 'ky'
66
import { env } from '@typebot.io/env'
77
import { isWriteWorkspaceForbidden } from '@/features/workspace/helpers/isWriteWorkspaceForbidden'
88

@@ -63,7 +63,9 @@ export const deleteCustomDomain = authenticatedProcedure
6363
})
6464

6565
const deleteDomainOnVercel = (name: string) =>
66-
got.delete({
67-
url: `https://api.vercel.com/v9/projects/${env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME}/domains/${name}?teamId=${env.VERCEL_TEAM_ID}`,
68-
headers: { Authorization: `Bearer ${env.VERCEL_TOKEN}` },
69-
})
66+
ky.delete(
67+
`https://api.vercel.com/v9/projects/${env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME}/domains/${name}?teamId=${env.VERCEL_TEAM_ID}`,
68+
{
69+
headers: { Authorization: `Bearer ${env.VERCEL_TOKEN}` },
70+
}
71+
)

apps/builder/src/features/publish/components/embeds/modals/WhatsAppModal/WhatsAppCredentialsModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ const SystemUserToken = ({
377377
<ListItem>Copy and paste the generated token:</ListItem>
378378
<TextInput
379379
isRequired
380+
type="password"
380381
label="System User Token"
381382
defaultValue={initialToken}
382383
onChange={(val) => setToken(val.trim())}

0 commit comments

Comments
 (0)