@lsby/net-core 0.3.22 → 0.3.23

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.
Files changed (131) hide show
  1. package/dist/bin/gen-list/bin.cjs +93 -47
  2. package/dist/bin/gen-list/index.cjs +93 -47
  3. package/dist/bin/gen-list/index.d.cts +1 -1
  4. package/dist/bin/gen-test/bin.cjs +90 -54
  5. package/dist/bin/gen-test/index.cjs +90 -54
  6. package/dist/bin/gen-test/index.d.cts +1 -1
  7. package/dist/bin/gen-type/bin.cjs +96 -93
  8. package/dist/bin/gen-type/index.cjs +96 -93
  9. package/dist/bin/gen-type/index.d.cts +1 -1
  10. package/dist/cjs/{interface/action → action}/action.cjs +1 -1
  11. package/dist/cjs/bin/gen-list/bin.cjs +93 -47
  12. package/dist/cjs/bin/gen-list/index.cjs +93 -47
  13. package/dist/cjs/bin/gen-list/index.d.cts +1 -1
  14. package/dist/cjs/bin/gen-test/bin.cjs +90 -54
  15. package/dist/cjs/bin/gen-test/index.cjs +90 -54
  16. package/dist/cjs/bin/gen-test/index.d.cts +1 -1
  17. package/dist/cjs/bin/gen-type/bin.cjs +96 -93
  18. package/dist/cjs/bin/gen-type/index.cjs +96 -93
  19. package/dist/cjs/bin/gen-type/index.d.cts +1 -1
  20. package/dist/cjs/index.cjs +62 -122
  21. package/dist/cjs/index.d.cts +12 -15
  22. package/dist/cjs/{extend/api-json-base.cjs → interface/extend/json-base.cjs} +54 -54
  23. package/dist/cjs/{extend/api-json-base.d.cts → interface/extend/json-base.d.cts} +8 -8
  24. package/dist/cjs/{extend/api-json-wrap.cjs → interface/extend/json-wrap.cjs} +79 -75
  25. package/dist/cjs/interface/extend/json-wrap.d.cts +26 -0
  26. package/dist/cjs/interface/{inst/interface-abstract.cjs → interface-inst.cjs} +9 -9
  27. package/dist/cjs/interface/interface-inst.d.cts +18 -0
  28. package/dist/cjs/{test/test-abstract.cjs → interface/interface-test.cjs} +7 -7
  29. package/dist/{esm/test/test-abstract.d.ts → cjs/interface/interface-test.d.cts} +2 -2
  30. package/dist/cjs/interface/{type/interface-type.cjs → interface-type.cjs} +2 -9
  31. package/dist/cjs/interface/interface-type.d.cts +28 -0
  32. package/dist/cjs/plugin/{chinese-path.cjs → extend/chinese-path.cjs} +3 -3
  33. package/dist/cjs/plugin/{chinese-path.d.cts → extend/chinese-path.d.cts} +1 -1
  34. package/dist/cjs/plugin/{custom-data.cjs → extend/custom-data.cjs} +3 -3
  35. package/dist/cjs/plugin/{custom-data.d.cts → extend/custom-data.d.cts} +1 -1
  36. package/dist/cjs/plugin/{json.cjs → extend/json.cjs} +4 -4
  37. package/dist/cjs/plugin/{json.d.cts → extend/json.d.cts} +2 -2
  38. package/dist/cjs/plugin/{urlencoded.cjs → extend/urlencoded.cjs} +4 -4
  39. package/dist/cjs/plugin/{urlencoded.d.cts → extend/urlencoded.d.cts} +1 -1
  40. package/dist/cjs/{interface → plugin}/plug.cjs +1 -1
  41. package/dist/cjs/server/server.d.cts +5 -5
  42. package/dist/esm/{interface/action → action}/action.js +1 -1
  43. package/dist/esm/bin/gen-list/bin.js +1 -1
  44. package/dist/esm/bin/gen-list/index.d.ts +1 -1
  45. package/dist/esm/bin/gen-list/index.js +1 -1
  46. package/dist/esm/bin/gen-test/bin.js +1 -1
  47. package/dist/esm/bin/gen-test/index.d.ts +1 -1
  48. package/dist/esm/bin/gen-test/index.js +1 -1
  49. package/dist/esm/bin/gen-type/bin.js +1 -2
  50. package/dist/esm/bin/gen-type/index.d.ts +1 -1
  51. package/dist/esm/bin/gen-type/index.js +1 -2
  52. package/dist/esm/{chunk-P6PGPAMW.js → chunk-2MN4G2DG.js} +2 -2
  53. package/dist/esm/chunk-3WT6TRYJ.js +37 -0
  54. package/dist/esm/chunk-B5W4H32C.js +112 -0
  55. package/dist/esm/chunk-IZ623QVE.js +11 -0
  56. package/dist/esm/{chunk-XG4VZZOX.js → chunk-KW3M3VXP.js} +2 -2
  57. package/dist/esm/chunk-MMAAGHJW.js +214 -0
  58. package/dist/esm/{chunk-KSZE2DTR.js → chunk-N4NY37XI.js} +1 -1
  59. package/dist/esm/{chunk-VJ4ORZR3.js → chunk-P4TLIJX4.js} +5 -5
  60. package/dist/esm/{chunk-S7GRYORG.js → chunk-P6ML63XI.js} +6 -6
  61. package/dist/esm/{chunk-CMHISRDG.js → chunk-SF5Z34AP.js} +2 -7
  62. package/dist/esm/{chunk-XRV64MDF.js → chunk-SFNQ5AWH.js} +3 -3
  63. package/dist/esm/chunk-TMRT3MBS.js +113 -0
  64. package/dist/esm/{chunk-N7G2H6GB.js → chunk-V3S5HDZD.js} +1 -1
  65. package/dist/esm/{chunk-5UUMGDDD.js → chunk-XTHURYQM.js} +3 -3
  66. package/dist/esm/index.d.ts +12 -15
  67. package/dist/esm/index.js +32 -46
  68. package/dist/esm/{extend/api-json-base.d.ts → interface/extend/json-base.d.ts} +8 -8
  69. package/dist/esm/interface/extend/json-base.js +10 -0
  70. package/dist/esm/interface/extend/json-wrap.d.ts +26 -0
  71. package/dist/esm/interface/extend/json-wrap.js +13 -0
  72. package/dist/esm/interface/interface-inst.d.ts +18 -0
  73. package/dist/esm/interface/interface-inst.js +7 -0
  74. package/dist/{cjs/test/test-abstract.d.cts → esm/interface/interface-test.d.ts} +2 -2
  75. package/dist/esm/interface/interface-test.js +6 -0
  76. package/dist/esm/interface/interface-type.d.ts +28 -0
  77. package/dist/esm/interface/interface-type.js +6 -0
  78. package/dist/esm/plugin/{chinese-path.d.ts → extend/chinese-path.d.ts} +1 -1
  79. package/dist/esm/plugin/{chinese-path.js → extend/chinese-path.js} +2 -2
  80. package/dist/esm/plugin/{custom-data.d.ts → extend/custom-data.d.ts} +1 -1
  81. package/dist/esm/plugin/{custom-data.js → extend/custom-data.js} +2 -2
  82. package/dist/esm/plugin/{json.d.ts → extend/json.d.ts} +2 -2
  83. package/dist/esm/plugin/extend/json.js +8 -0
  84. package/dist/esm/plugin/{urlencoded.d.ts → extend/urlencoded.d.ts} +1 -1
  85. package/dist/esm/plugin/{urlencoded.js → extend/urlencoded.js} +2 -2
  86. package/dist/esm/{interface → plugin}/plug.js +1 -1
  87. package/dist/esm/server/server.d.ts +5 -5
  88. package/package.json +4 -2
  89. package/dist/bin/gen-type/calc-code.cjs +0 -53
  90. package/dist/bin/gen-type/calc-code.d.cts +0 -3
  91. package/dist/cjs/bin/gen-type/calc-code.cjs +0 -53
  92. package/dist/cjs/bin/gen-type/calc-code.d.cts +0 -3
  93. package/dist/cjs/extend/api-json-wrap.d.cts +0 -55
  94. package/dist/cjs/interface/inst/interface-abstract.d.cts +0 -18
  95. package/dist/cjs/interface/inst/interface.cjs +0 -167
  96. package/dist/cjs/interface/inst/interface.d.cts +0 -18
  97. package/dist/cjs/interface/type/interface-type-abstract.cjs +0 -31
  98. package/dist/cjs/interface/type/interface-type-abstract.d.cts +0 -21
  99. package/dist/cjs/interface/type/interface-type.d.cts +0 -22
  100. package/dist/cjs/test/test.cjs +0 -60
  101. package/dist/cjs/test/test.d.cts +0 -19
  102. package/dist/esm/bin/gen-type/calc-code.d.ts +0 -3
  103. package/dist/esm/bin/gen-type/calc-code.js +0 -6
  104. package/dist/esm/chunk-34QVQSKM.js +0 -20
  105. package/dist/esm/chunk-4KSHDKSP.js +0 -11
  106. package/dist/esm/chunk-CSZNLNB5.js +0 -76
  107. package/dist/esm/chunk-DMQXYTFQ.js +0 -7
  108. package/dist/esm/chunk-DQX4L6GK.js +0 -187
  109. package/dist/esm/chunk-FLIKJZGI.js +0 -29
  110. package/dist/esm/chunk-LSG6UGUR.js +0 -54
  111. package/dist/esm/chunk-PIYVLQLM.js +0 -27
  112. package/dist/esm/chunk-YYOST4AX.js +0 -67
  113. package/dist/esm/extend/api-json-base.js +0 -10
  114. package/dist/esm/extend/api-json-wrap.d.ts +0 -55
  115. package/dist/esm/extend/api-json-wrap.js +0 -15
  116. package/dist/esm/interface/inst/interface-abstract.d.ts +0 -18
  117. package/dist/esm/interface/inst/interface-abstract.js +0 -7
  118. package/dist/esm/interface/inst/interface.d.ts +0 -18
  119. package/dist/esm/interface/inst/interface.js +0 -8
  120. package/dist/esm/interface/type/interface-type-abstract.d.ts +0 -21
  121. package/dist/esm/interface/type/interface-type-abstract.js +0 -6
  122. package/dist/esm/interface/type/interface-type.d.ts +0 -22
  123. package/dist/esm/interface/type/interface-type.js +0 -7
  124. package/dist/esm/plugin/json.js +0 -8
  125. package/dist/esm/test/test-abstract.js +0 -6
  126. package/dist/esm/test/test.d.ts +0 -19
  127. package/dist/esm/test/test.js +0 -7
  128. /package/dist/cjs/{interface/action → action}/action.d.cts +0 -0
  129. /package/dist/cjs/{interface → plugin}/plug.d.cts +0 -0
  130. /package/dist/esm/{interface/action → action}/action.d.ts +0 -0
  131. /package/dist/esm/{interface → plugin}/plug.d.ts +0 -0
