[add] first

This commit is contained in:
2022-04-29 15:25:10 +08:00
commit da8024fc30
87 changed files with 16892 additions and 0 deletions

6
test/proto/MsgChat.ts Normal file
View File

@@ -0,0 +1,6 @@
export interface MsgChat {
channel: number,
userName: string,
content: string,
time: number
}

14
test/proto/PtlObjId.ts Normal file
View File

@@ -0,0 +1,14 @@
// @ts-ignore
import { ObjectId } from "mongodb";
export interface ReqObjId {
id1: ObjectId;
buf?: Uint8Array,
date?: Date
}
export interface ResObjId {
id2: ObjectId;
buf?: Uint8Array,
date?: Date
}

7
test/proto/PtlTest.ts Normal file
View File

@@ -0,0 +1,7 @@
export interface ReqTest {
name: string
};
export type ResTest = {
reply: string
};

View File

@@ -0,0 +1,10 @@
import { MsgChat } from '../../../MsgChat';
export interface ReqTest {
name: string
};
export type ResTest = {
reply: string,
chat?: MsgChat
};

203
test/proto/serviceProto.ts Normal file
View File

@@ -0,0 +1,203 @@
import { ServiceProto } from 'tsrpc-proto';
import { ReqTest, ResTest } from './a/b/c/PtlTest';
import { MsgChat } from './MsgChat';
import { ReqObjId, ResObjId } from './PtlObjId';
import { ReqTest as ReqTest_1, ResTest as ResTest_1 } from './PtlTest';
export interface ServiceType {
api: {
"a/b/c/Test": {
req: ReqTest,
res: ResTest
},
"ObjId": {
req: ReqObjId,
res: ResObjId
},
"Test": {
req: ReqTest_1,
res: ResTest_1
}
},
msg: {
"Chat": MsgChat
}
}
export const serviceProto: ServiceProto<ServiceType> = {
"version": 1,
"services": [
{
"id": 0,
"name": "a/b/c/Test",
"type": "api"
},
{
"id": 1,
"name": "Chat",
"type": "msg"
},
{
"id": 2,
"name": "ObjId",
"type": "api"
},
{
"id": 3,
"name": "Test",
"type": "api"
}
],
"types": {
"a/b/c/PtlTest/ReqTest": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "name",
"type": {
"type": "String"
}
}
]
},
"a/b/c/PtlTest/ResTest": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "reply",
"type": {
"type": "String"
}
},
{
"id": 1,
"name": "chat",
"type": {
"type": "Reference",
"target": "MsgChat/MsgChat"
},
"optional": true
}
]
},
"MsgChat/MsgChat": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "channel",
"type": {
"type": "Number"
}
},
{
"id": 1,
"name": "userName",
"type": {
"type": "String"
}
},
{
"id": 2,
"name": "content",
"type": {
"type": "String"
}
},
{
"id": 3,
"name": "time",
"type": {
"type": "Number"
}
}
]
},
"PtlObjId/ReqObjId": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "id1",
"type": {
"type": "Reference",
"target": "?mongodb/ObjectId"
}
},
{
"id": 1,
"name": "buf",
"type": {
"type": "Buffer",
"arrayType": "Uint8Array"
},
"optional": true
},
{
"id": 2,
"name": "date",
"type": {
"type": "Date"
},
"optional": true
}
]
},
"PtlObjId/ResObjId": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "id2",
"type": {
"type": "Reference",
"target": "?mongodb/ObjectId"
}
},
{
"id": 1,
"name": "buf",
"type": {
"type": "Buffer",
"arrayType": "Uint8Array"
},
"optional": true
},
{
"id": 2,
"name": "date",
"type": {
"type": "Date"
},
"optional": true
}
]
},
"PtlTest/ReqTest": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "name",
"type": {
"type": "String"
}
}
]
},
"PtlTest/ResTest": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "reply",
"type": {
"type": "String"
}
}
]
}
}
};