Skip to content

Commit

Permalink
Adds generation for buf connect gRPCWeb ts clients. (#6031)
Browse files Browse the repository at this point in the history
<!--
Before you open the request please review the following guidelines and
tips to help it be more easily integrated:

 - Describe the scope of your change - i.e. what the change does.
 - Describe any known limitations with your change.
- Please run any tests or examples that can exercise your modified code.

 Thank you for contributing!
 -->
Part one of a series for #6013

### Description of the change

<!-- Describe the scope of your change - i.e. what the change does. -->
Adds support for the typescript clients used by buf connect's gRPC-Web.

### Benefits

<!-- What benefits will be realized by the code change? -->
Just allows the next PR to be reviewable, only containing the actual
code changes rather than the generated changes.

### Possible drawbacks

<!-- Describe any known limitations with your change -->

### Applicable issues

<!-- Enter any applicable Issues here (You can reference an issue using
#) -->

- ref #6013

### Additional information

<!-- If there's anything else that's important and relevant to your pull
request, mention that information here.-->

Once we've switched over, we can also look at removing this generated
code altogether, since the buf connect system has support for remote
plugins, enabling simple imports of the remotely generated code.

---------

Signed-off-by: Michael Nelson <minelson@vmware.com>
  • Loading branch information
absoludity authored Mar 8, 2023
1 parent 6b2cd93 commit e3d4cd5
Show file tree
Hide file tree
Showing 17 changed files with 8,883 additions and 2 deletions.
12 changes: 12 additions & 0 deletions cmd/kubeapps-apis/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,15 @@ plugins:
- outputClientImpl=grpc-web # client implementation it generates
- esModuleInterop=true # use imports as required in modern ts setups
- useOptionals=messages # use optional TypeScript properties instead of undefined
- name: es
opt:
- target=ts
- import_extension=none
out: ../../dashboard/src/gen
path: ../../dashboard/node_modules/.bin/protoc-gen-es
- name: connect-es
out: ../../dashboard/src/gen
opt:
- target=ts
- import_extension=none
path: ../../dashboard/node_modules/.bin/protoc-gen-connect-es
10 changes: 8 additions & 2 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"compile-lang": "formatjs compile-folder lang src/locales/ --ast --format simple",
"copy-clr": "shx cp ./node_modules/@clr/ui/clr-ui-dark.min.css public/clr-ui-dark.min.css && shx cp node_modules/@clr/ui/clr-ui.min.css public/clr-ui.min.css && shx cp ./node_modules/@clr/ui/clr-ui-dark.min.css.map public/clr-ui-dark.min.css.map && shx cp ./node_modules/@clr/ui/clr-ui.min.css.map public/clr-ui.min.css.map",
"eject": "craco eject",
"eslint-check": "eslint --config ./.eslintrc.json 'src/**/*.{js,ts,tsx}' --max-warnings=0",
"eslint": "eslint --config ./.eslintrc.json 'src/**/*.{js,ts,tsx}' --fix --max-warnings=0",
"eslint-check": "eslint --config ./.eslintrc.json 'src/**/*.{js,ts,tsx}' --max-warnings=0 --ignore-pattern='src/gen/'",
"eslint": "eslint --config ./.eslintrc.json 'src/**/*.{js,ts,tsx}' --fix --max-warnings=0 --ignore-pattern='src/gen/'",
"extract-lang": "formatjs extract 'src/**/*.ts*' --out-file lang/en.json --id-interpolation-pattern '[sha512:contenthash:base64:6]' --format simple",
"lint": "npm-run-all lint-css-check eslint-check",
"lint-css-check": "stylelint --config ./.stylelintrc.json 'src/**/*.scss'",
Expand All @@ -27,6 +27,9 @@
},
"dependencies": {
"@babel/parser": "^7.20.15",
"@bufbuild/connect": "^0.8.1",
"@bufbuild/connect-web": "^0.8.1",
"@bufbuild/protobuf": "^1.0.0",
"@cds/city": "^1.1.0",
"@cds/core": "^6.2.0",
"@cds/react": "^6.2.0",
Expand Down Expand Up @@ -73,6 +76,9 @@
"yaml": "^2.2.1"
},
"devDependencies": {
"@bufbuild/buf": "^1.14.0-1",
"@bufbuild/protoc-gen-connect-es": "^0.8.1",
"@bufbuild/protoc-gen-es": "^1.0.0",
"@craco/craco": "^7.0.0",
"@formatjs/cli": "^6.0.1",
"@improbable-eng/grpc-web-fake-transport": "^0.15.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Copyright 2021-2022 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0

// @generated by protoc-gen-connect-es v0.8.1 with parameter "target=ts,import_extension=none"
// @generated from file kubeappsapis/core/packages/v1alpha1/packages.proto (package kubeappsapis.core.packages.v1alpha1, syntax proto3)
/* eslint-disable */
// @ts-nocheck

import {
CreateInstalledPackageRequest,
CreateInstalledPackageResponse,
DeleteInstalledPackageRequest,
DeleteInstalledPackageResponse,
GetAvailablePackageDetailRequest,
GetAvailablePackageDetailResponse,
GetAvailablePackageSummariesRequest,
GetAvailablePackageSummariesResponse,
GetAvailablePackageVersionsRequest,
GetAvailablePackageVersionsResponse,
GetInstalledPackageDetailRequest,
GetInstalledPackageDetailResponse,
GetInstalledPackageResourceRefsRequest,
GetInstalledPackageResourceRefsResponse,
GetInstalledPackageSummariesRequest,
GetInstalledPackageSummariesResponse,
UpdateInstalledPackageRequest,
UpdateInstalledPackageResponse,
} from "./packages_pb";
import { MethodKind } from "@bufbuild/protobuf";

/**
* Each packages v1alpha1 plugin must implement at least the following rpcs:
*
*
* @generated from service kubeappsapis.core.packages.v1alpha1.PackagesService
*/
export const PackagesService = {
typeName: "kubeappsapis.core.packages.v1alpha1.PackagesService",
methods: {
/**
* @generated from rpc kubeappsapis.core.packages.v1alpha1.PackagesService.GetAvailablePackageSummaries
*/
getAvailablePackageSummaries: {
name: "GetAvailablePackageSummaries",
I: GetAvailablePackageSummariesRequest,
O: GetAvailablePackageSummariesResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kubeappsapis.core.packages.v1alpha1.PackagesService.GetAvailablePackageDetail
*/
getAvailablePackageDetail: {
name: "GetAvailablePackageDetail",
I: GetAvailablePackageDetailRequest,
O: GetAvailablePackageDetailResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kubeappsapis.core.packages.v1alpha1.PackagesService.GetAvailablePackageVersions
*/
getAvailablePackageVersions: {
name: "GetAvailablePackageVersions",
I: GetAvailablePackageVersionsRequest,
O: GetAvailablePackageVersionsResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kubeappsapis.core.packages.v1alpha1.PackagesService.GetInstalledPackageSummaries
*/
getInstalledPackageSummaries: {
name: "GetInstalledPackageSummaries",
I: GetInstalledPackageSummariesRequest,
O: GetInstalledPackageSummariesResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kubeappsapis.core.packages.v1alpha1.PackagesService.GetInstalledPackageDetail
*/
getInstalledPackageDetail: {
name: "GetInstalledPackageDetail",
I: GetInstalledPackageDetailRequest,
O: GetInstalledPackageDetailResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kubeappsapis.core.packages.v1alpha1.PackagesService.CreateInstalledPackage
*/
createInstalledPackage: {
name: "CreateInstalledPackage",
I: CreateInstalledPackageRequest,
O: CreateInstalledPackageResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kubeappsapis.core.packages.v1alpha1.PackagesService.UpdateInstalledPackage
*/
updateInstalledPackage: {
name: "UpdateInstalledPackage",
I: UpdateInstalledPackageRequest,
O: UpdateInstalledPackageResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kubeappsapis.core.packages.v1alpha1.PackagesService.DeleteInstalledPackage
*/
deleteInstalledPackage: {
name: "DeleteInstalledPackage",
I: DeleteInstalledPackageRequest,
O: DeleteInstalledPackageResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kubeappsapis.core.packages.v1alpha1.PackagesService.GetInstalledPackageResourceRefs
*/
getInstalledPackageResourceRefs: {
name: "GetInstalledPackageResourceRefs",
I: GetInstalledPackageResourceRefsRequest,
O: GetInstalledPackageResourceRefsResponse,
kind: MethodKind.Unary,
},
},
} as const;
Loading

0 comments on commit e3d4cd5

Please sign in to comment.