Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark deprecated methods and print comments #22

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 31 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 12 additions & 3 deletions _examples/node-ts/server/server.gen.ts
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -37,7 +37,16 @@ export interface Page {
}

export interface ExampleService {
/**
* Ping to test healthiness of service
*/
ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>
/**
* Get user endpoint
*
* gives you basic info about user
* @deprecated
*/
getUser(args: GetUserArgs, headers?: object, signal?: AbortSignal): Promise<GetUserReturn>
}

Expand Down
5 changes: 5 additions & 0 deletions _examples/node-ts/service.ridl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
15 changes: 12 additions & 3 deletions _examples/node-ts/webapp/client.gen.ts
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -37,7 +37,16 @@ export interface Page {
}

export interface ExampleService {
/**
* Ping to test healthiness of service
*/
ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>
/**
* Get user endpoint
*
* gives you basic info about user
* @deprecated
*/
getUser(args: GetUserArgs, headers?: object, signal?: AbortSignal): Promise<GetUserReturn>
}

Expand Down
6 changes: 3 additions & 3 deletions _examples/sse/webapp/client.gen.ts
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
14 changes: 14 additions & 0 deletions types.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{{- $typeMap := .TypeMap -}}
{{- $types := .Types -}}
{{- $services := .Services -}}
{{- $webrpcVersion := .WebrpcVersion -}}

//
// Types
Expand Down Expand Up @@ -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}}
}
Expand Down
Loading