echoapi-converter 0.0.50 → 0.0.52

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/index.d.ts CHANGED
@@ -13,7 +13,7 @@ declare class ApipostToSwagger {
13
13
  private array2NamePathObj;
14
14
  private array2TreeExport;
15
15
  private handleApis;
16
- apiToswagger(apipostObj: ApipostObj, version: "2.0" | "3.0"): {
16
+ apiToswagger(apipostObj: ApipostObj, version: "2.0" | "3.0", language?: 'en' | 'zh-cn' | 'ja' | 'zh-hant' | 'id'): {
17
17
  status: "error" | "success";
18
18
  message: string;
19
19
  data: any;
package/dist/index.js CHANGED
@@ -266,10 +266,10 @@ const THUNDER_CLIENT_GRANT_TYPES = {
266
266
  // plain: 'text/plain',
267
267
  // html: 'text/html',
268
268
  // };
269
- const FILL_TYPES = {
270
- left: '左填充',
271
- right: '右填充'
272
- };
269
+ // export const FILL_TYPES = {
270
+ // left:'左填充',
271
+ // right: '右填充'
272
+ // }
273
273
  const RULE_TYPES_ICON = {
274
274
  1: '(,)',
275
275
  2: '(|)',
@@ -282,6 +282,359 @@ const RULE_TYPES_ICON = {
282
282
  9: '(\\r\\n)',
283
283
  };
284
284
 
285
+ var securityConnectionMessage$4 = "When connecting via a secure connection";
286
+ var enableServerCertificateValidation$4 = "do not enable server certificate validation";
287
+ var pleaseEnableServerCertificateValidation$4 = "please enable server certificate validation";
288
+ var useClientVersion$4 = "and use client version";
289
+ var specifyHandshakePath$4 = "with no specified handshake path";
290
+ var performConnection$4 = "Perform the connection";
291
+ var allowUnlimitedSendContent$4 = "And allow unlimited content to be sent";
292
+ var allowMaxSendContentSize$4 = "And allow the maximum content size to be sent as";
293
+ var leftPaddingLength$4 = "Left pad to a length of";
294
+ var rightPaddingLength$4 = "Right pad to a length of";
295
+ var paddingCharacter$4 = "padding character";
296
+ var addEndingDelimiter$4 = "Add an ending delimiter";
297
+ var requestEncodingFormat$4 = "The encoding format of the request message is";
298
+ var addNewline$4 = "Add a newline character at the end of each request message";
299
+ var addContentLength$4 = "Calculate the content length (excluding the header) and add it to the header (text format, header byte length is";
300
+ var removeResponseHeader$4 = "The response message needs to remove the packet header (length of";
301
+ var byte$4 = "bytes";
302
+ var trimTrailingNewline$4 = "trim trailing newline characters";
303
+ var convertXmlToJson$4 = "and convert the XML content to JSON format";
304
+ var completeOnReceive$4 = "Completion is assumed upon data reception (subpacket handling is not addressed)";
305
+ var specialCharText$4 = "For text-type messages, the packet tail contains special character";
306
+ var specialCharBinary$4 = "For binary-type messages, the packet tail contains special character";
307
+ var headerBodyFormat$4 = "[Header+Body] formatted message (header contains the byte length of the body)";
308
+ var fixedLength$4 = "The message has a fixed length of";
309
+ var serverAddress$4 = "Server address";
310
+ var pktCompletion$4 = "Method to determine message reception completio";
311
+ var createDir$4 = "Create directory";
312
+ var createProj$4 = "Create project";
313
+ var createEnv$4 = "Create environment";
314
+ var en = {
315
+ securityConnectionMessage: securityConnectionMessage$4,
316
+ enableServerCertificateValidation: enableServerCertificateValidation$4,
317
+ pleaseEnableServerCertificateValidation: pleaseEnableServerCertificateValidation$4,
318
+ useClientVersion: useClientVersion$4,
319
+ specifyHandshakePath: specifyHandshakePath$4,
320
+ performConnection: performConnection$4,
321
+ allowUnlimitedSendContent: allowUnlimitedSendContent$4,
322
+ allowMaxSendContentSize: allowMaxSendContentSize$4,
323
+ leftPaddingLength: leftPaddingLength$4,
324
+ rightPaddingLength: rightPaddingLength$4,
325
+ paddingCharacter: paddingCharacter$4,
326
+ addEndingDelimiter: addEndingDelimiter$4,
327
+ requestEncodingFormat: requestEncodingFormat$4,
328
+ addNewline: addNewline$4,
329
+ addContentLength: addContentLength$4,
330
+ removeResponseHeader: removeResponseHeader$4,
331
+ byte: byte$4,
332
+ trimTrailingNewline: trimTrailingNewline$4,
333
+ convertXmlToJson: convertXmlToJson$4,
334
+ completeOnReceive: completeOnReceive$4,
335
+ specialCharText: specialCharText$4,
336
+ specialCharBinary: specialCharBinary$4,
337
+ headerBodyFormat: headerBodyFormat$4,
338
+ fixedLength: fixedLength$4,
339
+ serverAddress: serverAddress$4,
340
+ pktCompletion: pktCompletion$4,
341
+ createDir: createDir$4,
342
+ createProj: createProj$4,
343
+ createEnv: createEnv$4
344
+ };
345
+
346
+ var securityConnectionMessage$3 = "Saat melakukan koneksi yang aman";
347
+ var enableServerCertificateValidation$3 = "Tidak perlu mengaktifkan validasi sertifikat server";
348
+ var pleaseEnableServerCertificateValidation$3 = "Silakan aktifkan validasi sertifikat server";
349
+ var useClientVersion$3 = "Dan gunakan versi klien";
350
+ var specifyHandshakePath$3 = "Dan tentukan path handshake";
351
+ var performConnection$3 = "Lakukan koneksi";
352
+ var allowUnlimitedSendContent$3 = "Dan izinkan isi yang dikirim tanpa batas";
353
+ var allowMaxSendContentSize$3 = "Dan izinkan ukuran isi maksimum yang dikirim sebagai";
354
+ var leftPaddingLength$3 = "Panjang padding di sebelah kiri";
355
+ var rightPaddingLength$3 = "Panjang padding di sebelah kanan";
356
+ var paddingCharacter$3 = "Karakter padding";
357
+ var addEndingDelimiter$3 = "Tambahkan delimiter penutup";
358
+ var requestEncodingFormat$3 = "Format enkripsi pesan permintaan adalah";
359
+ var addNewline$3 = "Tambahkan karakter baris baru di akhir setiap pesan permintaan";
360
+ var addContentLength$3 = "Hitung panjang isi (tidak termasuk header) dan tambahkan ke header (format teks, panjang byte header adalah";
361
+ var removeResponseHeader$3 = "Hapus header respons (panjangnya adalah";
362
+ var byte$3 = "byte";
363
+ var trimTrailingNewline$3 = "Hapus karakter baris baru di akhir";
364
+ var convertXmlToJson$3 = "Dan ubah konten XML menjadi format JSON";
365
+ var completeOnReceive$3 = "Anggap data diterima sebagai lengkap (tanpa menangani segmentasi paket)";
366
+ var specialCharText$3 = "Pesan berakhir dengan karakter khusus (pesan teks)";
367
+ var specialCharBinary$3 = "Pesan berakhir dengan karakter khusus (pesan biner)";
368
+ var headerBodyFormat$3 = "[Header + Body] format pesan (header menyimpan panjang byte body)";
369
+ var fixedLength$3 = "Pesan dengan panjang tetap";
370
+ var serverAddress$3 = "Alamat server";
371
+ var pktCompletion$3 = "Tentukan metode penyelesaian penerimaan pesan";
372
+ var createDir$3 = "Buat direktori";
373
+ var createProj$3 = "Buat proyek";
374
+ var createEnv$3 = "Buat lingkungan";
375
+ var id = {
376
+ securityConnectionMessage: securityConnectionMessage$3,
377
+ enableServerCertificateValidation: enableServerCertificateValidation$3,
378
+ pleaseEnableServerCertificateValidation: pleaseEnableServerCertificateValidation$3,
379
+ useClientVersion: useClientVersion$3,
380
+ specifyHandshakePath: specifyHandshakePath$3,
381
+ performConnection: performConnection$3,
382
+ allowUnlimitedSendContent: allowUnlimitedSendContent$3,
383
+ allowMaxSendContentSize: allowMaxSendContentSize$3,
384
+ leftPaddingLength: leftPaddingLength$3,
385
+ rightPaddingLength: rightPaddingLength$3,
386
+ paddingCharacter: paddingCharacter$3,
387
+ addEndingDelimiter: addEndingDelimiter$3,
388
+ requestEncodingFormat: requestEncodingFormat$3,
389
+ addNewline: addNewline$3,
390
+ addContentLength: addContentLength$3,
391
+ removeResponseHeader: removeResponseHeader$3,
392
+ byte: byte$3,
393
+ trimTrailingNewline: trimTrailingNewline$3,
394
+ convertXmlToJson: convertXmlToJson$3,
395
+ completeOnReceive: completeOnReceive$3,
396
+ specialCharText: specialCharText$3,
397
+ specialCharBinary: specialCharBinary$3,
398
+ headerBodyFormat: headerBodyFormat$3,
399
+ fixedLength: fixedLength$3,
400
+ serverAddress: serverAddress$3,
401
+ pktCompletion: pktCompletion$3,
402
+ createDir: createDir$3,
403
+ createProj: createProj$3,
404
+ createEnv: createEnv$3
405
+ };
406
+
407
+ var securityConnectionMessage$2 = "安全接続を行う際に";
408
+ var enableServerCertificateValidation$2 = "サーバー証明書の検証を有効にする必要はありません";
409
+ var pleaseEnableServerCertificateValidation$2 = "サーバー証明書の検証を有効にしてください";
410
+ var useClientVersion$2 = "クライアントバージョンを使用してください";
411
+ var specifyHandshakePath$2 = "ハンドシェイクパスを指定してください";
412
+ var performConnection$2 = "接続を行います";
413
+ var allowUnlimitedSendContent$2 = "送信可能なコンテンツを無制限に許可します";
414
+ var allowMaxSendContentSize$2 = "送信可能な最大コンテンツサイズをとして許可します";
415
+ var leftPaddingLength$2 = "左側のパディング長さ";
416
+ var rightPaddingLength$2 = "右側のパディング長さ";
417
+ var paddingCharacter$2 = "パディング文字";
418
+ var addEndingDelimiter$2 = "終了区切り文字を追加します";
419
+ var requestEncodingFormat$2 = "リクエストメッセージのエンコーディング形式は";
420
+ var addNewline$2 = "各リクエストメッセージの末尾に改行文字を追加します";
421
+ var addContentLength$2 = "コンテンツ長さを計算(ヘッダーを除く)し、ヘッダーに追加します(テキスト形式、ヘッダーバイト長は";
422
+ var removeResponseHeader$2 = "レスポンスヘッダーを削除します(長さは";
423
+ var byte$2 = "バイト";
424
+ var trimTrailingNewline$2 = "行末の改行文字を削除します";
425
+ var convertXmlToJson$2 = "XML形式のコンテンツをJSON形式に変換します";
426
+ var completeOnReceive$2 = "データを受信した時点で完了とみなします(パケット分割は処理しません)";
427
+ var specialCharText$2 = "メッセージの末尾に特殊文字が含まれています(テキストメッセージ)";
428
+ var specialCharBinary$2 = "メッセージの末尾に特殊文字が含まれています(バイナリメッセージ)";
429
+ var headerBodyFormat$2 = "[ヘッダー + ボディ]形式のメッセージ(ヘッダーにボディのバイト長を格納)";
430
+ var fixedLength$2 = "固定長メッセージ";
431
+ var serverAddress$2 = "サーバーアドレス";
432
+ var pktCompletion$2 = "メッセージ受信完了方法を判断する";
433
+ var createDir$2 = "ディレクトリを作成する";
434
+ var createProj$2 = "プロジェクトを作成する";
435
+ var createEnv$2 = "環境を作成する";
436
+ var ja = {
437
+ securityConnectionMessage: securityConnectionMessage$2,
438
+ enableServerCertificateValidation: enableServerCertificateValidation$2,
439
+ pleaseEnableServerCertificateValidation: pleaseEnableServerCertificateValidation$2,
440
+ useClientVersion: useClientVersion$2,
441
+ specifyHandshakePath: specifyHandshakePath$2,
442
+ performConnection: performConnection$2,
443
+ allowUnlimitedSendContent: allowUnlimitedSendContent$2,
444
+ allowMaxSendContentSize: allowMaxSendContentSize$2,
445
+ leftPaddingLength: leftPaddingLength$2,
446
+ rightPaddingLength: rightPaddingLength$2,
447
+ paddingCharacter: paddingCharacter$2,
448
+ addEndingDelimiter: addEndingDelimiter$2,
449
+ requestEncodingFormat: requestEncodingFormat$2,
450
+ addNewline: addNewline$2,
451
+ addContentLength: addContentLength$2,
452
+ removeResponseHeader: removeResponseHeader$2,
453
+ byte: byte$2,
454
+ trimTrailingNewline: trimTrailingNewline$2,
455
+ convertXmlToJson: convertXmlToJson$2,
456
+ completeOnReceive: completeOnReceive$2,
457
+ specialCharText: specialCharText$2,
458
+ specialCharBinary: specialCharBinary$2,
459
+ headerBodyFormat: headerBodyFormat$2,
460
+ fixedLength: fixedLength$2,
461
+ serverAddress: serverAddress$2,
462
+ pktCompletion: pktCompletion$2,
463
+ createDir: createDir$2,
464
+ createProj: createProj$2,
465
+ createEnv: createEnv$2
466
+ };
467
+
468
+ var securityConnectionMessage$1 = "在通过安全连接时";
469
+ var enableServerCertificateValidation$1 = "无需启用服务器证书验证";
470
+ var pleaseEnableServerCertificateValidation$1 = "请启用服务器证书验证";
471
+ var useClientVersion$1 = "并使用客户端版本";
472
+ var specifyHandshakePath$1 = "和指定的握手路径";
473
+ var performConnection$1 = "进行连接";
474
+ var allowUnlimitedSendContent$1 = "并且允许接收的最大发送内容无限制。";
475
+ var allowMaxSendContentSize$1 = "并且允许接收的最大发送内容为";
476
+ var leftPaddingLength$1 = "左填充至长度";
477
+ var rightPaddingLength$1 = "右填充至长度";
478
+ var paddingCharacter$1 = "填充字符";
479
+ var addEndingDelimiter$1 = "结尾添加分隔符";
480
+ var requestEncodingFormat$1 = "请求报文的编码格式为";
481
+ var addNewline$1 = "在每个请求报文的结尾添加换行符";
482
+ var addContentLength$1 = "计算内容长度(不包括包头)并将其添加到包头(文本格式,包头字节长度为";
483
+ var removeResponseHeader$1 = "响应报文需要去除包头(长度为";
484
+ var byte$1 = "字节";
485
+ var trimTrailingNewline$1 = "去除行尾的换行符";
486
+ var convertXmlToJson$1 = "并将 XML 格式的内容转换为 JSON 格式";
487
+ var completeOnReceive$1 = "收到数据即认为完成(不处理分包问题)";
488
+ var specialCharText$1 = "包尾含特殊字符(文本报文)";
489
+ var specialCharBinary$1 = "包尾含特殊字符(二进制报文)";
490
+ var headerBodyFormat$1 = "[包头+包体]格式报文(包头存包体字节长度)";
491
+ var fixedLength$1 = "定长报文";
492
+ var serverAddress$1 = "服务端地址";
493
+ var pktCompletion$1 = "判断报文接收完成方式";
494
+ var createDir$1 = "新建目录";
495
+ var createProj$1 = "新建项目";
496
+ var createEnv$1 = "新建环境";
497
+ var cn = {
498
+ securityConnectionMessage: securityConnectionMessage$1,
499
+ enableServerCertificateValidation: enableServerCertificateValidation$1,
500
+ pleaseEnableServerCertificateValidation: pleaseEnableServerCertificateValidation$1,
501
+ useClientVersion: useClientVersion$1,
502
+ specifyHandshakePath: specifyHandshakePath$1,
503
+ performConnection: performConnection$1,
504
+ allowUnlimitedSendContent: allowUnlimitedSendContent$1,
505
+ allowMaxSendContentSize: allowMaxSendContentSize$1,
506
+ leftPaddingLength: leftPaddingLength$1,
507
+ rightPaddingLength: rightPaddingLength$1,
508
+ paddingCharacter: paddingCharacter$1,
509
+ addEndingDelimiter: addEndingDelimiter$1,
510
+ requestEncodingFormat: requestEncodingFormat$1,
511
+ addNewline: addNewline$1,
512
+ addContentLength: addContentLength$1,
513
+ removeResponseHeader: removeResponseHeader$1,
514
+ byte: byte$1,
515
+ trimTrailingNewline: trimTrailingNewline$1,
516
+ convertXmlToJson: convertXmlToJson$1,
517
+ completeOnReceive: completeOnReceive$1,
518
+ specialCharText: specialCharText$1,
519
+ specialCharBinary: specialCharBinary$1,
520
+ headerBodyFormat: headerBodyFormat$1,
521
+ fixedLength: fixedLength$1,
522
+ serverAddress: serverAddress$1,
523
+ pktCompletion: pktCompletion$1,
524
+ createDir: createDir$1,
525
+ createProj: createProj$1,
526
+ createEnv: createEnv$1
527
+ };
528
+
529
+ var securityConnectionMessage = "在進行安全連線時";
530
+ var enableServerCertificateValidation = "無需啟用伺服器憑證驗證";
531
+ var pleaseEnableServerCertificateValidation = "請啟用伺服器憑證驗證";
532
+ var useClientVersion = "並使用客戶端版本";
533
+ var specifyHandshakePath = "和指定的握手路徑";
534
+ var performConnection = "進行連線";
535
+ var allowUnlimitedSendContent = "並允許無限制地發送內容";
536
+ var allowMaxSendContentSize = "並允許發送的最大內容大小為";
537
+ var leftPaddingLength = "左側填補長度";
538
+ var rightPaddingLength = "右側填補長度";
539
+ var paddingCharacter = "填補字符";
540
+ var addEndingDelimiter = "在結尾添加分隔符";
541
+ var requestEncodingFormat = "請求報文的編碼格式為";
542
+ var addNewline = "在每個請求報文的結尾添加換行符";
543
+ var addContentLength = "計算內容長度(不包括包頭)並將其添加到包頭(文本格式,包頭字節長度為";
544
+ var removeResponseHeader = "移除響應報文的包頭(長度為";
545
+ var byte = "位元組";
546
+ var trimTrailingNewline = "去除行尾的換行符";
547
+ var convertXmlToJson = "並將 XML 格式的內容轉換為 JSON 格式";
548
+ var completeOnReceive = "收到數據即認為完成(不處理分包問題)";
549
+ var specialCharText = "包尾含特殊字符(文本報文)";
550
+ var specialCharBinary = "包尾含特殊字符(二進制報文)";
551
+ var headerBodyFormat = "[包頭+包體]格式報文(包頭存包體字節長度)";
552
+ var fixedLength = "定長報文";
553
+ var serverAddress = "伺服器地址";
554
+ var pktCompletion = "判斷報文接收完成方式";
555
+ var createDir = "新建目錄";
556
+ var createProj = "新建項目";
557
+ var createEnv = "新建環境";
558
+ var tw = {
559
+ securityConnectionMessage: securityConnectionMessage,
560
+ enableServerCertificateValidation: enableServerCertificateValidation,
561
+ pleaseEnableServerCertificateValidation: pleaseEnableServerCertificateValidation,
562
+ useClientVersion: useClientVersion,
563
+ specifyHandshakePath: specifyHandshakePath,
564
+ performConnection: performConnection,
565
+ allowUnlimitedSendContent: allowUnlimitedSendContent,
566
+ allowMaxSendContentSize: allowMaxSendContentSize,
567
+ leftPaddingLength: leftPaddingLength,
568
+ rightPaddingLength: rightPaddingLength,
569
+ paddingCharacter: paddingCharacter,
570
+ addEndingDelimiter: addEndingDelimiter,
571
+ requestEncodingFormat: requestEncodingFormat,
572
+ addNewline: addNewline,
573
+ addContentLength: addContentLength,
574
+ removeResponseHeader: removeResponseHeader,
575
+ byte: byte,
576
+ trimTrailingNewline: trimTrailingNewline,
577
+ convertXmlToJson: convertXmlToJson,
578
+ completeOnReceive: completeOnReceive,
579
+ specialCharText: specialCharText,
580
+ specialCharBinary: specialCharBinary,
581
+ headerBodyFormat: headerBodyFormat,
582
+ fixedLength: fixedLength,
583
+ serverAddress: serverAddress,
584
+ pktCompletion: pktCompletion,
585
+ createDir: createDir,
586
+ createProj: createProj,
587
+ createEnv: createEnv
588
+ };
589
+
590
+ // utils/i18n.js
591
+ // let i18nInstance:any = null;
592
+ let language = 'en';
593
+ const resources = {
594
+ "zh-cn": {
595
+ translation: cn,
596
+ },
597
+ en: {
598
+ translation: en,
599
+ },
600
+ ja: {
601
+ translation: ja,
602
+ },
603
+ 'zh-Hant': {
604
+ translation: tw,
605
+ },
606
+ id: {
607
+ translation: id,
608
+ },
609
+ };
610
+ /**
611
+ * 获取或创建独立的 i18next 实例
612
+ * @returns {i18next.i18n} - i18next 实例
613
+ */
614
+ const I18nInit = (lng) => {
615
+ language = lng;
616
+ // if (!i18nInstance) {
617
+ // i18nInstance = i18next.createInstance();
618
+ // await i18nInstance.init({
619
+ // lng: lng,
620
+ // fallbackLng: 'zh-cn',
621
+ // resources,
622
+ // });
623
+ // }else{
624
+ // await i18nInstance?.changeLanguage(lng);
625
+ // }
626
+ // return i18nInstance;
627
+ };
628
+ /**
629
+ * 根据语言和键获取翻译
630
+ * @param {string} lng - 语言代码,例如 'en', 'zh'
631
+ * @param {string} key - 翻译键,例如 'greeting'
632
+ */
633
+ const t = (key) => {
634
+ var _a, _b;
635
+ return ((_b = (_a = resources === null || resources === void 0 ? void 0 : resources[language]) === null || _a === void 0 ? void 0 : _a.translation) === null || _b === void 0 ? void 0 : _b[key]) || key;
636
+ };
637
+
285
638
  // @ts-nocheck
286
639
  const MAX_DEEP_COUNT = 10;
287
640
  const schemaPath = (name, version) => {
@@ -577,11 +930,11 @@ const handleSocketMethodParameterDescription = (item, mode) => {
577
930
  let description = item === null || item === void 0 ? void 0 : item.description;
578
931
  let rules = item === null || item === void 0 ? void 0 : item.rules;
579
932
  if (mode == 'fixed_message') {
580
- let fillTypStr = (FILL_TYPES === null || FILL_TYPES === void 0 ? void 0 : FILL_TYPES[rules === null || rules === void 0 ? void 0 : rules.fill_type]) || '';
581
- return `${description}\n${fillTypStr}至长度${rules === null || rules === void 0 ? void 0 : rules.length},填充字符${rules === null || rules === void 0 ? void 0 : rules.custom}`;
933
+ let fillTypStr = (rules === null || rules === void 0 ? void 0 : rules.fill_type) == 'left' ? t('leftPaddingLength') : (rules === null || rules === void 0 ? void 0 : rules.fill_type) == 'right' ? t('rightPaddingLength') : '';
934
+ return `${description}\n${fillTypStr}${rules === null || rules === void 0 ? void 0 : rules.length},${t('paddingCharacter')}${rules === null || rules === void 0 ? void 0 : rules.custom}`;
582
935
  }
583
936
  else if (mode == 'delimiter_message') {
584
- return `${description}\n结尾添加分隔符${RULE_TYPES_ICON[rules === null || rules === void 0 ? void 0 : rules.delimiter]}`;
937
+ return `${description}\n${t('addEndingDelimiter')}${RULE_TYPES_ICON[rules === null || rules === void 0 ? void 0 : rules.delimiter]}`;
585
938
  }
586
939
  return description;
587
940
  };
@@ -707,11 +1060,12 @@ const handlePathItemRequestBody = (body, pathItem, modelsObj) => {
707
1060
  schema: {
708
1061
  type: "object",
709
1062
  properties: parameter.reduce((lastData, item) => {
1063
+ var _a;
710
1064
  if (lodash.isString(item === null || item === void 0 ? void 0 : item.key) &&
711
1065
  item.key.length > 0 &&
712
1066
  (!lodash.has(item, "is_checked") || (item === null || item === void 0 ? void 0 : item.is_checked) > 0)) {
713
1067
  lastData[item.key] = {
714
- type: "string",
1068
+ type: ((_a = item === null || item === void 0 ? void 0 : item.field_type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || 'string',
715
1069
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
716
1070
  example: (item === null || item === void 0 ? void 0 : item.value) || "",
717
1071
  };
@@ -782,11 +1136,11 @@ const createPathItem = (item, sourceObj, pid, pidName, modelsObj, apiVersion, ta
782
1136
  switch (target_type) {
783
1137
  case 'socketio':
784
1138
  pathItem.description = `${pathItem.description}
785
- Over a secure connection,${((_o = item === null || item === void 0 ? void 0 : item.config) === null || _o === void 0 ? void 0 : _o.certificate_verification) == -1 ? 'Do not enable server certificate verification.' : 'Enable server certificate verification'},And use the client version ${((_p = item === null || item === void 0 ? void 0 : item.config) === null || _p === void 0 ? void 0 : _p.socket_version) || 'v4'}And the specified handshake path ${((_q = item === null || item === void 0 ? void 0 : item.config) === null || _q === void 0 ? void 0 : _q.shake_hands_path) || '/socket.io'} make a connection.`;
1139
+ ${t('securityConnectionMessage')},${((_o = item === null || item === void 0 ? void 0 : item.config) === null || _o === void 0 ? void 0 : _o.certificate_verification) == -1 ? t('enableServerCertificateValidation') : t('pleaseEnableServerCertificateValidation')},${t('useClientVersion')} ${((_p = item === null || item === void 0 ? void 0 : item.config) === null || _p === void 0 ? void 0 : _p.socket_version) || 'v4'}${t('specifyHandshakePath')} ${((_q = item === null || item === void 0 ? void 0 : item.config) === null || _q === void 0 ? void 0 : _q.shake_hands_path) || '/socket.io'} ${t('performConnection')}.`;
786
1140
  break;
787
1141
  case 'websocket2':
788
1142
  pathItem.description = `${pathItem.description}
789
- Over a secure connection,${((_r = item === null || item === void 0 ? void 0 : item.config) === null || _r === void 0 ? void 0 : _r.certificate_verification) == -1 ? 'Do not enable server certificate verification.' : 'Enable server certificate verification'},${((_s = item === null || item === void 0 ? void 0 : item.config) === null || _s === void 0 ? void 0 : _s.information_size) == 0 ? 'And there is no limit to the maximum sent content that can be received。' : `And the maximum sent content allowed to be received is${((_t = item === null || item === void 0 ? void 0 : item.config) === null || _t === void 0 ? void 0 : _t.information_size) || 5}M。`}`;
1143
+ ${t('securityConnectionMessage')},${((_r = item === null || item === void 0 ? void 0 : item.config) === null || _r === void 0 ? void 0 : _r.certificate_verification) == -1 ? t('enableServerCertificateValidation') : t('pleaseEnableServerCertificateValidation')},${((_s = item === null || item === void 0 ? void 0 : item.config) === null || _s === void 0 ? void 0 : _s.information_size) == 0 ? t('allowUnlimitedSendContent') : `${t('allowMaxSendContentSize')}${((_t = item === null || item === void 0 ? void 0 : item.config) === null || _t === void 0 ? void 0 : _t.information_size) || 5}M。`}`;
790
1144
  break;
791
1145
  }
792
1146
  }
@@ -812,7 +1166,7 @@ Over a secure connection,${((_r = item === null || item === void 0 ? void 0 :
812
1166
  // 拼接description
813
1167
  const configs = (_8 = item === null || item === void 0 ? void 0 : item.request) === null || _8 === void 0 ? void 0 : _8.configs;
814
1168
  if (lodash.isPlainObject(configs)) {
815
- let requestString = `The encoding format of the request packet is ${configs === null || configs === void 0 ? void 0 : configs.charset} ${lodash.isArray((_9 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _9 === void 0 ? void 0 : _9.request) && ((_10 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _10 === void 0 ? void 0 : _10.request.length) > 0 ?
1169
+ let requestString = `${t('requestEncodingFormat')} ${configs === null || configs === void 0 ? void 0 : configs.charset} ${lodash.isArray((_9 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _9 === void 0 ? void 0 : _9.request) && ((_10 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _10 === void 0 ? void 0 : _10.request.length) > 0 ?
816
1170
  (_11 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _11 === void 0 ? void 0 : _11.request.map((r, index) => {
817
1171
  var _a;
818
1172
  let str = getTcpMethodFucString(r);
@@ -850,30 +1204,30 @@ Over a secure connection,${((_r = item === null || item === void 0 ? void 0 :
850
1204
  const getTcpMethodFucString = (func) => {
851
1205
  switch (func === null || func === void 0 ? void 0 : func.id) {
852
1206
  case 'addCharToPacketEnd':
853
- return `Add a newline character at the end of each request message ${func === null || func === void 0 ? void 0 : func.option}`;
1207
+ return `${t('addNewline')} ${func === null || func === void 0 ? void 0 : func.option}`;
854
1208
  case 'calcLengthToPacketHeader':
855
- return `Calculates the content length (excluding the header) and adds it to the header (in text format, the header byte length is ${func === null || func === void 0 ? void 0 : func.option})`;
1209
+ return `${t('addContentLength')} ${func === null || func === void 0 ? void 0 : func.option})`;
856
1210
  case 'removePacketHeader':
857
- return `The response packet needs to be stripped of its header (length ${func === null || func === void 0 ? void 0 : func.option} byte)`;
1211
+ return `${t('removeResponseHeader')}${func === null || func === void 0 ? void 0 : func.option} ${t('byte')})`;
858
1212
  case 'removeWrapChar':
859
- return `Removes the newline character at the end of the line ${func === null || func === void 0 ? void 0 : func.option}`;
1213
+ return `${t('trimTrailingNewline')} ${func === null || func === void 0 ? void 0 : func.option}`;
860
1214
  case 'parseXmlToJson':
861
- return 'And convert the content in XML format to JSON format';
1215
+ return t('convertXmlToJson');
862
1216
  }
863
1217
  return '';
864
1218
  };
865
1219
  const getSocketRequestStr = (end_func) => {
866
1220
  switch (end_func === null || end_func === void 0 ? void 0 : end_func.name) {
867
1221
  case 'none':
868
- return `Data received deemed complete (subcontracting is not addressed`;
1222
+ return t('completeOnReceive');
869
1223
  case 'endedChar':
870
- return `Packet tail with special characters ${end_func === null || end_func === void 0 ? void 0 : end_func.option}`;
1224
+ return `${t('specialCharText')} ${end_func === null || end_func === void 0 ? void 0 : end_func.option}`;
871
1225
  case 'endedHexChar':
872
- return `Packet tail with special characters (binary message) ${end_func === null || end_func === void 0 ? void 0 : end_func.option}`;
1226
+ return `${t('specialCharBinary')} ${end_func === null || end_func === void 0 ? void 0 : end_func.option}`;
873
1227
  case 'endedHeaderByteLength':
874
- return `[header + packet body] format message ${end_func === null || end_func === void 0 ? void 0 : end_func.option}`;
1228
+ return `${t('headerBodyFormat')} ${end_func === null || end_func === void 0 ? void 0 : end_func.option}`;
875
1229
  case 'endedContentByteLength':
876
- return `Fixed-length message ${end_func === null || end_func === void 0 ? void 0 : end_func.option}`;
1230
+ return `${t('fixedLength')} ${end_func === null || end_func === void 0 ? void 0 : end_func.option}`;
877
1231
  }
878
1232
  return '';
879
1233
  };
@@ -1179,7 +1533,7 @@ class ApipostToSwagger {
1179
1533
  handleProject() {
1180
1534
  const { name, intro, marks, attributes } = this.apiToSwaggerOrigin.project || {};
1181
1535
  this.apiToSwaggerResult.info = {
1182
- title: name || "New Project",
1536
+ title: name || t('createProj'),
1183
1537
  description: intro || "",
1184
1538
  version: "1.0.0",
1185
1539
  };
@@ -1235,7 +1589,7 @@ class ApipostToSwagger {
1235
1589
  for (const env of envs) {
1236
1590
  const servers = {
1237
1591
  url: (env === null || env === void 0 ? void 0 : env.url) || "",
1238
- description: (env === null || env === void 0 ? void 0 : env.name) || "New Environment",
1592
+ description: (env === null || env === void 0 ? void 0 : env.name) || t('createEnv'),
1239
1593
  };
1240
1594
  if (lodash.isPlainObject(env === null || env === void 0 ? void 0 : env.env_var_list)) {
1241
1595
  servers.variables = {};
@@ -1345,14 +1699,14 @@ class ApipostToSwagger {
1345
1699
  }
1346
1700
  // 收到数据即认为完成(不处理分包问题) none
1347
1701
  if (item.target_type === 'socket' && lodash.isPlainObject((_b = item === null || item === void 0 ? void 0 : item.request) === null || _b === void 0 ? void 0 : _b.end_func)) {
1348
- item.description = `| Server address | Determine the completion mode of receiving packets |
1702
+ item.description = `| ${t('serverAddress')} | ${t('pktCompletion')} |
1349
1703
  | --- | --- |
1350
1704
  | ${item === null || item === void 0 ? void 0 : item.url} | ${getSocketRequestStr((_c = item === null || item === void 0 ? void 0 : item.request) === null || _c === void 0 ? void 0 : _c.end_func)}
1351
1705
  ${item.description}
1352
1706
  `;
1353
1707
  }
1354
1708
  this.apiToSwaggerResult.tags.push({
1355
- name: (item === null || item === void 0 ? void 0 : item.name) || "New Folder",
1709
+ name: (item === null || item === void 0 ? void 0 : item.name) || t('createDir'),
1356
1710
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
1357
1711
  'x-type': item.target_type,
1358
1712
  'x-url': (item === null || item === void 0 ? void 0 : item.url) || '',
@@ -1442,7 +1796,9 @@ ${item.description}
1442
1796
  this.array2TreeExport("target_id", "parent_id", modelsObj) || [];
1443
1797
  }
1444
1798
  }
1445
- apiToswagger(apipostObj, version) {
1799
+ apiToswagger(apipostObj, version, language) {
1800
+ // 初始化语言包
1801
+ I18nInit(language || 'en');
1446
1802
  this.apiToSwaggerOrigin = apipostObj;
1447
1803
  this.apiToSwaggerVersion = version;
1448
1804
  this.apiToSwaggerResult = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoapi-converter",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "description": "echoapi to swagger",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -15,6 +15,7 @@
15
15
  "license": "ISC",
16
16
  "devDependencies": {
17
17
  "@rollup/plugin-alias": "^5.1.0",
18
+ "@rollup/plugin-json": "^6.1.0",
18
19
  "@types/jest": "^29.5.12",
19
20
  "@types/node": "^20.11.22",
20
21
  "@types/url-parse": "^1.4.11",
@@ -35,6 +36,7 @@
35
36
  "apipost-tools": "0.0.34",
36
37
  "axios": "^1.6.7",
37
38
  "fs": "^0.0.1-security",
39
+ "i18next": "^24.2.3",
38
40
  "jest": "^29.7.0",
39
41
  "lodash": "^4.17.21",
40
42
  "path": "^0.12.7",