Skip to content

Commit

Permalink
🔀 🐛 Fix any typeOf (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
devkanro authored Dec 28, 2022
1 parent e954eee commit f3dab20
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 39 deletions.
14 changes: 7 additions & 7 deletions examples/example-simple/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/example-simple",
"version": "2.0.4",
"version": "2.0.5",
"description": "Example project using sisyphus.js",
"main": "dist/index.js",
"scripts": {
Expand All @@ -26,14 +26,14 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"devDependencies": {
"@sisyphus.js/cli": "^2.0.4",
"@sisyphus.js/google.proto": "^2.0.4",
"@sisyphus.js/runtime.proto": "^2.0.4"
"@sisyphus.js/cli": "^2.0.5",
"@sisyphus.js/google.proto": "^2.0.5",
"@sisyphus.js/runtime.proto": "^2.0.5"
},
"dependencies": {
"@sisyphus.js/google": "^2.0.4",
"@sisyphus.js/runtime": "^2.0.4",
"@sisyphus.js/transport-aip": "^2.0.4"
"@sisyphus.js/google": "^2.0.5",
"@sisyphus.js/runtime": "^2.0.5",
"@sisyphus.js/transport-aip": "^2.0.5"
},
"directories": {
"proto": "proto"
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"packages/*",
"examples/*"
],
"version": "2.0.4"
"version": "2.0.5"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build": "lerna bootstrap --hoist && lerna run clean && lerna run build",
"publish": "lerna publish from-package --yes --no-verify-access",
"watch": "lerna run --stream --no-sort --concurrency 9999 watch",
"test": "lerna run test"
"test": "lerna run test",
"version": "lerna version --no-git-tag-version"
}
}
10 changes: 5 additions & 5 deletions packages/sisyphus-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/cli",
"version": "2.0.4",
"version": "2.0.5",
"description": "Protoc cli for sisyphus project on js platform",
"bin": {
"sisygen": "lib/index.js"
Expand Down Expand Up @@ -30,10 +30,10 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"dependencies": {
"@sisyphus.js/compiler": "^2.0.4",
"@sisyphus.js/protoc": "^2.0.4",
"@sisyphus.js/runtime": "^2.0.4",
"@sisyphus.js/runtime.proto": "^2.0.4",
"@sisyphus.js/compiler": "^2.0.5",
"@sisyphus.js/protoc": "^2.0.5",
"@sisyphus.js/runtime": "^2.0.5",
"@sisyphus.js/runtime.proto": "^2.0.5",
"commander": "^9.3.0",
"npmlog": "^7.0.1"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/sisyphus-compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/compiler",
"version": "2.0.4",
"version": "2.0.5",
"description": "Precompiled google common protos by sisyphus protobuf compiler",
"main": "lib/index.js",
"sisyphus": {
Expand Down Expand Up @@ -35,6 +35,6 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"dependencies": {
"@sisyphus.js/protoc": "^2.0.4"
"@sisyphus.js/protoc": "^2.0.5"
}
}
10 changes: 5 additions & 5 deletions packages/sisyphus-google-aip/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/google.aip",
"version": "2.0.4",
"version": "2.0.5",
"description": "Precompiled google common aip clients by sisyphus protobuf compiler",
"scripts": {
"clean": "tsc --build --clean",
Expand Down Expand Up @@ -33,12 +33,12 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"devDependencies": {
"@sisyphus.js/cli": "^2.0.4",
"@sisyphus.js/google.proto": "^2.0.4"
"@sisyphus.js/cli": "^2.0.5",
"@sisyphus.js/google.proto": "^2.0.5"
},
"dependencies": {
"@sisyphus.js/google": "^2.0.4",
"@sisyphus.js/transport-aip": "^2.0.4"
"@sisyphus.js/google": "^2.0.5",
"@sisyphus.js/transport-aip": "^2.0.5"
},
"directories": {
"lib": "lib"
Expand Down
10 changes: 5 additions & 5 deletions packages/sisyphus-google-proto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/google.proto",
"version": "2.0.4",
"version": "2.0.5",
"description": "Precompiled google common protos with full protobuf by sisyphus protobuf compiler",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -34,12 +34,12 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"devDependencies": {
"@sisyphus.js/cli": "^2.0.4"
"@sisyphus.js/cli": "^2.0.5"
},
"dependencies": {
"@sisyphus.js/google": "^2.0.4",
"@sisyphus.js/runtime": "^2.0.4",
"@sisyphus.js/runtime.proto": "^2.0.4"
"@sisyphus.js/google": "^2.0.5",
"@sisyphus.js/runtime": "^2.0.5",
"@sisyphus.js/runtime.proto": "^2.0.5"
},
"directories": {
"lib": "lib"
Expand Down
6 changes: 3 additions & 3 deletions packages/sisyphus-google/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/google",
"version": "2.0.4",
"version": "2.0.5",
"description": "Precompiled google common protos by sisyphus protobuf compiler",
"scripts": {
"clean": "tsc --build --clean",
Expand Down Expand Up @@ -34,10 +34,10 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"devDependencies": {
"@sisyphus.js/cli": "^2.0.4"
"@sisyphus.js/cli": "^2.0.5"
},
"dependencies": {
"@sisyphus.js/runtime": "^2.0.4"
"@sisyphus.js/runtime": "^2.0.5"
},
"directories": {
"lib": "lib",
Expand Down
2 changes: 1 addition & 1 deletion packages/sisyphus-protoc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/protoc",
"version": "2.0.4",
"version": "2.0.5",
"description": "Install protoc for current platform.",
"main": "lib/index.js",
"bin": {
Expand Down
4 changes: 2 additions & 2 deletions packages/sisyphus-protoc/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function downloadRedirected(uri: string, redirects: string[] = []): Promise<Inco
if (redirects.indexOf(uri) >= 0) throw new Error(`Redirect looped.\n${redirects.join('\n')}\n${uri}`)

return new Promise((res, rej) => {
requireHttp(url).get(url, (response: IncomingMessage) => {
requireHttp(url).get(uri, (response: IncomingMessage) => {
if (!response.statusCode) return rej(new Error(`Download ${uri} failed.`))

if (response.statusCode >= 400) return rej(new Error(`Download ${uri} failed(${response.statusCode}).`))
Expand Down Expand Up @@ -81,7 +81,7 @@ export function getRedirectLocation(uri: string): Promise<string> {
const url = new URL(uri)

return new Promise((res, rej) => {
requireHttp(url).get(url, (response: IncomingMessage) => {
requireHttp(url).get(uri, (response: IncomingMessage) => {
if (!response.statusCode) return rej(new Error(`GET ${uri} failed.`))

if (response.statusCode >= 400) return rej(new Error(`GET ${uri} failed(${response.statusCode}).`))
Expand Down
4 changes: 2 additions & 2 deletions packages/sisyphus-runtime-proto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/runtime.proto",
"version": "2.0.4",
"version": "2.0.5",
"description": "Protobuf full runtime for sisyphus project on js platform, support protobuf binary format.",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -34,7 +34,7 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"dependencies": {
"@sisyphus.js/runtime": "^2.0.4"
"@sisyphus.js/runtime": "^2.0.5"
},
"directories": {
"lib": "lib"
Expand Down
2 changes: 1 addition & 1 deletion packages/sisyphus-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/runtime",
"version": "2.0.4",
"version": "2.0.5",
"description": "Protobuf lite runtime for sisyphus project on js platform, only support JSON format.",
"main": "lib/index.js",
"scripts": {
Expand Down
7 changes: 6 additions & 1 deletion packages/sisyphus-runtime/src/any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ declare module './google/protobuf/any' {
function isAny(object: any): boolean

function typeOf(object: any): string

function typeUrl(type: string): string
}
}

Expand All @@ -20,6 +22,9 @@ Any.isAny = function (object: any): boolean {
Any.typeOf = function typeOf(object: any): string {
if (!Any.isAny(object)) throw new Error(`Object must contains '@type' type info.`)
const type: string = object['@type']
return type.substring(type.lastIndexOf('/') + 1)
}

return type.substring(type.lastIndexOf('/'))
Any.typeUrl = function typeUrl(type: string): string {
return `type.butterapis.com/${type}`
}
6 changes: 3 additions & 3 deletions packages/sisyphus-transport-aip/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/transport-aip",
"version": "2.0.4",
"version": "2.0.5",
"description": "gRPC transport based on AIP spec(gRPC to HTTP/Json Transcoding).",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -32,8 +32,8 @@
},
"homepage": "https://github.com/ButterCam/sisyphus-js#readme",
"dependencies": {
"@sisyphus.js/google": "^2.0.4",
"@sisyphus.js/runtime": "^2.0.4"
"@sisyphus.js/google": "^2.0.5",
"@sisyphus.js/runtime": "^2.0.5"
},
"directories": {
"lib": "lib",
Expand Down
1 change: 1 addition & 0 deletions packages/sisyphus-transport-aip/src/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class StatusError extends Error {
}

export function transcoding(host: string, config?: TranscodingListener): Rpc {
host = host.replace(/\/+$/, '')
return async function (method: MethodDescriptor, input: any): Promise<any> {
let rawInput = input
input = {...input}
Expand Down

0 comments on commit f3dab20

Please sign in to comment.