├── .github └── workflows │ └── test.yml ├── .gitignore ├── Readme.md ├── dist ├── index.js ├── index.js.map ├── main.js ├── main.js.map ├── utils.js └── utils.js.map ├── package.json ├── renovate.json ├── runTest.js ├── src ├── index.ts ├── main.ts └── utils.ts ├── testInterface ├── enumTest.ts ├── onAdd.ts ├── onRank.ts ├── rank.playerHandler.beginGame.ts ├── rank.playerHandler.onlyNotify.ts └── share │ └── myrank.ts ├── tsconfig.json └── yarn.lock /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test-parse 2 | 3 | on: 4 | [push,pull_request] 5 | 6 | jobs: 7 | test: 8 | runs-on: ubuntu-latest 9 | env: 10 | NODE_ENV: ci 11 | steps: 12 | - uses: actions/checkout@v1 13 | - uses: actions/setup-node@v1 14 | with: 15 | node-version: 12 16 | - run: npm install --dev 17 | - run: npm run build 18 | - run: node ./runTest.js -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | /node_modules 3 | /.idea 4 | tmp.json -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | ![test-parse](https://github.com/whtiehack/pinus-parse-interface/workflows/test-parse/badge.svg) 2 | 3 | 4 | #### parse TS interface to pinus-protobuf JSON 5 | 解析 ts 的interface 到 pinus-protobuf用的 json格式。 6 | 7 | 8 | 9 | pinus: https://github.com/node-pinus/pinus 10 | 11 | ## changelog 12 | ``` 13 | v0.2.3: 14 | fix sort method. 15 | 16 | v0.2.2: 17 | 生成的消息做排序 18 | 19 | v0.2.1: 20 | 支持 结构放到顶层 (默认的客户端不支持,需要修改客户端) 21 | 22 | v0.1.6: 23 | 支持 notify 消息。可以没有Response. 24 | 25 | v0.1.5: 26 | 文件统一解析。 加快解析速度 27 | 28 | v0.1.3: 29 | 修复interface成员全部为可选时会出错的bug。 30 | 31 | ``` 32 | ## install 33 | 34 | `npm install pinus-parse-interface` 35 | 36 | or 37 | 38 | `yarn add pinus-parse-interface` 39 | 40 | 41 | ## usage 42 | 43 | ``` 44 | const main = require('pinus-parse-interface'); 45 | 46 | const test = main.parseToPinusProtobuf('path_to_you_interface_dir'); 47 | console.log('result',JSON.stringify(test,null,4)); 48 | ``` 49 | 50 | 合并所有的message到顶层 51 | 52 | ``` 53 | // 第四个参数表示把所有的message结构放到顶层 (默认的客户端不支持,需要修改客户端) 54 | main.parseToPinusProtobuf('path_to_you_interface_dir','_Req','_Res',true); 55 | ``` 56 | 57 | 58 | ## interface 结构约定 59 | 1. 以文件名为消息名。 60 | 1. 客户端与服务端的结构放到一起。 61 | 1. 客户端消息,以 `文件名_Req` 为结尾 62 | 1. 服务端消息,以 `文件名_Res` 为结尾 63 | 1. 文件名中的`.` 会被转换成 `_` 64 | 1. 服务端推送消息直接以文件名命名 65 | 1. `_Res`,`_Req` 可以使用自定义名字 66 | 67 | > 例如: `rank.playerHandler.beginGame.ts` 68 | > 会寻找 `rank_playerHandler_beginGame_Req`,`rank_playerHandler_beginGame_Res` 69 | 70 | 71 | 72 | #### auto generate 73 | `serverProtos.json`,`clientProtos.json`. 74 | 75 | ### example 76 | 77 | it can also be used on the `pomelo-protobuf` declaration file(serverProtos.json,clientProtos.json). 78 | 79 | input 80 | ``` 81 | // onAdd.ts 82 | export interface onAdd{ 83 | nickname:string; 84 | nickname11:number; 85 | 86 | nowplayers:number; 87 | /** 88 | * The float of the nowplayers. 89 | * 90 | * @TJS-type float 91 | */ 92 | nowplayers2:number; 93 | /** 94 | * The float of the nowplayers. 95 | * 96 | * @TJS-type double 97 | */ 98 | nowplayers3:number; 99 | } 100 | 101 | 102 | // onRank.ts 103 | 104 | 105 | import {GGG, MyRank} from "../share/myrank"; 106 | 107 | 108 | interface IGG{ 109 | ggenv?:string[]; 110 | } 111 | 112 | interface IFF{ 113 | ffname:string; 114 | aa?:IGG[]; 115 | } 116 | 117 | enum EnumTest{ 118 | AA, 119 | BB, 120 | CC 121 | } 122 | 123 | export interface onRank extends IFF,IGG{ 124 | /** 125 | * The float of the nowplayers. 126 | * 127 | * @additionalProperties uInt32 128 | * @TJS-type array 129 | */ 130 | normalArr:number[]; 131 | /** 132 | * @TJS-type uInt32 133 | */ 134 | enum:EnumTest; 135 | normalStrArr:string[]; 136 | innerGGG?:GGG; 137 | ranks:MyRank[]; 138 | rk?:MyRank; 139 | val?:number; 140 | } 141 | 142 | // rank.playerHandler.beginGame.ts 143 | 144 | export interface rank_playerHandler_beginGame_Req{ 145 | token:number; 146 | msg?:string; 147 | } 148 | 149 | export interface rank_playerHandler_beginGame_Res{ 150 | /** 151 | * @TJS-type uInt32 152 | */ 153 | code?:number; 154 | msg?:string; 155 | /** 156 | * @TJS-type uInt32 157 | */ 158 | currank:number; 159 | } 160 | 161 | 162 | ``` 163 | 164 | 165 | 166 | output 167 | 168 | ``` 169 | { 170 | "client": { 171 | "rank.playerHandler.beginGame": { 172 | "required uInt32 token": 1, 173 | "optional string msg": 2 174 | } 175 | }, 176 | "server": { 177 | "enumTest": { 178 | "optional string aa": 1, 179 | "required uInt32 bb": 2, 180 | "required uInt32 cc": 3, 181 | "optional string enumstr": 4 182 | }, 183 | "onAdd": { 184 | "required string nickname": 1, 185 | "required uInt32 nickname11": 2, 186 | "required uInt32 nowplayers": 3, 187 | "required float nowplayers2": 4, 188 | "required double nowplayers3": 5 189 | }, 190 | "onRank": { 191 | "repeated uInt32 normalArr": 1, 192 | "required uInt32 enum": 2, 193 | "repeated string normalStrArr": 3, 194 | "message GGG": { 195 | "required uInt32 ccgg": 1 196 | }, 197 | "optional GGG innerGGG": 4, 198 | "message MyRank": { 199 | "required uInt32 nickname": 1, 200 | "message GGG": { 201 | "required uInt32 ccgg": 1 202 | }, 203 | "required GGG ggg": 2, 204 | "required GGG xxx": 3 205 | }, 206 | "repeated MyRank ranks": 5, 207 | "optional MyRank rk": 6, 208 | "optional uInt32 val": 7, 209 | "required string ffname": 8, 210 | "message IGG": { 211 | "repeated string ggenv": 1 212 | }, 213 | "repeated IGG aa": 9, 214 | "repeated string ggenv": 10 215 | }, 216 | "rank.playerHandler.beginGame": { 217 | "optional uInt32 code": 1, 218 | "optional string msg": 2, 219 | "required uInt32 currank": 3 220 | } 221 | } 222 | } 223 | ``` 224 | 225 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function __export(m) { 3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; 4 | } 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | __export(require("./main")); 7 | __export(require("./utils")); 8 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAEA,4BAAuB;AAEvB,6BAAwB"} -------------------------------------------------------------------------------- /dist/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const path = require("path"); 4 | const path_1 = require("path"); 5 | const TJS = require("typescript-json-schema"); 6 | const fs = require("fs"); 7 | const util = require("util"); 8 | function log(...args) { 9 | console.log(...args); 10 | } 11 | function error(msg, ...args) { 12 | const str = util.format(msg, ...args); 13 | console.error(str); 14 | throw new Error(str); 15 | } 16 | let responseStr = '_Res'; 17 | let requestStr = '_Req'; 18 | let MergeMessage = false; 19 | /** 20 | * 21 | * @param baseDir 22 | * @param reqStr 23 | * @param resStr 24 | * @param mergeMessage message 结构放到顶层 (默认的客户端不支持,需要修改客户端) 25 | */ 26 | function parseToPinusProtobuf(baseDir, reqStr = '_Req', resStr = '_Res', mergeMessage = false) { 27 | responseStr = resStr; 28 | requestStr = reqStr; 29 | MergeMessage = mergeMessage; 30 | let retObj = { client: {}, server: {} }; 31 | const files = fs.readdirSync(baseDir); 32 | const tsFilePaths = []; 33 | files.forEach(val => { 34 | if (!val.endsWith('.ts')) { 35 | return; 36 | } 37 | tsFilePaths.push(path_1.resolve(baseDir + '/' + val)); 38 | // const obj = parseFile(baseDir,val); 39 | // const tmp = path.parse(val); 40 | // retObj.client[tmp.name] = obj.client; 41 | // retObj.server[tmp.name] = obj.server; 42 | }); 43 | // optionally pass argument to schema generator 44 | const settings = { 45 | required: true 46 | }; 47 | // optionally pass ts compiler options 48 | const compilerOptions = { 49 | strictNullChecks: true 50 | }; 51 | const program = TJS.getProgramFromFiles(tsFilePaths, compilerOptions, baseDir); 52 | const generator = TJS.buildGenerator(program, settings); 53 | // all symbols 54 | const symbols = generator.getMainFileSymbols(program); 55 | let clientMessages = {}; 56 | let serverMessages = {}; 57 | files.forEach(val => { 58 | if (!val.endsWith('.ts')) { 59 | return; 60 | } 61 | if (!mergeMessage) { 62 | clientMessages = {}; 63 | serverMessages = {}; 64 | } 65 | const obj = parseFile(baseDir, val, program, generator, symbols, clientMessages, serverMessages); 66 | const tmp = path.parse(val); 67 | retObj.client[tmp.name] = obj.client; 68 | retObj.server[tmp.name] = obj.server; 69 | }); 70 | retObj.client = sortMsg(retObj.client); 71 | retObj.server = sortMsg(retObj.server); 72 | if (mergeMessage) { 73 | let obj = {}; 74 | for (let k in clientMessages) { 75 | obj['message ' + k] = clientMessages[k]; 76 | } 77 | obj = sortMsg(obj); 78 | for (let k in obj) { 79 | retObj.client[k] = obj[k]; 80 | } 81 | obj = {}; 82 | for (let k in serverMessages) { 83 | obj['message ' + k] = serverMessages[k]; 84 | } 85 | obj = sortMsg(obj); 86 | for (let k in obj) { 87 | retObj.server[k] = obj[k]; 88 | } 89 | } 90 | return retObj; 91 | } 92 | exports.parseToPinusProtobuf = parseToPinusProtobuf; 93 | function sortMsg(obj) { 94 | let arr = []; 95 | for (let k in obj) { 96 | arr.push({ k: k, v: obj[k] }); 97 | } 98 | arr.sort((a, b) => { 99 | if (a.k.includes('.')) { 100 | if (b.k.includes('.')) { 101 | return a.k > b.k ? 1 : -1; 102 | } 103 | return -1; 104 | } 105 | if (b.k.includes('.')) { 106 | return 1; 107 | } 108 | return a.k > b.k ? 1 : -1; 109 | }); 110 | let newObj = {}; 111 | for (let v of arr) { 112 | newObj[v.k] = v.v; 113 | } 114 | return newObj; 115 | } 116 | function parseFile(baseDir, filename, program, generator, symbols, clientMessages, serverMessages) { 117 | if (!symbols || !symbols.length) { 118 | return; 119 | } 120 | const filePath = path.parse(filename); 121 | filename = filePath.name.replace(/\./g, '_'); 122 | // const symbolName = symbols[symbols.length-1]; 123 | // if(!symbolName){ 124 | // return; 125 | // } 126 | let symbolClient; 127 | if (symbols.includes(filename + requestStr)) { 128 | symbolClient = generator.getSchemaForSymbol(filename + requestStr); 129 | } 130 | let client; 131 | let server; 132 | if (symbolClient) { 133 | client = parseSymbol(symbolClient, symbolClient, clientMessages); 134 | } 135 | let symbolServer; 136 | if (symbols.includes(filename + responseStr)) { 137 | if (!client) { 138 | console.warn('WARNING:', filename, `has ${responseStr} without ${requestStr}`); 139 | } 140 | symbolServer = generator.getSchemaForSymbol(filename + responseStr); 141 | } 142 | if (!symbolServer) { 143 | if (client) { 144 | // console.warn('WARNING:',filename,`has ${requestStr} without ${responseStr}`); 145 | } 146 | if (symbols.includes(filename)) { 147 | symbolServer = generator.getSchemaForSymbol(filename); 148 | } 149 | } 150 | if (!symbolServer) { 151 | return { client: client }; 152 | } 153 | server = parseSymbol(symbolServer, symbolServer, serverMessages); 154 | return { client: client, server: server }; 155 | // return transMessage(obj,messages); 156 | } 157 | const PROTOBUF_TYPES = [ 158 | "uInt32", 159 | "sInt32", 160 | "int32", 161 | "double", 162 | "string", 163 | "message", 164 | "float" 165 | ]; 166 | function getDefinitionFromRoot(root, ref) { 167 | // "#/definitions/MyRank" 168 | let name = ref.split('/'); 169 | name = name[name.length - 1]; 170 | const ret = root.definitions[name]; 171 | if (!ret) { 172 | error('!find definition from root error', root, ret); 173 | } 174 | ret['name'] = name; 175 | return ret; 176 | } 177 | function normalType(typeName) { 178 | if (PROTOBUF_TYPES.includes(typeName)) { 179 | return typeName; 180 | } 181 | if (typeName == 'number') { 182 | return 'uInt32'; 183 | } 184 | error('!! error typeName', typeName); 185 | } 186 | function parseSymbol(root, symbol, messages) { 187 | /* 188 | { 189 | "type": "object", 190 | "properties": { 191 | "normalArr": { 192 | "description": "The float of the nowplayers.", 193 | "additionalProperties": "uInt32", 194 | "type": "array" 195 | }, 196 | "normalStrArr": { 197 | "type": "array", 198 | "items": { 199 | "type": "string" 200 | } 201 | }, 202 | "ranks": { 203 | "type": "array", 204 | "items": { 205 | "$ref": "#/definitions/MyRank" 206 | } 207 | }, 208 | "rk": { 209 | "$ref": "#/definitions/MyRank" 210 | }, 211 | "val": { 212 | "type": "number" 213 | } 214 | }, 215 | "required": [ 216 | "normalArr", 217 | "normalStrArr", 218 | "ranks" 219 | ], 220 | "definitions": { 221 | "MyRank": { 222 | "type": "object", 223 | "properties": { 224 | "nickname": { 225 | "type": "number" 226 | }, 227 | "ggg": { 228 | "$ref": "#/definitions/GGG" 229 | } 230 | }, 231 | "required": [ 232 | "ggg", 233 | "nickname" 234 | ] 235 | }, 236 | "GGG": { 237 | "type": "object", 238 | "properties": { 239 | "ccgg": { 240 | "type": "number" 241 | } 242 | }, 243 | "required": [ 244 | "ccgg" 245 | ] 246 | } 247 | }, 248 | "$schema": "http://json-schema.org/draft-06/schema#" 249 | } 250 | */ 251 | function parseRef(obj, key, $ref) { 252 | const definition = getDefinitionFromRoot(root, $ref); 253 | const name = definition.name; 254 | if (definition.enum) { 255 | if (!definition.type) { 256 | console.log(obj, key, $ref, definition, name); 257 | throw new Error('!! un know enum type'); 258 | } 259 | let type = definition.type; 260 | if (type == 'number' || type == 'boolean') { 261 | type = 'uInt32'; 262 | } 263 | return ' ' + type + ' ' + key; 264 | } 265 | if (!messages[name]) { 266 | messages[name] = parseSymbol(root, definition, messages); 267 | } 268 | if (!MergeMessage) { 269 | obj['message ' + name] = messages[name]; 270 | } 271 | return ' ' + name + ' ' + key; 272 | } 273 | let val = {}; 274 | let i = 1; 275 | for (let key in symbol.properties) { 276 | const prop = symbol.properties[key]; 277 | let msgkey = 'optional'; 278 | // 判断是否是required 279 | if (prop.type == 'array') { 280 | msgkey = 'repeated'; 281 | } 282 | else if (symbol.required && symbol.required.includes(key)) { 283 | msgkey = 'required'; 284 | } 285 | // 判断类型 type items additionalProperties 286 | if (prop.type != 'array') { 287 | if (prop.$ref) { 288 | if (prop.type) { 289 | msgkey += ' ' + normalType(prop.type) + ' ' + key; 290 | } 291 | else { 292 | msgkey += parseRef(val, key, prop.$ref); 293 | } 294 | } 295 | else { 296 | msgkey += ' ' + normalType(prop.type) + ' ' + key; 297 | } 298 | } 299 | else { 300 | // array 301 | if (prop.additionalProperties) { 302 | msgkey += ' ' + normalType(prop.additionalProperties) + ' ' + key; 303 | } 304 | else { 305 | if (prop.items.type) { 306 | msgkey += ' ' + normalType(prop.items.type) + ' ' + key; 307 | } 308 | else { 309 | msgkey += parseRef(val, key, prop.items.$ref); 310 | } 311 | } 312 | } 313 | val[msgkey] = i++; 314 | } 315 | return val; 316 | } 317 | //# sourceMappingURL=main.js.map -------------------------------------------------------------------------------- /dist/main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,+BAA+B;AAC/B,8CAA8C;AAE9C,yBAAyB;AACzB,6BAA6B;AAE7B,SAAS,GAAG,CAAC,GAAG,IAAI;IAChB,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI;IACvB,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IACtC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,IAAI,WAAW,GAAG,MAAM,CAAC;AACzB,IAAI,UAAU,GAAG,MAAM,CAAC;AACxB,IAAI,YAAY,GAAG,KAAK,CAAA;AAExB;;;;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;aAAM,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACzD,MAAM,GAAG,UAAU,CAAC;SACvB;QACD,wCAAwC;QACxC,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,EAAE;YACtB,IAAI,IAAI,CAAC,IAAI,EAAE;gBACX,IAAI,IAAI,CAAC,IAAI,EAAE;oBACX,MAAM,IAAI,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC;iBACrD;qBAAM;oBACH,MAAM,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC3C;aAEJ;iBAAM;gBACH,MAAM,IAAI,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC;aACrD;SACJ;aAAM;YACH,QAAQ;YACR,IAAI,IAAI,CAAC,oBAAoB,EAAE;gBAC3B,MAAM,IAAI,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC;aACrE;iBAAM;gBACH,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;oBACjB,MAAM,IAAI,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC;iBAC3D;qBAAM;oBACH,MAAM,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;iBACjD;aACJ;SACJ;QACD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;KACrB;IACD,OAAO,GAAG,CAAC;AACf,CAAC"} -------------------------------------------------------------------------------- /dist/utils.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const fs = require("fs"); 4 | const main_1 = require("./main"); 5 | function parseAndWrite(sourcePath, distPath) { 6 | const result = main_1.parseToPinusProtobuf(sourcePath); 7 | return fs.writeFileSync(distPath, JSON.stringify(result, null, 4)); 8 | } 9 | exports.parseAndWrite = parseAndWrite; 10 | //# sourceMappingURL=utils.js.map -------------------------------------------------------------------------------- /dist/utils.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AACA,yBAAyB;AACzB,iCAA4C;AAE5C,SAAgB,aAAa,CAAC,UAAiB,EAAC,QAAe;IAC3D,MAAM,MAAM,GAAG,2BAAoB,CAAC,UAAU,CAAC,CAAC;IAChD,OAAO,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAHD,sCAGC"} -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pinus-parse-interface", 3 | "version": "0.2.3", 4 | "dependencies": { 5 | "@types/node": "^14.0.0", 6 | "typescript": "^4.0.0", 7 | "typescript-json-schema": "^0.51.0" 8 | }, 9 | "homepage": "https://github.com/whtiehack/pinus-parse-interface", 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/whtiehack/pinus-parse-interface.git" 13 | }, 14 | "engines": { 15 | "node": ">=8" 16 | }, 17 | "main": "./dist/index", 18 | "types": "./src/index", 19 | "scripts": { 20 | "build": "tsc", 21 | "prepare": "yarn run build" 22 | }, 23 | "keywords": [ 24 | "pinus", 25 | "interface", 26 | "json", 27 | "parser", 28 | "protobuf" 29 | ], 30 | "devDependencies": { 31 | "ts-node": "10.2.1" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /runTest.js: -------------------------------------------------------------------------------- 1 | require('ts-node/register'); 2 | const main = require('./src/'); 3 | 4 | 5 | let test = main.parseToPinusProtobuf('./testInterface'); 6 | console.log('server result', JSON.stringify(test, null, 4)); 7 | 8 | main.parseAndWrite('./testInterface', './tmp.json'); 9 | let compare = JSON.stringify({ 10 | "client": { 11 | "rank.playerHandler.beginGame": { 12 | "required uInt32 token": 1, 13 | "optional string msg": 2, 14 | "message IGG_1": { 15 | "repeated string ggenv": 1, 16 | "optional uInt32 zz": 2 17 | }, 18 | "optional IGG_1 duplicateIgg": 3, 19 | "message GGG": { 20 | "required uInt32 ccgg": 1 21 | }, 22 | "optional GGG sharewithServerused": 4 23 | }, 24 | "rank.playerHandler.onlyNotify": { 25 | "required uInt32 token": 1, 26 | "optional string msg": 2 27 | } 28 | }, 29 | "server": { 30 | "rank.playerHandler.beginGame": { 31 | "optional uInt32 code": 1, 32 | "optional string msg": 2, 33 | "required uInt32 currank": 3 34 | }, 35 | "enumTest": { 36 | "optional string aa": 1, 37 | "required uInt32 bb": 2, 38 | "required uInt32 cc": 3, 39 | "optional string enumstr": 4 40 | }, 41 | "onAdd": { 42 | "required string nickname": 1, 43 | "required uInt32 nickname11": 2, 44 | "required uInt32 nowplayers": 3, 45 | "required float nowplayers2": 4, 46 | "required double nowplayers3": 5 47 | }, 48 | "onRank": { 49 | "repeated uInt32 normalArr": 1, 50 | "required uInt32 enum": 2, 51 | "repeated string normalStrArr": 3, 52 | "message GGG": { 53 | "required uInt32 ccgg": 1 54 | }, 55 | "optional GGG innerGGG": 4, 56 | "message MyRank": { 57 | "required uInt32 nickname": 1, 58 | "message GGG": { 59 | "required uInt32 ccgg": 1 60 | }, 61 | "required GGG ggg": 2, 62 | "required GGG xxx": 3 63 | }, 64 | "repeated MyRank ranks": 5, 65 | "optional MyRank rk": 6, 66 | "optional uInt32 val": 7, 67 | "required string ffname": 8, 68 | "message IGG": { 69 | "repeated string ggenv": 1 70 | }, 71 | "repeated IGG aa": 9, 72 | "repeated string ggenv": 10 73 | } 74 | } 75 | }) 76 | if (process.env['NODE_ENV'] === 'ci' && JSON.stringify(test) !== compare) { 77 | console.error(JSON.stringify(test), "compare:", compare) 78 | throw new Error("error") 79 | } 80 | 81 | 82 | test = main.parseToPinusProtobuf('./testInterface', '_Req', '_Res', true); 83 | console.log('@@@server result', JSON.stringify(test, null, 4)); 84 | 85 | if (process.env['NODE_ENV'] === 'ci') { 86 | let val = JSON.stringify({ 87 | "client": { 88 | "rank.playerHandler.beginGame": { 89 | "required uInt32 token": 1, 90 | "optional string msg": 2, 91 | "optional IGG_1 duplicateIgg": 3, 92 | "optional GGG sharewithServerused": 4 93 | }, 94 | "rank.playerHandler.onlyNotify": { 95 | "required uInt32 token": 1, 96 | "optional string msg": 2 97 | }, 98 | "message GGG": { 99 | "required uInt32 ccgg": 1 100 | }, 101 | "message IGG_1": { 102 | "repeated string ggenv": 1, 103 | "optional uInt32 zz": 2 104 | } 105 | }, 106 | "server": { 107 | "rank.playerHandler.beginGame": { 108 | "optional uInt32 code": 1, 109 | "optional string msg": 2, 110 | "required uInt32 currank": 3 111 | }, 112 | "enumTest": { 113 | "optional string aa": 1, 114 | "required uInt32 bb": 2, 115 | "required uInt32 cc": 3, 116 | "optional string enumstr": 4 117 | }, 118 | "onAdd": { 119 | "required string nickname": 1, 120 | "required uInt32 nickname11": 2, 121 | "required uInt32 nowplayers": 3, 122 | "required float nowplayers2": 4, 123 | "required double nowplayers3": 5 124 | }, 125 | "onRank": { 126 | "repeated uInt32 normalArr": 1, 127 | "required uInt32 enum": 2, 128 | "repeated string normalStrArr": 3, 129 | "optional GGG innerGGG": 4, 130 | "repeated MyRank ranks": 5, 131 | "optional MyRank rk": 6, 132 | "optional uInt32 val": 7, 133 | "required string ffname": 8, 134 | "repeated IGG aa": 9, 135 | "repeated string ggenv": 10 136 | }, 137 | "message GGG": { 138 | "required uInt32 ccgg": 1 139 | }, 140 | "message IGG": { 141 | "repeated string ggenv": 1 142 | }, 143 | "message MyRank": { 144 | "required uInt32 nickname": 1, 145 | "required GGG ggg": 2, 146 | "required GGG xxx": 3 147 | } 148 | } 149 | }) 150 | if (JSON.stringify(test) !== val) { 151 | console.error(JSON.stringify(test), "compare:", compare) 152 | throw new Error("error") 153 | } 154 | console.log("test passed") 155 | } 156 | 157 | 158 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | export * from './main'; 4 | 5 | export * from './utils'; -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | import { resolve } from 'path'; 3 | import * as TJS from "typescript-json-schema"; 4 | import { Definition, JsonSchemaGenerator } from "typescript-json-schema"; 5 | import * as fs from 'fs'; 6 | import * as util from 'util'; 7 | 8 | function log(...args) { 9 | console.log(...args); 10 | } 11 | 12 | function error(msg, ...args) { 13 | const str = util.format(msg, ...args); 14 | console.error(str); 15 | throw new Error(str); 16 | } 17 | 18 | let responseStr = '_Res'; 19 | let requestStr = '_Req'; 20 | let MergeMessage = false 21 | 22 | /** 23 | * 24 | * @param baseDir 25 | * @param reqStr 26 | * @param resStr 27 | * @param mergeMessage message 结构放到顶层 (默认的客户端不支持,需要修改客户端) 28 | */ 29 | export function parseToPinusProtobuf(baseDir: string, reqStr = '_Req', resStr = '_Res', mergeMessage = false): { client: object, server: object } { 30 | responseStr = resStr; 31 | requestStr = reqStr; 32 | MergeMessage = mergeMessage 33 | let retObj = { client: {}, server: {} }; 34 | const files = fs.readdirSync(baseDir); 35 | const tsFilePaths: string[] = []; 36 | files.forEach(val => { 37 | if (!val.endsWith('.ts')) { 38 | return; 39 | } 40 | tsFilePaths.push(resolve(baseDir + '/' + val)); 41 | // const obj = parseFile(baseDir,val); 42 | // const tmp = path.parse(val); 43 | // retObj.client[tmp.name] = obj.client; 44 | // retObj.server[tmp.name] = obj.server; 45 | }); 46 | 47 | // optionally pass argument to schema generator 48 | const settings: TJS.PartialArgs = { 49 | required: true 50 | }; 51 | 52 | // optionally pass ts compiler options 53 | const compilerOptions: TJS.CompilerOptions = { 54 | strictNullChecks: true 55 | }; 56 | const program = TJS.getProgramFromFiles(tsFilePaths, compilerOptions, baseDir); 57 | const generator = TJS.buildGenerator(program, settings); 58 | // all symbols 59 | 60 | const symbols = generator.getMainFileSymbols(program); 61 | let clientMessages = {} 62 | let serverMessages = {} 63 | files.forEach(val => { 64 | if (!val.endsWith('.ts')) { 65 | return; 66 | } 67 | if (!mergeMessage) { 68 | clientMessages = {} 69 | serverMessages = {} 70 | } 71 | const obj = parseFile(baseDir, val, program, generator, symbols, clientMessages, serverMessages); 72 | const tmp = path.parse(val); 73 | retObj.client[tmp.name] = obj.client; 74 | retObj.server[tmp.name] = obj.server; 75 | }); 76 | retObj.client = sortMsg(retObj.client) 77 | retObj.server = sortMsg(retObj.server) 78 | if (mergeMessage) { 79 | let obj = {} 80 | for (let k in clientMessages) { 81 | obj['message ' + k] = clientMessages[k] 82 | } 83 | obj = sortMsg(obj) 84 | for (let k in obj) { 85 | retObj.client[k] = obj[k] 86 | } 87 | obj = {} 88 | for (let k in serverMessages) { 89 | obj['message ' + k] = serverMessages[k] 90 | } 91 | obj = sortMsg(obj) 92 | for (let k in obj) { 93 | retObj.server[k] = obj[k] 94 | } 95 | } 96 | return retObj; 97 | } 98 | 99 | function sortMsg(obj) { 100 | let arr: { k: string, v: object }[] = [] 101 | for (let k in obj) { 102 | arr.push({ k: k, v: obj[k] }) 103 | } 104 | arr.sort((a, b) => { 105 | if (a.k.includes('.')) { 106 | if (b.k.includes('.')) { 107 | return a.k > b.k ? 1 : -1 108 | } 109 | return -1 110 | } 111 | if (b.k.includes('.')) { 112 | return 1 113 | } 114 | return a.k > b.k ? 1 : -1 115 | }) 116 | let newObj = {} 117 | for (let v of arr) { 118 | newObj[v.k] = v.v 119 | } 120 | return newObj 121 | } 122 | 123 | function parseFile(baseDir: string, filename: string, program: TJS.Program, generator: JsonSchemaGenerator, symbols: string[], clientMessages, serverMessages) { 124 | if (!symbols || !symbols.length) { 125 | return; 126 | } 127 | const filePath = path.parse(filename); 128 | filename = filePath.name.replace(/\./g, '_'); 129 | // const symbolName = symbols[symbols.length-1]; 130 | // if(!symbolName){ 131 | // return; 132 | // } 133 | 134 | let symbolClient; 135 | if (symbols.includes(filename + requestStr)) { 136 | symbolClient = generator.getSchemaForSymbol(filename + requestStr); 137 | } 138 | let client; 139 | let server; 140 | if (symbolClient) { 141 | client = parseSymbol(symbolClient, symbolClient, clientMessages); 142 | } 143 | let symbolServer; 144 | if (symbols.includes(filename + responseStr)) { 145 | if (!client) { 146 | console.warn('WARNING:', filename, `has ${ responseStr } without ${ requestStr }`); 147 | } 148 | symbolServer = generator.getSchemaForSymbol(filename + responseStr); 149 | } 150 | if (!symbolServer) { 151 | if (client) { 152 | // console.warn('WARNING:',filename,`has ${requestStr} without ${responseStr}`); 153 | } 154 | if (symbols.includes(filename)) { 155 | symbolServer = generator.getSchemaForSymbol(filename); 156 | } 157 | } 158 | if (!symbolServer) { 159 | return { client: client }; 160 | } 161 | server = parseSymbol(symbolServer, symbolServer, serverMessages); 162 | return { client: client, server: server }; 163 | // return transMessage(obj,messages); 164 | } 165 | 166 | 167 | interface IProp { 168 | $ref?: string; 169 | type?: string; 170 | additionalProperties?: string; 171 | items: { type?: string; $ref?: string }; 172 | } 173 | 174 | const PROTOBUF_TYPES = [ 175 | "uInt32", 176 | "sInt32", 177 | "int32", 178 | "double", 179 | "string", 180 | "message", 181 | "float" 182 | ]; 183 | 184 | function getDefinitionFromRoot(root: Definition, ref: string): Definition { 185 | // "#/definitions/MyRank" 186 | let name: string = ref.split('/') as any; 187 | name = name[name.length - 1]; 188 | const ret = root.definitions[name]; 189 | if (!ret) { 190 | error('!find definition from root error', root, ret); 191 | } 192 | ret['name'] = name; 193 | return ret as Definition; 194 | } 195 | 196 | function normalType(typeName: string) { 197 | if (PROTOBUF_TYPES.includes(typeName)) { 198 | return typeName; 199 | } 200 | if (typeName == 'number') { 201 | return 'uInt32'; 202 | } 203 | error('!! error typeName', typeName); 204 | } 205 | 206 | function parseSymbol(root: Definition, symbol: Definition, messages: object) { 207 | /* 208 | { 209 | "type": "object", 210 | "properties": { 211 | "normalArr": { 212 | "description": "The float of the nowplayers.", 213 | "additionalProperties": "uInt32", 214 | "type": "array" 215 | }, 216 | "normalStrArr": { 217 | "type": "array", 218 | "items": { 219 | "type": "string" 220 | } 221 | }, 222 | "ranks": { 223 | "type": "array", 224 | "items": { 225 | "$ref": "#/definitions/MyRank" 226 | } 227 | }, 228 | "rk": { 229 | "$ref": "#/definitions/MyRank" 230 | }, 231 | "val": { 232 | "type": "number" 233 | } 234 | }, 235 | "required": [ 236 | "normalArr", 237 | "normalStrArr", 238 | "ranks" 239 | ], 240 | "definitions": { 241 | "MyRank": { 242 | "type": "object", 243 | "properties": { 244 | "nickname": { 245 | "type": "number" 246 | }, 247 | "ggg": { 248 | "$ref": "#/definitions/GGG" 249 | } 250 | }, 251 | "required": [ 252 | "ggg", 253 | "nickname" 254 | ] 255 | }, 256 | "GGG": { 257 | "type": "object", 258 | "properties": { 259 | "ccgg": { 260 | "type": "number" 261 | } 262 | }, 263 | "required": [ 264 | "ccgg" 265 | ] 266 | } 267 | }, 268 | "$schema": "http://json-schema.org/draft-06/schema#" 269 | } 270 | */ 271 | function parseRef(obj, key, $ref) { 272 | const definition = getDefinitionFromRoot(root, $ref); 273 | const name = (definition as any).name; 274 | if (definition.enum) { 275 | if (!definition.type) { 276 | console.log(obj, key, $ref, definition, name); 277 | throw new Error('!! un know enum type'); 278 | } 279 | let type = definition.type; 280 | if (type == 'number' || type == 'boolean') { 281 | type = 'uInt32'; 282 | } 283 | return ' ' + type + ' ' + key; 284 | } 285 | if (!messages[name]) { 286 | messages[name]={}; 287 | messages[name] = parseSymbol(root, definition, messages); 288 | } 289 | if (!MergeMessage) { 290 | obj['message ' + name] = messages[name]; 291 | } 292 | return ' ' + name + ' ' + key; 293 | } 294 | 295 | let val = {}; 296 | let i = 1; 297 | for (let key in symbol.properties) { 298 | const prop = symbol.properties[key]; 299 | let msgkey = 'optional'; 300 | // 判断是否是required 301 | if (prop.type == 'array') { 302 | msgkey = 'repeated'; 303 | } else if (symbol.required && symbol.required.includes(key)) { 304 | msgkey = 'required'; 305 | } 306 | // 判断类型 type items additionalProperties 307 | if (prop.type != 'array') { 308 | if (prop.$ref) { 309 | if (prop.type) { 310 | msgkey += ' ' + normalType(prop.type) + ' ' + key; 311 | } else { 312 | msgkey += parseRef(val, key, prop.$ref); 313 | } 314 | 315 | } else { 316 | msgkey += ' ' + normalType(prop.type) + ' ' + key; 317 | } 318 | } else { 319 | // array 320 | if (prop.additionalProperties) { 321 | msgkey += ' ' + normalType(prop.additionalProperties) + ' ' + key; 322 | } else { 323 | if (prop.items.type) { 324 | msgkey += ' ' + normalType(prop.items.type) + ' ' + key; 325 | } else { 326 | msgkey += parseRef(val, key, prop.items.$ref); 327 | } 328 | } 329 | } 330 | val[msgkey] = i++; 331 | } 332 | return val; 333 | } 334 | 335 | 336 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as fs from 'fs'; 3 | import {parseToPinusProtobuf} from "./main"; 4 | 5 | export function parseAndWrite(sourcePath:string,distPath:string){ 6 | const result = parseToPinusProtobuf(sourcePath); 7 | return fs.writeFileSync(distPath,JSON.stringify(result,null,4)); 8 | } 9 | -------------------------------------------------------------------------------- /testInterface/enumTest.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | enum EnumTestInt{ 4 | AA, 5 | CC , 6 | DD , 7 | } 8 | 9 | enum EnumTestSTR{ 10 | CC ='aa', 11 | DD ='cc', 12 | } 13 | 14 | export interface enumTest{ 15 | aa?:string; 16 | bb:number; 17 | /** 18 | * @TJS-type uInt32 19 | */ 20 | cc:EnumTestInt; 21 | enumstr?:EnumTestSTR; 22 | } -------------------------------------------------------------------------------- /testInterface/onAdd.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | 5 | "onAdd": { 6 | "required string nickname": 1, 7 | "required uInt32 nowplayers": 2 8 | }, 9 | */ 10 | 11 | 12 | 13 | 14 | export interface onAdd{ 15 | nickname:string; 16 | nickname11:number; 17 | 18 | nowplayers:number; 19 | /** 20 | * The float of the nowplayers. 21 | * 22 | * @TJS-type float 23 | */ 24 | nowplayers2:number; 25 | /** 26 | * The float of the nowplayers. 27 | * 28 | * @TJS-type double 29 | */ 30 | nowplayers3:number; 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /testInterface/onRank.ts: -------------------------------------------------------------------------------- 1 | // "onSegRanks": { 2 | // "message Array": { 3 | // "required uInt32 rank": 1, 4 | // "required string nickname": 2, 5 | // "required uInt32 score": 3, 6 | // "required uInt32 tag": 4, 7 | // "required uInt32 dienum": 5 8 | // }, 9 | // "repeated Array ranks": 1 10 | // }, 11 | 12 | import {GGG, MyRank} from "./share/myrank"; 13 | 14 | 15 | interface IGG{ 16 | ggenv?:string[]; 17 | } 18 | 19 | interface IFF{ 20 | ffname:string; 21 | aa?:IGG[]; 22 | } 23 | 24 | enum EnumTest{ 25 | AA, 26 | BB, 27 | CC 28 | } 29 | 30 | export interface onRank extends IFF,IGG{ 31 | /** 32 | * The float of the nowplayers. 33 | * 34 | * @additionalProperties uInt32 35 | * @TJS-type array 36 | */ 37 | normalArr:number[]; 38 | /** 39 | * @TJS-type uInt32 40 | */ 41 | enum:EnumTest; 42 | normalStrArr:string[]; 43 | innerGGG?:GGG; 44 | ranks:MyRank[]; 45 | rk?:MyRank; 46 | val?:number; 47 | } -------------------------------------------------------------------------------- /testInterface/rank.playerHandler.beginGame.ts: -------------------------------------------------------------------------------- 1 | /* 2 | "rank.playerHandler.beginGame":{ 3 | "optional uInt32 code":1, 4 | "optional string msg":2, 5 | "optional uInt32 currank":3 6 | }, 7 | */ 8 | 9 | // duplicate IGG name 10 | import { GGG } from "./share/myrank"; 11 | 12 | interface IGG { 13 | ggenv?: string[]; 14 | zz?: number; 15 | } 16 | 17 | export interface rank_playerHandler_beginGame_Req { 18 | token: number; 19 | msg?: string; 20 | duplicateIgg?: IGG 21 | sharewithServerused?: GGG 22 | } 23 | 24 | export interface rank_playerHandler_beginGame_Res { 25 | /** 26 | * @TJS-type uInt32 27 | */ 28 | code?: number; 29 | msg?: string; 30 | /** 31 | * @TJS-type uInt32 32 | */ 33 | currank: number; 34 | } 35 | -------------------------------------------------------------------------------- /testInterface/rank.playerHandler.onlyNotify.ts: -------------------------------------------------------------------------------- 1 | /* 2 | "rank.playerHandler.beginGame":{ 3 | "optional uInt32 code":1, 4 | "optional string msg":2, 5 | "optional uInt32 currank":3 6 | }, 7 | */ 8 | 9 | 10 | export interface rank_playerHandler_onlyNotify_Req{ 11 | token:number; 12 | msg?:string; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /testInterface/share/myrank.ts: -------------------------------------------------------------------------------- 1 | 2 | // "message Array": { 3 | // "required uInt32 rank": 1, 4 | // "required string nickname": 2, 5 | // "required uInt32 score": 3, 6 | // "required uInt32 tag": 4, 7 | // "required uInt32 dienum": 5 8 | // }, 9 | 10 | export interface GGG{ 11 | ccgg:number; 12 | } 13 | export interface MyRank{ 14 | nickname:number; 15 | ggg:GGG; 16 | xxx:GGG; 17 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es2017", 5 | "sourceMap": true, 6 | "experimentalDecorators":true, 7 | "emitDecoratorMetadata": true, 8 | "moduleResolution": "node", 9 | "outDir": "./dist" 10 | }, 11 | "exclude": [ 12 | "node_modules", 13 | "testInterface" 14 | ], 15 | "include": [ 16 | "./src/**/*.ts" 17 | ] 18 | } -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@cspotcode/source-map-consumer@0.8.0": 6 | version "0.8.0" 7 | resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b" 8 | integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg== 9 | 10 | "@cspotcode/source-map-support@0.6.1": 11 | version "0.6.1" 12 | resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.6.1.tgz#118511f316e2e87ee4294761868e254d3da47960" 13 | integrity sha512-DX3Z+T5dt1ockmPdobJS/FAsQPW4V4SrWEhD2iYQT2Cb2tQsiMnYxrcUH9By/Z3B+v0S5LMBkQtV/XOBbpLEOg== 14 | dependencies: 15 | "@cspotcode/source-map-consumer" "0.8.0" 16 | 17 | "@tsconfig/node10@^1.0.7": 18 | version "1.0.7" 19 | resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.7.tgz#1eb1de36c73478a2479cc661ef5af1c16d86d606" 20 | integrity sha512-aBvUmXLQbayM4w3A8TrjwrXs4DZ8iduJnuJLLRGdkWlyakCf1q6uHZJBzXoRA/huAEknG5tcUyQxN3A+In5euQ== 21 | 22 | "@tsconfig/node12@^1.0.7": 23 | version "1.0.7" 24 | resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.7.tgz#677bd9117e8164dc319987dd6ff5fc1ba6fbf18b" 25 | integrity sha512-dgasobK/Y0wVMswcipr3k0HpevxFJLijN03A8mYfEPvWvOs14v0ZlYTR4kIgMx8g4+fTyTFv8/jLCIfRqLDJ4A== 26 | 27 | "@tsconfig/node14@^1.0.0": 28 | version "1.0.0" 29 | resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.0.tgz#5bd046e508b1ee90bc091766758838741fdefd6e" 30 | integrity sha512-RKkL8eTdPv6t5EHgFKIVQgsDapugbuOptNd9OOunN/HAkzmmTnZELx1kNCK0rSdUYGmiFMM3rRQMAWiyp023LQ== 31 | 32 | "@tsconfig/node16@^1.0.2": 33 | version "1.0.2" 34 | resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e" 35 | integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA== 36 | 37 | "@types/json-schema@^7.0.9": 38 | version "7.0.9" 39 | resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" 40 | integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== 41 | 42 | "@types/node@^14.0.0": 43 | version "14.17.2" 44 | resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.2.tgz#1e94476db57ec93a372c7f7d29aa5707cfb92339" 45 | integrity sha512-sld7b/xmFum66AAKuz/rp/CUO8+98fMpyQ3SBfzzBNGMd/1iHBTAg9oyAvcYlAj46bpc74r91jSw2iFdnx29nw== 46 | 47 | "@types/node@^16.9.2": 48 | version "16.9.2" 49 | resolved "https://registry.yarnpkg.com/@types/node/-/node-16.9.2.tgz#81f5a039d6ed1941f8cc57506c74e7c2b8fc64b9" 50 | integrity sha512-ZHty/hKoOLZvSz6BtP1g7tc7nUeJhoCf3flLjh8ZEv1vFKBWHXcnMbJMyN/pftSljNyy0kNW/UqI3DccnBnZ8w== 51 | 52 | acorn-walk@^8.1.1: 53 | version "8.1.1" 54 | resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.1.1.tgz#3ddab7f84e4a7e2313f6c414c5b7dac85f4e3ebc" 55 | integrity sha512-FbJdceMlPHEAWJOILDk1fXD8lnTlEIWFkqtfk+MvmL5q/qlHfN7GEHcsFZWt/Tea9jRNPWUZG4G976nqAAmU9w== 56 | 57 | acorn@^8.4.1: 58 | version "8.4.1" 59 | resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.4.1.tgz#56c36251fc7cabc7096adc18f05afe814321a28c" 60 | integrity sha512-asabaBSkEKosYKMITunzX177CXxQ4Q8BSSzMTKD+FefUhipQC70gfW5SiUDhYQ3vk8G+81HqQk7Fv9OXwwn9KA== 61 | 62 | ansi-regex@^5.0.0: 63 | version "5.0.0" 64 | resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" 65 | integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== 66 | 67 | ansi-styles@^4.0.0: 68 | version "4.3.0" 69 | resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" 70 | integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== 71 | dependencies: 72 | color-convert "^2.0.1" 73 | 74 | arg@^4.1.0: 75 | version "4.1.0" 76 | resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.0.tgz#583c518199419e0037abb74062c37f8519e575f0" 77 | 78 | balanced-match@^1.0.0: 79 | version "1.0.0" 80 | resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" 81 | 82 | brace-expansion@^1.1.7: 83 | version "1.1.11" 84 | resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" 85 | dependencies: 86 | balanced-match "^1.0.0" 87 | concat-map "0.0.1" 88 | 89 | cliui@^7.0.2: 90 | version "7.0.4" 91 | resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" 92 | integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== 93 | dependencies: 94 | string-width "^4.2.0" 95 | strip-ansi "^6.0.0" 96 | wrap-ansi "^7.0.0" 97 | 98 | color-convert@^2.0.1: 99 | version "2.0.1" 100 | resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" 101 | integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== 102 | dependencies: 103 | color-name "~1.1.4" 104 | 105 | color-name@~1.1.4: 106 | version "1.1.4" 107 | resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" 108 | integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== 109 | 110 | concat-map@0.0.1: 111 | version "0.0.1" 112 | resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" 113 | 114 | create-require@^1.1.0: 115 | version "1.1.1" 116 | resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" 117 | integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== 118 | 119 | diff@^4.0.1: 120 | version "4.0.1" 121 | resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.1.tgz#0c667cb467ebbb5cea7f14f135cc2dba7780a8ff" 122 | 123 | emoji-regex@^8.0.0: 124 | version "8.0.0" 125 | resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" 126 | integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== 127 | 128 | escalade@^3.1.1: 129 | version "3.1.1" 130 | resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" 131 | integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== 132 | 133 | fs.realpath@^1.0.0: 134 | version "1.0.0" 135 | resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" 136 | 137 | get-caller-file@^2.0.5: 138 | version "2.0.5" 139 | resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" 140 | integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== 141 | 142 | glob@^7.1.7: 143 | version "7.1.7" 144 | resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" 145 | integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ== 146 | dependencies: 147 | fs.realpath "^1.0.0" 148 | inflight "^1.0.4" 149 | inherits "2" 150 | minimatch "^3.0.4" 151 | once "^1.3.0" 152 | path-is-absolute "^1.0.0" 153 | 154 | inflight@^1.0.4: 155 | version "1.0.6" 156 | resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" 157 | dependencies: 158 | once "^1.3.0" 159 | wrappy "1" 160 | 161 | inherits@2: 162 | version "2.0.3" 163 | resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" 164 | 165 | is-fullwidth-code-point@^3.0.0: 166 | version "3.0.0" 167 | resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" 168 | integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== 169 | 170 | json-stable-stringify@^1.0.1: 171 | version "1.0.1" 172 | resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" 173 | dependencies: 174 | jsonify "~0.0.0" 175 | 176 | jsonify@~0.0.0: 177 | version "0.0.0" 178 | resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" 179 | 180 | make-error@^1.1.1: 181 | version "1.3.4" 182 | resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.4.tgz#19978ed575f9e9545d2ff8c13e33b5d18a67d535" 183 | 184 | minimatch@^3.0.4: 185 | version "3.0.4" 186 | resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" 187 | dependencies: 188 | brace-expansion "^1.1.7" 189 | 190 | once@^1.3.0: 191 | version "1.4.0" 192 | resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" 193 | dependencies: 194 | wrappy "1" 195 | 196 | path-is-absolute@^1.0.0: 197 | version "1.0.1" 198 | resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" 199 | 200 | require-directory@^2.1.1: 201 | version "2.1.1" 202 | resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" 203 | 204 | string-width@^4.1.0, string-width@^4.2.0: 205 | version "4.2.0" 206 | resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" 207 | integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== 208 | dependencies: 209 | emoji-regex "^8.0.0" 210 | is-fullwidth-code-point "^3.0.0" 211 | strip-ansi "^6.0.0" 212 | 213 | strip-ansi@^6.0.0: 214 | version "6.0.0" 215 | resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" 216 | integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== 217 | dependencies: 218 | ansi-regex "^5.0.0" 219 | 220 | ts-node@10.2.1, ts-node@^10.2.1: 221 | version "10.2.1" 222 | resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.2.1.tgz#4cc93bea0a7aba2179497e65bb08ddfc198b3ab5" 223 | integrity sha512-hCnyOyuGmD5wHleOQX6NIjJtYVIO8bPP8F2acWkB4W06wdlkgyvJtubO/I9NkI88hCFECbsEgoLc0VNkYmcSfw== 224 | dependencies: 225 | "@cspotcode/source-map-support" "0.6.1" 226 | "@tsconfig/node10" "^1.0.7" 227 | "@tsconfig/node12" "^1.0.7" 228 | "@tsconfig/node14" "^1.0.0" 229 | "@tsconfig/node16" "^1.0.2" 230 | acorn "^8.4.1" 231 | acorn-walk "^8.1.1" 232 | arg "^4.1.0" 233 | create-require "^1.1.0" 234 | diff "^4.0.1" 235 | make-error "^1.1.1" 236 | yn "3.1.1" 237 | 238 | typescript-json-schema@^0.51.0: 239 | version "0.51.0" 240 | resolved "https://registry.yarnpkg.com/typescript-json-schema/-/typescript-json-schema-0.51.0.tgz#e2abff69b8564c98c0edef2c13d55ef10fd71427" 241 | integrity sha512-POhWbUNs2oaBti1W9k/JwS+uDsaZD9J/KQiZ/iXRQEOD0lTn9VmshIls9tn+A9X6O+smPjeEz5NEy6WTkCCzrQ== 242 | dependencies: 243 | "@types/json-schema" "^7.0.9" 244 | "@types/node" "^16.9.2" 245 | glob "^7.1.7" 246 | json-stable-stringify "^1.0.1" 247 | ts-node "^10.2.1" 248 | typescript "~4.2.3" 249 | yargs "^17.1.1" 250 | 251 | typescript@^4.0.0: 252 | version "4.0.2" 253 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2" 254 | integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ== 255 | 256 | typescript@~4.2.3: 257 | version "4.2.4" 258 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961" 259 | integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg== 260 | 261 | wrap-ansi@^7.0.0: 262 | version "7.0.0" 263 | resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" 264 | integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== 265 | dependencies: 266 | ansi-styles "^4.0.0" 267 | string-width "^4.1.0" 268 | strip-ansi "^6.0.0" 269 | 270 | wrappy@1: 271 | version "1.0.2" 272 | resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" 273 | 274 | y18n@^5.0.5: 275 | version "5.0.5" 276 | resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.5.tgz#8769ec08d03b1ea2df2500acef561743bbb9ab18" 277 | integrity sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg== 278 | 279 | yargs-parser@^20.2.2: 280 | version "20.2.4" 281 | resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" 282 | integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== 283 | 284 | yargs@^17.1.1: 285 | version "17.1.1" 286 | resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.1.1.tgz#c2a8091564bdb196f7c0a67c1d12e5b85b8067ba" 287 | integrity sha512-c2k48R0PwKIqKhPMWjeiF6y2xY/gPMUlro0sgxqXpbOIohWiLNXWslsootttv7E1e73QPAMQSg5FeySbVcpsPQ== 288 | dependencies: 289 | cliui "^7.0.2" 290 | escalade "^3.1.1" 291 | get-caller-file "^2.0.5" 292 | require-directory "^2.1.1" 293 | string-width "^4.2.0" 294 | y18n "^5.0.5" 295 | yargs-parser "^20.2.2" 296 | 297 | yn@3.1.1: 298 | version "3.1.1" 299 | resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" 300 | --------------------------------------------------------------------------------