mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
Merge branch 'main' of github.com:foomo/gotsrpc into typfix
This commit is contained in:
commit
16fa0b11ad
27
.github/workflows/test.yml
vendored
27
.github/workflows/test.yml
vendored
@ -4,9 +4,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main ]
|
|
||||||
merge_group:
|
merge_group:
|
||||||
branches: [ main ]
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
@ -17,6 +15,11 @@ env:
|
|||||||
GOFLAGS: -mod=readonly
|
GOFLAGS: -mod=readonly
|
||||||
GOPROXY: https://proxy.golang.org
|
GOPROXY: https://proxy.golang.org
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: read
|
||||||
|
checks: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -28,10 +31,24 @@ jobs:
|
|||||||
check-latest: true
|
check-latest: true
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
|
||||||
|
- name: Run yarn install
|
||||||
|
working-directory: example
|
||||||
|
run: yarn install
|
||||||
|
|
||||||
|
- name: Run go mod tidy
|
||||||
|
run: |
|
||||||
|
make tidy
|
||||||
|
git diff --exit-code
|
||||||
|
|
||||||
- uses: golangci/golangci-lint-action@v5
|
- uses: golangci/golangci-lint-action@v5
|
||||||
with:
|
|
||||||
working-directory: ${{ matrix.gomod }}
|
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: go test -v ./...
|
run: make test
|
||||||
|
|
||||||
|
- name: Make examples
|
||||||
|
run: |
|
||||||
|
make examples
|
||||||
|
git diff --exit-code
|
||||||
|
|
||||||
|
|||||||
28
.gitignore
vendored
28
.gitignore
vendored
@ -1,7 +1,27 @@
|
|||||||
!.git*
|
.*
|
||||||
/vendor/
|
|
||||||
dist/
|
|
||||||
.idea
|
|
||||||
bin/
|
bin/
|
||||||
|
dist/
|
||||||
tmp/
|
tmp/
|
||||||
|
|
||||||
|
## Git ##
|
||||||
|
!.gitignore
|
||||||
|
!.gitkeep
|
||||||
|
|
||||||
|
## GitHub ##
|
||||||
|
!.github/
|
||||||
|
|
||||||
|
## Node ##
|
||||||
**/node_modules/
|
**/node_modules/
|
||||||
|
|
||||||
|
## TypeScript ###
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
## Goreleaser ###
|
||||||
|
!.goreleaser.yaml
|
||||||
|
|
||||||
|
### Go ###
|
||||||
|
/go.mod
|
||||||
|
/go.sum
|
||||||
|
/go.work
|
||||||
|
/go.work.sum
|
||||||
|
!.golangci.yaml
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
/* eslint:disable */
|
/* eslint:disable */
|
||||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||||
import * as github_com_foomo_gotsrpc_v2_example_basic_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
|
import * as github_com_foomo_gotsrpc_v2_example_basic_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
|
||||||
|
|
||||||
// github.com/foomo/gotsrpc/v2/example/basic/service.Float32Type
|
// github.com/foomo/gotsrpc/v2/example/basic/service.Float32Type
|
||||||
export enum Float32Type {
|
export enum Float32Type {
|
||||||
Float32AType = 1,
|
Float32AType = 1,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
module:
|
module:
|
||||||
name: github.com/foomo/gotsrpc/v2/example/basic
|
name: github.com/foomo/gotsrpc/v2
|
||||||
path: ./
|
path: ../../
|
||||||
|
|
||||||
targets:
|
targets:
|
||||||
basic:
|
basic:
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
/* eslint:disable */
|
/* eslint:disable */
|
||||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||||
import * as github_com_foomo_gotsrpc_v2_example_errors_service_frontend from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
|
import * as github_com_foomo_gotsrpc_v2_example_errors_service_frontend from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
|
||||||
|
|
||||||
// github.com/foomo/gotsrpc/v2/example/errors/service/frontend.ErrMulti
|
// github.com/foomo/gotsrpc/v2/example/errors/service/frontend.ErrMulti
|
||||||
export type ErrMulti = (typeof github_com_foomo_gotsrpc_v2_example_errors_service_frontend.ErrMultiA) & (typeof github_com_foomo_gotsrpc_v2_example_errors_service_frontend.ErrMultiB)
|
export const ErrMulti = { ...github_com_foomo_gotsrpc_v2_example_errors_service_frontend.ErrMultiA, ...github_com_foomo_gotsrpc_v2_example_errors_service_frontend.ErrMultiB }
|
||||||
|
export type ErrMulti = typeof ErrMulti
|
||||||
// github.com/foomo/gotsrpc/v2/example/errors/service/frontend.ErrMultiA
|
// github.com/foomo/gotsrpc/v2/example/errors/service/frontend.ErrMultiA
|
||||||
export enum ErrMultiA {
|
export enum ErrMultiA {
|
||||||
One = "one",
|
One = "one",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
module:
|
module:
|
||||||
name: github.com/foomo/gotsrpc/v2/example/errors
|
name: github.com/foomo/gotsrpc/v2
|
||||||
path: ./
|
path: ../../
|
||||||
|
|
||||||
targets:
|
targets:
|
||||||
frontend:
|
frontend:
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
module:
|
module:
|
||||||
name: github.com/foomo/gotsrpc/v2/example/monitor
|
name: github.com/foomo/gotsrpc/v2
|
||||||
path: ./
|
path: ../../
|
||||||
|
|
||||||
targets:
|
targets:
|
||||||
monitor:
|
monitor:
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
/* eslint:disable */
|
/* eslint:disable */
|
||||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||||
import * as github_com_foomo_gotsrpc_v2_example_nullable_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
|
import * as github_com_foomo_gotsrpc_v2_example_nullable_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
|
||||||
|
|
||||||
// github.com/foomo/gotsrpc/v2/example/nullable/service.ACustomType
|
// github.com/foomo/gotsrpc/v2/example/nullable/service.ACustomType
|
||||||
export enum ACustomType {
|
export enum ACustomType {
|
||||||
One = "one",
|
One = "one",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
module:
|
module:
|
||||||
name: github.com/foomo/gotsrpc/v2/example/nullable
|
name: github.com/foomo/gotsrpc/v2
|
||||||
path: ./
|
path: ../../
|
||||||
|
|
||||||
targets:
|
targets:
|
||||||
nullable:
|
nullable:
|
||||||
|
|||||||
@ -3,6 +3,6 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"name": "@foomo/gotsrpc-examples",
|
"name": "@foomo/gotsrpc-examples",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^4.6.2"
|
"typescript": "5.6.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
/* eslint:disable */
|
/* eslint:disable */
|
||||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||||
import * as github_com_foomo_gotsrpc_v2_example_time_service from './service-vo-service'; // ./client/src/service-client.ts to ./client/src/service-vo-service.ts
|
import * as github_com_foomo_gotsrpc_v2_example_time_service from './service-vo-service'; // ./client/src/service-client.ts to ./client/src/service-vo-service.ts
|
||||||
import * as time from './service-vo-time'; // ./client/src/service-client.ts to ./client/src/service-vo-time.ts
|
|
||||||
|
|
||||||
export class ServiceClient {
|
export class ServiceClient {
|
||||||
public static defaultEndpoint = "/service";
|
public static defaultEndpoint = "/service";
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
/* eslint:disable */
|
/* eslint:disable */
|
||||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||||
import * as github_com_foomo_gotsrpc_v2_example_time_service from './service-vo-service'; // ./client/src/service-vo-service.ts to ./client/src/service-vo-service.ts
|
|
||||||
import * as time from './service-vo-time'; // ./client/src/service-vo-service.ts to ./client/src/service-vo-time.ts
|
|
||||||
// github.com/foomo/gotsrpc/v2/example/time/service.TimeStruct
|
// github.com/foomo/gotsrpc/v2/example/time/service.TimeStruct
|
||||||
export interface TimeStruct {
|
export interface TimeStruct {
|
||||||
time:number;
|
time:number;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/* eslint:disable */
|
/* eslint:disable */
|
||||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||||
import * as github_com_foomo_gotsrpc_v2_example_time_service from './service-vo-service'; // ./client/src/service-vo-time.ts to ./client/src/service-vo-service.ts
|
|
||||||
import * as time from './service-vo-time'; // ./client/src/service-vo-time.ts to ./client/src/service-vo-time.ts
|
import * as time from './service-vo-time'; // ./client/src/service-vo-time.ts to ./client/src/service-vo-time.ts
|
||||||
|
|
||||||
// time.Time
|
// time.Time
|
||||||
export interface Time {
|
export interface Time {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
module:
|
module:
|
||||||
name: github.com/foomo/gotsrpc/v2/example/time
|
name: github.com/foomo/gotsrpc/v2
|
||||||
path: ./
|
path: ../../
|
||||||
|
|
||||||
targets:
|
targets:
|
||||||
time:
|
time:
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
/* eslint:disable */
|
/* eslint:disable */
|
||||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||||
import * as github_com_foomo_gotsrpc_v2_example_union_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
|
import * as github_com_foomo_gotsrpc_v2_example_union_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
|
||||||
|
|
||||||
// github.com/foomo/gotsrpc/v2/example/union/service.InlineStruct
|
// github.com/foomo/gotsrpc/v2/example/union/service.InlineStruct
|
||||||
export interface InlineStruct extends github_com_foomo_gotsrpc_v2_example_union_service.InlineStructA , github_com_foomo_gotsrpc_v2_example_union_service.InlineStructB {
|
export interface InlineStruct extends github_com_foomo_gotsrpc_v2_example_union_service.InlineStructA , github_com_foomo_gotsrpc_v2_example_union_service.InlineStructB {
|
||||||
value:string;
|
value:string;
|
||||||
@ -19,7 +20,8 @@ export interface InlineStructPtr extends Partial<github_com_foomo_gotsrpc_v2_exa
|
|||||||
value:string;
|
value:string;
|
||||||
}
|
}
|
||||||
// github.com/foomo/gotsrpc/v2/example/union/service.UnionString
|
// github.com/foomo/gotsrpc/v2/example/union/service.UnionString
|
||||||
export type UnionString = (typeof github_com_foomo_gotsrpc_v2_example_union_service.UnionStringA) & (typeof github_com_foomo_gotsrpc_v2_example_union_service.UnionStringB)
|
export const UnionString = { ...github_com_foomo_gotsrpc_v2_example_union_service.UnionStringA, ...github_com_foomo_gotsrpc_v2_example_union_service.UnionStringB }
|
||||||
|
export type UnionString = typeof UnionString
|
||||||
// github.com/foomo/gotsrpc/v2/example/union/service.UnionStringA
|
// github.com/foomo/gotsrpc/v2/example/union/service.UnionStringA
|
||||||
export enum UnionStringA {
|
export enum UnionStringA {
|
||||||
One = "one",
|
One = "one",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
module:
|
module:
|
||||||
name: github.com/foomo/gotsrpc/v2/example/union
|
name: github.com/foomo/gotsrpc/v2
|
||||||
path: ./
|
path: ../../
|
||||||
|
|
||||||
targets:
|
targets:
|
||||||
union:
|
union:
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
typescript@^4.6.2:
|
typescript@5.6.3:
|
||||||
version "4.6.2"
|
version "5.6.3"
|
||||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4"
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.3.tgz#5f3449e31c9d94febb17de03cc081dd56d81db5b"
|
||||||
integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==
|
integrity sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==
|
||||||
|
|||||||
@ -185,13 +185,7 @@ func renderTypescriptStruct(str *Struct, mappings config.TypeScriptMappings, sca
|
|||||||
}
|
}
|
||||||
ts.app(" }")
|
ts.app(" }")
|
||||||
ts.nl()
|
ts.nl()
|
||||||
ts.app("export type " + str.Name + " = ")
|
ts.app("export type " + str.Name + " = typeof " + str.Name)
|
||||||
for i, field := range str.UnionFields {
|
|
||||||
if i > 0 {
|
|
||||||
ts.app(" | ")
|
|
||||||
}
|
|
||||||
field.Value.tsType(mappings, scalars, structs, ts, &JSONInfo{OmitEmpty: true})
|
|
||||||
}
|
|
||||||
ts.nl()
|
ts.nl()
|
||||||
default:
|
default:
|
||||||
return errors.New("could not resolve this union type")
|
return errors.New("could not resolve this union type")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user