All Projects → whtiehack → pinus-parse-interface

whtiehack / pinus-parse-interface

Licence: other
parse interface to pinus-protobuf JSON

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to pinus-parse-interface

nimpb
Protocol Buffers for Nim
Stars: ✭ 29 (+16%)
Mutual labels:  protobuf
parse-function
(!! moved to tunnckoCore/opensource multi-package repository !!) 🔱 Parse a function into an object using espree, acorn or babylon parsers. Extensible through Smart Plugins.
Stars: ✭ 37 (+48%)
Mutual labels:  parse
protoc-gen-micro
Protobuf code generation
Stars: ✭ 287 (+1048%)
Mutual labels:  protobuf
rails-microservices-book
A guide to building distributed Ruby on Rails applications using Protocol Buffers, NATS and RabbitMQ
Stars: ✭ 23 (-8%)
Mutual labels:  protobuf
python-yamlable
A thin wrapper of PyYaml to convert Python objects to YAML and back
Stars: ✭ 28 (+12%)
Mutual labels:  parse
tsrpc
A TypeScript RPC framework, with runtime type checking and serialization, support both HTTP and WebSocket. It is very suitable for website / APP / games, and absolutely comfortable to full-stack TypeScript developers.
Stars: ✭ 866 (+3364%)
Mutual labels:  protobuf
vtprotobuf
A Protocol Buffers compiler that generates optimized marshaling & unmarshaling Go code for ProtoBuf APIv2
Stars: ✭ 418 (+1572%)
Mutual labels:  protobuf
netty-chat-tutorial
Netty Chat tutorial with Protobuf
Stars: ✭ 23 (-8%)
Mutual labels:  protobuf
ytnef
Yeraze's TNEF Stream Reader - for winmail.dat files
Stars: ✭ 28 (+12%)
Mutual labels:  parse
gonids
gonids is a library to parse IDS rules, with a focus primarily on Suricata rule compatibility. There is a discussion forum available that you can join on Google Groups: https://groups.google.com/forum/#!topic/gonids/
Stars: ✭ 140 (+460%)
Mutual labels:  parse
ocaml-protoc-plugin
ocaml-protoc-plugin
Stars: ✭ 36 (+44%)
Mutual labels:  protobuf
pb3-gen-sol
Generate solidity decoders from proto3 files
Stars: ✭ 15 (-40%)
Mutual labels:  protobuf
gpp-decrypt
Tool to parse the Group Policy Preferences XML file which extracts the username and decrypts the cpassword attribute.
Stars: ✭ 13 (-48%)
Mutual labels:  parse
fieldmask-utils
Protobuf Field Mask Go utils
Stars: ✭ 127 (+408%)
Mutual labels:  protobuf
ppx deriving protobuf
A Protocol Buffers codec generator for OCaml
Stars: ✭ 76 (+204%)
Mutual labels:  protobuf
sjson-cpp
An Simplified JSON (SJSON) C++ reader and writer
Stars: ✭ 16 (-36%)
Mutual labels:  parse
Script.apex
Evaluate Javascript expressions in Apex
Stars: ✭ 18 (-28%)
Mutual labels:  parse
ocaml-pb-plugin
A protoc plugin for generating OCaml code from protobuf (.proto) files.
Stars: ✭ 18 (-28%)
Mutual labels:  protobuf
docarray
The data structure for unstructured data
Stars: ✭ 561 (+2144%)
Mutual labels:  protobuf
scalapb-playjson
Json/Protobuf convertors for ScalaPB use play-json
Stars: ✭ 15 (-40%)
Mutual labels:  protobuf

test-parse

parse TS interface to pinus-protobuf JSON

解析 ts 的interface 到 pinus-protobuf用的 json格式。

pinus: https://github.com/node-pinus/pinus

changelog

v0.2.3:
fix sort method.

v0.2.2: 
生成的消息做排序

v0.2.1:
支持 结构放到顶层 (默认的客户端不支持,需要修改客户端)

v0.1.6:
支持 notify 消息。可以没有Response.

v0.1.5:
文件统一解析。 加快解析速度