@@ -1,18 +0,0 @@
1
- import { z } from 'zod';
2
- import { Either } from '@lsby/ts-fp-data';
3
- import { 正确结果 as ____$1, 错误结果 as ____$2 } from '../../result/result.cjs';
4
- import { 业务行为 as ____ } from '../action/action.cjs';
5
- import { 合并插件结果 as ______ } from '../plug.cjs';
6
- import { 接口类型插件们 as _______, 接口类型错误结果 as ________, 接口类型正确结果 as ________$1, 任意接口类型 as ______$1 } from '../type/interface-type-abstract.cjs';
7
- import 'express';
8
-
9
- type 计算实现参数<接口类型描述> = ______<_______<接口类型描述>>;
10
- type 计算实现返回<接口类型描述> = Promise<Either<z.infer<________<接口类型描述>>, z.infer<________$1<接口类型描述>>>>;
11
- declare abstract class API接口基类<接口类型描述 extends ______$1> extends ____<计算实现参数<接口类型描述>, z.infer<________<接口类型描述>>, z.infer<________$1<接口类型描述>>> {
12
- protected abstract 业务行为实现(参数: 计算实现参数<接口类型描述>): 计算实现返回<接口类型描述>;
13
- abstract 获得API类型(): 接口类型描述;
14
- abstract API实现(参数: 计算实现参数<接口类型描述>): Promise<____$1<z.infer<________$1<接口类型描述>>> | ____$2<z.infer<________<接口类型描述>>>>;
15
- }
16
- type 任意接口 = API接口基类<any>;
17
-
18
- export { API接口基类, type 任意接口, type 计算实现参数, type 计算实现返回 };
@@ -1,167 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/interface/inst/interface.ts
21
- var interface_exports = {};
22
- __export(interface_exports, {
23
- API\u63A5\u53E3: () => API\u63A5\u53E3
24
- });
25
- module.exports = __toCommonJS(interface_exports);
26
-
27
- // src/interface/action/action.ts
28
- var import_ts_fp_data = require("@lsby/ts-fp-data");
29
- var \u4E1A\u52A1\u884C\u4E3A = class _\u4E1A\u52A1\u884C\u4E3A {
30
- // ================================= 静态 =================================
31
- static \u901A\u8FC7\u5B9E\u73B0\u6784\u9020(\u5B9E\u73B0) {
32
- return new class extends _\u4E1A\u52A1\u884C\u4E3A {
33
- async \u4E1A\u52A1\u884C\u4E3A\u5B9E\u73B0(\u53C2\u6570) {
34
- return \u5B9E\u73B0(\u53C2\u6570);
35
- }
36
- }();
37
- }
38
- static \u901A\u8FC7\u6B63\u786E\u503C\u6784\u9020(a) {
39
- return _\u4E1A\u52A1\u884C\u4E3A.\u901A\u8FC7\u5B9E\u73B0\u6784\u9020(async () => new import_ts_fp_data.Right(a));
40
- }
41
- static \u901A\u8FC7\u9519\u8BEF\u503C\u6784\u9020(a) {
42
- return _\u4E1A\u52A1\u884C\u4E3A.\u901A\u8FC7\u5B9E\u73B0\u6784\u9020(async () => new import_ts_fp_data.Left(a));
43
- }
44
- static \u6D41\u5F0F\u7EC4\u5408(a, b) {
45
- return a.\u6D41\u5F0F\u7EC4\u5408(b);
46
- }
47
- static \u6DF7\u5408\u7EC4\u5408(a, b) {
48
- return a.\u6DF7\u5408\u7EC4\u5408(b);
49
- }
50
- /**
51
- * 对多个项混合组合
52
- */
53
- static \u6DF7\u5408\u7EC4\u5408\u591A\u9879(arr) {
54
- return arr.reduce((s, a) => s.\u6DF7\u5408\u7EC4\u5408(a));
55
- }
56
- /**
57
- * 同时运行多个模型, 并提供一个函数处理它们的结果
58
- * 如果其中任何一个模型发生错误, 则最终模型输出第一个错误
59
- * 处理函数的类型是: 所有模型的结果合并 => 泛型A
60
- * 新模型的类型是:
61
- * - 参数: 所有模型的参数合并
62
- * - 错误: 所有模型的错误合并
63
- * - 返回值: 泛型A
64
- */
65
- static \u5E76\u884C\u7EC4\u5408(arr, f) {
66
- return _\u4E1A\u52A1\u884C\u4E3A.\u901A\u8FC7\u5B9E\u73B0\u6784\u9020(async (\u53C2\u6570) => {
67
- var \u6240\u6709\u7ED3\u679C = await Promise.all(arr.map((a) => a.\u8FD0\u884C\u4E1A\u52A1\u884C\u4E3A(\u53C2\u6570)));
68
- var \u9519\u8BEF = \u6240\u6709\u7ED3\u679C.filter((a) => a.isLeft())[0];
69
- if (\u9519\u8BEF)
70
- return \u9519\u8BEF;
71
- var \u6B63\u786E\u7ED3\u679C\u5408\u5E76 = \u6240\u6709\u7ED3\u679C.map((a) => a.assertRight().getRight()).reduce((s, a) => Object.assign(s, a), {});
72
- return new import_ts_fp_data.Right(await f(\u6B63\u786E\u7ED3\u679C\u5408\u5E76));
73
- });
74
- }
75
- // ================================= 设置 =================================
76
- \u8BBE\u7F6E\u53C2\u6570(\u8BBE\u7F6E\u53C2\u6570) {
77
- return _\u4E1A\u52A1\u884C\u4E3A.\u901A\u8FC7\u5B9E\u73B0\u6784\u9020(async (\u53C2\u6570) => {
78
- return await this.\u8FD0\u884C\u4E1A\u52A1\u884C\u4E3A({ ...\u8BBE\u7F6E\u53C2\u6570, ...\u53C2\u6570 });
79
- });
80
- }
81
- // ================================= 运行 =================================
82
- async \u8FD0\u884C\u4E1A\u52A1\u884C\u4E3A(\u53C2\u6570) {
83
- try {
84
- return await this.\u4E1A\u52A1\u884C\u4E3A\u5B9E\u73B0(\u53C2\u6570);
85
- } catch (e) {
86
- throw e;
87
- }
88
- }
89
- // ================================= 组合 =================================
90
- /**
91
- * 将两个模型串接, 得到一个新模型, 新模型的类型是:
92
- * - 参数: a模型的参数
93
- * - 错误: a模型的错误+b模型的错误
94
- * - 返回值: b模型的返回值
95
- */
96
- \u6D41\u5F0F\u7EC4\u5408(b) {
97
- return _\u4E1A\u52A1\u884C\u4E3A.\u901A\u8FC7\u5B9E\u73B0\u6784\u9020(async (\u53C2\u6570) => {
98
- const \u6211\u7684\u7ED3\u679C = await this.\u8FD0\u884C\u4E1A\u52A1\u884C\u4E3A(\u53C2\u6570);
99
- if (\u6211\u7684\u7ED3\u679C.isLeft())
100
- return new import_ts_fp_data.Left(\u6211\u7684\u7ED3\u679C.assertLeft().getLeft());
101
- return b.\u8FD0\u884C\u4E1A\u52A1\u884C\u4E3A(\u6211\u7684\u7ED3\u679C.assertRight().getRight());
102
- });
103
- }
104
- /**
105
- * 将两个模型串接, 得到一个新的模型
106
- * 相比流式组合, 本函数不要求串联位置参数匹配, 缺少的参数将在调用时补全
107
- * 新模型的类型是:
108
- * - 参数: a模型的参数+(b模型的参数-a模型的返回值)
109
- * - 错误: a模型的错误+b模型的错误
110
- * - 返回值: a模型的返回值+b模型的返回值
111
- */
112
- \u6DF7\u5408\u7EC4\u5408(b) {
113
- return _\u4E1A\u52A1\u884C\u4E3A.\u901A\u8FC7\u5B9E\u73B0\u6784\u9020(async (\u53C2\u6570) => {
114
- const \u6211\u7684\u7ED3\u679C = await this.\u8FD0\u884C\u4E1A\u52A1\u884C\u4E3A(\u53C2\u6570);
115
- if (\u6211\u7684\u7ED3\u679C.isLeft())
116
- return new import_ts_fp_data.Left(\u6211\u7684\u7ED3\u679C.assertLeft().getLeft());
117
- var \u5BF9\u65B9\u7ED3\u679C = await b.\u8FD0\u884C\u4E1A\u52A1\u884C\u4E3A({ ...\u53C2\u6570, ...\u6211\u7684\u7ED3\u679C.assertRight().getRight() });
118
- return \u5BF9\u65B9\u7ED3\u679C.map((a) => Object.assign(a, \u6211\u7684\u7ED3\u679C.assertRight().getRight()));
119
- });
120
- }
121
- // ================================= 映射 =================================
122
- \u6620\u5C04\u7ED3\u679C(f) {
123
- return _\u4E1A\u52A1\u884C\u4E3A.\u901A\u8FC7\u5B9E\u73B0\u6784\u9020(async (\u53C2\u6570) => {
124
- const \u6211\u7684\u7ED3\u679C = await this.\u8FD0\u884C\u4E1A\u52A1\u884C\u4E3A(\u53C2\u6570);
125
- if (\u6211\u7684\u7ED3\u679C.isLeft())
126
- return new import_ts_fp_data.Left(\u6211\u7684\u7ED3\u679C.assertLeft().getLeft());
127
- return import_ts_fp_data.Either.pure(f(\u6211\u7684\u7ED3\u679C.assertRight().getRight()));
128
- });
129
- }
130
- \u6620\u5C04\u9519\u8BEF(f) {
131
- return _\u4E1A\u52A1\u884C\u4E3A.\u901A\u8FC7\u5B9E\u73B0\u6784\u9020(async (\u53C2\u6570) => {
132
- const \u6211\u7684\u7ED3\u679C = await this.\u8FD0\u884C\u4E1A\u52A1\u884C\u4E3A(\u53C2\u6570);
133
- if (\u6211\u7684\u7ED3\u679C.isLeft())
134
- return new import_ts_fp_data.Left(f(\u6211\u7684\u7ED3\u679C.assertLeft().getLeft()));
135
- return import_ts_fp_data.Either.pure(\u6211\u7684\u7ED3\u679C.assertRight().getRight());
136
- });
137
- }
138
- \u7ED1\u5B9A(f) {
139
- return _\u4E1A\u52A1\u884C\u4E3A.\u901A\u8FC7\u5B9E\u73B0\u6784\u9020(async (\u53C2\u6570) => {
140
- const \u6211\u7684\u7ED3\u679C = await this.\u8FD0\u884C\u4E1A\u52A1\u884C\u4E3A(\u53C2\u6570);
141
- if (\u6211\u7684\u7ED3\u679C.isLeft())
142
- return new import_ts_fp_data.Left(\u6211\u7684\u7ED3\u679C.assertLeft().getLeft());
143
- return f(\u6211\u7684\u7ED3\u679C.assertRight().getRight()).\u8FD0\u884C\u4E1A\u52A1\u884C\u4E3A(\u53C2\u6570);
144
- });
145
- }
146
- };
147
-
148
- // src/interface/inst/interface-abstract.ts
149
- var API\u63A5\u53E3\u57FA\u7C7B = class extends \u4E1A\u52A1\u884C\u4E3A {
150
- };
151
-
152
- // src/interface/inst/interface.ts
153
- var API\u63A5\u53E3 = class extends API\u63A5\u53E3\u57FA\u7C7B {
154
- constructor(\u63A5\u53E3\u7C7B\u578B, API\u5B9E\u73B0, \u4E1A\u52A1\u884C\u4E3A\u5B9E\u73B0) {
155
- super();
156
- this.\u63A5\u53E3\u7C7B\u578B = \u63A5\u53E3\u7C7B\u578B;
157
- this.API\u5B9E\u73B0 = API\u5B9E\u73B0;
158
- this.\u4E1A\u52A1\u884C\u4E3A\u5B9E\u73B0 = \u4E1A\u52A1\u884C\u4E3A\u5B9E\u73B0;
159
- }
160
- \u83B7\u5F97API\u7C7B\u578B() {
161
- return this.\u63A5\u53E3\u7C7B\u578B;
162
- }
163
- };
164
- // Annotate the CommonJS export names for ESM import in node:
165
- 0 && (module.exports = {
166
- API\u63A5\u53E3
167
- });
@@ -1,18 +0,0 @@
1
- import { z } from 'zod';
2
- import { Either } from '@lsby/ts-fp-data';
3
- import { 正确结果 as ____, 错误结果 as ____$1 } from '../../result/result.cjs';
4
- import { 插件项类型 as _____, 合并插件结果 as ______ } from '../plug.cjs';
5
- import { 接口类型抽象类 as _______ } from '../type/interface-type-abstract.cjs';
6
- import { API接口基类 as API____ } from './interface-abstract.cjs';
7
- import 'express';
8
- import '../action/action.cjs';
9
-
10
- declare class API接口<路径 extends string, 方法 extends 'get' | 'post', 插件们 extends Array<_____>, 正确返回类型 extends z.ZodTypeAny, 错误返回类型 extends z.ZodTypeAny> extends API____<_______<路径, 方法, 插件们, 正确返回类型, 错误返回类型>> {
11
- private 接口类型;
12
- API实现: (参数: ______<插件们>) => Promise<____<z.infer<正确返回类型>> | ____$1<z.infer<错误返回类型>>>;
13
- protected 业务行为实现: (插件结果: ______<插件们>) => Promise<Either<z.infer<错误返回类型>, z.infer<正确返回类型>>>;
14
- constructor(接口类型: _______<路径, 方法, 插件们, 正确返回类型, 错误返回类型>, API实现: (参数: ______<插件们>) => Promise<____<z.infer<正确返回类型>> | ____$1<z.infer<错误返回类型>>>, 业务行为实现: (插件结果: ______<插件们>) => Promise<Either<z.infer<错误返回类型>, z.infer<正确返回类型>>>);
15
- 获得API类型(): _______<路径, 方法, 插件们, 正确返回类型, 错误返回类型>;
16
- }
17
-
18
- export { API接口 };
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/interface/type/interface-type-abstract.ts
21
- var interface_type_abstract_exports = {};
22
- __export(interface_type_abstract_exports, {
23
- \u63A5\u53E3\u7C7B\u578B\u62BD\u8C61\u7C7B: () => \u63A5\u53E3\u7C7B\u578B\u62BD\u8C61\u7C7B
24
- });
25
- module.exports = __toCommonJS(interface_type_abstract_exports);
26
- var \u63A5\u53E3\u7C7B\u578B\u62BD\u8C61\u7C7B = class {
27
- };
28
- // Annotate the CommonJS export names for ESM import in node:
29
- 0 && (module.exports = {
30
- \u63A5\u53E3\u7C7B\u578B\u62BD\u8C61\u7C7B
31
- });
@@ -1,21 +0,0 @@
1
- import { z } from 'zod';
2
- import { 插件项类型 as _____ } from '../plug.cjs';
3
- import 'express';
4
- import '@lsby/ts-fp-data';
5
-
6
- type 接口类型路径<A> = A extends 接口类型抽象类<infer A1, infer _A2, infer _A3, infer _A4, infer _A5> ? A1 : never;
7
- type 接口类型方法<A> = A extends 接口类型抽象类<infer _A1, infer A2, infer _A3, infer _A4, infer _A5> ? A2 : never;
8
- type 接口类型插件们<A> = A extends 接口类型抽象类<infer _A1, infer _A2, infer A3, infer _A4, infer _A5> ? A3 : never;
9
- type 接口类型正确结果<A> = A extends 接口类型抽象类<infer _A1, infer _A2, infer _A3, infer A4, infer _A5> ? A4 : never;
10
- type 接口类型错误结果<A> = A extends 接口类型抽象类<infer _A1, infer _A2, infer _A3, infer _A4, infer A5> ? A5 : never;
11
- declare abstract class 接口类型抽象类<路径 extends string, 方法 extends 'get' | 'post', 插件们 extends Array<_____>, 正确结果类型 extends z.ZodTypeAny, 错误结果类型 extends z.ZodTypeAny> {
12
- abstract 获得路径(): 路径;
13
- abstract 获得方法(): 方法;
14
- abstract 获得插件们(): [...插件们];
15
- abstract 获得正确结果类型(): 正确结果类型;
16
- abstract 获得错误结果类型(): 错误结果类型;
17
- }
18
- type 任意接口类型 = 接口类型抽象类<any, any, any, any, any>;
19
- type 获得接口插件们<接口类型描述> = 接口类型描述 extends 接口类型抽象类<any, any, infer 插件, any, any> ? 插件 : never;
20
-
21
- export { type 任意接口类型, 接口类型抽象类, type 接口类型插件们, type 接口类型方法, type 接口类型正确结果, type 接口类型路径, type 接口类型错误结果, type 获得接口插件们 };
@@ -1,22 +0,0 @@
1
- import { z } from 'zod';
2
- import { 插件项类型 as _____ } from '../plug.cjs';
3
- import { 接口类型抽象类 as _______ } from './interface-type-abstract.cjs';
4
- import 'express';
5
- import '@lsby/ts-fp-data';
6
-
7
- declare class 接口类型<路径 extends string, 方法 extends 'get' | 'post', 插件们 extends Array<_____>, 正确结果类型 extends z.ZodTypeAny, 错误结果类型 extends z.ZodTypeAny> extends _______<路径, 方法, 插件们, 正确结果类型, 错误结果类型> {
8
- private 路径;
9
- private 方法;
10
- private 插件们;
11
- private 正确结果;
12
- private 错误结果;
13
- protected readonly __类型保持符号?: [路径, 方法, 插件们, 正确结果类型, 错误结果类型];
14
- constructor(路径: 路径, 方法: 方法, 插件们: [...插件们], 正确结果: 正确结果类型, 错误结果: 错误结果类型);
15
- 获得路径(): 路径;
16
- 获得方法(): 方法;
17
- 获得插件们(): [...插件们];
18
- 获得正确结果类型(): 正确结果类型;
19
- 获得错误结果类型(): 错误结果类型;
20
- }
21
-
22
- export { 接口类型 };
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/test/test.ts
21
- var test_exports = {};
22
- __export(test_exports, {
23
- \u6D4B\u8BD5: () => \u6D4B\u8BD5
24
- });
25
- module.exports = __toCommonJS(test_exports);
26
-
27
- // src/test/test-abstract.ts
28
- var \u6D4B\u8BD5\u62BD\u8C61\u7C7B = class {
29
- constructor() {
30
- }
31
- async \u8FD0\u884C() {
32
- await this.\u524D\u7F6E\u5B9E\u73B0();
33
- var \u4E2D\u7F6E\u7ED3\u679C = await this.\u4E2D\u7F6E\u5B9E\u73B0();
34
- await this.\u540E\u7F6E\u5B9E\u73B0(\u4E2D\u7F6E\u7ED3\u679C);
35
- }
36
- };
37
-
38
- // src/test/test.ts
39
- var \u6D4B\u8BD5 = class extends \u6D4B\u8BD5\u62BD\u8C61\u7C7B {
40
- constructor(\u63A5\u53E3\u7C7B\u578B, \u524D\u7F6E, \u4E2D\u7F6E, \u540E\u7F6E) {
41
- super();
42
- this.\u63A5\u53E3\u7C7B\u578B = \u63A5\u53E3\u7C7B\u578B;
43
- this.\u524D\u7F6E = \u524D\u7F6E;
44
- this.\u4E2D\u7F6E = \u4E2D\u7F6E;
45
- this.\u540E\u7F6E = \u540E\u7F6E;
46
- }
47
- \u524D\u7F6E\u5B9E\u73B0() {
48
- return this.\u524D\u7F6E();
49
- }
50
- \u4E2D\u7F6E\u5B9E\u73B0() {
51
- return this.\u4E2D\u7F6E();
52
- }
53
- \u540E\u7F6E\u5B9E\u73B0(\u4E2D\u7F6E\u7ED3\u679C) {
54
- return this.\u540E\u7F6E(\u4E2D\u7F6E\u7ED3\u679C);
55
- }
56
- };
57
- // Annotate the CommonJS export names for ESM import in node:
58
- 0 && (module.exports = {
59
- \u6D4B\u8BD5
60
- });
@@ -1,19 +0,0 @@
1
- import { 任意接口类型 as ______ } from '../interface/type/interface-type-abstract.cjs';
2
- import { 测试抽象类 as _____ } from './test-abstract.cjs';
3
- import 'zod';
4
- import '../interface/plug.cjs';
5
- import 'express';
6
- import '@lsby/ts-fp-data';
7
-
8
- declare class 测试 extends _____ {
9
- private 接口类型;
10
- protected 前置: () => Promise<void>;
11
- protected 中置: () => Promise<object>;
12
- protected 后置: (中置结果: object) => Promise<void>;
13
- constructor(接口类型: ______, 前置: () => Promise<void>, 中置: () => Promise<object>, 后置: (中置结果: object) => Promise<void>);
14
- 前置实现(): Promise<void>;
15
- 中置实现(): Promise<object>;
16
- 后置实现(中置结果: object): Promise<void>;
17
- }
18
-
19
- export { 测试 };
@@ -1,3 +0,0 @@
1
- declare const calcCode = "\nimport type { z } from 'zod'\nimport type { \u5408\u5E76JSON\u63D2\u4EF6\u7ED3\u679C, \u63A5\u53E3\u7C7B\u578B\u62BD\u8C61\u7C7B } from '@lsby/net-core'\nimport exportedApiSchema from './type'\n\ntype Api =\n typeof exportedApiSchema extends \u63A5\u53E3\u7C7B\u578B\u62BD\u8C61\u7C7B<\n infer Path,\n infer Method,\n infer PreApis,\n infer SuccessSchema,\n infer ErrorSchema\n >\n ? {\n path: Path\n method: Method\n input: \u5408\u5E76JSON\u63D2\u4EF6\u7ED3\u679C<PreApis>\n successOutput: z.infer<SuccessSchema>\n errorOutput: z.infer<ErrorSchema>\n }\n : never\n\nexport default Api\n";
2
-
3
- export { calcCode };
@@ -1,6 +0,0 @@
1
- import {
2
- calcCode
3
- } from "../../chunk-FLIKJZGI.js";
4
- export {
5
- calcCode
6
- };
@@ -1,20 +0,0 @@
1
- import {
2
- API接口基类
3
- } from "./chunk-4KSHDKSP.js";
4
-
5
- // src/interface/inst/interface.ts
6
- var API\u63A5\u53E3 = class extends API\u63A5\u53E3\u57FA\u7C7B {
7
- constructor(\u63A5\u53E3\u7C7B\u578B, API\u5B9E\u73B0, \u4E1A\u52A1\u884C\u4E3A\u5B9E\u73B0) {
8
- super();
9
- this.\u63A5\u53E3\u7C7B\u578B = \u63A5\u53E3\u7C7B\u578B;
10
- this.API\u5B9E\u73B0 = API\u5B9E\u73B0;
11
- this.\u4E1A\u52A1\u884C\u4E3A\u5B9E\u73B0 = \u4E1A\u52A1\u884C\u4E3A\u5B9E\u73B0;
12
- }
13
- \u83B7\u5F97API\u7C7B\u578B() {
14
- return this.\u63A5\u53E3\u7C7B\u578B;
15
- }
16
- };
17
-
18
- export {
19
- API接口
20
- };
@@ -1,11 +0,0 @@
1
- import {
2
- 业务行为
3
- } from "./chunk-N7G2H6GB.js";
4
-
5
- // src/interface/inst/interface-abstract.ts
6
- var API\u63A5\u53E3\u57FA\u7C7B = class extends \u4E1A\u52A1\u884C\u4E3A {
7
- };
8
-
9
- export {
10
- API接口基类
11
- };
@@ -1,76 +0,0 @@
1
- // src/bin/gen-test/index.ts
2
- import fs, { existsSync, mkdirSync, writeFileSync } from "node:fs";
3
- import path from "node:path";
4
- import ts from "typescript";
5
- import { Log } from "@lsby/ts-log";
6
- async function main(tsconfigPath, interfaceFolderPath, outFilePath, filter) {
7
- var log = new Log("@lsby:net-core").extend("gen-test");
8
- await log.debug("\u51C6\u5907\u751F\u6210\u6D4B\u8BD5\u6587\u4EF6...");
9
- const projectRootPath = path.dirname(tsconfigPath);
10
- const tsconfigJson = ts.parseConfigFileTextToJson(tsconfigPath, fs.readFileSync(tsconfigPath, "utf8"));
11
- if (tsconfigJson.error) {
12
- throw new Error("\u65E0\u6CD5\u89E3\u6790 tsconfig.json");
13
- }
14
- const parsedTsconfig = ts.parseJsonConfigFileContent(tsconfigJson.config, ts.sys, path.resolve(tsconfigPath, ".."));
15
- await log.debug("\u6210\u529F\u89E3\u6790 tsconfig \u6587\u4EF6...");
16
- const projectHost = ts.createCompilerHost(parsedTsconfig.options);
17
- const project = ts.createProgram(parsedTsconfig.fileNames, parsedTsconfig.options, projectHost);
18
- await log.debug("\u6210\u529F\u8BFB\u53D6\u9879\u76EE...");
19
- const _check = project.getTypeChecker();
20
- const allSourceFiles = project.getSourceFiles();
21
- const typeSourceFiles = allSourceFiles.filter((sourceFile) => {
22
- return new RegExp(`${interfaceFolderPath.replaceAll("\\", "\\\\")}.*type.ts`).test(
23
- path.resolve(sourceFile.fileName)
24
- );
25
- });
26
- const testSourceFiles = allSourceFiles.filter((sourceFile) => {
27
- return new RegExp(`${interfaceFolderPath.replaceAll("\\", "\\\\")}.*.test.ts`).test(
28
- path.resolve(sourceFile.fileName)
29
- );
30
- });
31
- const testSourceFilesFilter = testSourceFiles.filter((sourceFile) => {
32
- return new RegExp(filter).test(path.resolve(sourceFile.fileName));
33
- });
34
- await log.debug(
35
- "\u627E\u5230 %o \u4E2A\u63A5\u53E3\uFF0C\u5176\u4E2D\u6709 %o \u4E2A\u6D4B\u8BD5\uFF0C\u7B5B\u9009\u540E\u8FD8\u5269 %o \u4E2A...",
36
- typeSourceFiles.length,
37
- testSourceFiles.length,
38
- testSourceFilesFilter.length
39
- );
40
- const importCode = [];
41
- const testCode = [];
42
- for (var index = 0; index < testSourceFilesFilter.length; index++) {
43
- var testSourceFile = testSourceFilesFilter[index];
44
- if (testSourceFile == null)
45
- throw new Error("\u975E\u9884\u671F\u7684\u6570\u7EC4\u8D8A\u754C");
46
- const filenameRelativeToApiFolder = path.relative(interfaceFolderPath, testSourceFile.fileName).replaceAll("\\", "/");
47
- const importName = filenameRelativeToApiFolder.replaceAll("/", "_").replaceAll(".test.ts", "").replaceAll("./", "").replaceAll("-", "_");
48
- const filenameRelativeToProjectRoot = path.relative(projectRootPath, testSourceFile.fileName).replaceAll("\\", "/").replaceAll(".ts", "");
49
- const outputFolderRelativeToProjectRoot = path.relative(path.dirname(outFilePath), projectRootPath).replaceAll("\\", "/");
50
- const importPath = path.join(outputFolderRelativeToProjectRoot, filenameRelativeToProjectRoot).replaceAll("\\", "/");
51
- await log.info(`\u5904\u7406\uFF08${index + 1} / ${testSourceFilesFilter.length}\uFF09\uFF1A${filenameRelativeToApiFolder}`);
52
- importCode.push(`import ${importName} from '${importPath}'`);
53
- testCode.push(generateTestCode(importName, importName));
54
- }
55
- const finalTestFile = [
56
- "import { test } from 'vitest'",
57
- "import './unit-test-prefix'",
58
- "",
59
- ...importCode,
60
- "",
61
- ...testCode,
62
- ""
63
- ].join("\n");
64
- var outDir = path.dirname(outFilePath);
65
- if (!existsSync(outDir)) {
66
- mkdirSync(outDir, { recursive: true });
67
- }
68
- writeFileSync(outFilePath, finalTestFile);
69
- }
70
- function generateTestCode(testCaseName, importName) {
71
- return `test('${testCaseName}', async () => await ${importName}.\u8FD0\u884C())`;
72
- }
73
-
74
- export {
75
- main
76
- };
@@ -1,7 +0,0 @@
1
- // src/interface/type/interface-type-abstract.ts
2
- var \u63A5\u53E3\u7C7B\u578B\u62BD\u8C61\u7C7B = class {
3
- };
4
-
5
- export {
6
- 接口类型抽象类
7
- };