tl: updated to layer 140

This commit is contained in:
teidesu 2022-04-28 17:23:44 +03:00
parent 2289cc690d
commit a1ea1315df
13 changed files with 70 additions and 25 deletions

View file

@ -14,7 +14,7 @@
"dependencies": {
"@types/long": "^4.0.1",
"@types/node": "^15.12.1",
"@mtcute/tl": "workspace:139.0",
"@mtcute/tl": "workspace:140.0.0",
"@mtcute/core": "workspace:^1.0.0",
"@mtcute/file-id": "workspace:^1.0.0",
"eager-async-pool": "^1.0.0",

View file

@ -20,7 +20,7 @@
"dependencies": {
"@types/node": "^15.12.1",
"@types/events": "^3.0.0",
"@mtcute/tl": "workspace:139.0",
"@mtcute/tl": "workspace:140.0.0",
"@mtcute/tl-runtime": "workspace:^1.0.0",
"big-integer": "1.6.48",
"long": "^4.0.0",

View file

@ -12,7 +12,7 @@
"build": "tsc"
},
"dependencies": {
"@mtcute/tl": "workspace:139.0",
"@mtcute/tl": "workspace:140.0.0",
"@mtcute/core": "workspace:^1.0.0",
"@mtcute/client": "workspace:^1.0.0",
"events": "^3.2.0"

View file

@ -12,7 +12,7 @@
"build": "tsc"
},
"dependencies": {
"@mtcute/tl": "workspace:139.0",
"@mtcute/tl": "workspace:140.0.0",
"@mtcute/tl-runtime": "workspace:^1.0.0",
"@mtcute/core": "workspace:^1.0.0",
"long": "^4.0.0"

View file

@ -13,7 +13,7 @@
"docs": "npx typedoc"
},
"dependencies": {
"@mtcute/tl": "workspace:~139.0",
"@mtcute/tl": "workspace:140.0.0",
"htmlparser2": "^6.0.1",
"long": "^4.0.0"
},

View file

@ -13,7 +13,7 @@
"docs": "npx typedoc"
},
"dependencies": {
"@mtcute/tl": "workspace:139.0",
"@mtcute/tl": "workspace:140.0.0",
"long": "^4.0.0"
},
"devDependencies": {

View file

@ -2,7 +2,7 @@
> TL schema and related utils used for MTCute.
Generated from TL layer **139** (last updated on 23.03.2022).
Generated from TL layer **140** (last updated on 28.04.2022).
## About

File diff suppressed because one or more lines are too long

View file

@ -6,6 +6,7 @@
"When contributing, please maintain alphabetical key ordering"
],
"class": {
"attachMenuBot": ["bot_id"],
"botInfo": ["user_id"],
"channel": ["id"],
"channelAdminLogEvent": ["user_id"],
@ -85,6 +86,7 @@
"updateBotCommands": ["bot_id"],
"updateBotInlineQuery": ["user_id"],
"updateBotInlineSend": ["user_id"],
"updateBotMenuButton": ["bot_id"],
"updateBotPrecheckoutQuery": ["user_id"],
"updateBotShippingQuery": ["user_id"],
"updateBotStopped": ["user_id"],
@ -119,6 +121,7 @@
"updateUserPhoto": ["user_id"],
"updateUserStatus": ["user_id"],
"updateUserTyping": ["user_id"],
"updateWebViewResultSent": ["bot_id"],
"user": ["id"],
"userEmpty": ["id"],
"userFull": ["id"],

View file

@ -1,6 +1,6 @@
{
"name": "@mtcute/tl",
"version": "139.0.0",
"version": "140.0.0",
"description": "TL schema used for MTCute",
"main": "index.js",
"author": "Alisa Sireneva <me@tei.su>",

View file

@ -261,7 +261,7 @@ export async function getCachedDocumentation(): Promise<CachedDocumentation | nu
try {
const file = await readFile(DOC_CACHE_FILE, 'utf8')
return JSON.parse(file)
} catch (e) {
} catch (e: any) {
if (e.code === 'ENOENT') {
return null
}

View file

@ -8,14 +8,18 @@ import { parseTlToEntries } from '@mtcute/tl-utils/src/parse'
import { parseFullTlSchema } from '@mtcute/tl-utils/src/schema'
import { mergeTlEntries, mergeTlSchemas } from '@mtcute/tl-utils/src/merge'
import { TlEntry, TlFullSchema } from '@mtcute/tl-utils/src/types'
import { readFile, writeFile } from 'fs/promises'
import { readdir, readFile, writeFile } from 'fs/promises'
import { join } from 'path'
import cheerio from 'cheerio'
import fetch from 'node-fetch'
import readline from 'readline'
import { writeTlEntryToString } from '@mtcute/tl-utils/src/stringify'
import {
CORE_DOMAIN, API_SCHEMA_JSON_FILE, TDESKTOP_SCHEMA, TDLIB_SCHEMA, COREFORK_DOMAIN
CORE_DOMAIN,
API_SCHEMA_JSON_FILE,
TDESKTOP_SCHEMA,
TDLIB_SCHEMA,
COREFORK_DOMAIN,
} from './constants'
import { fetchRetry } from './utils'
import {
@ -27,6 +31,7 @@ import { packTlSchema } from './schema'
const README_MD_FILE = join(__dirname, '../README.md')
const PACKAGE_JSON_FILE = join(__dirname, '../package.json')
const PACKAGES_DIR = join(__dirname, '../../')
function tlToFullSchema(tl: string): TlFullSchema {
return parseFullTlSchema(parseTlToEntries(tl))
@ -66,7 +71,10 @@ async function fetchTdesktopSchema(): Promise<Schema> {
}
}
async function fetchCoreSchema(domain = CORE_DOMAIN, name = 'Core'): Promise<Schema> {
async function fetchCoreSchema(
domain = CORE_DOMAIN,
name = 'Core'
): Promise<Schema> {
const html = await fetchRetry(`${domain}/schema`)
const $ = cheerio.load(html)
// cheerio doesn't always unescape them
@ -115,9 +123,7 @@ async function updatePackageVersion(
) {
const packageJson = JSON.parse(await readFile(PACKAGE_JSON_FILE, 'utf8'))
const version: string = packageJson.version
let [major, minor, patch] = version.split('.').map((i) => parseInt(i))
patch = 0
let [major, minor] = version.split('.').map((i) => parseInt(i))
if (major === currentLayer) {
console.log('Current version: %s. Bump minor version?', version)
@ -132,8 +138,40 @@ async function updatePackageVersion(
}
console.log('Updating package version...')
packageJson.version = `${major}.${minor}.${patch}`
const versionStr = `${major}.${minor}.0`
packageJson.version = versionStr
await writeFile(PACKAGE_JSON_FILE, JSON.stringify(packageJson, null, 4))
console.log('Updating dependant packages...')
for (const dir of await readdir(PACKAGES_DIR, { withFileTypes: true })) {
if (!dir.isDirectory()) continue
const pkgFile = join(PACKAGES_DIR, dir.name, 'package.json')
let pkg
try {
pkg = JSON.parse(await readFile(pkgFile, 'utf8'))
} catch (e: any) {
if (e.code === 'ENOENT') continue
throw e
}
if (pkg.dependencies && '@mtcute/tl' in pkg.dependencies) {
pkg.dependencies['@mtcute/tl'] = 'workspace:' + versionStr
}
if (pkg.devDependencies && '@mtcute/tl' in pkg.devDependencies) {
pkg.devDependencies['@mtcute/tl'] = 'workspace:' + versionStr
}
await writeFile(pkgFile, JSON.stringify(pkg, null, 4) + '\n')
}
// because i am fucking dumb and have adhd and always forget it lol
console.log(
'Done! Please make sure packages compile before committing and pushing'
)
}
async function overrideInt53(schema: TlFullSchema): Promise<void> {
@ -150,7 +188,9 @@ async function overrideInt53(schema: TlFullSchema): Promise<void> {
overrides.forEach((argName) => {
const arg = entry.arguments.find((it) => it.name === argName)
if (!arg) {
console.log(`[warn] Cannot override ${entry.name}#${argName}: argument does not exist`)
console.log(
`[warn] Cannot override ${entry.name}#${argName}: argument does not exist`
)
return
}
@ -159,7 +199,9 @@ async function overrideInt53(schema: TlFullSchema): Promise<void> {
} else if (arg.type.toLowerCase() === 'vector<long>') {
arg.type = 'vector<int53>'
} else {
console.log(`[warn] Cannot override ${entry.name}#${argName}: argument is not long (${arg.type})`)
console.log(
`[warn] Cannot override ${entry.name}#${argName}: argument is not long (${arg.type})`
)
}
})
})

View file

@ -51,7 +51,7 @@ importers:
specifiers:
'@mtcute/core': workspace:^1.0.0
'@mtcute/file-id': workspace:^1.0.0
'@mtcute/tl': workspace:139.0
'@mtcute/tl': workspace:140.0.0
'@types/long': ^4.0.1
'@types/node': ^15.12.1
eager-async-pool: ^1.0.0
@ -69,7 +69,7 @@ importers:
packages/core:
specifiers:
'@mtcute/tl': workspace:139.0
'@mtcute/tl': workspace:140.0.0
'@mtcute/tl-runtime': workspace:^1.0.0
'@types/events': ^3.0.0
'@types/node': ^15.12.1
@ -103,7 +103,7 @@ importers:
specifiers:
'@mtcute/client': workspace:^1.0.0
'@mtcute/core': workspace:^1.0.0
'@mtcute/tl': workspace:139.0
'@mtcute/tl': workspace:140.0.0
events: ^3.2.0
dependencies:
'@mtcute/client': link:../client
@ -114,7 +114,7 @@ importers:
packages/file-id:
specifiers:
'@mtcute/core': workspace:^1.0.0
'@mtcute/tl': workspace:139.0
'@mtcute/tl': workspace:140.0.0
'@mtcute/tl-runtime': workspace:^1.0.0
'@types/long': ^4.0.1
long: ^4.0.0
@ -129,7 +129,7 @@ importers:
packages/html-parser:
specifiers:
'@mtcute/client': ^1.0.0
'@mtcute/tl': workspace:~139.0
'@mtcute/tl': workspace:140.0.0
'@types/long': ^4.0.1
htmlparser2: ^6.0.1
long: ^4.0.0
@ -150,7 +150,7 @@ importers:
packages/markdown-parser:
specifiers:
'@mtcute/client': workspace:^1.0.0
'@mtcute/tl': workspace:139.0
'@mtcute/tl': workspace:140.0.0
'@types/long': ^4.0.1
long: ^4.0.0
dependencies: