@grom.js/bot-api-spec 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/format.d.ts +149 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +2 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +3 -601
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -21765
- package/dist/index.js.map +1 -0
- package/dist/methods.gen.d.ts +175 -0
- package/dist/methods.gen.d.ts.map +1 -0
- package/dist/methods.gen.js +12380 -0
- package/dist/methods.gen.js.map +1 -0
- package/dist/types.gen.d.ts +293 -0
- package/dist/types.gen.d.ts.map +1 -0
- package/dist/types.gen.js +19804 -0
- package/dist/types.gen.js.map +1 -0
- package/package.json +30 -21
- package/src/format.ts +188 -0
- package/src/index.ts +2 -0
- package/src/methods.gen.ts +12544 -0
- package/src/types.gen.ts +20087 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grom.js/bot-api-spec",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"description": "Telegram Bot API specification as a collection of JavaScript objects in a custom format.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -12,32 +12,41 @@
|
|
|
12
12
|
".": {
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
14
|
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./format": {
|
|
17
|
+
"types": "./dist/format.d.ts",
|
|
18
|
+
"import": "./dist/format.js"
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
"files": [
|
|
18
|
-
"dist/"
|
|
22
|
+
"./dist/",
|
|
23
|
+
"./src/"
|
|
19
24
|
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=22.18"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@antfu/eslint-config": "7.0.1",
|
|
30
|
+
"@types/node": "22.19.7",
|
|
31
|
+
"@types/turndown": "5.0.6",
|
|
32
|
+
"bumpp": "10.4.0",
|
|
33
|
+
"cheerio": "1.1.2",
|
|
34
|
+
"domhandler": "5.0.3",
|
|
35
|
+
"eslint": "9.39.2",
|
|
36
|
+
"eslint-plugin-format": "1.3.1",
|
|
37
|
+
"taze": "19.9.2",
|
|
38
|
+
"turndown": "7.2.2",
|
|
39
|
+
"typescript": "5.9.3",
|
|
40
|
+
"zod": "4.3.5"
|
|
41
|
+
},
|
|
20
42
|
"scripts": {
|
|
21
|
-
"typecheck": "tsc",
|
|
22
|
-
"build": "
|
|
43
|
+
"typecheck": "tsc --build --noEmit",
|
|
44
|
+
"build": "tsc --build",
|
|
23
45
|
"lint": "eslint .",
|
|
24
46
|
"lint:fix": "eslint . --fix",
|
|
25
|
-
"gen:spec": "
|
|
26
|
-
"gen:return-types": "
|
|
47
|
+
"gen:spec": "node ./scripts/gen.ts",
|
|
48
|
+
"gen:return-types": "node --env-file=./.env ./scripts/gen-return-types.ts",
|
|
49
|
+
"deps": "taze --write --interactive --include-locked minor",
|
|
27
50
|
"release": "bumpp"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"@antfu/eslint-config": "^5.4.1",
|
|
31
|
-
"@types/bun": "^1.2.22",
|
|
32
|
-
"@types/turndown": "^5.0.5",
|
|
33
|
-
"bumpp": "^10.2.3",
|
|
34
|
-
"cheerio": "^1.1.2",
|
|
35
|
-
"domhandler": "^5.0.3",
|
|
36
|
-
"eslint": "^9.36.0",
|
|
37
|
-
"eslint-plugin-format": "^1.0.1",
|
|
38
|
-
"tsdown": "^0.15.5",
|
|
39
|
-
"turndown": "^7.2.1",
|
|
40
|
-
"typescript": "^5.9.2",
|
|
41
|
-
"zod": "^4.1.11"
|
|
42
51
|
}
|
|
43
|
-
}
|
|
52
|
+
}
|
package/src/format.ts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { types } from './types.gen.ts'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type defined in the API. It can either be an {@link ApiTypeObject object}
|
|
5
|
+
* or a {@link ApiTypeOneOf union}.
|
|
6
|
+
*/
|
|
7
|
+
export type ApiType
|
|
8
|
+
= | ApiTypeObject
|
|
9
|
+
| ApiTypeOneOf
|
|
10
|
+
|
|
11
|
+
export interface ApiTypeObject {
|
|
12
|
+
/**
|
|
13
|
+
* Name of the type.
|
|
14
|
+
*/
|
|
15
|
+
name: string
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Description of the type.
|
|
19
|
+
*/
|
|
20
|
+
description: Description
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Fields of the object representing this type.
|
|
24
|
+
*/
|
|
25
|
+
fields: Array<FieldOrParam>
|
|
26
|
+
|
|
27
|
+
oneOf?: never
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ApiTypeOneOf {
|
|
31
|
+
/**
|
|
32
|
+
* Name of the type.
|
|
33
|
+
*/
|
|
34
|
+
name: string
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Description of the type.
|
|
38
|
+
*/
|
|
39
|
+
description: Description
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Array of possible types this type can be.
|
|
43
|
+
*/
|
|
44
|
+
oneOf: Array<ValueTypeApiType>
|
|
45
|
+
|
|
46
|
+
fields?: never
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ApiMethod {
|
|
50
|
+
/**
|
|
51
|
+
* Name of the method.
|
|
52
|
+
*/
|
|
53
|
+
name: string
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Description of the method.
|
|
57
|
+
*/
|
|
58
|
+
description: Description
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Parameters this method takes.
|
|
62
|
+
*/
|
|
63
|
+
parameters: Array<FieldOrParam>
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Type of the value this method returns.
|
|
67
|
+
*/
|
|
68
|
+
returnType: ValueType
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface FieldOrParam {
|
|
72
|
+
/**
|
|
73
|
+
* Name of the field/parameter.
|
|
74
|
+
*/
|
|
75
|
+
name: string
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Type of the value this field/parameter can be assigned.
|
|
79
|
+
*/
|
|
80
|
+
type: ValueType
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Whether this is a required field/parameter.
|
|
84
|
+
*/
|
|
85
|
+
required: boolean
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Description of the field/parameter.
|
|
89
|
+
*/
|
|
90
|
+
description: Description
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Whether this field/parameter should be JSON-serialized.
|
|
94
|
+
*/
|
|
95
|
+
jsonSerialized: boolean
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Description of a type/method/field/parameter.
|
|
100
|
+
*/
|
|
101
|
+
export interface Description {
|
|
102
|
+
markdown: string
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Type of a value.
|
|
107
|
+
*/
|
|
108
|
+
export type ValueType
|
|
109
|
+
= | ValueTypeString
|
|
110
|
+
| ValueTypeBoolean
|
|
111
|
+
| ValueTypeInteger32
|
|
112
|
+
| ValueTypeInteger53
|
|
113
|
+
| ValueTypeFloat
|
|
114
|
+
| ValueTypeInputFile
|
|
115
|
+
| ValueTypeApiType
|
|
116
|
+
| ValueTypeArray
|
|
117
|
+
| ValueTypeUnion
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* `String` value type.
|
|
121
|
+
*/
|
|
122
|
+
export interface ValueTypeString {
|
|
123
|
+
type: 'str'
|
|
124
|
+
literal?: string
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* `Boolean` value type.
|
|
129
|
+
*/
|
|
130
|
+
export interface ValueTypeBoolean {
|
|
131
|
+
type: 'bool'
|
|
132
|
+
literal?: boolean
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* `Integer` value type, which fits in a 32-bit integer.
|
|
137
|
+
*/
|
|
138
|
+
export interface ValueTypeInteger32 {
|
|
139
|
+
type: 'int32'
|
|
140
|
+
literal?: number
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* `Integer` value type, which may have more than 32 significant bits, but has
|
|
145
|
+
* at most 52 significant bits, so a 64-bit integer or double-precision float
|
|
146
|
+
* type are safe for storing values of this type.
|
|
147
|
+
*/
|
|
148
|
+
export interface ValueTypeInteger53 {
|
|
149
|
+
type: 'int53'
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* `Float` value type.
|
|
154
|
+
*/
|
|
155
|
+
export interface ValueTypeFloat {
|
|
156
|
+
type: 'float'
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* [`InputFile`](https://core.telegram.org/bots/api#inputfile) value type.
|
|
161
|
+
*/
|
|
162
|
+
export interface ValueTypeInputFile {
|
|
163
|
+
type: 'input-file'
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Any {@link ApiType} value type.
|
|
168
|
+
*/
|
|
169
|
+
export interface ValueTypeApiType {
|
|
170
|
+
type: 'api-type'
|
|
171
|
+
name: keyof typeof types
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Array of any value type.
|
|
176
|
+
*/
|
|
177
|
+
export interface ValueTypeArray {
|
|
178
|
+
type: 'array'
|
|
179
|
+
of: ValueType
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Union of any value types.
|
|
184
|
+
*/
|
|
185
|
+
export interface ValueTypeUnion {
|
|
186
|
+
type: 'union'
|
|
187
|
+
types: Array<ValueType>
|
|
188
|
+
}
|
package/src/index.ts
ADDED