kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: update tsconfig to use moduleResolution: "bundler"
rodzic
f56d358ffb
commit
5401db8e33
|
@ -3,25 +3,25 @@ import 'dotenv/config'
|
||||||
|
|
||||||
import restoreCursor from 'restore-cursor'
|
import restoreCursor from 'restore-cursor'
|
||||||
|
|
||||||
// import { SearxngClient } from '../src/services/searxng-client.js'
|
// import { SearxngClient } from '../src/services/searxng-client'
|
||||||
// import { ClearbitClient } from '../src/index.js'
|
// import { ClearbitClient } from '../src/index'
|
||||||
// import { ProxycurlClient } from '../src/services/proxycurl-client.js'
|
// import { ProxycurlClient } from '../src/services/proxycurl-client'
|
||||||
// import { WikipediaClient } from '../src/index.js'
|
// import { WikipediaClient } from '../src/index'
|
||||||
// import { PerigonClient } from '../src/index.js'
|
// import { PerigonClient } from '../src/index'
|
||||||
// import { FirecrawlClient } from '../src/index.js'
|
// import { FirecrawlClient } from '../src/index'
|
||||||
// import { ExaClient } from '../src/index.js'
|
// import { ExaClient } from '../src/index'
|
||||||
// import { DiffbotClient } from '../src/index.js'
|
// import { DiffbotClient } from '../src/index'
|
||||||
// import { WolframAlphaClient } from '../src/index.js'
|
// import { WolframAlphaClient } from '../src/index'
|
||||||
// import {
|
// import {
|
||||||
// createTwitterV2Client,
|
// createTwitterV2Client,
|
||||||
// TwitterClient
|
// TwitterClient
|
||||||
// } from '../src/services/twitter/index.js'
|
// } from '../src/services/twitter/index'
|
||||||
// import { MidjourneyClient } from '../src/index.js'
|
// import { MidjourneyClient } from '../src/index'
|
||||||
// import { BingClient } from '../src/index.js'
|
// import { BingClient } from '../src/index'
|
||||||
// import { TavilyClient } from '../src/index.js'
|
// import { TavilyClient } from '../src/index'
|
||||||
// import { SocialDataClient } from '../src/index.js'
|
// import { SocialDataClient } from '../src/index'
|
||||||
// import { HunterClient } from '../src/index.js'
|
// import { HunterClient } from '../src/index'
|
||||||
import { JinaClient } from '../src/index.js'
|
import { JinaClient } from '../src/index'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scratch pad for testing.
|
* Scratch pad for testing.
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { expect, test } from 'vitest'
|
import { expect, test } from 'vitest'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { AIFunctionSet } from './ai-function-set.js'
|
import { AIFunctionSet } from './ai-function-set'
|
||||||
import { aiFunction, AIFunctionsProvider } from './fns.js'
|
import { aiFunction, AIFunctionsProvider } from './fns'
|
||||||
import { calculator } from './tools/calculator.js'
|
import { calculator } from './tools/calculator'
|
||||||
|
|
||||||
class MockAITool extends AIFunctionsProvider {
|
class MockAITool extends AIFunctionsProvider {
|
||||||
@aiFunction({
|
@aiFunction({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type * as types from './types.ts'
|
import type * as types from './types.ts'
|
||||||
import { AIFunctionsProvider } from './fns.js'
|
import { AIFunctionsProvider } from './fns'
|
||||||
import { isAIFunction } from './utils.js'
|
import { isAIFunction } from './utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of AI functions intended to make it easier to work with large sets of
|
* A set of AI functions intended to make it easier to work with large sets of
|
||||||
|
|
|
@ -2,12 +2,12 @@ import type { SetOptional } from 'type-fest'
|
||||||
import type { z } from 'zod'
|
import type { z } from 'zod'
|
||||||
import pMap from 'p-map'
|
import pMap from 'p-map'
|
||||||
|
|
||||||
import type * as types from './types.js'
|
import type * as types from './types'
|
||||||
import { AIFunctionSet } from './ai-function-set.js'
|
import { AIFunctionSet } from './ai-function-set'
|
||||||
import { AbortError } from './errors.js'
|
import { AbortError } from './errors'
|
||||||
import { Msg } from './message.js'
|
import { Msg } from './message'
|
||||||
import { asSchema, augmentSystemMessageWithJsonSchema } from './schema.js'
|
import { asSchema, augmentSystemMessageWithJsonSchema } from './schema'
|
||||||
import { getErrorMessage } from './utils.js'
|
import { getErrorMessage } from './utils'
|
||||||
|
|
||||||
export type AIChainParams<Result extends types.AIChainResult = string> = {
|
export type AIChainParams<Result extends types.AIChainResult = string> = {
|
||||||
chatFn: types.ChatFn
|
chatFn: types.ChatFn
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { createAIFunction } from './create-ai-function.js'
|
import { createAIFunction } from './create-ai-function'
|
||||||
|
|
||||||
const fullName = createAIFunction(
|
const fullName = createAIFunction(
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import type { z } from 'zod'
|
import type { z } from 'zod'
|
||||||
|
|
||||||
import type * as types from './types.js'
|
import type * as types from './types'
|
||||||
import { parseStructuredOutput } from './parse-structured-output.js'
|
import { parseStructuredOutput } from './parse-structured-output'
|
||||||
import { assert } from './utils.js'
|
import { assert } from './utils'
|
||||||
import { zodToJsonSchema } from './zod-to-json-schema.js'
|
import { zodToJsonSchema } from './zod-to-json-schema'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a function meant to be used with OpenAI tool or function calling.
|
* Create a function meant to be used with OpenAI tool or function calling.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type * as types from './types.js'
|
import type * as types from './types'
|
||||||
import { type AIChainParams, createAIChain } from './create-ai-chain.js'
|
import { type AIChainParams, createAIChain } from './create-ai-chain'
|
||||||
|
|
||||||
export type ExtractObjectParams<Result extends types.AIChainResult = string> =
|
export type ExtractObjectParams<Result extends types.AIChainResult = string> =
|
||||||
types.Simplify<
|
types.Simplify<
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import type { z } from 'zod'
|
import type { z } from 'zod'
|
||||||
|
|
||||||
import type * as types from './types.js'
|
import type * as types from './types'
|
||||||
import { AIFunctionSet } from './ai-function-set.js'
|
import { AIFunctionSet } from './ai-function-set'
|
||||||
import { createAIFunction } from './create-ai-function.js'
|
import { createAIFunction } from './create-ai-function'
|
||||||
import { assert } from './utils.js'
|
import { assert } from './utils'
|
||||||
|
|
||||||
export interface PrivateAIFunctionMetadata {
|
export interface PrivateAIFunctionMetadata {
|
||||||
name: string
|
name: string
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
export * from './ai-function-set.js'
|
export * from './ai-function-set'
|
||||||
export * from './create-ai-chain.js'
|
export * from './create-ai-chain'
|
||||||
export * from './create-ai-function.js'
|
export * from './create-ai-function'
|
||||||
export * from './errors.js'
|
export * from './errors'
|
||||||
export * from './extract-object.js'
|
export * from './extract-object'
|
||||||
export * from './fns.js'
|
export * from './fns'
|
||||||
export * from './message.js'
|
export * from './message'
|
||||||
export * from './parse-structured-output.js'
|
export * from './parse-structured-output'
|
||||||
export * from './schema.js'
|
export * from './schema'
|
||||||
export * from './services/index.js'
|
export * from './services/index'
|
||||||
export * from './tools/search-and-crawl.js'
|
export * from './tools/search-and-crawl'
|
||||||
export type * from './types.js'
|
export type * from './types'
|
||||||
export * from './url-utils.js'
|
export * from './url-utils'
|
||||||
export * from './utils.js'
|
export * from './utils'
|
||||||
export * from './zod-to-json-schema.js'
|
export * from './zod-to-json-schema'
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import type * as OpenAI from 'openai-fetch'
|
import type * as OpenAI from 'openai-fetch'
|
||||||
import { describe, expect, expectTypeOf, it } from 'vitest'
|
import { describe, expect, expectTypeOf, it } from 'vitest'
|
||||||
|
|
||||||
import type * as types from './types.js'
|
import type * as types from './types'
|
||||||
import { Msg } from './message.js'
|
import { Msg } from './message'
|
||||||
|
|
||||||
describe('Msg', () => {
|
describe('Msg', () => {
|
||||||
it('creates a message and fixes indentation', () => {
|
it('creates a message and fixes indentation', () => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { Jsonifiable } from 'type-fest'
|
import type { Jsonifiable } from 'type-fest'
|
||||||
|
|
||||||
import { cleanStringForModel, stringifyForModel } from './utils.js'
|
import { cleanStringForModel, stringifyForModel } from './utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic/default OpenAI message without any narrowing applied.
|
* Generic/default OpenAI message without any narrowing applied.
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
parseNumberOutput,
|
parseNumberOutput,
|
||||||
parseObjectOutput,
|
parseObjectOutput,
|
||||||
parseStructuredOutput
|
parseStructuredOutput
|
||||||
} from './parse-structured-output.js'
|
} from './parse-structured-output'
|
||||||
|
|
||||||
test('extractJSONFromString should extract JSON object from string', () => {
|
test('extractJSONFromString should extract JSON object from string', () => {
|
||||||
let jsonStr = 'Some text {"name":"John Doe"} more text'
|
let jsonStr = 'Some text {"name":"John Doe"} more text'
|
||||||
|
|
|
@ -3,8 +3,8 @@ import { jsonrepair, JSONRepairError } from 'jsonrepair'
|
||||||
import { z, type ZodType } from 'zod'
|
import { z, type ZodType } from 'zod'
|
||||||
import { fromZodError } from 'zod-validation-error'
|
import { fromZodError } from 'zod-validation-error'
|
||||||
|
|
||||||
import { ParseError } from './errors.js'
|
import { ParseError } from './errors'
|
||||||
import { type SafeParseResult } from './types.js'
|
import { type SafeParseResult } from './types'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a string which is expected to contain a structured JSON value.
|
* Parses a string which is expected to contain a structured JSON value.
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import type { z } from 'zod'
|
import type { z } from 'zod'
|
||||||
|
|
||||||
import type * as types from './types.js'
|
import type * as types from './types'
|
||||||
import { safeParseStructuredOutput } from './parse-structured-output.js'
|
import { safeParseStructuredOutput } from './parse-structured-output'
|
||||||
import { stringifyForModel } from './utils.js'
|
import { stringifyForModel } from './utils'
|
||||||
import { zodToJsonSchema } from './zod-to-json-schema.js'
|
import { zodToJsonSchema } from './zod-to-json-schema'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to mark schemas so we can support both Zod and custom schemas.
|
* Used to mark schemas so we can support both Zod and custom schemas.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { tool } from 'ai'
|
import { tool } from 'ai'
|
||||||
|
|
||||||
import type { AIFunctionLike } from '../types.js'
|
import type { AIFunctionLike } from '../types'
|
||||||
import { AIFunctionSet } from '../ai-function-set.js'
|
import { AIFunctionSet } from '../ai-function-set'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a set of Agentic stdlib AI functions to an object compatible with
|
* Converts a set of Agentic stdlib AI functions to an object compatible with
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { createAIFunction } from '@dexaai/dexter'
|
import { createAIFunction } from '@dexaai/dexter'
|
||||||
|
|
||||||
import type { AIFunctionLike } from '../types.js'
|
import type { AIFunctionLike } from '../types'
|
||||||
import { AIFunctionSet } from '../ai-function-set.js'
|
import { AIFunctionSet } from '../ai-function-set'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a set of Agentic stdlib AI functions to an array of Dexter-
|
* Converts a set of Agentic stdlib AI functions to an array of Dexter-
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { defineTool } from '@genkit-ai/ai'
|
import { defineTool } from '@genkit-ai/ai'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import type { AIFunctionLike } from '../types.js'
|
import type { AIFunctionLike } from '../types'
|
||||||
import { AIFunctionSet } from '../ai-function-set.js'
|
import { AIFunctionSet } from '../ai-function-set'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a set of Agentic stdlib AI functions to an array of Genkit-
|
* Converts a set of Agentic stdlib AI functions to an array of Genkit-
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { DynamicStructuredTool } from '@langchain/core/tools'
|
import { DynamicStructuredTool } from '@langchain/core/tools'
|
||||||
|
|
||||||
import type { AIFunctionLike } from '../types.js'
|
import type { AIFunctionLike } from '../types'
|
||||||
import { AIFunctionSet } from '../ai-function-set.js'
|
import { AIFunctionSet } from '../ai-function-set'
|
||||||
import { stringifyForModel } from '../utils.js'
|
import { stringifyForModel } from '../utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a set of Agentic stdlib AI functions to an array of LangChain-
|
* Converts a set of Agentic stdlib AI functions to an array of LangChain-
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { FunctionTool } from 'llamaindex'
|
import { FunctionTool } from 'llamaindex'
|
||||||
|
|
||||||
import type { AIFunctionLike } from '../types.js'
|
import type { AIFunctionLike } from '../types'
|
||||||
import { AIFunctionSet } from '../ai-function-set.js'
|
import { AIFunctionSet } from '../ai-function-set'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a set of Agentic stdlib AI functions to an array of LlamaIndex-
|
* Converts a set of Agentic stdlib AI functions to an array of LlamaIndex-
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, omit } from '../utils.js'
|
import { assert, getEnv, omit } from '../utils'
|
||||||
|
|
||||||
export namespace bing {
|
export namespace bing {
|
||||||
export const API_BASE_URL = 'https://api.bing.microsoft.com'
|
export const API_BASE_URL = 'https://api.bing.microsoft.com'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import defaultKy from 'ky'
|
import defaultKy from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
|
|
||||||
import type { KyInstance } from '../types.js'
|
import type { KyInstance } from '../types'
|
||||||
import {
|
import {
|
||||||
assert,
|
assert,
|
||||||
delay,
|
delay,
|
||||||
|
@ -9,7 +9,7 @@ import {
|
||||||
pruneNullOrUndefinedDeep,
|
pruneNullOrUndefinedDeep,
|
||||||
sanitizeSearchParams,
|
sanitizeSearchParams,
|
||||||
throttleKy
|
throttleKy
|
||||||
} from '../utils.js'
|
} from '../utils'
|
||||||
|
|
||||||
export namespace clearbit {
|
export namespace clearbit {
|
||||||
// Allow up to 600 requests per minute by default.
|
// Allow up to 600 requests per minute by default.
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { Msg } from '../message.js'
|
import { Msg } from '../message'
|
||||||
import { assert, getEnv } from '../utils.js'
|
import { assert, getEnv } from '../utils'
|
||||||
|
|
||||||
export namespace dexa {
|
export namespace dexa {
|
||||||
export const AskDexaOptionsSchema = z.object({
|
export const AskDexaOptionsSchema = z.object({
|
||||||
|
|
|
@ -2,8 +2,8 @@ import defaultKy, { type KyInstance } from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils.js'
|
import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils'
|
||||||
|
|
||||||
export namespace diffbot {
|
export namespace diffbot {
|
||||||
export const API_BASE_URL = 'https://api.diffbot.com'
|
export const API_BASE_URL = 'https://api.diffbot.com'
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, pruneUndefined } from '../utils.js'
|
import { assert, getEnv, pruneUndefined } from '../utils'
|
||||||
|
|
||||||
export namespace exa {
|
export namespace exa {
|
||||||
export const TextContentsOptionsSchema = z.object({
|
export const TextContentsOptionsSchema = z.object({
|
||||||
|
|
|
@ -2,10 +2,10 @@ import defaultKy, { type KyInstance } from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
import z from 'zod'
|
import z from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { isZodSchema } from '../schema.js'
|
import { isZodSchema } from '../schema'
|
||||||
import { assert, delay, getEnv, throttleKy } from '../utils.js'
|
import { assert, delay, getEnv, throttleKy } from '../utils'
|
||||||
import { zodToJsonSchema } from '../zod-to-json-schema.js'
|
import { zodToJsonSchema } from '../zod-to-json-schema'
|
||||||
|
|
||||||
export namespace firecrawl {
|
export namespace firecrawl {
|
||||||
export const BASE_URL = 'https://api.firecrawl.dev'
|
export const BASE_URL = 'https://api.firecrawl.dev'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Octokit } from 'octokit'
|
import { Octokit } from 'octokit'
|
||||||
|
|
||||||
import { AIFunctionsProvider } from '../fns.js'
|
import { AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv } from '../utils.js'
|
import { assert, getEnv } from '../utils'
|
||||||
|
|
||||||
export namespace github {
|
export namespace github {
|
||||||
export interface User {
|
export interface User {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
|
|
||||||
import { AIFunctionsProvider } from '../fns.js'
|
import { AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv } from '../utils.js'
|
import { assert, getEnv } from '../utils'
|
||||||
|
|
||||||
export namespace hackernews {
|
export namespace hackernews {
|
||||||
export type ItemType =
|
export type ItemType =
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import {
|
import {
|
||||||
assert,
|
assert,
|
||||||
getEnv,
|
getEnv,
|
||||||
pruneNullOrUndefinedDeep,
|
pruneNullOrUndefinedDeep,
|
||||||
sanitizeSearchParams
|
sanitizeSearchParams
|
||||||
} from '../utils.js'
|
} from '../utils'
|
||||||
|
|
||||||
export namespace hunter {
|
export namespace hunter {
|
||||||
export const API_BASE_URL = 'https://api.hunter.io'
|
export const API_BASE_URL = 'https://api.hunter.io'
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
export * from './bing-client.js'
|
export * from './bing-client'
|
||||||
export * from './clearbit-client.js'
|
export * from './clearbit-client'
|
||||||
export * from './dexa-client.js'
|
export * from './dexa-client'
|
||||||
export * from './diffbot-client.js'
|
export * from './diffbot-client'
|
||||||
export * from './exa-client.js'
|
export * from './exa-client'
|
||||||
export * from './firecrawl-client.js'
|
export * from './firecrawl-client'
|
||||||
export * from './github-client.js'
|
export * from './github-client'
|
||||||
export * from './hacker-news-client.js'
|
export * from './hacker-news-client'
|
||||||
export * from './hunter-client.js'
|
export * from './hunter-client'
|
||||||
export * from './jina-client.js'
|
export * from './jina-client'
|
||||||
export * from './midjourney-client.js'
|
export * from './midjourney-client'
|
||||||
export * from './novu-client.js'
|
export * from './novu-client'
|
||||||
export * from './people-data-labs-client.js'
|
export * from './people-data-labs-client'
|
||||||
export * from './perigon-client.js'
|
export * from './perigon-client'
|
||||||
export * from './polygon-client.js'
|
export * from './polygon-client'
|
||||||
export * from './predict-leads-client.js'
|
export * from './predict-leads-client'
|
||||||
export * from './proxycurl-client.js'
|
export * from './proxycurl-client'
|
||||||
export * from './scraper-client.js'
|
export * from './scraper-client'
|
||||||
export * from './searxng-client.js'
|
export * from './searxng-client'
|
||||||
export * from './serpapi-client.js'
|
export * from './serpapi-client'
|
||||||
export * from './serper-client.js'
|
export * from './serper-client'
|
||||||
export * from './slack-client.js'
|
export * from './slack-client'
|
||||||
export * from './social-data-client.js'
|
export * from './social-data-client'
|
||||||
export * from './tavily-client.js'
|
export * from './tavily-client'
|
||||||
export * from './twilio-client.js'
|
export * from './twilio-client'
|
||||||
export * from './weather-client.js'
|
export * from './weather-client'
|
||||||
export * from './wikipedia-client.js'
|
export * from './wikipedia-client'
|
||||||
export * from './wolfram-alpha-client.js'
|
export * from './wolfram-alpha-client'
|
||||||
|
|
|
@ -2,8 +2,8 @@ import defaultKy, { type KyInstance } from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { getEnv, pruneNullOrUndefined, throttleKy } from '../utils.js'
|
import { getEnv, pruneNullOrUndefined, throttleKy } from '../utils'
|
||||||
|
|
||||||
export namespace jina {
|
export namespace jina {
|
||||||
export const ReaderFormatSchema = z.enum([
|
export const ReaderFormatSchema = z.enum([
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { TimeoutError } from '../errors.js'
|
import { TimeoutError } from '../errors'
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, delay, getEnv, pruneNullOrUndefined } from '../utils.js'
|
import { assert, delay, getEnv, pruneNullOrUndefined } from '../utils'
|
||||||
|
|
||||||
// TODO: add additional methods for upscaling, variations, etc.
|
// TODO: add additional methods for upscaling, variations, etc.
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv } from '../utils.js'
|
import { assert, getEnv } from '../utils'
|
||||||
|
|
||||||
export namespace novu {
|
export namespace novu {
|
||||||
export const API_BASE_URL = 'https://api.novu.co/v1'
|
export const API_BASE_URL = 'https://api.novu.co/v1'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
|
|
||||||
import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils.js'
|
import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: I'm holding off on converting this client to an `AIFunctionsProvider`
|
* TODO: I'm holding off on converting this client to an `AIFunctionsProvider`
|
||||||
|
|
|
@ -2,8 +2,8 @@ import defaultKy, { type KyInstance } from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils.js'
|
import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils'
|
||||||
|
|
||||||
// TODO: https://docs.goperigon.com/docs/searching-sources
|
// TODO: https://docs.goperigon.com/docs/searching-sources
|
||||||
// TODO: https://docs.goperigon.com/docs/journalist-data
|
// TODO: https://docs.goperigon.com/docs/journalist-data
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
|
|
||||||
import { AIFunctionsProvider } from '../fns.js'
|
import { AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv } from '../utils.js'
|
import { assert, getEnv } from '../utils'
|
||||||
|
|
||||||
// TODO: add aiFunction decorator to select methods
|
// TODO: add aiFunction decorator to select methods
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,15 @@ import defaultKy, { type KyInstance } from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import type { DeepNullable } from '../types.js'
|
import type { DeepNullable } from '../types'
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import {
|
import {
|
||||||
assert,
|
assert,
|
||||||
getEnv,
|
getEnv,
|
||||||
pruneUndefined,
|
pruneUndefined,
|
||||||
sanitizeSearchParams,
|
sanitizeSearchParams,
|
||||||
throttleKy
|
throttleKy
|
||||||
} from '../utils.js'
|
} from '../utils'
|
||||||
|
|
||||||
// TODO: improve `domain` validation for fast-fail
|
// TODO: improve `domain` validation for fast-fail
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ import defaultKy, { type KyInstance } from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils.js'
|
import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils'
|
||||||
|
|
||||||
// All proxycurl types are auto-generated from their openapi spec
|
// All proxycurl types are auto-generated from their openapi spec
|
||||||
export namespace proxycurl {
|
export namespace proxycurl {
|
||||||
|
|
|
@ -2,8 +2,8 @@ import defaultKy, { type KyInstance } from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, omit, throttleKy } from '../utils.js'
|
import { assert, getEnv, omit, throttleKy } from '../utils'
|
||||||
|
|
||||||
export namespace scraper {
|
export namespace scraper {
|
||||||
// Allow up to 1 request per second by default.
|
// Allow up to 1 request per second by default.
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, omit, pick, pruneUndefined } from '../utils.js'
|
import { assert, getEnv, omit, pick, pruneUndefined } from '../utils'
|
||||||
|
|
||||||
export namespace searxng {
|
export namespace searxng {
|
||||||
export const SearchCategorySchema = z.enum([
|
export const SearchCategorySchema = z.enum([
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv } from '../utils.js'
|
import { assert, getEnv } from '../utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All types have been exported from the `serpapi` package, which we're
|
* All types have been exported from the `serpapi` package, which we're
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, omit } from '../utils.js'
|
import { assert, getEnv, omit } from '../utils'
|
||||||
|
|
||||||
export namespace serper {
|
export namespace serper {
|
||||||
export const API_BASE_URL = 'https://google.serper.dev'
|
export const API_BASE_URL = 'https://google.serper.dev'
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { TimeoutError } from '../errors.js'
|
import { TimeoutError } from '../errors'
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, delay, getEnv } from '../utils.js'
|
import { assert, delay, getEnv } from '../utils'
|
||||||
|
|
||||||
// TODO: need to expose more aiFunctions
|
// TODO: need to expose more aiFunctions
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
|
|
||||||
import { AIFunctionsProvider } from '../fns.js'
|
import { AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils.js'
|
import { assert, getEnv, sanitizeSearchParams, throttleKy } from '../utils'
|
||||||
|
|
||||||
// TODO: need to add `aiFunction` wrappers for each method
|
// TODO: need to add `aiFunction` wrappers for each method
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ import defaultKy, { type KyInstance } from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, pruneNullOrUndefined, throttleKy } from '../utils.js'
|
import { assert, getEnv, pruneNullOrUndefined, throttleKy } from '../utils'
|
||||||
|
|
||||||
export namespace tavily {
|
export namespace tavily {
|
||||||
export const API_BASE_URL = 'https://api.tavily.com'
|
export const API_BASE_URL = 'https://api.tavily.com'
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { TimeoutError } from '../errors.js'
|
import { TimeoutError } from '../errors'
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, delay, getEnv } from '../utils.js'
|
import { assert, delay, getEnv } from '../utils'
|
||||||
|
|
||||||
export namespace twilio {
|
export namespace twilio {
|
||||||
export const CONVERSATION_API_BASE_URL = 'https://conversations.twilio.com/v1'
|
export const CONVERSATION_API_BASE_URL = 'https://conversations.twilio.com/v1'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { auth, Client as TwitterV2Client } from 'twitter-api-sdk'
|
import { auth, Client as TwitterV2Client } from 'twitter-api-sdk'
|
||||||
|
|
||||||
import { assert, getEnv } from '../../utils.js'
|
import { assert, getEnv } from '../../utils'
|
||||||
import { getNango, validateNangoConnectionOAuthScopes } from './nango.js'
|
import { getNango, validateNangoConnectionOAuthScopes } from './nango'
|
||||||
|
|
||||||
// Auth new Nango accounts here: https://app.nango.dev/connections
|
// Auth new Nango accounts here: https://app.nango.dev/connections
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export * from './client.js'
|
export * from './client'
|
||||||
export * from './error.js'
|
export * from './error'
|
||||||
export * from './nango.js'
|
export * from './nango'
|
||||||
export * from './twitter-client.js'
|
export * from './twitter-client'
|
||||||
export type * from './types.js'
|
export type * from './types'
|
||||||
export * from './utils.js'
|
export * from './utils'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { type Connection, Nango } from '@nangohq/node'
|
import { type Connection, Nango } from '@nangohq/node'
|
||||||
|
|
||||||
import { getEnv } from '../../utils.js'
|
import { getEnv } from '../../utils'
|
||||||
|
|
||||||
// This is intentionally left as a global singleton to avoid re-creating the
|
// This is intentionally left as a global singleton to avoid re-creating the
|
||||||
// Nango connection instance on successive calls in serverless environments.
|
// Nango connection instance on successive calls in serverless environments.
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import type * as types from './types.js'
|
import type * as types from './types'
|
||||||
import { aiFunction, AIFunctionsProvider } from '../../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../../fns'
|
||||||
import { assert, getEnv } from '../../utils.js'
|
import { assert, getEnv } from '../../utils'
|
||||||
import { handleKnownTwitterErrors } from './utils.js'
|
import { handleKnownTwitterErrors } from './utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file contains rate-limited wrappers around all of the core Twitter API
|
* This file contains rate-limited wrappers around all of the core Twitter API
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type * as types from './types.js'
|
import type * as types from './types'
|
||||||
import { omit } from '../../utils.js'
|
import { omit } from '../../utils'
|
||||||
import { TwitterError } from './error.js'
|
import { TwitterError } from './error'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error handler which takes in an unknown Error object and converts it to a
|
* Error handler which takes in an unknown Error object and converts it to a
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, sanitizeSearchParams } from '../utils.js'
|
import { assert, getEnv, sanitizeSearchParams } from '../utils'
|
||||||
|
|
||||||
export namespace weatherapi {
|
export namespace weatherapi {
|
||||||
export const BASE_URL = 'https://api.weatherapi.com/v1'
|
export const BASE_URL = 'https://api.weatherapi.com/v1'
|
||||||
|
|
|
@ -2,8 +2,8 @@ import defaultKy, { type KyInstance } from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, throttleKy } from '../utils.js'
|
import { assert, getEnv, throttleKy } from '../utils'
|
||||||
|
|
||||||
export namespace wikipedia {
|
export namespace wikipedia {
|
||||||
// Allow up to 200 requests per second by default.
|
// Allow up to 200 requests per second by default.
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import defaultKy, { type KyInstance } from 'ky'
|
import defaultKy, { type KyInstance } from 'ky'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { assert, getEnv, sanitizeSearchParams } from '../utils.js'
|
import { assert, getEnv, sanitizeSearchParams } from '../utils'
|
||||||
|
|
||||||
export namespace wolframalpha {
|
export namespace wolframalpha {
|
||||||
export const API_BASE_URL = 'https://www.wolframalpha.com/api/'
|
export const API_BASE_URL = 'https://www.wolframalpha.com/api/'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { evaluate } from 'mathjs'
|
import { evaluate } from 'mathjs'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { createAIFunction } from '../create-ai-function.js'
|
import { createAIFunction } from '../create-ai-function'
|
||||||
|
|
||||||
// TODO: ensure `expr` is sanitized to not run arbitrary code
|
// TODO: ensure `expr` is sanitized to not run arbitrary code
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { CodeInterpreter, type ProcessMessage } from '@e2b/code-interpreter'
|
import { CodeInterpreter, type ProcessMessage } from '@e2b/code-interpreter'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { createAIFunction } from '../create-ai-function.js'
|
import { createAIFunction } from '../create-ai-function'
|
||||||
import { getEnv } from '../utils.js'
|
import { getEnv } from '../utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* E2B Python code interpreter sandbox.
|
* E2B Python code interpreter sandbox.
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import pMap from 'p-map'
|
import pMap from 'p-map'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
import { aiFunction, AIFunctionsProvider } from '../fns'
|
||||||
import { type diffbot, DiffbotClient } from '../services/diffbot-client.js'
|
import { type diffbot, DiffbotClient } from '../services/diffbot-client'
|
||||||
import { SerpAPIClient } from '../services/serpapi-client.js'
|
import { SerpAPIClient } from '../services/serpapi-client'
|
||||||
import { isValidCrawlableUrl, normalizeUrl } from '../url-utils.js'
|
import { isValidCrawlableUrl, normalizeUrl } from '../url-utils'
|
||||||
import { omit, pick } from '../utils.js'
|
import { omit, pick } from '../utils'
|
||||||
|
|
||||||
// TODO: allow `search` tool to support other search clients
|
// TODO: allow `search` tool to support other search clients
|
||||||
// (e.g. Bing, Exa, Searxng, Serper, Tavily)
|
// (e.g. Bing, Exa, Searxng, Serper, Tavily)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import type { Jsonifiable, SetOptional, Simplify } from 'type-fest'
|
import type { Jsonifiable, SetOptional, Simplify } from 'type-fest'
|
||||||
import type { z } from 'zod'
|
import type { z } from 'zod'
|
||||||
|
|
||||||
import type { AIFunctionSet } from './ai-function-set.js'
|
import type { AIFunctionSet } from './ai-function-set'
|
||||||
import type { AIFunctionsProvider } from './fns.js'
|
import type { AIFunctionsProvider } from './fns'
|
||||||
import type { Msg } from './message.js'
|
import type { Msg } from './message'
|
||||||
|
|
||||||
export type { Msg } from './message.js'
|
export type { Msg } from './message'
|
||||||
export type { Schema } from './schema.js'
|
export type { Schema } from './schema'
|
||||||
export type { KyInstance } from 'ky'
|
export type { KyInstance } from 'ky'
|
||||||
export type { ThrottledFunction } from 'p-throttle'
|
export type { ThrottledFunction } from 'p-throttle'
|
||||||
export type { SetRequired, Simplify } from 'type-fest'
|
export type { SetRequired, Simplify } from 'type-fest'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { describe, expect, test } from 'vitest'
|
import { describe, expect, test } from 'vitest'
|
||||||
|
|
||||||
import { normalizeUrl } from './url-utils.js'
|
import { normalizeUrl } from './url-utils'
|
||||||
|
|
||||||
describe('normalizeUrl', () => {
|
describe('normalizeUrl', () => {
|
||||||
test('valid urls', async () => {
|
test('valid urls', async () => {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import normalizeUrlImpl, {
|
||||||
} from 'normalize-url'
|
} from 'normalize-url'
|
||||||
import QuickLRU from 'quick-lru'
|
import QuickLRU from 'quick-lru'
|
||||||
|
|
||||||
import { hashObject } from './utils.js'
|
import { hashObject } from './utils'
|
||||||
|
|
||||||
const protocolAllowList = new Set(['https:', 'http:'])
|
const protocolAllowList = new Set(['https:', 'http:'])
|
||||||
const normalizedUrlCache = new QuickLRU<string, string>({
|
const normalizedUrlCache = new QuickLRU<string, string>({
|
||||||
|
|
|
@ -2,14 +2,14 @@ import ky from 'ky'
|
||||||
import pThrottle from 'p-throttle'
|
import pThrottle from 'p-throttle'
|
||||||
import { describe, expect, test } from 'vitest'
|
import { describe, expect, test } from 'vitest'
|
||||||
|
|
||||||
import { mockKyInstance } from './_utils.js'
|
import { mockKyInstance } from './_utils'
|
||||||
import {
|
import {
|
||||||
omit,
|
omit,
|
||||||
pick,
|
pick,
|
||||||
sanitizeSearchParams,
|
sanitizeSearchParams,
|
||||||
stringifyForModel,
|
stringifyForModel,
|
||||||
throttleKy
|
throttleKy
|
||||||
} from './utils.js'
|
} from './utils'
|
||||||
|
|
||||||
test('pick', () => {
|
test('pick', () => {
|
||||||
expect(pick({ a: 1, b: 2, c: 3 }, 'a', 'c')).toEqual({ a: 1, c: 3 })
|
expect(pick({ a: 1, b: 2, c: 3 }, 'a', 'c')).toEqual({ a: 1, c: 3 })
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import dedent from 'dedent'
|
import dedent from 'dedent'
|
||||||
import hashObjectImpl, { type Options as HashObjectOptions } from 'hash-object'
|
import hashObjectImpl, { type Options as HashObjectOptions } from 'hash-object'
|
||||||
|
|
||||||
import type * as types from './types.js'
|
import type * as types from './types'
|
||||||
|
|
||||||
export { assert } from './assert.js'
|
export { assert } from './assert'
|
||||||
export { default as delay } from 'delay'
|
export { default as delay } from 'delay'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { zodToJsonSchema } from './zod-to-json-schema.js'
|
import { zodToJsonSchema } from './zod-to-json-schema'
|
||||||
|
|
||||||
describe('zodToJsonSchema', () => {
|
describe('zodToJsonSchema', () => {
|
||||||
it('handles basic objects', () => {
|
it('handles basic objects', () => {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import type { z } from 'zod'
|
import type { z } from 'zod'
|
||||||
import { zodToJsonSchema as zodToJsonSchemaImpl } from 'zod-to-json-schema'
|
import { zodToJsonSchema as zodToJsonSchemaImpl } from 'zod-to-json-schema'
|
||||||
|
|
||||||
import type * as types from './types.js'
|
import type * as types from './types'
|
||||||
import { omit } from './utils.js'
|
import { omit } from './utils'
|
||||||
|
|
||||||
/** Generate a JSON Schema from a Zod schema. */
|
/** Generate a JSON Schema from a Zod schema. */
|
||||||
export function zodToJsonSchema(schema: z.ZodType): types.JSONSchema {
|
export function zodToJsonSchema(schema: z.ZodType): types.JSONSchema {
|
||||||
|
|
|
@ -1,29 +1,31 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2020",
|
"lib": ["esnext", "dom.iterable"],
|
||||||
"lib": ["ESNext"],
|
"module": "esnext",
|
||||||
"esModuleInterop": true,
|
"moduleResolution": "bundler",
|
||||||
"skipLibCheck": true,
|
|
||||||
"verbatimModuleSyntax": true,
|
|
||||||
"allowJs": true,
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"moduleDetection": "force",
|
"moduleDetection": "force",
|
||||||
|
"noEmit": true,
|
||||||
|
"target": "es2020",
|
||||||
|
"outDir": "dist",
|
||||||
|
|
||||||
|
"allowImportingTsExtensions": false,
|
||||||
|
"allowJs": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"incremental": false,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"useDefineForClassFields": true,
|
|
||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
|
"noUncheckedIndexedAccess": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"strict": true,
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"verbatimModuleSyntax": true
|
||||||
|
|
||||||
// NOTE: these are deprecated
|
// NOTE: these are deprecated
|
||||||
// "experimentalDecorators": true,
|
// "experimentalDecorators": true,
|
||||||
// "emitDecoratorMetadata": true,
|
// "emitDecoratorMetadata": true,
|
||||||
|
|
||||||
"strict": true,
|
|
||||||
"noUncheckedIndexedAccess": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
|
|
||||||
"module": "NodeNext",
|
|
||||||
"moduleResolution": "NodeNext",
|
|
||||||
"outDir": "dist",
|
|
||||||
"sourceMap": true
|
|
||||||
},
|
},
|
||||||
"include": ["src"]
|
"include": ["src"]
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue