Skip to content

Commit

Permalink
Use latest WebRPC (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
klaidliadon authored Nov 29, 2024
1 parent 22f2acb commit 724a470
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 41 deletions.
6 changes: 3 additions & 3 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/webrpc/gen-golang v0.16.0/go.mod h1:qy1qEWMlTvrRzjSuQLy+176RqNaX1ymUULDtlo7Dapo=
github.com/webrpc/gen-typescript v0.15.0/go.mod h1:xQzYnVaSMfcygDXA5SuW8eYyCLHBHkj15wCF7gcJF5Y=
github.com/webrpc/webrpc v0.21.0/go.mod h1:1WwQ1WRobFUjJiG34r8QMCXRLb1hr27+rdWmfWjSF2Y=
github.com/webrpc/gen-golang v0.17.0/go.mod h1:qy1qEWMlTvrRzjSuQLy+176RqNaX1ymUULDtlo7Dapo=
github.com/webrpc/gen-typescript v0.16.1/go.mod h1:xQzYnVaSMfcygDXA5SuW8eYyCLHBHkj15wCF7gcJF5Y=
github.com/webrpc/webrpc v0.22.0/go.mod h1:eeABnLz9BC4F9GGw6UKebVPkzkFYLrZRlcOvh6o8n10=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
Expand Down
25 changes: 16 additions & 9 deletions proto/authcontrol.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 31 additions & 8 deletions proto/authcontrol.gen.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/* eslint-disable */
// authcontrol v0.9.0 896c9dd61e9b52933577b35ac021a229cdc54fe2
// authcontrol v0.9.1 809804f85757ee407e93c191d6d5bfb75b82cb56
// --
// Code generated by webrpc-gen@v0.21.0 with typescript@v0.15.0 generator. DO NOT EDIT.
// Code generated by webrpc-gen@v0.22.0 with typescript@v0.16.1 generator. DO NOT EDIT.
//
// webrpc-gen -schema=authcontrol.ridl -target=typescript@v0.15.0 -client -out=./authcontrol.gen.ts
// webrpc-gen -schema=authcontrol.ridl -target=typescript@v0.16.1 -client -out=./authcontrol.gen.ts

export const WebrpcHeader = "Webrpc"

export const WebrpcHeaderValue = "webrpc@v0.21.0;gen-typescript@v0.15.0;[email protected].0"
export const WebrpcHeaderValue = "webrpc@v0.22.0;gen-typescript@v0.16.1;[email protected].1"

// WebRPC description and code-gen version
export const WebRPCVersion = "v1"

// Schema version of your RIDL schema
export const WebRPCSchemaVersion = "v0.9.0"
export const WebRPCSchemaVersion = "v0.9.1"

// Schema hash generated from your RIDL schema
export const WebRPCSchemaHash = "896c9dd61e9b52933577b35ac021a229cdc54fe2"
export const WebRPCSchemaHash = "809804f85757ee407e93c191d6d5bfb75b82cb56"

type WebrpcGenVersions = {
webrpcGenVersion: string;
Expand Down Expand Up @@ -84,7 +84,7 @@ export enum SessionType {


const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => {
const reqHeaders = { ...headers, 'Content-Type': 'application/json' }
const reqHeaders: {[key: string]: string} = { ...headers, 'Content-Type': 'application/json' }
reqHeaders[WebrpcHeader] = WebrpcHeaderValue

return {
Expand Down Expand Up @@ -437,7 +437,30 @@ export enum errors {
ProjectNotFound = 'ProjectNotFound',
}

const webrpcErrorByCode: { [code: number]: any } = {
export enum WebrpcErrorCodes {
WebrpcEndpoint = 0,
WebrpcRequestFailed = -1,
WebrpcBadRoute = -2,
WebrpcBadMethod = -3,
WebrpcBadRequest = -4,
WebrpcBadResponse = -5,
WebrpcServerPanic = -6,
WebrpcInternalError = -7,
WebrpcClientDisconnected = -8,
WebrpcStreamLost = -9,
WebrpcStreamFinished = -10,
Unauthorized = 1000,
PermissionDenied = 1001,
SessionExpired = 1002,
MethodNotFound = 1003,
RequestConflict = 1004,
Aborted = 1005,
Geoblocked = 1006,
RateLimited = 1007,
ProjectNotFound = 1008,
}

export const webrpcErrorByCode: { [code: number]: any } = {
[0]: WebrpcEndpointError,
[-1]: WebrpcRequestFailedError,
[-2]: WebrpcBadRouteError,
Expand Down
12 changes: 2 additions & 10 deletions proto/authcontrol.ridl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
webrpc = v1

name = authcontrol
version = v0.9.0
version = v0.9.1

enum SessionType: uint16
- Public # Public access (anonymous)
Expand All @@ -12,12 +12,4 @@ enum SessionType: uint16
- Admin # Admin-level access (jwt)
- InternalService # Internal service-to-service access (jwt)

error 1000 Unauthorized "Unauthorized access" HTTP 401
error 1001 PermissionDenied "Permission denied" HTTP 403
error 1002 SessionExpired "Session expired" HTTP 403
error 1003 MethodNotFound "Method not found" HTTP 404
error 1004 RequestConflict "Conflict with target resource" HTTP 409
error 1005 Aborted "Request aborted" HTTP 400
error 1006 Geoblocked "Geoblocked region" HTTP 451
error 1007 RateLimited "Rate-limited. Please slow down." HTTP 429
error 1008 ProjectNotFound "Project not found" HTTP 401
import "./errors.ridl"
14 changes: 14 additions & 0 deletions proto/errors.ridl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
webrpc = v1

name = authcontrol
version = v0.9.1

error 1000 Unauthorized "Unauthorized access" HTTP 401
error 1001 PermissionDenied "Permission denied" HTTP 403
error 1002 SessionExpired "Session expired" HTTP 403
error 1003 MethodNotFound "Method not found" HTTP 404
error 1004 RequestConflict "Conflict with target resource" HTTP 409
error 1005 Aborted "Request aborted" HTTP 400
error 1006 Geoblocked "Geoblocked region" HTTP 451
error 1007 RateLimited "Rate-limited. Please slow down." HTTP 429
error 1008 ProjectNotFound "Project not found" HTTP 401
4 changes: 2 additions & 2 deletions proto/proto.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=authcontrol.ridl -target=golang@v0.16.0 -pkg=proto -client -out=./authcontrol.gen.go
//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=authcontrol.ridl -target=typescript@v0.15.0 -client -out=./authcontrol.gen.ts
//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=authcontrol.ridl -target=golang@v0.17.0 -pkg=proto -client -out=./authcontrol.gen.go
//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=authcontrol.ridl -target=typescript@v0.16.1 -client -out=./authcontrol.gen.ts
package proto

const SessionType_Max SessionType = SessionType_InternalService + 1
Expand Down
6 changes: 3 additions & 3 deletions tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

require (
github.com/goware/rerun v0.0.9
github.com/webrpc/webrpc v0.21.0
github.com/webrpc/webrpc v0.22.0
)

require (
Expand Down Expand Up @@ -45,11 +45,11 @@ require (
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/webrpc/gen-dart v0.1.1 // indirect
github.com/webrpc/gen-golang v0.16.0 // indirect
github.com/webrpc/gen-golang v0.17.0 // indirect
github.com/webrpc/gen-javascript v0.13.0 // indirect
github.com/webrpc/gen-kotlin v0.1.0 // indirect
github.com/webrpc/gen-openapi v0.15.0 // indirect
github.com/webrpc/gen-typescript v0.15.0 // indirect
github.com/webrpc/gen-typescript v0.16.1 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/mod v0.20.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,18 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/webrpc/gen-dart v0.1.1 h1:PZh5oNNdA84Qxu8ixKDf1cT8Iv6t0g7x6q9aeX1bti4=
github.com/webrpc/gen-dart v0.1.1/go.mod h1:yq0ThW3ANNulJLyR50jx1aZMEVBDp19VUHucK65ayPs=
github.com/webrpc/gen-golang v0.16.0 h1:A41DrslXhvhSHUrpLx3Rdx3Jl3fxrk66L0z5M9MiT0A=
github.com/webrpc/gen-golang v0.16.0/go.mod h1:qy1qEWMlTvrRzjSuQLy+176RqNaX1ymUULDtlo7Dapo=
github.com/webrpc/gen-golang v0.17.0 h1:qCvkhrIdEalQNYJEyqUhKiZ/wK5yEOhx0TJ5X0fzoKM=
github.com/webrpc/gen-golang v0.17.0/go.mod h1:qy1qEWMlTvrRzjSuQLy+176RqNaX1ymUULDtlo7Dapo=
github.com/webrpc/gen-javascript v0.13.0 h1:tw7U1xueUjZz3cQAAA4/DZ90BHydkQKiJC4VXd/j2hg=
github.com/webrpc/gen-javascript v0.13.0/go.mod h1:5EhapSJgzbiWrIGlqzZN9Lg9mE9209wwX+Du2dgn4EU=
github.com/webrpc/gen-kotlin v0.1.0 h1:tnlinqbDgowEoSy8E3VovTdP2OjyOIbgACCbahRjNcc=
github.com/webrpc/gen-kotlin v0.1.0/go.mod h1:PIPys9Gn1Ro7q7uoacydEX8CtqBlAJSV98A++tdj4ak=
github.com/webrpc/gen-openapi v0.15.0 h1:RrHAcDTlm0YH+YCz12p0KLCYIwfHrxf4x6/LjJ6kePY=
github.com/webrpc/gen-openapi v0.15.0/go.mod h1:fwY3ylZmdiCr+WXjR8Ek8wm08CFRr2/GaXI7Zd/Ou4Y=
github.com/webrpc/gen-typescript v0.15.0 h1:cRnbarQiSoxA0taJ4V0v7TmHKE6UBhO6klvIrGu/CaM=
github.com/webrpc/gen-typescript v0.15.0/go.mod h1:xQzYnVaSMfcygDXA5SuW8eYyCLHBHkj15wCF7gcJF5Y=
github.com/webrpc/webrpc v0.21.0 h1:gjZFP6FUL++2Lp4+Ts23kVvW9zk/sxvajZ+kXwB/ZuU=
github.com/webrpc/webrpc v0.21.0/go.mod h1:1WwQ1WRobFUjJiG34r8QMCXRLb1hr27+rdWmfWjSF2Y=
github.com/webrpc/gen-typescript v0.16.1 h1:4t9YNGROOV2ZL0UyB5wjWMpJklXDDNEj8eg05+8BF5Y=
github.com/webrpc/gen-typescript v0.16.1/go.mod h1:xQzYnVaSMfcygDXA5SuW8eYyCLHBHkj15wCF7gcJF5Y=
github.com/webrpc/webrpc v0.22.0 h1:DkpXYA9p7em+Oqn76+VZrQJkrlbMEO8vBPpcjQ+lGvo=
github.com/webrpc/webrpc v0.22.0/go.mod h1:eeABnLz9BC4F9GGw6UKebVPkzkFYLrZRlcOvh6o8n10=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down

0 comments on commit 724a470

Please sign in to comment.