Skip to content

Commit 9cf55dd

Browse files
authored
Merge pull request #332 from Permify/update-grpc-client-setup
refactor: update buf generation and improve build script logic
2 parents 783a8ba + 05817d0 commit 9cf55dd

File tree

5 files changed

+39
-1758
lines changed

5 files changed

+39
-1758
lines changed

buf.gen.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
version: v2
22
managed:
33
enabled: true
4-
inputs:
5-
- module: buf.build/permifyco/permify
6-
# Permify proto version - update this when upgrading
74
plugins:
8-
- remote: buf.build/community/stephenh-ts-proto:v2.6.1
5+
- local: ["node_modules/.bin/protoc-gen-ts_proto"]
96
out: src/grpc/generated
107
opt:
11-
- oneof=unions
12-
- forceLong=long
13-
- esModuleInterop=true
14-
- env=node
158
- outputServices=nice-grpc
169
- outputServices=generic-definitions
10+
- esModuleInterop=true
11+
- env=node
1712
- useExactTypes=false
13+
- forceLong=long
14+
- oneof=unions

package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"run-instance": "scripts/run-instance.sh",
1616
"run-test": "ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json",
1717
"lint": "eslint \"src/**/*.ts\"",
18-
"build": "npx tsc",
18+
"build": "rm -rf ./dist && npx tsc && cp -r src/grpc/generated dist/src/grpc/",
1919
"buf:generate": "buf generate"
2020
},
2121
"keywords": [
@@ -31,8 +31,6 @@
3131
"license": "Apache-2.0",
3232
"dependencies": {
3333
"@grpc/grpc-js": "^1.9.0",
34-
"@protobuf-ts/runtime": "^2.9.1",
35-
"@protobuf-ts/runtime-rpc": "^2.9.1",
3634
"nice-grpc": "^2.1.9",
3735
"nice-grpc-common": "^2.0.0",
3836
"long": "^5.2.3"
@@ -45,10 +43,8 @@
4543
"eslint": "^9.21.0",
4644
"globals": "^16.0.0",
4745
"jasmine": "^5.2.0",
48-
"jest": "^30.0.0",
49-
"ts-jest": "^29.2.4",
5046
"ts-node": "^10.9.2",
51-
"ts-proto": "^2.8.3",
47+
"ts-proto": "^2.6.1",
5248
"typescript": "^5.0.0"
5349
}
5450
}

src/grpc/clients.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import {ClientMiddleware, createChannel, createClientFactory, ChannelCredentials} from 'nice-grpc';
2-
1+
import { ClientMiddleware, createChannel, createClientFactory, ChannelCredentials } from 'nice-grpc';
32
import {
43
PermissionDefinition,
54
SchemaDefinition,
@@ -8,11 +7,10 @@ import {
87
WatchDefinition,
98
BundleDefinition
109
} from './generated/base/v1/service';
11-
12-
import {Config} from "./config";
10+
import { Config } from './config';
1311

1412
/**
15-
* Create a new gRPC service client for of Permify.
13+
* Create a new gRPC service client for Permify.
1614
* The client can be configured with multiple client interceptors. For authentication interceptors,
1715
* see the interceptors in this package.
1816
*
@@ -22,10 +20,10 @@ import {Config} from "./config";
2220
* @returns A new gRPC service client for the Permission API of Permify.
2321
*/
2422
export function newClient(conf: Config, ...interceptors: ClientMiddleware[]) {
25-
const channel = (conf.insecure)
26-
? createChannel(conf.endpoint, ChannelCredentials.createInsecure())
27-
: createChannel(conf.endpoint, ChannelCredentials.createSsl(conf.cert, conf.pk, conf.certChain));
28-
23+
const channel = conf.insecure
24+
? createChannel(conf.endpoint, ChannelCredentials.createInsecure())
25+
: createChannel(conf.endpoint, ChannelCredentials.createSsl(conf.cert, conf.pk, conf.certChain));
26+
2927
let factory = createClientFactory();
3028
for (const interceptor of interceptors) {
3129
factory = factory.use(interceptor);

tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"allowSyntheticDefaultImports": true,
1313
"esModuleInterop": true,
1414
"rootDir": "./",
15+
"strict": false,
16+
"strictNullChecks": false,
1517
"typeRoots": [
1618
"node_modules/@types"
1719
]

0 commit comments

Comments
 (0)