v0.1.3:
修复interface成员全部为可选时会出错的bug。

install

npm install pinus-parse-interface

or

yarn add pinus-parse-interface

usage

const main = require('pinus-parse-interface');

const test = main.parseToPinusProtobuf('path_to_you_interface_dir');
console.log('result',JSON.stringify(test,null,4));

合并所有的message到顶层

// 第四个参数表示把所有的message结构放到顶层 (默认的客户端不支持,需要修改客户端)
main.parseToPinusProtobuf('path_to_you_interface_dir','_Req','_Res',true);

interface 结构约定

  1. 以文件名为消息名。
  2. 客户端与服务端的结构放到一起。
  3. 客户端消息,以 文件名_Req 为结尾
  4. 服务端消息,以 文件名_Res 为结尾
  5. 文件名中的. 会被转换成 _
  6. 服务端推送消息直接以文件名命名
  7. _Res,_Req 可以使用自定义名字

例如: rank.playerHandler.beginGame.ts 会寻找 rank_playerHandler_beginGame_Req,rank_playerHandler_beginGame_Res

auto generate

serverProtos.json,clientProtos.json.

example

it can also be used on the pomelo-protobuf declaration file(serverProtos.json,clientProtos.json).

input

// onAdd.ts
export interface onAdd{
    nickname:string;
    nickname11:number;

    nowplayers:number;
    /**
     * The float of the nowplayers.
     *
     * @TJS-type float
     */
    nowplayers2:number;
    /**
     * The float of the nowplayers.
     *
     * @TJS-type double
     */
    nowplayers3:number;
}


// onRank.ts


import {GGG, MyRank} from "../share/myrank";


interface IGG{
    ggenv?:string[];
}

interface IFF{
    ffname:string;
    aa?:IGG[];
}

enum EnumTest{
    AA,
    BB,
    CC
}

export interface onRank extends IFF,IGG{
    /**
     * The float of the nowplayers.
     *
     * @additionalProperties uInt32
     * @TJS-type array
     */
    normalArr:number[];
    /**
     * @TJS-type uInt32
     */
    enum:EnumTest;
    normalStrArr:string[];
    innerGGG?:GGG;
    ranks:MyRank[];
    rk?:MyRank;
    val?:number;
}

// rank.playerHandler.beginGame.ts

export interface rank_playerHandler_beginGame_Req{
    token:number;
    msg?:string;
}

export interface rank_playerHandler_beginGame_Res{
    /**
     * @TJS-type uInt32
     */
    code?:number;
    msg?:string;
    /**
     * @TJS-type uInt32
     */
    currank:number;
}


output

{
    "client": {
        "rank.playerHandler.beginGame": {
            "required uInt32 token": 1,
            "optional string msg": 2
        }
    },
    "server": {
        "enumTest": {
            "optional string aa": 1,
            "required uInt32 bb": 2,
            "required uInt32 cc": 3,
            "optional string enumstr": 4
        },
        "onAdd": {
            "required string nickname": 1,
            "required uInt32 nickname11": 2,
            "required uInt32 nowplayers": 3,
            "required float nowplayers2": 4,
            "required double nowplayers3": 5
        },
        "onRank": {
            "repeated uInt32 normalArr": 1,
            "required uInt32 enum": 2,
            "repeated string normalStrArr": 3,
            "message GGG": {
                "required uInt32 ccgg": 1
            },
            "optional GGG innerGGG": 4,
            "message MyRank": {
                "required uInt32 nickname": 1,
                "message GGG": {
                    "required uInt32 ccgg": 1
                },
                "required GGG ggg": 2,
                "required GGG xxx": 3
            },
            "repeated MyRank ranks": 5,
            "optional MyRank rk": 6,
            "optional uInt32 val": 7,
            "required string ffname": 8,
            "message IGG": {
                "repeated string ggenv": 1
            },
            "repeated IGG aa": 9,
            "repeated string ggenv": 10
        },
        "rank.playerHandler.beginGame": {
            "optional uInt32 code": 1,
            "optional string msg": 2,
            "required uInt32 currank": 3
        }
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].