Skip to content

Commit

Permalink
🐛 Fix long can't convert to json correctly (#9)
Browse files Browse the repository at this point in the history
* 💚 Skip publish to github packages

* 🐛 Fix long can't convert to json correctly

* 🔖 v0.0.1-alpha.10
  • Loading branch information
devkanro authored Sep 4, 2020
1 parent 1a38638 commit 2bf7d77
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 17 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ jobs:
- run: npm run publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
- run: npm run publish-gpr
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
2 changes: 2 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Sisyphus for JavaScript/TypeScript

[![](https://img.shields.io/npm/v/@sisyphus.js/core)](https://www.npmjs.com/package/@sisyphus.js/core) ![](https://img.shields.io/librariesio/release/npm/@sisyphus.js/core)

Sisyphus.JS is the way how we connect with our Sisyphus backend services. It uses [HTTP and gRPC Transcoding](https://aip.bybutter.com/127) to call gRPC APIs.

## 🚀 Quick Start
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"packages": [
"packages/*"
],
"version": "0.0.1-alpha.9"
"version": "0.0.1-alpha.10"
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
},
"scripts": {
"prepare": "lerna bootstrap --hoist && lerna run build",
"publish": "lerna publish from-package --yes",
"publish-gpr": "lerna publish from-package --yes --registry https://npm.pkg.github.com/"
"publish": "lerna publish from-package --yes"
}
}
2 changes: 1 addition & 1 deletion packages/sisyphus-cli/package-lock.json

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

4 changes: 2 additions & 2 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": "0.0.1-alpha.9",
"version": "0.0.1-alpha.10",
"description": "Protobuf generator cli for sisyphus project",
"author": "Kanro <higan@live.cn>",
"bugs": {
Expand All @@ -24,7 +24,7 @@
"build": "tsc"
},
"dependencies": {
"@sisyphus.js/generator": "^0.0.1-alpha.9",
"@sisyphus.js/generator": "^0.0.1-alpha.10",
"commander": "^6.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/sisyphus-core/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/sisyphus-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/core",
"version": "0.0.1-alpha.9",
"version": "0.0.1-alpha.10",
"description": "Protobuf runtime for sisyphus project on js platform",
"author": "Kanro <higan@live.cn>",
"bugs": {
Expand Down
3 changes: 3 additions & 0 deletions packages/sisyphus-core/src/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ export function toJson(field: MapField | Field | Type | Enum | string, value: an
case "sint64":
case "fixed64":
case "sfixed64":
if (long.isLong(value)) {
return value.toNumber()
}
return value
}
}
11 changes: 7 additions & 4 deletions packages/sisyphus-core/src/transcoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,21 @@ function getField(message: any, field: string | string[]): any {
return message
}

function getFieldInfo(type: Type, field: string | string[]): Type {
function getFieldInfo(type: Type, field: string | string[]): Type | null {
if (typeof field === "string") {
return getFieldInfo(type, field.split("."))
}

for (let string of field) {
type = <any>type.fields[string].resolvedType
if (!type) return null
}

return type
}

export function fillUrl(url: string, message: any): string {
return url.replace(/{([a-zA-Z0-9_]+)(?:=[^}]+)?}/g, (substring, g1) => `${getField(message, g1)}`)
return url.replace(/{([a-zA-Z0-9_.]+)(?:=[^}]+)?}/g, (substring, g1) => `${getField(message, g1)}`)
}

export function transcoding(http: IHttpImpl, config?: ITranscodingConfig): IRpcImpl {
Expand Down Expand Up @@ -135,8 +137,9 @@ export function transcoding(http: IHttpImpl, config?: ITranscodingConfig): IRpcI
break
default:
data = getField(message, rule.body)
if (data && data instanceof Message) {
messageCtor = getFieldInfo(desc.resolvedRequestType.messageCtor.$type, rule.body).messageCtor
let type = getFieldInfo(desc.resolvedRequestType.messageCtor.$type, rule.body)
if (data && type) {
messageCtor = type.messageCtor
}
break
}
Expand Down
4 changes: 2 additions & 2 deletions packages/sisyphus-generator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sisyphus.js/generator",
"version": "0.0.1-alpha.9",
"version": "0.0.1-alpha.10",
"description": "Protobuf generator for sisyphus project on js platform",
"author": "Kanro <higan@live.cn>",
"bugs": {
Expand All @@ -21,7 +21,7 @@
"build": "tsc"
},
"dependencies": {
"@sisyphus.js/core": "^0.0.1-alpha.9",
"@sisyphus.js/core": "^0.0.1-alpha.10",
"change-case": "^4.1.1",
"protobufjs": "^6.10.1"
},
Expand Down

0 comments on commit 2bf7d77

Please sign in to comment.