build: fixed vitest version in @mtcute/test + fixed vite configs
This commit is contained in:
parent
852b1b766c
commit
b4099f15bd
12 changed files with 693 additions and 1327 deletions
|
@ -1,5 +1,6 @@
|
||||||
/// <reference types="vitest" />
|
/// <reference types="vitest" />
|
||||||
import { defineConfig, mergeConfig } from 'vite'
|
import { defineConfig, mergeConfig } from 'vite'
|
||||||
|
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
||||||
|
|
||||||
import baseConfig from './vite.mjs'
|
import baseConfig from './vite.mjs'
|
||||||
import { fixupCjs } from './vite-utils/fixup-cjs'
|
import { fixupCjs } from './vite-utils/fixup-cjs'
|
||||||
|
@ -16,6 +17,8 @@ export default mergeConfig(baseConfig, defineConfig({
|
||||||
toFake: ['setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'Date']
|
toFake: ['setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'Date']
|
||||||
},
|
},
|
||||||
retry: process.env.CI ? 3 : 0,
|
retry: process.env.CI ? 3 : 0,
|
||||||
|
isolate: false,
|
||||||
|
fileParallelism: false, // leads to ERR_INSUFFICIENT_RESOURCES
|
||||||
// for whatever reason using exclude-s makes the vite never start the browser, so we use skip-s instead.
|
// for whatever reason using exclude-s makes the vite never start the browser, so we use skip-s instead.
|
||||||
// exclude: [
|
// exclude: [
|
||||||
// './packages/crypto-node/**',
|
// './packages/crypto-node/**',
|
||||||
|
@ -24,6 +27,14 @@ export default mergeConfig(baseConfig, defineConfig({
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
fixupCjs(),
|
fixupCjs(),
|
||||||
|
nodePolyfills({
|
||||||
|
include: ['stream', 'path', 'zlib', 'util'],
|
||||||
|
globals: {
|
||||||
|
Buffer: false,
|
||||||
|
global: false,
|
||||||
|
process: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
],
|
],
|
||||||
define: {
|
define: {
|
||||||
'import.meta.env.TEST_ENV': '"browser"'
|
'import.meta.env.TEST_ENV': '"browser"'
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
"@commitlint/cli": "17.6.5",
|
"@commitlint/cli": "17.6.5",
|
||||||
"@commitlint/config-conventional": "17.6.5",
|
"@commitlint/config-conventional": "17.6.5",
|
||||||
"@types/node": "20.10.0",
|
"@types/node": "20.10.0",
|
||||||
"@types/node-forge": "1.3.2",
|
|
||||||
"@types/ws": "8.5.4",
|
"@types/ws": "8.5.4",
|
||||||
"@typescript-eslint/eslint-plugin": "6.4.0",
|
"@typescript-eslint/eslint-plugin": "6.4.0",
|
||||||
"@typescript-eslint/parser": "6.4.0",
|
"@typescript-eslint/parser": "6.4.0",
|
||||||
|
@ -57,8 +56,7 @@
|
||||||
"glob": "10.2.6",
|
"glob": "10.2.6",
|
||||||
"husky": "8.0.3",
|
"husky": "8.0.3",
|
||||||
"lint-staged": "13.2.2",
|
"lint-staged": "13.2.2",
|
||||||
"node-forge": "1.3.1",
|
"playwright": "^1.42.1",
|
||||||
"playwright": "^1.40.1",
|
|
||||||
"prettier": "3.0.3",
|
"prettier": "3.0.3",
|
||||||
"rimraf": "5.0.1",
|
"rimraf": "5.0.1",
|
||||||
"semver": "7.5.1",
|
"semver": "7.5.1",
|
||||||
|
@ -67,6 +65,7 @@
|
||||||
"typedoc": "0.25.3",
|
"typedoc": "0.25.3",
|
||||||
"typescript": "5.1.6",
|
"typescript": "5.1.6",
|
||||||
"vite": "5.1.6",
|
"vite": "5.1.6",
|
||||||
|
"vite-plugin-node-polyfills": "0.21.0",
|
||||||
"vitest": "1.4.0"
|
"vitest": "1.4.0"
|
||||||
},
|
},
|
||||||
"prettier": "./.config/prettier.cjs",
|
"prettier": "./.config/prettier.cjs",
|
||||||
|
|
|
@ -8,9 +8,9 @@ import {
|
||||||
testRefMessagesRepository,
|
testRefMessagesRepository,
|
||||||
} from '@mtcute/test'
|
} from '@mtcute/test'
|
||||||
|
|
||||||
import { SqliteStorage } from '../src/index.js'
|
|
||||||
|
|
||||||
if (import.meta.env.TEST_ENV === 'node') {
|
if (import.meta.env.TEST_ENV === 'node') {
|
||||||
|
const { SqliteStorage } = await import('../src/index.js')
|
||||||
|
|
||||||
describe('SqliteStorage', () => {
|
describe('SqliteStorage', () => {
|
||||||
const storage = new SqliteStorage(':memory:')
|
const storage = new SqliteStorage(':memory:')
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
"@mtcute/node": "workspace:^",
|
"@mtcute/node": "workspace:^",
|
||||||
"@mtcute/web": "workspace:^",
|
"@mtcute/web": "workspace:^",
|
||||||
"@mtcute/tl": "workspace:*",
|
"@mtcute/tl": "workspace:*",
|
||||||
"vitest": "^0.34.6"
|
"vitest": "1.4.0"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"@mtcute/node": {
|
"@mtcute/node": {
|
||||||
|
|
|
@ -572,576 +572,3 @@ exports[`generateTlSchemasDifference > shows removed unions 1`] = `
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`generateTlSchemasDifference shows added constructors 1`] = `
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 3847402009,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test2",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"unions": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 3847402009,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test2",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"name": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTlSchemasDifference shows added unions 1`] = `
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 3739166976,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test1",
|
|
||||||
"type": "Test1",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"arguments": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"name": "foo",
|
|
||||||
"type": {
|
|
||||||
"new": "Foo",
|
|
||||||
"old": "int",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"new": 3348640942,
|
|
||||||
"old": 1331975629,
|
|
||||||
},
|
|
||||||
"name": "test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"unions": {
|
|
||||||
"added": [
|
|
||||||
{
|
|
||||||
"classes": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 3739166976,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test1",
|
|
||||||
"type": "Test1",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"name": "Test1",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTlSchemasDifference shows modified constructors 1`] = `
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"arguments": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"name": "foo",
|
|
||||||
"type": {
|
|
||||||
"new": "Foo",
|
|
||||||
"old": "int",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"new": 3348640942,
|
|
||||||
"old": 1331975629,
|
|
||||||
},
|
|
||||||
"name": "test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"unions": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTlSchemasDifference shows modified methods 1`] = `
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"id": {
|
|
||||||
"new": 3994885231,
|
|
||||||
"old": 471282454,
|
|
||||||
},
|
|
||||||
"name": "test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"unions": {
|
|
||||||
"added": [
|
|
||||||
undefined,
|
|
||||||
],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [
|
|
||||||
undefined,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTlSchemasDifference shows modified unions 1`] = `
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 3847402009,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test2",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"arguments": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"name": "foo",
|
|
||||||
"type": {
|
|
||||||
"new": "Foo",
|
|
||||||
"old": "int",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"new": 3348640942,
|
|
||||||
"old": 1331975629,
|
|
||||||
},
|
|
||||||
"name": "test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 1809692154,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test1",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"unions": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 3847402009,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test2",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 1809692154,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test1",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"name": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTlSchemasDifference shows modified unions 2`] = `
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
{
|
|
||||||
"name": "foo",
|
|
||||||
"type": "Foo",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"id": 711487159,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test2",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 704164487,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test3",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
{
|
|
||||||
"name": "foo",
|
|
||||||
"type": "int",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"id": 1331975629,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 1809692154,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test1",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"unions": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
{
|
|
||||||
"name": "foo",
|
|
||||||
"type": "Foo",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"id": 711487159,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test2",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 704164487,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test3",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [
|
|
||||||
{
|
|
||||||
"arguments": [
|
|
||||||
{
|
|
||||||
"name": "foo",
|
|
||||||
"type": "int",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"id": 1331975629,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 1809692154,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test1",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"name": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTlSchemasDifference shows modified unions 3`] = `
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"id": {
|
|
||||||
"new": 1997819349,
|
|
||||||
"old": 471282454,
|
|
||||||
},
|
|
||||||
"name": "test",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": {
|
|
||||||
"new": 3739166976,
|
|
||||||
"old": 1809692154,
|
|
||||||
},
|
|
||||||
"name": "test1",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"unions": {
|
|
||||||
"added": [
|
|
||||||
{
|
|
||||||
"classes": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 1997819349,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test",
|
|
||||||
"type": "Test1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 3739166976,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test1",
|
|
||||||
"type": "Test1",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"name": "Test1",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [
|
|
||||||
{
|
|
||||||
"classes": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 471282454,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 1809692154,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test1",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"name": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTlSchemasDifference shows removed constructors 1`] = `
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 3847402009,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test2",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"unions": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 3847402009,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test2",
|
|
||||||
"type": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"name": "Test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTlSchemasDifference shows removed unions 1`] = `
|
|
||||||
{
|
|
||||||
"classes": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"arguments": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [
|
|
||||||
{
|
|
||||||
"name": "foo",
|
|
||||||
"type": {
|
|
||||||
"new": "Foo",
|
|
||||||
"old": "int",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"new": 3348640942,
|
|
||||||
"old": 1331975629,
|
|
||||||
},
|
|
||||||
"name": "test",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"removed": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 3739166976,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test1",
|
|
||||||
"type": "Test1",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"methods": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [],
|
|
||||||
},
|
|
||||||
"unions": {
|
|
||||||
"added": [],
|
|
||||||
"modified": [],
|
|
||||||
"removed": [
|
|
||||||
{
|
|
||||||
"classes": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 3739166976,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "test1",
|
|
||||||
"type": "Test1",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"name": "Test1",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
|
@ -29,24 +29,3 @@ exports[`groupTlEntriesByNamespace > should group entries correctly 1`] = `
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`groupTlEntriesByNamespace should group entries correctly 1`] = `
|
|
||||||
{
|
|
||||||
"foo": [
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 0,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "foo.bar",
|
|
||||||
"type": "FooBar",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"arguments": [],
|
|
||||||
"id": 0,
|
|
||||||
"kind": "class",
|
|
||||||
"name": "foo.baz",
|
|
||||||
"type": "FooBaz",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
|
@ -71,79 +71,3 @@ exports.RpcError = RpcError;
|
||||||
",
|
",
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`generateCodeForErrors should correctly generate errors 1`] = `
|
|
||||||
[
|
|
||||||
|
|
||||||
"type MtErrorText =
|
|
||||||
| 'USER_NOT_FOUND'
|
|
||||||
| 'FLOOD_WAIT_%d'
|
|
||||||
|
|
||||||
| (string & {}) // to keep hints
|
|
||||||
|
|
||||||
interface MtErrorArgMap {
|
|
||||||
'FLOOD_WAIT_%d': { duration: number },
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type RpcErrorWithArgs<T extends string> =
|
|
||||||
RpcError & { text: T } & (T extends keyof MtErrorArgMap ? (RpcError & MtErrorArgMap[T]) : {});
|
|
||||||
|
|
||||||
export class RpcError extends Error {
|
|
||||||
static BAD_REQUEST: 400;
|
|
||||||
|
|
||||||
|
|
||||||
readonly code: number;
|
|
||||||
readonly text: MtErrorText;
|
|
||||||
readonly unknown: boolean;
|
|
||||||
constructor(code: number, text: MtErrorText);
|
|
||||||
|
|
||||||
is<const T extends MtErrorText>(text: T): this is RpcErrorWithArgs<T>;
|
|
||||||
static is<const T extends MtErrorText>(err: unknown): err is RpcError;
|
|
||||||
static is<const T extends MtErrorText>(err: unknown, text: T): err is RpcErrorWithArgs<T>;
|
|
||||||
static create<const T extends MtErrorText>(code: number, text: T): RpcErrorWithArgs<T>;
|
|
||||||
static fromTl(obj: object): RpcError;
|
|
||||||
}
|
|
||||||
"
|
|
||||||
,
|
|
||||||
|
|
||||||
"const _descriptionsMap = JSON.parse('{"FLOOD_WAIT_%d":"Wait %d seconds"}')
|
|
||||||
class RpcError extends Error {
|
|
||||||
constructor(code, text, description) {
|
|
||||||
super(description || 'Unknown RPC error: [' + code + ':' + text + ']');
|
|
||||||
this.code = code;
|
|
||||||
this.text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
static is(err, text) { return err.constructor === RpcError && (!text || err.text === text); }
|
|
||||||
is(text) { return this.text === text; }
|
|
||||||
}
|
|
||||||
RpcError.fromTl = function (obj) {
|
|
||||||
if (obj.errorMessage in _descriptionsMap) {
|
|
||||||
return new RpcError(obj.errorCode, obj.errorMessage, _descriptionsMap[obj.errorMessage]);
|
|
||||||
}
|
|
||||||
|
|
||||||
var err = new RpcError(obj.errorCode, obj.errorMessage);
|
|
||||||
var match, param;
|
|
||||||
if ((match=err.text.match(/^FLOOD_WAIT_(d+)$/))!=null){ err.text = 'FLOOD_WAIT_%d'; param = err.duration = parseInt(match[1]) }
|
|
||||||
|
|
||||||
else return err
|
|
||||||
|
|
||||||
err.message = _descriptionsMap[err.text].replace('%d', param);
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
RpcError.create = function(code, text) {
|
|
||||||
var desc = _descriptionsMap[text];
|
|
||||||
var err = new RpcError(code, text, desc);
|
|
||||||
if (!desc) {
|
|
||||||
err.unknown = true;
|
|
||||||
}
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
RpcError.BAD_REQUEST = 400;
|
|
||||||
|
|
||||||
exports.RpcError = RpcError;
|
|
||||||
"
|
|
||||||
,
|
|
||||||
]
|
|
||||||
`;
|
|
||||||
|
|
|
@ -59,65 +59,6 @@ exports[`generateReaderCodeForTlEntries > updates readers used in bare vectors 1
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntries doesn't generate code for methods by default 1`] = `
|
|
||||||
"var m={
|
|
||||||
471282454:function(r){return{_:'test'}},
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntries generates code for methods if asked to 1`] = `
|
|
||||||
"var m={
|
|
||||||
471282454:function(r){return{_:'test'}},
|
|
||||||
2119910527:function(r){return{_:'test2'}},
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntries generates code for multiple entries 1`] = `
|
|
||||||
"var m={
|
|
||||||
471282454:function(r){return{_:'test'}},
|
|
||||||
2119910527:function(r){return{_:'test2'}},
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntries method return readers doesn't include Bool parsing 1`] = `
|
|
||||||
"var m={
|
|
||||||
_results:{
|
|
||||||
},
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntries method return readers includes primitive return type parsing info 1`] = `
|
|
||||||
"var m={
|
|
||||||
1809692154:function(r){return{_:'test1'}},
|
|
||||||
_results:{
|
|
||||||
'test':function(r){return r.int()},
|
|
||||||
},
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntries method return readers includes primitive vectors return type parsing info 1`] = `
|
|
||||||
"var m={
|
|
||||||
_results:{
|
|
||||||
'test':function(r){return r.vector(r.int)},
|
|
||||||
},
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntries method return readers includes primitive vectors return type parsing info 2`] = `
|
|
||||||
"var m={
|
|
||||||
_results:{
|
|
||||||
'test':function(r){return r.vector(r.int)},
|
|
||||||
},
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntries updates readers used in bare vectors 1`] = `
|
|
||||||
"var m={
|
|
||||||
471282454:function(r=this){return{_:'test'}},
|
|
||||||
3562390222:function(r){return{_:'test2',a:r.vector(m[471282454],1),}},
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry > generates code for bare types 1`] = `"1945237724:function(r){return{_:'msg_container',messages:r.vector(m[155834844],1),}},"`;
|
exports[`generateReaderCodeForTlEntry > generates code for bare types 1`] = `"1945237724:function(r){return{_:'msg_container',messages:r.vector(m[155834844],1),}},"`;
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry > generates code for bare types 2`] = `"2924480661:function(r){return{_:'future_salts',salts:r.vector(m[155834844]),current:r.object(),}},"`;
|
exports[`generateReaderCodeForTlEntry > generates code for bare types 2`] = `"2924480661:function(r){return{_:'future_salts',salts:r.vector(m[155834844]),current:r.object(),}},"`;
|
||||||
|
@ -147,33 +88,3 @@ exports[`generateReaderCodeForTlEntry > generates code for constructors with vec
|
||||||
exports[`generateReaderCodeForTlEntry > generates code for constructors without arguments 1`] = `"2875595611:function(r){return{_:'topPeerCategoryBotsPM'}},"`;
|
exports[`generateReaderCodeForTlEntry > generates code for constructors without arguments 1`] = `"2875595611:function(r){return{_:'topPeerCategoryBotsPM'}},"`;
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry > generates code with raw flags for constructors with flags 1`] = `"1554225816:function(r){var flags=r.uint(),flags2=r.uint();return{_:'test',flags:flags,flags2:flags2,}},"`;
|
exports[`generateReaderCodeForTlEntry > generates code with raw flags for constructors with flags 1`] = `"1554225816:function(r){var flags=r.uint(),flags2=r.uint();return{_:'test',flags:flags,flags2:flags2,}},"`;
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for bare types 1`] = `"1945237724:function(r){return{_:'msg_container',messages:r.vector(m[155834844],1),}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for bare types 2`] = `"2924480661:function(r){return{_:'future_salts',salts:r.vector(m[155834844]),current:r.object(),}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for bare types 3`] = `"2924480661:function(r){return{_:'future_salts',salts:r.vector(m[155834844],1),current:m[155834844](r),}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for constructors with arguments before flags field 1`] = `"2262925665:function(r){var id=r.long(),flags=r.uint();return{_:'poll',id:id,quiz:!!(flags&8),question:r.string(),}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for constructors with generics 1`] = `"3667594509:function(r){return{_:'invokeWithLayer',layer:r.int(),query:r.object(),}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for constructors with multiple flags fields 1`] = `"1041346555:function(r){var flags=r.uint(),pts=r.int(),timeout=flags&2?r.int():void 0,flags2=r.uint();return{_:'updates.channelDifferenceEmpty',final:!!(flags&1),pts:pts,timeout:timeout,canDeleteChannel:!!(flags2&1),}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for constructors with optional arguments 1`] = `"1041346555:function(r){var flags=r.uint();return{_:'updates.channelDifferenceEmpty',final:!!(flags&1),pts:r.int(),timeout:flags&2?r.int():void 0,}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for constructors with optional vector arguments 1`] = `"2338894028:function(r){var flags=r.uint();return{_:'messages.getWebPagePreview',message:r.string(),entities:flags&8?r.vector(r.object):void 0,}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for constructors with simple arguments 1`] = `"2299280777:function(r){return{_:'inputBotInlineMessageID',dcId:r.int(),id:r.long(),accessHash:r.long(),}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for constructors with simple arguments 2`] = `"341499403:function(r){return{_:'contact',userId:r.long(),mutual:r.boolean(),}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for constructors with simple arguments 3`] = `"2933316530:function(r){return{_:'maskCoords',n:r.int(),x:r.double(),y:r.double(),zoom:r.double(),}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for constructors with true flags 1`] = `"649453030:function(r){var flags=r.uint();return{_:'messages.messageEditData',caption:!!(flags&1),}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for constructors with vector arguments 1`] = `"2131196633:function(r){return{_:'contacts.resolvedPeer',peer:r.object(),chats:r.vector(r.object),users:r.vector(r.object),}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code for constructors without arguments 1`] = `"2875595611:function(r){return{_:'topPeerCategoryBotsPM'}},"`;
|
|
||||||
|
|
||||||
exports[`generateReaderCodeForTlEntry generates code with raw flags for constructors with flags 1`] = `"1554225816:function(r){var flags=r.uint(),flags2=r.uint();return{_:'test',flags:flags,flags2:flags2,}},"`;
|
|
||||||
|
|
|
@ -163,169 +163,6 @@ exports[`generateTypescriptDefinitionsForTlEntry > writes generic types 1`] = `
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry comments adds return type comments 1`] = `
|
|
||||||
"/**
|
|
||||||
* This is a test method
|
|
||||||
*
|
|
||||||
* RPC method returns {@link tl.TypeTest}
|
|
||||||
*/
|
|
||||||
interface RawTestRequest {
|
|
||||||
_: 'test';
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry comments adds return type comments 2`] = `
|
|
||||||
"/**
|
|
||||||
* This is a test method
|
|
||||||
*
|
|
||||||
* RPC method returns {@link tl.TypeTest}
|
|
||||||
*/
|
|
||||||
interface RawTestRequest {
|
|
||||||
_: 'test';
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry comments adds return type comments 3`] = `
|
|
||||||
"/**
|
|
||||||
* RPC method returns {@link tl.TypeTest} array
|
|
||||||
*/
|
|
||||||
interface RawTestRequest {
|
|
||||||
_: 'test';
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry comments adds tdlib style comments 1`] = `
|
|
||||||
"/**
|
|
||||||
* This is a test constructor
|
|
||||||
*/
|
|
||||||
interface RawTest {
|
|
||||||
_: 'test';
|
|
||||||
/**
|
|
||||||
* Some field
|
|
||||||
*/
|
|
||||||
field: number;
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry comments adds tl style comments 1`] = `
|
|
||||||
"/**
|
|
||||||
* This is a test constructor
|
|
||||||
*/
|
|
||||||
interface RawTest {
|
|
||||||
_: 'test';
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry comments adds usage info comments 1`] = `
|
|
||||||
"/**
|
|
||||||
* RPC method returns {@link tl.TypeTest}
|
|
||||||
*
|
|
||||||
* This method is **not** available for bots
|
|
||||||
*
|
|
||||||
* This method *may* throw one of these errors: FOO, BAR
|
|
||||||
*/
|
|
||||||
interface RawTestRequest {
|
|
||||||
_: 'test';
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry comments adds usage info comments 2`] = `
|
|
||||||
"/**
|
|
||||||
* RPC method returns {@link tl.TypeTest}
|
|
||||||
*
|
|
||||||
* This method is **not** available for normal users
|
|
||||||
*/
|
|
||||||
interface RawTestBotRequest {
|
|
||||||
_: 'testBot';
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry comments should not break @link tags 1`] = `
|
|
||||||
"/**
|
|
||||||
* This is a test constructor with a very long comment
|
|
||||||
* {@link whatever} more text
|
|
||||||
*/
|
|
||||||
interface RawTest {
|
|
||||||
_: 'test';
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry comments wraps long comments 1`] = `
|
|
||||||
"/**
|
|
||||||
* This is a test constructor with a very very very very very
|
|
||||||
* very very very long comment
|
|
||||||
*/
|
|
||||||
interface RawTest {
|
|
||||||
_: 'test';
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry comments wraps long comments 2`] = `
|
|
||||||
"/**
|
|
||||||
* This is a test method with a very very very very very very
|
|
||||||
* very very long comment
|
|
||||||
*
|
|
||||||
* RPC method returns {@link tl.TypeTest}
|
|
||||||
*/
|
|
||||||
interface RawTestRequest {
|
|
||||||
_: 'test';
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry generates code with raw flags for constructors with flags 1`] = `
|
|
||||||
"interface RawTest {
|
|
||||||
_: 'test';
|
|
||||||
flags: number;
|
|
||||||
flags2: number;
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry ignores namespace for name 1`] = `
|
|
||||||
"interface RawTest {
|
|
||||||
_: 'test.test';
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry marks optional fields as optional 1`] = `
|
|
||||||
"interface RawTest {
|
|
||||||
_: 'test';
|
|
||||||
a?: boolean;
|
|
||||||
b?: string;
|
|
||||||
c?: tl.TypeFoo;
|
|
||||||
d?: tl.namespace.TypeFoo[];
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry renames non-primitive types 1`] = `
|
|
||||||
"interface RawTest {
|
|
||||||
_: 'test';
|
|
||||||
foo: tl.TypeFoo;
|
|
||||||
bar: tl.TypeBar[];
|
|
||||||
baz: tl.namespace.TypeBaz;
|
|
||||||
egg: tl.namespace.TypeEgg[];
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry replaces primitive types 1`] = `
|
|
||||||
"interface RawTest {
|
|
||||||
_: 'test';
|
|
||||||
a: number;
|
|
||||||
b: Long;
|
|
||||||
c: Double;
|
|
||||||
d: string;
|
|
||||||
e: Uint8Array;
|
|
||||||
f: boolean;
|
|
||||||
g: number[];
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlEntry writes generic types 1`] = `
|
|
||||||
"interface RawInvokeWithoutUpdatesRequest<X extends tl.TlObject = tl.TlObject> {
|
|
||||||
_: 'invokeWithoutUpdates';
|
|
||||||
query: X;
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlSchema > writes schemas with methods 1`] = `
|
exports[`generateTypescriptDefinitionsForTlSchema > writes schemas with methods 1`] = `
|
||||||
"interface RawTest {
|
"interface RawTest {
|
||||||
_: 'test';
|
_: 'test';
|
||||||
|
@ -453,131 +290,3 @@ exports[`generateTypescriptDefinitionsForTlSchema > writes simple schemas 2`] =
|
||||||
"ns.isAnyTest = _isAny('Test');
|
"ns.isAnyTest = _isAny('Test');
|
||||||
_types = JSON.parse('{"test":"Test"}');"
|
_types = JSON.parse('{"test":"Test"}');"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlSchema writes schemas with methods 1`] = `
|
|
||||||
"interface RawTest {
|
|
||||||
_: 'test';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* RPC method returns {@link tl.TypeTest}
|
|
||||||
*/
|
|
||||||
interface RawGetTestRequest {
|
|
||||||
_: 'getTest';
|
|
||||||
}
|
|
||||||
interface RpcCallReturn {
|
|
||||||
'getTest': tl.TypeTest
|
|
||||||
}
|
|
||||||
type TypeTest = tl.RawTest
|
|
||||||
function isAnyTest(o: object): o is TypeTest
|
|
||||||
type RpcMethod =
|
|
||||||
| tl.RawGetTestRequest
|
|
||||||
|
|
||||||
type TlObject =
|
|
||||||
| tl.RawTest
|
|
||||||
| tl.RawGetTestRequest"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlSchema writes schemas with methods 2`] = `
|
|
||||||
"ns.isAnyTest = _isAny('Test');
|
|
||||||
_types = JSON.parse('{"test":"Test"}');"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlSchema writes schemas with multi-unions 1`] = `
|
|
||||||
"interface RawTest {
|
|
||||||
_: 'test';
|
|
||||||
}
|
|
||||||
interface RawTest2 {
|
|
||||||
_: 'test2';
|
|
||||||
}
|
|
||||||
interface RpcCallReturn {
|
|
||||||
}
|
|
||||||
type TypeTest = tl.RawTest | tl.RawTest2
|
|
||||||
function isAnyTest(o: object): o is TypeTest
|
|
||||||
|
|
||||||
type TlObject =
|
|
||||||
| tl.RawTest
|
|
||||||
| tl.RawTest2"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlSchema writes schemas with multi-unions 2`] = `
|
|
||||||
"ns.isAnyTest = _isAny('Test');
|
|
||||||
_types = JSON.parse('{"test":"Test","test2":"Test"}');"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlSchema writes schemas with namespaces 1`] = `
|
|
||||||
"interface RawTest {
|
|
||||||
_: 'test';
|
|
||||||
}
|
|
||||||
interface RawTest2 {
|
|
||||||
_: 'test2';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* RPC method returns {@link tl.TypeTest}
|
|
||||||
*/
|
|
||||||
interface RawGetTestRequest {
|
|
||||||
_: 'getTest';
|
|
||||||
}
|
|
||||||
interface RpcCallReturn extends test.RpcCallReturn {
|
|
||||||
'getTest': tl.TypeTest
|
|
||||||
}
|
|
||||||
type TypeTest = tl.RawTest | tl.RawTest2
|
|
||||||
function isAnyTest(o: object): o is TypeTest
|
|
||||||
|
|
||||||
namespace test {
|
|
||||||
interface RawTest {
|
|
||||||
_: 'test.test';
|
|
||||||
}
|
|
||||||
interface RawTest2 {
|
|
||||||
_: 'test.test2';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* RPC method returns {@link tl.test.TypeTest}
|
|
||||||
*/
|
|
||||||
interface RawGetTestRequest {
|
|
||||||
_: 'test.getTest';
|
|
||||||
}
|
|
||||||
interface RpcCallReturn {
|
|
||||||
'test.getTest': tl.test.TypeTest
|
|
||||||
}
|
|
||||||
type TypeTest = tl.test.RawTest | tl.test.RawTest2
|
|
||||||
function isAnyTest(o: object): o is TypeTest
|
|
||||||
}
|
|
||||||
type RpcMethod =
|
|
||||||
| tl.RawGetTestRequest
|
|
||||||
| tl.test.RawGetTestRequest
|
|
||||||
|
|
||||||
type TlObject =
|
|
||||||
| tl.RawTest
|
|
||||||
| tl.RawTest2
|
|
||||||
| tl.test.RawTest
|
|
||||||
| tl.test.RawTest2
|
|
||||||
| tl.RawGetTestRequest
|
|
||||||
| tl.test.RawGetTestRequest"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlSchema writes schemas with namespaces 2`] = `
|
|
||||||
"ns.isAnyTest = _isAny('Test');
|
|
||||||
ns.test = {};
|
|
||||||
(function(ns){
|
|
||||||
ns.isAnyTest = _isAny('test.Test');
|
|
||||||
})(ns.test);
|
|
||||||
_types = JSON.parse('{"test":"Test","test2":"Test","test.test":"test.Test","test.test2":"test.Test"}');"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlSchema writes simple schemas 1`] = `
|
|
||||||
"interface RawTest {
|
|
||||||
_: 'test';
|
|
||||||
}
|
|
||||||
interface RpcCallReturn {
|
|
||||||
}
|
|
||||||
type TypeTest = tl.RawTest
|
|
||||||
function isAnyTest(o: object): o is TypeTest
|
|
||||||
|
|
||||||
type TlObject =
|
|
||||||
| tl.RawTest"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateTypescriptDefinitionsForTlSchema writes simple schemas 2`] = `
|
|
||||||
"ns.isAnyTest = _isAny('Test');
|
|
||||||
_types = JSON.parse('{"test":"Test"}');"
|
|
||||||
`;
|
|
||||||
|
|
|
@ -29,35 +29,6 @@ _staticSize:{
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntries generates code for bare types 1`] = `
|
|
||||||
"var m={
|
|
||||||
'future_salt':function(w,v){w.uint(155834844);w.bytes(h(v,'salt'));},
|
|
||||||
'future_salts':function(w,v){w.uint(2924480661);w.vector(m._bare[155834844],h(v,'salts'),1);m._bare[155834844](w,h(v,'current'));},
|
|
||||||
_bare:{
|
|
||||||
155834844:function(w=this,v){w.bytes(h(v,'salt'));},
|
|
||||||
},
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntries should include prelude by default 1`] = `
|
|
||||||
"function h(o,p){var q=o[p];if(q===void 0)throw Error('Object '+o._+' is missing required property '+p);return q}
|
|
||||||
var m={
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntries should include static sizes calculations 1`] = `
|
|
||||||
"function h(o,p){var q=o[p];if(q===void 0)throw Error('Object '+o._+' is missing required property '+p);return q}
|
|
||||||
var m={
|
|
||||||
'test1':function(w,v){w.uint(102026291);w.int(h(v,'foo'));w.int(h(v,'bar'));},
|
|
||||||
'test2':function(w,v){w.uint(2926357645);w.int(h(v,'foo'));w.double(h(v,'bar'));},
|
|
||||||
'test3':function(w,v){w.uint(3373702963);w.int(h(v,'foo'));w.bytes(h(v,'bar'));},
|
|
||||||
_staticSize:{
|
|
||||||
'test1':12,
|
|
||||||
'test2':16,
|
|
||||||
},
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry > automatically computes constructor ID if needed 1`] = `"'topPeerCategoryBotsPM':function(w){w.uint(2875595611);},"`;
|
exports[`generateWriterCodeForTlEntry > automatically computes constructor ID if needed 1`] = `"'topPeerCategoryBotsPM':function(w){w.uint(2875595611);},"`;
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry > generates code for bare vectors 1`] = `"'msg_container':function(w,v){w.uint(1945237724);w.vector(m._bare[155834844],h(v,'messages'),1);},"`;
|
exports[`generateWriterCodeForTlEntry > generates code for bare vectors 1`] = `"'msg_container':function(w,v){w.uint(1945237724);w.vector(m._bare[155834844],h(v,'messages'),1);},"`;
|
||||||
|
@ -87,33 +58,3 @@ exports[`generateWriterCodeForTlEntry > generates code for constructors with vec
|
||||||
exports[`generateWriterCodeForTlEntry > generates code for constructors without arguments 1`] = `"'topPeerCategoryBotsPM':function(w){w.uint(2875595611);},"`;
|
exports[`generateWriterCodeForTlEntry > generates code for constructors without arguments 1`] = `"'topPeerCategoryBotsPM':function(w){w.uint(2875595611);},"`;
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry > generates code with raw flags for constructors with flags 1`] = `"'test':function(w,v){w.uint(1554225816);var flags=v.flags;w.uint(flags);var flags2=v.flags2;w.uint(flags2);},"`;
|
exports[`generateWriterCodeForTlEntry > generates code with raw flags for constructors with flags 1`] = `"'test':function(w,v){w.uint(1554225816);var flags=v.flags;w.uint(flags);var flags2=v.flags2;w.uint(flags2);},"`;
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry automatically computes constructor ID if needed 1`] = `"'topPeerCategoryBotsPM':function(w){w.uint(2875595611);},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for bare vectors 1`] = `"'msg_container':function(w,v){w.uint(1945237724);w.vector(m._bare[155834844],h(v,'messages'),1);},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for bare vectors 2`] = `"'future_salts':function(w,v){w.uint(2924480661);w.vector(m._bare[155834844],h(v,'salts'));w.object(h(v,'current'));},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for constructors with generics 1`] = `"'invokeWithLayer':function(w,v){w.uint(3667594509);w.int(h(v,'layer'));w.object(h(v,'query'));},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for constructors with multiple fields using the same flag 1`] = `"'inputMediaPoll':function(w,v){w.uint(261416433);var flags=0;var _solution=v.solution!==undefined;var _solutionEntities=v.solutionEntities&&v.solutionEntities.length;var _flags_1=_solution||_solutionEntities;if(_flags_1)flags|=2;w.uint(flags);if(_flags_1)w.string(v.solution);if(_flags_1)w.vector(w.object,v.solutionEntities);},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for constructors with multiple flags fields 1`] = `"'updates.channelDifferenceEmpty':function(w,v){w.uint(1041346555);var flags=0;if(v.final===true)flags|=1;var _timeout=v.timeout!==undefined;if(_timeout)flags|=2;w.uint(flags);w.int(h(v,'pts'));if(_timeout)w.int(v.timeout);var flags2=0;if(v.canDeleteChannel===true)flags2|=1;w.uint(flags2);},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for constructors with optional arguments 1`] = `"'updates.channelDifferenceEmpty':function(w,v){w.uint(1041346555);var flags=0;if(v.final===true)flags|=1;var _timeout=v.timeout!==undefined;if(_timeout)flags|=2;w.uint(flags);w.int(h(v,'pts'));if(_timeout)w.int(v.timeout);},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for constructors with optional vector arguments 1`] = `"'messages.getWebPagePreview':function(w,v){w.uint(2338894028);var flags=0;var _entities=v.entities&&v.entities.length;if(_entities)flags|=8;w.uint(flags);w.string(h(v,'message'));if(_entities)w.vector(w.object,v.entities);},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for constructors with simple arguments 1`] = `"'inputBotInlineMessageID':function(w,v){w.uint(2299280777);w.int(h(v,'dcId'));w.long(h(v,'id'));w.long(h(v,'accessHash'));},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for constructors with simple arguments 2`] = `"'contact':function(w,v){w.uint(341499403);w.long(h(v,'userId'));w.boolean(h(v,'mutual'));},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for constructors with simple arguments 3`] = `"'maskCoords':function(w,v){w.uint(2933316530);w.int(h(v,'n'));w.double(h(v,'x'));w.double(h(v,'y'));w.double(h(v,'zoom'));},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for constructors with true flags 1`] = `"'messages.messageEditData':function(w,v){w.uint(649453030);var flags=0;if(v.caption===true)flags|=1;w.uint(flags);},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for constructors with vector arguments 1`] = `"'contacts.resolvedPeer':function(w,v){w.uint(2131196633);w.object(h(v,'peer'));w.vector(w.object,h(v,'chats'));w.vector(w.object,h(v,'users'));},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code for constructors without arguments 1`] = `"'topPeerCategoryBotsPM':function(w){w.uint(2875595611);},"`;
|
|
||||||
|
|
||||||
exports[`generateWriterCodeForTlEntry generates code with raw flags for constructors with flags 1`] = `"'test':function(w,v){w.uint(1554225816);var flags=v.flags;w.uint(flags);var flags2=v.flags2;w.uint(flags2);},"`;
|
|
||||||
|
|
887
pnpm-lock.yaml
887
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -4,7 +4,7 @@ import { fileURLToPath } from 'url'
|
||||||
import { getPackageJsons } from './utils.mjs'
|
import { getPackageJsons } from './utils.mjs'
|
||||||
|
|
||||||
export async function validateDepsVersions() {
|
export async function validateDepsVersions() {
|
||||||
const packageJsons = await getPackageJsons()
|
const packageJsons = await getPackageJsons(true)
|
||||||
|
|
||||||
const versions = {}
|
const versions = {}
|
||||||
const errors = []
|
const errors = []
|
||||||
|
|
Loading…
Reference in a new issue