-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
235 lines (199 loc) · 6.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
import { GetServerSideProps, GetStaticProps, GetStaticPaths } from 'next'
import ApolloClient from 'apollo-client'
import { NormalizedCacheObject } from 'apollo-cache-inmemory'
import SchemaLink from 'apollo-link-schema'
export type Config = {
common: {
timeFormatter: string
siteName: string
}
server: {
jwt: {
secret: string
}
repo: {
url: string
}
}
}
// Client
export type ServerRuntimeConfig = Config['server']
export type PublicRuntimeConfig = Omit<Config, 'server'>
export type SchemaContext =
| SchemaLink.ResolverContextFunction
| Record<string, any>
export type ParsedUrlQuery = Record<string, string | string[] | undefined>
export type StrDict<T = any> = Record<string, T>
export type ServerSideContext<P, Q extends ParsedUrlQuery> = Parameters<
GetServerSideProps<P, Q>
>[0]
export type StaticContext<P, Q extends ParsedUrlQuery> = Parameters<
GetStaticProps<P, Q>
>[0]
export type GetServerPropsWithApollo<P, Q extends ParsedUrlQuery> = (
context: ServerSideContext<P, Q>,
client: ApolloClient<NormalizedCacheObject>
) => ReturnType<GetServerSideProps<P, Q>>
export type GetStaticPropsWithApollo<P, Q extends ParsedUrlQuery> = (
context: StaticContext<P, Q>,
client: ApolloClient<NormalizedCacheObject>
) => ReturnType<GetStaticProps<P, Q>>
//Server
export interface ServerContext {}
export interface CommonListOptions {
offset?: number
limit?: number
}
export type ItemType<T extends any[]> = T extends Array<infer U> ? U : never
export interface PostEntity {
id: number
title: string
author?: UserEntity
updatedAt: Date
slug: string
}
export interface CategoryOrTagEntity {
id: number
slug: string
name: string
}
export interface UserEntity {
id: number
name?: string | null
email?: string | null
githubId?: number | string | null
bio?: string | null
}
// Type definitions for highlight.js v9.12
// Project: https://github.com/isagalaev/highlight.js
// Definitions by: Niklas Mollenhauer <https://github.com/nikeee>
// Jeremy Hull <https://github.com/sourrust>
// Josh Goldberg <https://github.com/joshuakgoldberg>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export namespace highlightjs {
// interface Node {}
export type highlight = (
name: string,
value: string,
ignore_illegals?: boolean,
continuation?: ICompiledMode
) => IHighlightResult
type highlightAuto = (
value: string,
languageSubset?: string[]
) => IAutoHighlightResult
// function fixMarkup(value: string): string
// export function highlightBlock(block: Node): void
// export function configure(options: IOptions): void
// export function initHighlighting(): void
// export function initHighlightingOnLoad(): void
export type registerLanguage = (
name: string,
language: (hljs?: HLJSStatic) => IModeBase
) => void
export type listLanguages = () => string[]
export type getLanguage = (name: string) => IMode
// export function inherit(parent: Object, obj: Object): Object
// export function COMMENT(
// begin: string | RegExp,
// end: string | RegExp,
// inherits: IModeBase
// ): IMode
// Common regexps
export var IDENT_RE: string
export var UNDERSCORE_IDENT_RE: string
export var NUMBER_RE: string
export var C_NUMBER_RE: string
export var BINARY_NUMBER_RE: string
export var RE_STARTERS_RE: string
// Common modes
export var BACKSLASH_ESCAPE: IMode
export var APOS_STRING_MODE: IMode
export var QUOTE_STRING_MODE: IMode
export var PHRASAL_WORDS_MODE: IMode
export var C_LINE_COMMENT_MODE: IMode
export var C_BLOCK_COMMENT_MODE: IMode
export var HASH_COMMENT_MODE: IMode
export var NUMBER_MODE: IMode
export var C_NUMBER_MODE: IMode
export var BINARY_NUMBER_MODE: IMode
export var CSS_NUMBER_MODE: IMode
export var REGEX_MODE: IMode
export var TITLE_MODE: IMode
export var UNDERSCORE_TITLE_MODE: IMode
export interface IHighlightResultBase {
relevance: number
language: string
value: string
}
export interface IAutoHighlightResult extends IHighlightResultBase {
second_best?: IAutoHighlightResult
}
export interface IHighlightResult extends IHighlightResultBase {
top: ICompiledMode
}
export interface HLJSStatic {
inherit(parent: Object, obj: Object): Object
// Common regexps
IDENT_RE: string
UNDERSCORE_IDENT_RE: string
NUMBER_RE: string
C_NUMBER_RE: string
BINARY_NUMBER_RE: string
RE_STARTERS_RE: string
// Common modes
BACKSLASH_ESCAPE: IMode
APOS_STRING_MODE: IMode
QUOTE_STRING_MODE: IMode
PHRASAL_WORDS_MODE: IMode
C_LINE_COMMENT_MODE: IMode
C_BLOCK_COMMENT_MODE: IMode
HASH_COMMENT_MODE: IMode
NUMBER_MODE: IMode
C_NUMBER_MODE: IMode
BINARY_NUMBER_MODE: IMode
CSS_NUMBER_MODE: IMode
REGEX_MODE: IMode
TITLE_MODE: IMode
UNDERSCORE_TITLE_MODE: IMode
}
// Reference:
// https://github.com/isagalaev/highlight.js/blob/master/docs/reference.rst
export interface IModeBase {
className?: string
aliases?: string[]
begin?: string | RegExp
end?: string | RegExp
case_insensitive?: boolean
beginKeyword?: string
endsWithParent?: boolean
lexems?: string
illegal?: string
excludeBegin?: boolean
excludeEnd?: boolean
returnBegin?: boolean
returnEnd?: boolean
starts?: string
subLanguage?: string
subLanguageMode?: string
relevance?: number
variants?: IMode[]
}
export interface IMode extends IModeBase {
keywords?: any
contains?: IMode[]
}
export interface ICompiledMode extends IModeBase {
compiled: boolean
contains?: ICompiledMode[]
keywords?: Object
terminators: RegExp
terminator_end?: string
}
export interface IOptions {
classPrefix?: string
tabReplace?: string
useBR?: boolean
languages?: string[]
}
}