-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathtypes.ts
89 lines (83 loc) · 2.28 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { QuestionCollection } from 'inquirer';
import { ConvenienceRenderer } from 'quicktype-core';
import { SegmentAPI } from '../api';
export interface TemplateContext {
version: string;
isDevelopment: boolean;
}
/**
* A Code Generator is a function that emits code into the render step of Quicktype.
*
* We use this to emit analytics code for each plataform
*/
export type CodeGenerator = (renderer: ConvenienceRenderer) => void;
/**
* Configuration for Typewriter Quicktype Renderers
*/
export interface QuicktypeTypewriterSettings {
/**
* Code Generators to execute for additional functions and code in the types output
*/
generators: CodeGenerator[];
typeNameModifiers?: {
prefix?: string;
suffix?: string;
};
}
export type GeneratorOptions = {
header?: string[];
outputFilename: string;
sdk: string;
prefixes?: {
functionName?: string;
typeName?: string;
};
suffixes?: {
functionName?: string;
typeName?: string;
};
} & Record<string, unknown>;
export type FileGenerateResult = ReadonlyMap<string, string>;
export interface LanguageGenerator {
/**
* Language ID
*/
id: string;
/**
* Language User-Friendly Name
*/
name: string;
/**
* File extension
*/
extension: string;
/**
* Required settings for the language generation.
* They are passed in an inquirer.js (https://github.com/SBoudrias/Inquirer.js) friendly version to be asked during configuration
*/
requiredOptions?: QuestionCollection;
/**
* Advanced Options for the language generation.
* They are passed in an inquirer.js (https://github.com/SBoudrias/Inquirer.js) friendly version to be asked during configuration
*/
advancedOptions?: QuestionCollection;
/**
* Key-value pairs of supported SDKs by the language generator.
* Key is the user friendly string
* Value is used in the configuration
*/
supportedSDKs: {
[key: string]: string;
};
/**
* Generates code from a set of Segment Protocol Rules
* @param rules Segment PublicAPI rules object
* @param options header, sdk and additional renderer options (optional)
* @returns generated code as string
*/
generate: (
rules: SegmentAPI.RuleMetadata[],
context: TemplateContext,
options: GeneratorOptions,
) => Promise<FileGenerateResult>;
}