2
0

♻️ Migrate from got to ky (#1416)

Closes #1415
This commit is contained in:
Baptiste Arnaud
2024-04-05 09:01:16 +02:00
committed by GitHub
parent ccc7101dd3
commit d96f384e02
59 changed files with 990 additions and 628 deletions

View File

@ -1,7 +1,7 @@
import { createAction, option } from '@typebot.io/forge'
import { isDefined } from '@typebot.io/lib'
import { ZemanticAiResponse } from '../types'
import { got } from 'got'
import ky from 'ky'
import { apiBaseUrl } from '../constants'
import { auth } from '../auth'
import { baseOptions } from '../baseOptions'
@ -63,7 +63,7 @@ export const searchDocuments = createAction({
},
variables,
}) => {
const res: ZemanticAiResponse = await got
const res = await ky
.post(apiBaseUrl, {
headers: {
Authorization: `Bearer ${apiKey}`,
@ -79,7 +79,7 @@ export const searchDocuments = createAction({
},
},
})
.json()
.json<ZemanticAiResponse>()
responseMapping?.forEach((mapping) => {
if (!mapping.variableId || !mapping.item) return

View File

@ -8,6 +8,7 @@ export const auth = {
label: 'API key',
isRequired: true,
placeholder: 'ze...',
inputType: 'password',
helperText:
'You can generate an API key [here](https://zemantic.ai/dashboard/settings).',
isDebounceDisabled: true,

View File

@ -1,6 +1,6 @@
import { createBlock } from '@typebot.io/forge'
import { ZemanticAiLogo } from './logo'
import { got } from 'got'
import ky from 'ky'
import { searchDocuments } from './actions/searchDocuments'
import { auth } from './auth'
import { baseOptions } from './baseOptions'
@ -19,7 +19,7 @@ export const zemanticAiBlock = createBlock({
fetch: async ({ credentials: { apiKey } }) => {
const url = 'https://api.zemantic.ai/v1/projects'
const response = await got
const response = await ky
.get(url, {
headers: {
Authorization: `Bearer ${apiKey}`,

View File

@ -11,6 +11,6 @@
"@types/react": "18.2.15",
"typescript": "5.3.2",
"@typebot.io/lib": "workspace:*",
"got": "12.6.0"
"ky": "1.2.3"
}
}