nexushub-commands 2.0.3 → 2.0.4
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/lib/shared-commands/ParserSharedCommands.service.js +24 -24
- package/package.json +1 -1
- package/src/shared-commands/ParserSharedCommands.service.ts +27 -26
- package/{CreateModel.parsed.final.d.ts → test.d.ts} +0 -1
- package/CreateModel.parsed.final.js +0 -137
- package/CreateModel.parsed.final.ts +0 -149
- package/CreateModel.parsed.from-original.d.ts +0 -3
- package/CreateModel.parsed.from-original.js +0 -139
- package/CreateModel.parsed.from-original.ts +0 -157
- package/CreateModel.parsed.improved.d.ts +0 -3
- package/CreateModel.parsed.improved.js +0 -138
- package/CreateModel.parsed.improved.ts +0 -151
- package/CreateModel.parsed.perfect.d.ts +0 -4
- package/CreateModel.parsed.perfect.js +0 -33
- package/CreateModel.parsed.perfect.ts +0 -133
- package/CreateModel.parsed.updated-service.d.ts +0 -4
- package/CreateModel.parsed.updated-service.js +0 -143
- package/CreateModel.parsed.updated-service.ts +0 -155
- package/test-imports.js +0 -29
- package/test-updated-service.js +0 -163
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.EscortCreateModelCommand = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const evogram_1 = require("evogram");
|
|
7
|
-
const migrated_1 = require("evogram/lib/migrated");
|
|
8
|
-
let EscortCreateModelCommand = class EscortCreateModelCommand extends SharedCommand {
|
|
9
|
-
execute(context, name, age, about, services, rating, specifications, _) {
|
|
10
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
-
const model = yield this.API.post(`/commands/${this.constructor.name}/createModel`, { name, age, about, services, rating, specifications, workerId: context.user.id }).then((res) => res.data);
|
|
12
|
-
return context.redirect(migrated_1.CommandManager.getCommandByName('EscortModelsCommand'), { model: model.id });
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
static createModel(_a) {
|
|
16
|
-
return tslib_1.__awaiter(this, arguments, void 0, function* ({ name, age, about, services, rating, specifications, workerId }) {
|
|
17
|
-
const model = yield ;
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
exports.EscortCreateModelCommand = EscortCreateModelCommand;
|
|
22
|
-
tslib_1.__decorate([
|
|
23
|
-
tslib_1.__param(1, (0, evogram_1.CommandArgument)({
|
|
24
|
-
name: 'name',
|
|
25
|
-
question: ({ context }) => context
|
|
26
|
-
.sendFormattedQuestion({
|
|
27
|
-
header: '<blockquote><b>👱♀️ Регистрация новой модели</b></blockquote>',
|
|
28
|
-
footer: '<i>Отправьте имя модели в следующем сообщении</i>',
|
|
29
|
-
})
|
|
30
|
-
.then((message) => message.text),
|
|
31
|
-
}
|
|
32
|
-
// stringValidator({ max: 20 })
|
|
33
|
-
)),
|
|
34
|
-
tslib_1.__param(2, (0, evogram_1.CommandArgument)({
|
|
35
|
-
name: 'age',
|
|
36
|
-
question: ({ context }) => context
|
|
37
|
-
.sendFormattedQuestion({
|
|
38
|
-
header: '<blockquote><b>👱♀️ Регистрация новой модели</b></blockquote>',
|
|
39
|
-
footer: '<i>Отправьте возраст модели в следующем сообщении (от 18 до 99 лет)</i>',
|
|
40
|
-
})
|
|
41
|
-
.then((message) => message.text),
|
|
42
|
-
}
|
|
43
|
-
// numberValidator({ min: 18, max: 99 })
|
|
44
|
-
)),
|
|
45
|
-
tslib_1.__param(3, (0, evogram_1.CommandArgument)({
|
|
46
|
-
name: 'about',
|
|
47
|
-
question: ({ context }) => context
|
|
48
|
-
.sendFormattedQuestion({
|
|
49
|
-
header: '<blockquote><b>👱♀️ Регистрация новой модели</b></blockquote>',
|
|
50
|
-
footer: '<i>Отправьте описание модели в следующем сообщении (не более 1000 символов)</i>',
|
|
51
|
-
})
|
|
52
|
-
.then((message) => message.text),
|
|
53
|
-
}
|
|
54
|
-
// stringValidator({ max: 1000 })
|
|
55
|
-
)),
|
|
56
|
-
tslib_1.__param(4, (0, evogram_1.CommandArgument)({
|
|
57
|
-
name: 'services',
|
|
58
|
-
question: ({ context }) => context
|
|
59
|
-
.sendFormattedQuestion({
|
|
60
|
-
header: '<blockquote><b>👱♀️ Регистрация новой модели</b></blockquote>',
|
|
61
|
-
footer: '<i>Отправьте услуги модели в следующем сообщении (через запятую)</i>',
|
|
62
|
-
})
|
|
63
|
-
.then((message) => message.text),
|
|
64
|
-
},
|
|
65
|
-
// stringValidator({ pattern: /^[а-яА-Яa-zA-Z0-9\s]+(,[а-яА-Яa-zA-Z0-9\s]+)*$/ }),
|
|
66
|
-
({ value }) => value.split(',').map((x) => x.trim()))),
|
|
67
|
-
tslib_1.__param(5, (0, evogram_1.CommandArgument)({
|
|
68
|
-
name: 'rating',
|
|
69
|
-
question: ({ context }) => context
|
|
70
|
-
.sendFormattedQuestion({
|
|
71
|
-
header: '<blockquote><b>👱♀️ Регистрация новой модели</b></blockquote>',
|
|
72
|
-
footer: '<i>Отправьте рейтинг модели в следующем сообщении (от 0.00 до 5.00)</i>',
|
|
73
|
-
})
|
|
74
|
-
.then((message) => message.text),
|
|
75
|
-
}
|
|
76
|
-
// numberValidator({ min: 0, max: 5, allowFloat: true })
|
|
77
|
-
)),
|
|
78
|
-
tslib_1.__param(6, (0, evogram_1.CommandArgument)({
|
|
79
|
-
name: 'specifications',
|
|
80
|
-
question: ({ context, error }) => context
|
|
81
|
-
.sendFormattedQuestion({
|
|
82
|
-
header: '<blockquote><b>👱♀️ Регистрация новой модели</b></blockquote>',
|
|
83
|
-
footer: `<i>Отправьте спецификации модели в следующем сообщении через запятую (${Object.values({
|
|
84
|
-
ethnicity: 'Этническая группа',
|
|
85
|
-
physique: 'Телосложение',
|
|
86
|
-
hair_color: 'Цвет волос',
|
|
87
|
-
height: 'Рост',
|
|
88
|
-
weight: 'Вес',
|
|
89
|
-
breasts: 'Грудь',
|
|
90
|
-
}).join(', ')})</i>`,
|
|
91
|
-
error: error === null || error === void 0 ? void 0 : error.message,
|
|
92
|
-
})
|
|
93
|
-
.then((message) => message.text),
|
|
94
|
-
},
|
|
95
|
-
// stringValidator({ pattern: /^[а-яА-Яa-zA-Z0-9\s]+(,[а-яА-Яa-zA-Z0-9\s]+)*$/ }),
|
|
96
|
-
({ value }) => value
|
|
97
|
-
.split(',')
|
|
98
|
-
.map((x) => x.trim())
|
|
99
|
-
.slice(0, 6), ({ value }) => {
|
|
100
|
-
if (value.length < 6)
|
|
101
|
-
throw new Error('Вы указали не все спецификации');
|
|
102
|
-
else
|
|
103
|
-
return value;
|
|
104
|
-
})),
|
|
105
|
-
tslib_1.__param(7, (0, evogram_1.CommandArgument)('confirm', ({ context, value, validateArgs, args }) => {
|
|
106
|
-
if (value)
|
|
107
|
-
return value;
|
|
108
|
-
console.log({ validateArgs, args });
|
|
109
|
-
context.sendFormatted({
|
|
110
|
-
header: `<blockquote><b>👱♀️ Регистрация новой модели ${validateArgs.name} [${validateArgs.age} лет]</b></blockquote>\n\n` + `<i>${validateArgs.about}</i>`,
|
|
111
|
-
body: [
|
|
112
|
-
{
|
|
113
|
-
title: 'ℹ️ Информация о моделе',
|
|
114
|
-
data: Array.from({ length: validateArgs.specifications.length }, (_, i) => [
|
|
115
|
-
Object.values({
|
|
116
|
-
ethnicity: 'Этническая группа',
|
|
117
|
-
physique: 'Телосложение',
|
|
118
|
-
hair_color: 'Цвет волос',
|
|
119
|
-
height: 'Рост',
|
|
120
|
-
weight: 'Вес',
|
|
121
|
-
breasts: 'Грудь',
|
|
122
|
-
})[i],
|
|
123
|
-
validateArgs.specifications[i],
|
|
124
|
-
]),
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
footer: `<b>💄 Услуги, входящие в стоимость тарифа:</b> <i>${validateArgs.services.length ? validateArgs.services.join(', ') : '-'}</i>`,
|
|
128
|
-
}, {
|
|
129
|
-
reply_markup: {
|
|
130
|
-
inline_keyboard: [[{ text: '✅ Подтвердить', command: EscortCreateModelCommand, payload: Object.assign(Object.assign({}, args), { confirm: true }) }]],
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
})),
|
|
134
|
-
tslib_1.__metadata("design:type", Function),
|
|
135
|
-
tslib_1.__metadata("design:paramtypes", [typeof (_a = typeof CommandContext !== "undefined" && CommandContext) === "function" ? _a : Object, String, Number, String, Array, Number, Array, Boolean]),
|
|
136
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
137
|
-
], EscortCreateModelCommand.prototype, "execute", null);
|
|
138
|
-
exports.EscortCreateModelCommand = EscortCreateModelCommand = tslib_1.__decorate([
|
|
139
|
-
(0, migrated_1.CommandD)({ name: 'escortcreatemodel', backButton: 'К созданию модели' })
|
|
140
|
-
], EscortCreateModelCommand);
|
|
141
|
-
async;
|
|
142
|
-
inlineExecute(context, migrated_1.InlineQueryContext, ...args, any);
|
|
143
|
-
{ }
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { CommandArgument } from 'evogram'
|
|
2
|
-
import { CommandD, CommandManager, InlineQueryContext } from 'evogram/lib/migrated'
|
|
3
|
-
|
|
4
|
-
@CommandD({ name: 'escortcreatemodel', backButton: 'К созданию модели' })
|
|
5
|
-
export class EscortCreateModelCommand extends SharedCommand {
|
|
6
|
-
async execute(
|
|
7
|
-
context: CommandContext,
|
|
8
|
-
@CommandArgument(
|
|
9
|
-
{
|
|
10
|
-
name: 'name',
|
|
11
|
-
question: ({ context }) =>
|
|
12
|
-
context
|
|
13
|
-
.sendFormattedQuestion({
|
|
14
|
-
header: '<blockquote><b>👱♀️ Регистрация новой модели</b></blockquote>',
|
|
15
|
-
footer: '<i>Отправьте имя модели в следующем сообщении</i>',
|
|
16
|
-
})
|
|
17
|
-
.then((message) => message.text),
|
|
18
|
-
}
|
|
19
|
-
// stringValidator({ max: 20 })
|
|
20
|
-
)
|
|
21
|
-
name: string,
|
|
22
|
-
@CommandArgument(
|
|
23
|
-
{
|
|
24
|
-
name: 'age',
|
|
25
|
-
question: ({ context }) =>
|
|
26
|
-
context
|
|
27
|
-
.sendFormattedQuestion({
|
|
28
|
-
header: '<blockquote><b>👱♀️ Регистрация новой модели</b></blockquote>',
|
|
29
|
-
footer: '<i>Отправьте возраст модели в следующем сообщении (от 18 до 99 лет)</i>',
|
|
30
|
-
})
|
|
31
|
-
.then((message) => message.text),
|
|
32
|
-
}
|
|
33
|
-
// numberValidator({ min: 18, max: 99 })
|
|
34
|
-
)
|
|
35
|
-
age: number,
|
|
36
|
-
@CommandArgument(
|
|
37
|
-
{
|
|
38
|
-
name: 'about',
|
|
39
|
-
question: ({ context }) =>
|
|
40
|
-
context
|
|
41
|
-
.sendFormattedQuestion({
|
|
42
|
-
header: '<blockquote><b>👱♀️ Регистрация новой модели</b></blockquote>',
|
|
43
|
-
footer: '<i>Отправьте описание модели в следующем сообщении (не более 1000 символов)</i>',
|
|
44
|
-
})
|
|
45
|
-
.then((message) => message.text),
|
|
46
|
-
}
|
|
47
|
-
// stringValidator({ max: 1000 })
|
|
48
|
-
)
|
|
49
|
-
about: string,
|
|
50
|
-
@CommandArgument(
|
|
51
|
-
{
|
|
52
|
-
name: 'services',
|
|
53
|
-
question: ({ context }) =>
|
|
54
|
-
context
|
|
55
|
-
.sendFormattedQuestion({
|
|
56
|
-
header: '<blockquote><b>👱♀️ Регистрация новой модели</b></blockquote>',
|
|
57
|
-
footer: '<i>Отправьте услуги модели в следующем сообщении (через запятую)</i>',
|
|
58
|
-
})
|
|
59
|
-
.then((message) => message.text),
|
|
60
|
-
},
|
|
61
|
-
// stringValidator({ pattern: /^[а-яА-Яa-zA-Z0-9\s]+(,[а-яА-Яa-zA-Z0-9\s]+)*$/ }),
|
|
62
|
-
({ value }) => value.split(',').map((x) => x.trim())
|
|
63
|
-
)
|
|
64
|
-
services: string[],
|
|
65
|
-
@CommandArgument(
|
|
66
|
-
{
|
|
67
|
-
name: 'rating',
|
|
68
|
-
question: ({ context }) =>
|
|
69
|
-
context
|
|
70
|
-
.sendFormattedQuestion({
|
|
71
|
-
header: '<blockquote><b>👱♀️ Регистрация новой модели</b></blockquote>',
|
|
72
|
-
footer: '<i>Отправьте рейтинг модели в следующем сообщении (от 0.00 до 5.00)</i>',
|
|
73
|
-
})
|
|
74
|
-
.then((message) => message.text),
|
|
75
|
-
}
|
|
76
|
-
// numberValidator({ min: 0, max: 5, allowFloat: true })
|
|
77
|
-
)
|
|
78
|
-
rating: number,
|
|
79
|
-
@CommandArgument(
|
|
80
|
-
{
|
|
81
|
-
name: 'specifications',
|
|
82
|
-
question: ({ context, error }) =>
|
|
83
|
-
context
|
|
84
|
-
.sendFormattedQuestion({
|
|
85
|
-
header: '<blockquote><b>👱♀️ Регистрация новой модели</b></blockquote>',
|
|
86
|
-
footer: `<i>Отправьте спецификации модели в следующем сообщении через запятую (${Object.values({
|
|
87
|
-
ethnicity: 'Этническая группа',
|
|
88
|
-
physique: 'Телосложение',
|
|
89
|
-
hair_color: 'Цвет волос',
|
|
90
|
-
height: 'Рост',
|
|
91
|
-
weight: 'Вес',
|
|
92
|
-
breasts: 'Грудь',
|
|
93
|
-
}).join(', ')})</i>`,
|
|
94
|
-
error: error?.message,
|
|
95
|
-
})
|
|
96
|
-
.then((message) => message.text),
|
|
97
|
-
},
|
|
98
|
-
// stringValidator({ pattern: /^[а-яА-Яa-zA-Z0-9\s]+(,[а-яА-Яa-zA-Z0-9\s]+)*$/ }),
|
|
99
|
-
({ value }) =>
|
|
100
|
-
value
|
|
101
|
-
.split(',')
|
|
102
|
-
.map((x) => x.trim())
|
|
103
|
-
.slice(0, 6),
|
|
104
|
-
({ value }) => {
|
|
105
|
-
if (value.length < 6) throw new Error('Вы указали не все спецификации')
|
|
106
|
-
else return value
|
|
107
|
-
}
|
|
108
|
-
)
|
|
109
|
-
specifications: string[],
|
|
110
|
-
@CommandArgument('confirm', ({ context, value, validateArgs, args }) => {
|
|
111
|
-
if (value) return value
|
|
112
|
-
console.log({ validateArgs, args })
|
|
113
|
-
|
|
114
|
-
context.sendFormatted(
|
|
115
|
-
{
|
|
116
|
-
header: `<blockquote><b>👱♀️ Регистрация новой модели ${validateArgs.name} [${validateArgs.age} лет]</b></blockquote>\n\n` + `<i>${validateArgs.about}</i>`,
|
|
117
|
-
body: [
|
|
118
|
-
{
|
|
119
|
-
title: 'ℹ️ Информация о моделе',
|
|
120
|
-
data: Array.from({ length: validateArgs.specifications.length }, (_, i) => [
|
|
121
|
-
Object.values({
|
|
122
|
-
ethnicity: 'Этническая группа',
|
|
123
|
-
physique: 'Телосложение',
|
|
124
|
-
hair_color: 'Цвет волос',
|
|
125
|
-
height: 'Рост',
|
|
126
|
-
weight: 'Вес',
|
|
127
|
-
breasts: 'Грудь',
|
|
128
|
-
})[i],
|
|
129
|
-
validateArgs.specifications[i],
|
|
130
|
-
]),
|
|
131
|
-
},
|
|
132
|
-
],
|
|
133
|
-
footer: `<b>💄 Услуги, входящие в стоимость тарифа:</b> <i>${validateArgs.services.length ? validateArgs.services.join(', ') : '-'}</i>`,
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
reply_markup: {
|
|
137
|
-
inline_keyboard: [[{ text: '✅ Подтвердить', command: EscortCreateModelCommand, payload: { ...args, confirm: true } }]],
|
|
138
|
-
},
|
|
139
|
-
}
|
|
140
|
-
)
|
|
141
|
-
})
|
|
142
|
-
_: true
|
|
143
|
-
) {
|
|
144
|
-
const model = await this.API.post(`/commands/${this.constructor.name}/createModel`, { name, age, about, services, rating, specifications, workerId: context.user.id }).then((res) => res.data)
|
|
145
|
-
return context.redirect(CommandManager.getCommandByName('EscortModelsCommand') as any, { model: model.id })
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
private static async createModel({ name, age, about, services, rating, specifications, workerId }: any) {
|
|
149
|
-
const model = await
|
|
150
|
-
)
|
|
151
|
-
})
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async inlineExecute(context: InlineQueryContext, ...args: any) {}
|
|
155
|
-
}
|
package/test-imports.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ParserSharedCommands_service_1 = require("./src/shared-commands/ParserSharedCommands.service");
|
|
4
|
-
// Тестовый код с разными типами импортов
|
|
5
|
-
const testCode = `
|
|
6
|
-
import * as fs from 'fs'
|
|
7
|
-
import * as path from 'path'
|
|
8
|
-
import { Injectable } from '@nestjs/common'
|
|
9
|
-
import { Command } from './Command'
|
|
10
|
-
import { BaseService } from '../services/BaseService'
|
|
11
|
-
import { Utils } from '/src/utils/Utils'
|
|
12
|
-
import { Config } from './config/Config'
|
|
13
|
-
|
|
14
|
-
class TestCommand extends Command {
|
|
15
|
-
private async processData() {
|
|
16
|
-
return fs.readFileSync('test.txt', 'utf-8')
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
private static validateInput(input: string) {
|
|
20
|
-
return path.isAbsolute(input)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
console.log('Исходный код:');
|
|
25
|
-
console.log(testCode);
|
|
26
|
-
console.log('\n' + '='.repeat(50) + '\n');
|
|
27
|
-
console.log('Преобразованный код:');
|
|
28
|
-
const transformed = ParserSharedCommands_service_1.ParserSharedCommandsService.transformCommand(testCode);
|
|
29
|
-
console.log(transformed);
|
package/test-updated-service.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
// Тест обновленного ParserSharedCommandsService
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
// Имитируем обновленный ParserSharedCommandsService
|
|
6
|
-
class ParserSharedCommandsService {
|
|
7
|
-
static parseClassName(commandContent) {
|
|
8
|
-
const classRegex = /class\s+(\w+)\s+extends\s+\w+/g;
|
|
9
|
-
const match = classRegex.exec(commandContent);
|
|
10
|
-
return match && match[1] ? match[1] : null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static removeLocalImports(content) {
|
|
14
|
-
let result = content.replace(/import\s+.*?from\s+['"]\.\.?\/[^'"]*['"];?\n?/g, '');
|
|
15
|
-
result = result.replace(/import\s+.*?from\s+['"]\/[^'"]*['"];?\n?/g, '');
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static cleanupOrphanedCode(content) {
|
|
20
|
-
let result = content;
|
|
21
|
-
|
|
22
|
-
// Убираем обрывки map функций
|
|
23
|
-
result = result.replace(/\w+\.map\(async\s*\([^)]*\)\s*=>\s*\{[\s\S]*?\}/g, '');
|
|
24
|
-
|
|
25
|
-
// Убираем обрывки вызовов database
|
|
26
|
-
result = result.replace(/client\.database\.[\w.]+\s*\([^)]*\)[\s\S]*?;?\n?/g, '');
|
|
27
|
-
|
|
28
|
-
// Убираем обрывки return await
|
|
29
|
-
result = result.replace(/return\s+await\s+[\w.]+\([^)]*\)[\s\S]*?;?\n?/g, '');
|
|
30
|
-
|
|
31
|
-
// Убираем ссылки на удаленные типы
|
|
32
|
-
result = result.replace(/Object\.values\([^)]+\)\.length/g, '6');
|
|
33
|
-
|
|
34
|
-
// Убираем лишние скобки в конце
|
|
35
|
-
result = result.replace(/\n\s*\)\s*\n\s*\)\s*\}\s*$/g, '\n}');
|
|
36
|
-
result = result.replace(/\n\s*\)\s*\n\s*\)\s*$/g, '\n');
|
|
37
|
-
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static createApiCall(methodName, args) {
|
|
42
|
-
let processedArgs = args.trim();
|
|
43
|
-
if (!processedArgs) {
|
|
44
|
-
processedArgs = '{}';
|
|
45
|
-
} else {
|
|
46
|
-
if (processedArgs.startsWith('{') && processedArgs.endsWith('}')) {
|
|
47
|
-
processedArgs = processedArgs.replace(/\s+/g, ' ');
|
|
48
|
-
} else {
|
|
49
|
-
processedArgs = `{ value: ${processedArgs} }`;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return `this.API.post(\`/commands/\${this.constructor.name}/${methodName}\`, ${processedArgs}).then((res) => res.data)`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static transformCommand(commandContent) {
|
|
56
|
-
let transformedContent = this.removeLocalImports(commandContent);
|
|
57
|
-
|
|
58
|
-
// Заменяем extends на SharedCommand
|
|
59
|
-
transformedContent = transformedContent.replace(/extends\s+\w+/g, 'extends SharedCommand');
|
|
60
|
-
|
|
61
|
-
// Находим все приватные методы
|
|
62
|
-
const privateMethodRegex = /private\s+(?:static\s+)?(?:async\s+)?(\w+)\s*\([^)]*\)\s*\{[\s\S]*?\n\s*\}\n?/g;
|
|
63
|
-
const privateMethods = [];
|
|
64
|
-
let match;
|
|
65
|
-
|
|
66
|
-
while ((match = privateMethodRegex.exec(commandContent)) !== null) {
|
|
67
|
-
privateMethods.push(match[1]);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Получаем название класса
|
|
71
|
-
const className = this.parseClassName(commandContent);
|
|
72
|
-
|
|
73
|
-
// Заменяем вызовы приватных методов на API вызовы
|
|
74
|
-
privateMethods.forEach((methodName) => {
|
|
75
|
-
const staticMethodCallRegex = new RegExp(`${className}\\.${methodName}\\s*\\(([^)]*)\\)`, 'g');
|
|
76
|
-
if (className) {
|
|
77
|
-
transformedContent = transformedContent.replace(staticMethodCallRegex, (match, args) => {
|
|
78
|
-
return this.createApiCall(methodName, args);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// Удаляем все приватные методы
|
|
84
|
-
privateMethods.forEach((methodName) => {
|
|
85
|
-
const methodRegex = new RegExp(`private\\s+(?:static\\s+)?(?:async\\s+)?${methodName}\\s*\\([^)]*\\)\\s*\\{[\\s\S]*?\\n\\s*\\}\\n?\\n?`, 'g');
|
|
86
|
-
transformedContent = transformedContent.replace(methodRegex, '');
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// Убираем обрывки кода
|
|
90
|
-
transformedContent = this.cleanupOrphanedCode(transformedContent);
|
|
91
|
-
|
|
92
|
-
// Убираем лишние скобки и пустые строки
|
|
93
|
-
transformedContent = transformedContent.replace(/\n\s*\}\s*\n\s*\}/g, '\n}');
|
|
94
|
-
transformedContent = transformedContent.replace(/\n\s*\)\s*\n\s*\)\s*$/g, '\n');
|
|
95
|
-
transformedContent = transformedContent.replace(/\n\s*return\s+\w+\s*\n/g, '\n');
|
|
96
|
-
|
|
97
|
-
// Убираем лишние пустые строки
|
|
98
|
-
transformedContent = transformedContent.replace(/\n\s*\n\s*\n/g, '\n\n');
|
|
99
|
-
|
|
100
|
-
return transformedContent;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
console.log('🧪 Тестирование обновленного ParserSharedCommandsService...');
|
|
106
|
-
|
|
107
|
-
const inputPath = '../escort/src/commands/shared/models/CreateModel.srdcmd.ts';
|
|
108
|
-
const outputPath = './CreateModel.parsed.updated-service.ts';
|
|
109
|
-
|
|
110
|
-
console.log('\n📖 Читаю оригинальный файл...');
|
|
111
|
-
const originalContent = fs.readFileSync(inputPath, 'utf-8');
|
|
112
|
-
console.log(`✅ Оригинальный файл прочитан: ${originalContent.length} символов`);
|
|
113
|
-
|
|
114
|
-
console.log('\n🔧 Парсинг через обновленный сервис...');
|
|
115
|
-
const parsedContent = ParserSharedCommandsService.transformCommand(originalContent);
|
|
116
|
-
console.log(`✅ Команда спарсена: ${parsedContent.length} символов`);
|
|
117
|
-
|
|
118
|
-
console.log('\n💾 Сохраняю результат...');
|
|
119
|
-
fs.writeFileSync(outputPath, parsedContent, 'utf-8');
|
|
120
|
-
console.log(`✅ Результат сохранен в: ${outputPath}`);
|
|
121
|
-
|
|
122
|
-
// Проверяем результат
|
|
123
|
-
console.log('\n🧹 ПРОВЕРКА РЕЗУЛЬТАТА:');
|
|
124
|
-
console.log('='.repeat(50));
|
|
125
|
-
|
|
126
|
-
const hasOrphanedCode = parsedContent.includes('specifications.map') ||
|
|
127
|
-
parsedContent.includes('client.database.models.createSpecification') ||
|
|
128
|
-
parsedContent.includes('ModelSpecificationTypes') ||
|
|
129
|
-
parsedContent.includes('return model');
|
|
130
|
-
|
|
131
|
-
const hasProperImports = parsedContent.includes('CommandContext') &&
|
|
132
|
-
parsedContent.includes('SharedCommand') &&
|
|
133
|
-
parsedContent.includes('CommandManager');
|
|
134
|
-
|
|
135
|
-
const hasApiCall = parsedContent.includes('this.API.post');
|
|
136
|
-
|
|
137
|
-
const hasProperExtends = parsedContent.includes('extends SharedCommand');
|
|
138
|
-
|
|
139
|
-
const hasExtraBrackets = parsedContent.includes('\n\t\t})\n\t}\n') ||
|
|
140
|
-
parsedContent.includes('\n\t\t})\n\t}\n');
|
|
141
|
-
|
|
142
|
-
console.log(` ${!hasOrphanedCode ? '✅' : '❌'} Обрывки кода: ${!hasOrphanedCode ? 'УДАЛЕНЫ' : 'ОСТАЛИСЬ'}`);
|
|
143
|
-
console.log(` ${hasProperImports ? '✅' : '❌'} Импорты: ${hasProperImports ? 'ПРАВИЛЬНЫЕ' : 'ОШИБКИ'}`);
|
|
144
|
-
console.log(` ${hasApiCall ? '✅' : '❌'} API вызов: ${hasApiCall ? 'НАЙДЕН' : 'ОТСУТСТВУЕТ'}`);
|
|
145
|
-
console.log(` ${hasProperExtends ? '✅' : '❌'} Наследование: ${hasProperExtends ? 'ПРАВИЛЬНОЕ' : 'ОШИБКА'}`);
|
|
146
|
-
console.log(` ${!hasExtraBrackets ? '✅' : '❌'} Лишние скобки: ${!hasExtraBrackets ? 'УДАЛЕНЫ' : 'ОСТАЛИСЬ'}`);
|
|
147
|
-
|
|
148
|
-
const compression = Math.round((1 - parsedContent.length / originalContent.length) * 100);
|
|
149
|
-
console.log(` 📊 Сжатие: ${compression}%`);
|
|
150
|
-
|
|
151
|
-
if (!hasOrphanedCode && hasProperImports && hasApiCall && hasProperExtends && !hasExtraBrackets) {
|
|
152
|
-
console.log('\n🎉 ОБНОВЛЕННЫЙ СЕРВИС РАБОТАЕТ ИДЕАЛЬНО!');
|
|
153
|
-
} else {
|
|
154
|
-
console.log('\n⚠️ Есть проблемы, требующие доработки!');
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
console.log('\n🎯 Тестирование завершено!');
|
|
158
|
-
console.log(`📁 Результат: ${path.resolve(outputPath)}`);
|
|
159
|
-
|
|
160
|
-
} catch (error) {
|
|
161
|
-
console.error('❌ Ошибка:', error.message);
|
|
162
|
-
process.exit(1);
|
|
163
|
-
}
|