diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95b0df9..d947a66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,46 +14,41 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install webrpc-gen - run: | - curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.19.3/webrpc-gen.linux-amd64 - chmod +x ./webrpc-gen - echo $PWD >> $GITHUB_PATH + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: "1.20" - # - name: Set up Go - # uses: actions/setup-go@v3 - # with: - # go-version: "1.20" - # - name: Install webrpc-gen (development) - # run: git clone --single-branch https://github.com/webrpc/webrpc.git --branch master && cd webrpc && make install + - name: Install webrpc-gen (development) + run: git clone --single-branch https://github.com/webrpc/webrpc.git --branch master && cd webrpc && make install - name: Regenerate examples run: cd _examples && make generate - name: Git diff of regenerated files run: cd _examples && make diff - webrpc-tests: - strategy: - matrix: - webrpc-version: [v0.14.0] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Set up webrpc binary cache folder - uses: actions/cache@v3 - with: - key: webrpc-binaries - path: tests/bin - - name: Install dependencies - run: cd tests && npm install - - name: Download webrpc binaries - run: cd tests && ./download.sh ${{ matrix.webrpc-version }} bin/${{ matrix.webrpc-version }} - - name: Export path of webrpc binaries - run: cd tests && echo "$PWD/bin/${{ matrix.webrpc-version }}" >> $GITHUB_PATH - - name: Run interoperability tests - run: cd tests && ./test.sh - - name: Run typescript check - run: cd tests && npm run ts-check +# webrpc-tests: +# strategy: +# matrix: +# webrpc-version: [v0.18.0] +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# - uses: actions/setup-node@v3 +# with: +# node-version: 18 +# - name: Set up webrpc binary cache folder +# uses: actions/cache@v3 +# with: +# key: webrpc-binaries +# path: tests/bin +# - name: Install dependencies +# run: cd tests && npm install +# - name: Download webrpc binaries +# run: cd tests && ./download.sh ${{ matrix.webrpc-version }} bin/${{ matrix.webrpc-version }} +# - name: Export path of webrpc binaries +# run: cd tests && echo "$PWD/bin/${{ matrix.webrpc-version }}" >> $GITHUB_PATH +# - name: Run interoperability tests +# run: cd tests && ./test.sh +# - name: Run typescript check +# run: cd tests && npm run ts-check diff --git a/_examples/node-ts/server/server.gen.ts b/_examples/node-ts/server/server.gen.ts index 658dbaf..afd14f1 100644 --- a/_examples/node-ts/server/server.gen.ts +++ b/_examples/node-ts/server/server.gen.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -// node-ts v1.0.0 bd572b349e330d81cc30b1ff3cf69d7ab59f1619 +// node-ts v1.0.0 70298cc691691b20d86e64e0d9a4875d7b3c1c9e // -- -// Code generated by webrpc-gen@v0.19.3 with ../../ generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.20.3-2-g18c094a with ../../ generator. DO NOT EDIT. // // webrpc-gen -schema=service.ridl -target=../../ -server -out=./server/server.gen.ts @@ -12,7 +12,7 @@ export const WebRPCVersion = "v1" export const WebRPCSchemaVersion = "v1.0.0" // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = "bd572b349e330d81cc30b1ff3cf69d7ab59f1619" +export const WebRPCSchemaHash = "70298cc691691b20d86e64e0d9a4875d7b3c1c9e" // // Types @@ -37,7 +37,16 @@ export interface Page { } export interface ExampleService { + /** + * Ping to test healthiness of service + */ ping(headers?: object, signal?: AbortSignal): Promise + /** + * Get user endpoint + * + * gives you basic info about user + * @deprecated + */ getUser(args: GetUserArgs, headers?: object, signal?: AbortSignal): Promise } diff --git a/_examples/node-ts/service.ridl b/_examples/node-ts/service.ridl index a121481..c1335ce 100644 --- a/_examples/node-ts/service.ridl +++ b/_examples/node-ts/service.ridl @@ -31,5 +31,10 @@ struct Page service ExampleService + # Ping to test healthiness of service - Ping() => () + # Get user endpoint + # + # gives you basic info about user + @deprecated - GetUser(userID: uint64) => (code: uint32, user: User) diff --git a/_examples/node-ts/webapp/client.gen.ts b/_examples/node-ts/webapp/client.gen.ts index 520005e..af29ec7 100644 --- a/_examples/node-ts/webapp/client.gen.ts +++ b/_examples/node-ts/webapp/client.gen.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -// node-ts v1.0.0 bd572b349e330d81cc30b1ff3cf69d7ab59f1619 +// node-ts v1.0.0 70298cc691691b20d86e64e0d9a4875d7b3c1c9e // -- -// Code generated by webrpc-gen@v0.19.3 with ../../ generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.20.3-2-g18c094a with ../../ generator. DO NOT EDIT. // // webrpc-gen -schema=service.ridl -target=../../ -client -out=./webapp/client.gen.ts @@ -12,7 +12,7 @@ export const WebRPCVersion = "v1" export const WebRPCSchemaVersion = "v1.0.0" // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = "bd572b349e330d81cc30b1ff3cf69d7ab59f1619" +export const WebRPCSchemaHash = "70298cc691691b20d86e64e0d9a4875d7b3c1c9e" // // Types @@ -37,7 +37,16 @@ export interface Page { } export interface ExampleService { + /** + * Ping to test healthiness of service + */ ping(headers?: object, signal?: AbortSignal): Promise + /** + * Get user endpoint + * + * gives you basic info about user + * @deprecated + */ getUser(args: GetUserArgs, headers?: object, signal?: AbortSignal): Promise } diff --git a/_examples/sse/webapp/client.gen.ts b/_examples/sse/webapp/client.gen.ts index 6f55779..176c6ee 100644 --- a/_examples/sse/webapp/client.gen.ts +++ b/_examples/sse/webapp/client.gen.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -// webrpc-sse-chat v1.0.0 e64bf9372e2faa45da9d449e8ea108dc0597a98d +// webrpc-sse-chat v1.0.0 a799dc63b082644f5d003c8881424546aee23a2c // -- -// Code generated by webrpc-gen@v0.19.3 with ../../ generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.20.3-2-g18c094a with ../../ generator. DO NOT EDIT. // // webrpc-gen -schema=service.ridl -target=../../ -client -out=./webapp/client.gen.ts @@ -12,7 +12,7 @@ export const WebRPCVersion = "v1" export const WebRPCSchemaVersion = "v1.0.0" // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = "e64bf9372e2faa45da9d449e8ea108dc0597a98d" +export const WebRPCSchemaHash = "a799dc63b082644f5d003c8881424546aee23a2c" // // Types diff --git a/main.go.tmpl b/main.go.tmpl index afff64c..1b111fa 100644 --- a/main.go.tmpl +++ b/main.go.tmpl @@ -76,7 +76,7 @@ export const WebRPCSchemaVersion = "{{.SchemaVersion}}" // Schema hash generated from your RIDL schema export const WebRPCSchemaHash = "{{.SchemaHash}}" -{{template "types" dict "Types" .Types "Services" .Services "TypeMap" $typeMap}} +{{template "types" dict "Types" .Types "Services" .Services "TypeMap" $typeMap "WebrpcVersion" .WebrpcVersion}} {{- if $opts.client}} {{template "client" dict "Services" .Services "Opts" $opts "TypeMap" $typeMap}} diff --git a/types.go.tmpl b/types.go.tmpl index 1493a87..05a4fbe 100644 --- a/types.go.tmpl +++ b/types.go.tmpl @@ -3,6 +3,7 @@ {{- $typeMap := .TypeMap -}} {{- $types := .Types -}} {{- $services := .Services -}} +{{- $webrpcVersion := .WebrpcVersion -}} // // Types @@ -44,6 +45,19 @@ export interface {{$type.Name}} { {{- range $_, $service := $services}} export interface {{$service.Name}} { {{- range $_, $method := $service.Methods}} +{{- if not (minVersion $webrpcVersion "v0.20.0") }} +{{- $deprecated := index $method.Annotations "deprecated" -}} + {{- if or (gt (len $method.Comments) 0) ($deprecated) }} + /** + {{- range $_, $comment := $method.Comments }} + * {{ replaceAll $comment "\"" "'" }} + {{- end }} + {{- if $deprecated }} + * @deprecated + {{- end }} + */ +{{- end }} +{{- end }} {{firstLetterToLower $method.Name}}({{template "methodInputs" dict "Method" $method "TypeMap" $typeMap}}): Promise<{{if $method.StreamOutput}}void{{else}}{{$method.Name}}Return{{end}}> {{- end}} }