UNPKG

1.58 kBPlain TextView Raw
1import doctrine from 'doctrine'
2import * as TS from 'ts-morph'
3import * as TJS from 'typescript-json-schema'
4
5/**
6 * Core FTS function definition that fully specifies the configuration, parameters,
7 * and return type for an FTS function.
8 */
9export interface Definition {
10 /** Name of the function */
11 title: string
12
13 /** Brief description of the function */
14 description?: string
15
16 /** Language and runtime-specific information */
17 config: Config
18
19 /** FTS version that generated this definition */
20 version: string
21
22 params: {
23 /** JSON Schema describing the function parameters */
24 schema: TJS.Definition
25
26 /** Ordering of the function parameters */
27 order: string[]
28
29 /** Whether or not the function takes in a context parameter */
30 context: boolean
31 }
32
33 returns: {
34 /** JSON Schema describing the function return type */
35 schema: TJS.Definition
36
37 /** Whether or not the function returns an async Promise */
38 async: boolean
39
40 /** Enables a fallback to disable type-checking for raw HTTP responses */
41 http: boolean
42 }
43}
44
45export interface Config {
46 language: string
47 defaultExport: boolean
48 namedExport?: string
49}
50
51export interface DefinitionOptions {
52 emit?: boolean
53 emitOptions?: TS.EmitOptions
54 compilerOptions?: TS.CompilerOptions
55 jsonSchemaOptions?: TJS.PartialArgs
56}
57
58export type PartialDefinitionOptions = Partial<DefinitionOptions>
59
60export interface DefinitionBuilder {
61 sourceFile: TS.SourceFile
62 main: TS.FunctionDeclaration
63 docs?: doctrine.Annotation
64 title: string
65 definition: Partial<Definition>
66}