@hodfords/nestjs-grpc-helper 12.3.1 → 12.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +218 -1
- package/commands/generate-sdk.command.js +8 -2
- package/commands/generate-sdk.command.js.map +1 -1
- package/constants/sdk-toolchain.const.d.ts +25 -0
- package/constants/sdk-toolchain.const.js +38 -0
- package/constants/sdk-toolchain.const.js.map +1 -0
- package/decorators/grpc-param.decorator.js +5 -4
- package/decorators/grpc-param.decorator.js.map +1 -1
- package/decorators/property.decorator.js +6 -3
- package/decorators/property.decorator.js.map +1 -1
- package/documents/microservice-document.controller.d.ts +1 -1
- package/dto/sort.dto.d.ts +1 -1
- package/dto/sort.dto.js +1 -1
- package/dto/sort.dto.js.map +1 -1
- package/helpers/generate.helper.d.ts +4 -3
- package/helpers/generate.helper.js +41 -3
- package/helpers/generate.helper.js.map +1 -1
- package/helpers/grpc-method.helper.js +1 -3
- package/helpers/grpc-method.helper.js.map +1 -1
- package/helpers/sdk-naming.helper.d.ts +7 -0
- package/helpers/sdk-naming.helper.js +197 -0
- package/helpers/sdk-naming.helper.js.map +1 -0
- package/helpers/sdk-output.helper.d.ts +6 -0
- package/helpers/sdk-output.helper.js +84 -0
- package/helpers/sdk-output.helper.js.map +1 -0
- package/helpers/shell.helper.d.ts +4 -0
- package/helpers/shell.helper.js +36 -0
- package/helpers/shell.helper.js.map +1 -1
- package/helpers/wire-response.helper.d.ts +8 -0
- package/helpers/wire-response.helper.js +23 -0
- package/helpers/wire-response.helper.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/package.json +3 -1
- package/sdk-stub/helpers/grpc.helper.d.ts +1 -0
- package/sdk-stub/helpers/grpc.helper.js +11 -13
- package/sdk-stub/helpers/grpc.helper.js.map +1 -1
- package/sdk-stub/helpers/grpc.helper.spec.ts +46 -0
- package/sdk-stub/helpers/grpc.helper.ts +19 -12
- package/services/generate-proto.service.d.ts +1 -1
- package/services/generate-proto.service.js +11 -19
- package/services/generate-proto.service.js.map +1 -1
- package/services/go-sdk-generator.service.d.ts +26 -0
- package/services/go-sdk-generator.service.js +227 -0
- package/services/go-sdk-generator.service.js.map +1 -0
- package/services/protoc.service.d.ts +5 -0
- package/services/protoc.service.js +26 -0
- package/services/protoc.service.js.map +1 -0
- package/services/rust-sdk-generator.service.d.ts +24 -0
- package/services/rust-sdk-generator.service.js +201 -0
- package/services/rust-sdk-generator.service.js.map +1 -0
- package/services/sdk-descriptor.service.d.ts +13 -0
- package/services/sdk-descriptor.service.js +142 -0
- package/services/sdk-descriptor.service.js.map +1 -0
- package/templates/go/client.hbs +171 -0
- package/templates/go/enums.hbs +14 -0
- package/templates/go/errors.hbs +55 -0
- package/templates/go/go-mod.hbs +8 -0
- package/templates/rust/cargo-toml.hbs +13 -0
- package/templates/rust/client.hbs +100 -0
- package/templates/rust/enums.hbs +61 -0
- package/templates/rust/error.hbs +52 -0
- package/templates/rust/lib.hbs +17 -0
- package/types/sdk-build-config.type.d.ts +15 -0
- package/types/sdk-build-config.type.js +1 -1
- package/types/sdk-build-config.type.js.map +1 -1
- package/types/sdk-descriptor.type.d.ts +29 -0
- package/types/sdk-descriptor.type.js +2 -0
- package/types/sdk-descriptor.type.js.map +1 -0
package/README.md
CHANGED
|
@@ -98,8 +98,25 @@ export class UserMicroservice {
|
|
|
98
98
|
@ResponseModel(UserResponse, true) // array of objects
|
|
99
99
|
@ResponseModel(String) // primitive (String, Number, Boolean)
|
|
100
100
|
@ResponseModel(UserResponse, { isAllowEmpty: true }) // object or null
|
|
101
|
+
@ResponseModel(String, false, true) // primitive or null
|
|
101
102
|
```
|
|
102
103
|
|
|
104
|
+
For a nullable result the generated TypeScript method returns `Promise<UserResponse | null>` /
|
|
105
|
+
`Promise<string | null>`.
|
|
106
|
+
|
|
107
|
+
> **Upgrading to 12.5:** an rpc that returns a nullable primitive (`@ResponseModel(String, false, true)`, also with
|
|
108
|
+
> `Number` or `Boolean`) now declares `NullableGrpcClassResponseOfNative*Value` in the proto instead of
|
|
109
|
+
> `Native*Value`. Before, the proto could not carry "no value" and every SDK decoded such a response wrongly. The
|
|
110
|
+
> return type of these rpcs changed on the wire, so regenerate the SDK and release the service together with the
|
|
111
|
+
> consumers that call them. No other rpc is affected.
|
|
112
|
+
>
|
|
113
|
+
> The generated TypeScript methods of nullable rpcs (objects and primitives) are now typed `T | null`, which is what
|
|
114
|
+
> they already returned. A consumer compiled with `strictNullChecks` gets a compile error wherever such a result is
|
|
115
|
+
> used without a null check.
|
|
116
|
+
>
|
|
117
|
+
> The Rust `ClientOptions` struct gained two fields. Code that builds it with a full struct literal
|
|
118
|
+
> (`ClientOptions { timeout: Some(..) }`) stops compiling after the SDK is regenerated; add `..Default::default()`.
|
|
119
|
+
|
|
103
120
|
### 3. Generate the proto file and start the gRPC server
|
|
104
121
|
|
|
105
122
|
Generate the proto file before the application starts, then connect the gRPC microservice:
|
|
@@ -156,9 +173,14 @@ accepted):
|
|
|
156
173
|
| `isArray` | Marks the field as repeated |
|
|
157
174
|
| `required` | `false` makes the field optional in the proto and SDK |
|
|
158
175
|
| `description` | Description used in documentation and the AI skill |
|
|
159
|
-
| `format` |
|
|
176
|
+
| `format` | Number type (`'int32'`, `'float'`, …; required for numbers) or `'any'` for dynamic JSON |
|
|
160
177
|
| `enum` / `enumName` | Declares an enum field; `enumName` names the generated enum |
|
|
161
178
|
|
|
179
|
+
> **Upgrading:** a `number` property without a `format` now fails proto generation (`make-sdk` and `make:proto`) with
|
|
180
|
+
> the class and property name. Such a proto used `number` as a field type and could never be loaded, so only the error
|
|
181
|
+
> moved earlier. A numeric enum without a `format` (`@Property({ type: Number, enum, enumName })`, `@GrpcEnum`,
|
|
182
|
+
> `@GrpcEnums`) now defaults to `int32`.
|
|
183
|
+
|
|
162
184
|
### Dynamic (`any`) fields
|
|
163
185
|
|
|
164
186
|
For values without a fixed schema, combine `format: 'any'` with `@AnyType`. The value is serialized to JSON on the wire
|
|
@@ -357,6 +379,201 @@ The generated package contains the proto file, a typed service class per microse
|
|
|
357
379
|
module for registration, and a mock module for testing. It is published under the name and version from your
|
|
358
380
|
`package.json`, and its method names, arguments, and response types match your service definitions exactly.
|
|
359
381
|
|
|
382
|
+
### Generating Rust and Go SDKs
|
|
383
|
+
|
|
384
|
+
`make-sdk` can also build a Rust crate and a Go module from the same proto. Add a `rust` and/or `go` block to
|
|
385
|
+
`sdk-config.json`; the existing fields keep describing the TypeScript SDK.
|
|
386
|
+
|
|
387
|
+
```json
|
|
388
|
+
{
|
|
389
|
+
"name": "sdkName",
|
|
390
|
+
"packageName": "@hodfords/package-name",
|
|
391
|
+
"output": "sdk",
|
|
392
|
+
"rust": {
|
|
393
|
+
"crateName": "sdk-name",
|
|
394
|
+
"version": "1.0.0",
|
|
395
|
+
"output": "../sdk-rust",
|
|
396
|
+
"build": true
|
|
397
|
+
},
|
|
398
|
+
"go": {
|
|
399
|
+
"module": "github.com/org/sdk-name-go",
|
|
400
|
+
"output": "../sdk-go",
|
|
401
|
+
"build": true
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
| Field | Description |
|
|
407
|
+
| ---------------- | -------------------------------------------------------------------------------------- |
|
|
408
|
+
| `rust.crateName` | Crate name written to `Cargo.toml` |
|
|
409
|
+
| `rust.version` | Crate version. Defaults to `0.1.0` |
|
|
410
|
+
| `rust.output` | Output directory of the crate |
|
|
411
|
+
| `rust.build` | Run `cargo check` after generation and fail if it does not compile. Default `false` |
|
|
412
|
+
| `go.module` | Go module path written to `go.mod`. Go modules are versioned by git tag |
|
|
413
|
+
| `go.output` | Output directory of the module |
|
|
414
|
+
| `go.build` | Run `go build ./...` after generation and fail if it does not compile. Default `false` |
|
|
415
|
+
|
|
416
|
+
Without `--lang`, TypeScript is always built, plus Rust and Go when their block is present. Pass `--lang` to build one
|
|
417
|
+
language only (`ts`, `rust` or `go`):
|
|
418
|
+
|
|
419
|
+
```shell
|
|
420
|
+
npm run wz-command make-sdk
|
|
421
|
+
npm run wz-command make-sdk -- --lang=rust
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
The stubs are generated when you run `make-sdk`, so the machine that runs it needs `protoc` and the plugins below;
|
|
425
|
+
projects that consume the SDK do not. Building the Rust crate (`rust.build`) needs Rust 1.85 or newer, and building the
|
|
426
|
+
Go module (`go.build`) needs Go 1.23 or newer. With `rust.build` / `go.build` an older toolchain is reported as an
|
|
427
|
+
error; the check runs in the build step, after the files are written. `protoc` and the plugins are checked first:
|
|
428
|
+
when one is missing or has an unsupported version, `make-sdk` fails before any SDK, including the TypeScript one, is
|
|
429
|
+
written, and the error lists every missing tool.
|
|
430
|
+
|
|
431
|
+
```shell
|
|
432
|
+
brew install protobuf # Debian/Ubuntu: apt-get install -y protobuf-compiler libprotobuf-dev
|
|
433
|
+
cargo install protoc-gen-prost@0.4.0 --locked
|
|
434
|
+
cargo install protoc-gen-tonic@0.4.1 --locked
|
|
435
|
+
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.6
|
|
436
|
+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
The output directory is never wiped. Only the generated paths are replaced (`Cargo.toml`, `microservice.proto` and
|
|
440
|
+
`src/` for Rust; `go.mod`, `microservice.proto`, `pb/`, `client.go`, `errors.go` and `enums.go` for Go), so the
|
|
441
|
+
directory can be its own git repository. Each run generates the proto, the stubs and the wrapper in a temporary
|
|
442
|
+
directory next to the output and replaces the generated paths only when all of that succeeded, so a failure while
|
|
443
|
+
generating leaves the previous SDK as it was. Formatting, `go mod tidy` and the optional `rust.build` / `go.build`
|
|
444
|
+
compile run after the replacement, so a failure there leaves the newly generated files in place.
|
|
445
|
+
An output may not be the working directory or any of its parent directories,
|
|
446
|
+
and may not be shared with, nested inside, or contain the TypeScript `output` / `outputBuild` or the other SDK's output
|
|
447
|
+
(the TypeScript generator deletes its directories on every run); a sibling directory such as `../sdk-go` is fine.
|
|
448
|
+
`rust.crateName` and `go.module` are required for the languages being built.
|
|
449
|
+
|
|
450
|
+
After generation the output is formatted with `cargo fmt` / `gofmt`. If the formatter is missing or fails, a warning is
|
|
451
|
+
logged and generation still succeeds. `go.mod` and `Cargo.toml` are rewritten on every run, so dependencies, `replace`
|
|
452
|
+
lines or features added there by hand are lost. `go.sum` is kept, and `make-sdk` runs `go mod tidy` in the Go output
|
|
453
|
+
itself when Go 1.23 or newer is on PATH; otherwise, or when `go mod tidy` fails (for example without network), it logs a
|
|
454
|
+
warning and you need to run `go mod tidy` before the module builds. With `go.build` a failing `go mod tidy` is an error.
|
|
455
|
+
|
|
456
|
+
Each microservice gets a client whose methods return the unwrapped value: a list, a native value, or an optional
|
|
457
|
+
model instead of the wire envelope. Client and method names follow the language: `AppMicroserviceClient::find_many` in
|
|
458
|
+
Rust, `NewAppMicroserviceClient` and `FindMany` in Go.
|
|
459
|
+
|
|
460
|
+
```rust
|
|
461
|
+
use sdk_name::{pb, AppMicroserviceClient, CallOptions, ClientOptions};
|
|
462
|
+
|
|
463
|
+
#[tokio::main]
|
|
464
|
+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
465
|
+
let client = AppMicroserviceClient::connect("http://localhost:50059", ClientOptions::default()).await?;
|
|
466
|
+
|
|
467
|
+
let mut options = CallOptions::default();
|
|
468
|
+
options.metadata.insert("workspace-id", "workspace-1".parse()?);
|
|
469
|
+
|
|
470
|
+
let users: Vec<pb::UserResponse> = client.find_many(pb::FindManyDto::default(), options).await?;
|
|
471
|
+
println!("{} users", users.len());
|
|
472
|
+
Ok(())
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
`ClientOptions` also takes `max_decoding_message_size` and `max_encoding_message_size` (in bytes). Responses larger
|
|
477
|
+
than tonic's default of 4 MiB are rejected unless the first one is raised; build the options with
|
|
478
|
+
`ClientOptions { max_decoding_message_size: Some(16 * 1024 * 1024), ..Default::default() }` so that fields added later
|
|
479
|
+
do not break your code. In Go the limit belongs to the connection:
|
|
480
|
+
`grpc.NewClient(address, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(16 * 1024 * 1024)), ...)`.
|
|
481
|
+
|
|
482
|
+
The crate root re-exports `pb`, `SdkError`, `SdkStream`, `ClientOptions`, `CallOptions` and every client; the enum
|
|
483
|
+
types live in `sdk_name::enums`. A crate name with hyphens is imported with underscores, and the consuming crate needs
|
|
484
|
+
`tokio` (with the `macros` and `rt-multi-thread` features) for the example above.
|
|
485
|
+
|
|
486
|
+
```go
|
|
487
|
+
package main
|
|
488
|
+
|
|
489
|
+
import (
|
|
490
|
+
"context"
|
|
491
|
+
"errors"
|
|
492
|
+
"fmt"
|
|
493
|
+
"time"
|
|
494
|
+
|
|
495
|
+
"google.golang.org/grpc"
|
|
496
|
+
"google.golang.org/grpc/credentials/insecure"
|
|
497
|
+
"google.golang.org/grpc/metadata"
|
|
498
|
+
|
|
499
|
+
sdk "github.com/org/sdk-name-go"
|
|
500
|
+
"github.com/org/sdk-name-go/pb"
|
|
501
|
+
)
|
|
502
|
+
|
|
503
|
+
func main() {
|
|
504
|
+
conn, err := grpc.NewClient("localhost:50059", grpc.WithTransportCredentials(insecure.NewCredentials()))
|
|
505
|
+
if err != nil {
|
|
506
|
+
panic(err)
|
|
507
|
+
}
|
|
508
|
+
defer conn.Close()
|
|
509
|
+
|
|
510
|
+
client := sdk.NewAppMicroserviceClient(conn, sdk.WithTimeout(5*time.Second))
|
|
511
|
+
users, err := client.FindMany(context.Background(), &pb.FindManyDto{},
|
|
512
|
+
sdk.WithMetadata(metadata.Pairs("workspace-id", "workspace-1")))
|
|
513
|
+
|
|
514
|
+
var serviceErr *sdk.Error
|
|
515
|
+
if errors.As(err, &serviceErr) {
|
|
516
|
+
fmt.Println("business error", serviceErr.Code, serviceErr.Message)
|
|
517
|
+
return
|
|
518
|
+
}
|
|
519
|
+
if err != nil {
|
|
520
|
+
panic(err)
|
|
521
|
+
}
|
|
522
|
+
fmt.Println(len(users), "users")
|
|
523
|
+
}
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
The Go package is named after the last segment of the module path, with characters that are not valid in an identifier
|
|
527
|
+
removed and the rest lower-cased (`github.com/org/sdk-name-go` becomes `sdknamego`), so import it with an alias as above.
|
|
528
|
+
A major-version suffix is skipped, as in Go (`github.com/org/sdk-go/v2` becomes `sdkgo`), and a name that is a Go
|
|
529
|
+
keyword gets an `sdk` suffix (`github.com/org/user-sdk/go` becomes `gosdk`).
|
|
530
|
+
`WithMetadata` can be passed to a constructor (as a default) and to a call; a later value for the same key replaces the
|
|
531
|
+
earlier one, and keys are lower-cased.
|
|
532
|
+
|
|
533
|
+
Business errors (gRPC `ABORTED` carrying `{ message, code, errors }`) become `SdkError::Service` in Rust and
|
|
534
|
+
`*sdk.Error` in Go; every other status is returned unchanged. A client-side timeout is reported as `DEADLINE_EXCEEDED`
|
|
535
|
+
in both languages. In Rust the timeout of a streaming call bounds only the wait for the first response (the response
|
|
536
|
+
headers), not the whole stream; in Go it bounds the whole stream.
|
|
537
|
+
|
|
538
|
+
Streaming methods return `SdkStream<T>` in Rust (a pinned, boxed `tokio_stream::Stream` of `Result<T, SdkError>`) and
|
|
539
|
+
`*Stream[T]` in Go. In Go, `Recv` returns `io.EOF` when the server has finished, and `Close` must be called when you stop
|
|
540
|
+
reading early.
|
|
541
|
+
|
|
542
|
+
Differences from the TypeScript SDK:
|
|
543
|
+
|
|
544
|
+
- Methods take the whole request message. `@SdkFlattenParams` and `@GrpcId`-style parameters are not flattened into
|
|
545
|
+
arguments.
|
|
546
|
+
- Enum fields keep their wire type (string or integer). The allowed values are generated in `enums.rs` (Rust enums with
|
|
547
|
+
`value()` / `as_str()` and `from_value()` helpers) and `enums.go` (typed constants). An enum that cannot be rendered
|
|
548
|
+
safely — member names that collide or are empty once converted, mixed string and number values, a non-integer,
|
|
549
|
+
out-of-int32-range or repeated value, or `type: Number` with non-numeric values — is left out of both files with a
|
|
550
|
+
warning.
|
|
551
|
+
- `format: 'any'` fields are JSON strings; encode and decode them yourself.
|
|
552
|
+
- Metadata parameters (`@GrpcMetadata`, `@GrpcMetadataId`) are set through the per-call metadata option. The generated
|
|
553
|
+
doc comment of each method lists the keys the server reads.
|
|
554
|
+
- A nullable primitive response (`@ResponseModel(String, false, true)`) is `Option<String>` in Rust and `*string` in
|
|
555
|
+
Go (likewise `Option<f32>` / `*float32` and `Option<bool>` / `*bool`); `None` / `nil` means the server returned no
|
|
556
|
+
value.
|
|
557
|
+
- There is no mock client and no AI skill file.
|
|
558
|
+
- `Number` responses (`@ResponseModel(Number)`) are `f32` in Rust and `float32` in Go, because the proto carries them as
|
|
559
|
+
`float`.
|
|
560
|
+
- A `number` property must declare a `format` (`int32`, `int64`, `float` or `double`) in every SDK; `make-sdk` and
|
|
561
|
+
`make:proto` fail with the class and property name otherwise. A numeric enum (`@Property` with `enum` / `enumName`,
|
|
562
|
+
`@GrpcEnum`, `@GrpcEnums`) without a `format` defaults to `int32`.
|
|
563
|
+
- Rust method and enum variant names that are keywords follow prost / tonic: an rpc `move` is `r#move`, and an enum
|
|
564
|
+
member `SELF` is the variant `Self_`. An rpc whose Rust name is `connect`, `new`, `with_origin`,
|
|
565
|
+
`with_interceptor`, `send_compressed`, `accept_compressed`, `max_decoding_message_size` or
|
|
566
|
+
`max_encoding_message_size` clashes with methods of the client or of tonic's generated client and fails generation;
|
|
567
|
+
rename it.
|
|
568
|
+
|
|
569
|
+
#### Trying the Rust and Go SDKs
|
|
570
|
+
|
|
571
|
+
The repository has a runnable example for each language: `pnpm run build:sample-sdk:native` generates both SDKs from
|
|
572
|
+
the `sample` app using `sample/sdk-config.native.json` (it also rewrites the TypeScript SDK in `sdk/`; add `--lang go`
|
|
573
|
+
or `--lang rust` to build one language), and the consumers call every rpc of the sample server and print the results.
|
|
574
|
+
Follow [`sample/consumer-go/README.md`](sample/consumer-go/README.md) or
|
|
575
|
+
[`sample/consumer-rust/README.md`](sample/consumer-rust/README.md) for the prerequisites, commands and expected output.
|
|
576
|
+
|
|
360
577
|
### Generating only the proto file
|
|
361
578
|
|
|
362
579
|
To generate just the proto file, without building the whole SDK, use the `make:proto` command. It reuses the same
|
|
@@ -9,22 +9,28 @@ import { Injectable } from '@nestjs/common';
|
|
|
9
9
|
import { generateSdk } from '../helpers/generate.helper.js';
|
|
10
10
|
import { readFileSync } from 'node:fs';
|
|
11
11
|
import path from 'node:path';
|
|
12
|
+
import { SDK_LANGUAGES } from '../types/sdk-build-config.type.js';
|
|
12
13
|
let GenerateSdkCommand = class GenerateSdkCommand extends BaseCommand {
|
|
13
14
|
handle() {
|
|
14
15
|
let [configFile] = this.params;
|
|
15
16
|
if (!configFile) {
|
|
16
17
|
configFile = 'sdk-config.json';
|
|
17
18
|
}
|
|
19
|
+
const { lang } = this.program.opts();
|
|
20
|
+
if (lang && !SDK_LANGUAGES.includes(lang)) {
|
|
21
|
+
throw new Error(`Unknown --lang "${lang}". Use ts, rust or go.`);
|
|
22
|
+
}
|
|
18
23
|
const configPath = path.isAbsolute(configFile) ? configFile : path.resolve(process.cwd(), configFile);
|
|
19
24
|
const options = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
20
|
-
generateSdk(options);
|
|
25
|
+
generateSdk(options, lang ? [lang] : undefined);
|
|
21
26
|
this.success(`Create sdk successfully!`);
|
|
22
27
|
}
|
|
23
28
|
};
|
|
24
29
|
GenerateSdkCommand = __decorate([
|
|
25
30
|
Command({
|
|
26
31
|
signature: 'make-sdk [configFile]',
|
|
27
|
-
description: 'Make sdk'
|
|
32
|
+
description: 'Make sdk',
|
|
33
|
+
options: [{ value: '--lang <language>', description: 'Build a single language: ts, rust or go' }]
|
|
28
34
|
}),
|
|
29
35
|
Injectable()
|
|
30
36
|
], GenerateSdkCommand);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-sdk.command.js","sourceRoot":"","sources":["../../../lib/commands/generate-sdk.command.ts"],"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CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;QACtG,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QAC7D,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC7C,CAAC;CACJ,CAAA;AAnBY,kBAAkB;IAN9B,OAAO,CAAC;QACL,SAAS,EAAE,uBAAuB;QAClC,WAAW,EAAE,UAAU;QACvB,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;KACpG,CAAC;IACD,UAAU,EAAE;GACA,kBAAkB,CAmB9B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type SdkToolRequirement = {
|
|
2
|
+
binary: string;
|
|
3
|
+
version?: string;
|
|
4
|
+
install: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const PROTOC_TOOL: SdkToolRequirement;
|
|
7
|
+
export declare const RUST_SDK_TOOLCHAIN: {
|
|
8
|
+
tools: SdkToolRequirement[];
|
|
9
|
+
minRustVersion: string;
|
|
10
|
+
crates: {
|
|
11
|
+
prost: string;
|
|
12
|
+
tonic: string;
|
|
13
|
+
tokioStream: string;
|
|
14
|
+
serdeJson: string;
|
|
15
|
+
thiserror: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare const GO_SDK_TOOLCHAIN: {
|
|
19
|
+
tools: SdkToolRequirement[];
|
|
20
|
+
goVersion: string;
|
|
21
|
+
modules: {
|
|
22
|
+
grpc: string;
|
|
23
|
+
protobuf: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const PROTOC_TOOL = {
|
|
2
|
+
binary: 'protoc',
|
|
3
|
+
install: 'brew install protobuf (Debian/Ubuntu: apt-get install -y protobuf-compiler libprotobuf-dev)'
|
|
4
|
+
};
|
|
5
|
+
export const RUST_SDK_TOOLCHAIN = {
|
|
6
|
+
tools: [
|
|
7
|
+
{ binary: 'protoc-gen-prost', version: '0.4', install: 'cargo install protoc-gen-prost@0.4.0 --locked' },
|
|
8
|
+
{ binary: 'protoc-gen-tonic', version: '0.4', install: 'cargo install protoc-gen-tonic@0.4.1 --locked' }
|
|
9
|
+
],
|
|
10
|
+
minRustVersion: '1.85',
|
|
11
|
+
crates: {
|
|
12
|
+
prost: '0.13',
|
|
13
|
+
tonic: '0.12',
|
|
14
|
+
tokioStream: '0.1',
|
|
15
|
+
serdeJson: '1',
|
|
16
|
+
thiserror: '1'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const GO_SDK_TOOLCHAIN = {
|
|
20
|
+
tools: [
|
|
21
|
+
{
|
|
22
|
+
binary: 'protoc-gen-go',
|
|
23
|
+
version: '1.36',
|
|
24
|
+
install: 'go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.6'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
binary: 'protoc-gen-go-grpc',
|
|
28
|
+
version: '1.5',
|
|
29
|
+
install: 'go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1'
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
goVersion: '1.23',
|
|
33
|
+
modules: {
|
|
34
|
+
grpc: 'v1.71.0',
|
|
35
|
+
protobuf: 'v1.36.6'
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=sdk-toolchain.const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-toolchain.const.js","sourceRoot":"","sources":["../../../lib/constants/sdk-toolchain.const.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,WAAW,GAAuB;IAC3C,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,8FAA8F;CAC1G,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B,KAAK,EAAE;QACH,EAAE,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,+CAA+C,EAAE;QACxG,EAAE,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,+CAA+C,EAAE;KACnF;IACzB,cAAc,EAAE,MAAM;IACtB,MAAM,EAAE;QACJ,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,KAAK;QAClB,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;KACjB;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,KAAK,EAAE;QACH;YACI,MAAM,EAAE,eAAe;YACvB,OAAO,EAAE,MAAM;YACf,OAAO,EAAE,iEAAiE;SAC7E;QACD;YACI,MAAM,EAAE,oBAAoB;YAC5B,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,iEAAiE;SAC7E;KACoB;IACzB,SAAS,EAAE,MAAM;IACjB,OAAO,EAAE;QACL,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,SAAS;KACtB;CACJ,CAAC"}
|
|
@@ -54,18 +54,19 @@ function getEnumType(enumObj) {
|
|
|
54
54
|
}
|
|
55
55
|
return type;
|
|
56
56
|
}
|
|
57
|
+
function resolveEnumOptions(option) {
|
|
58
|
+
return { type: getEnumType(option.enum), ...option };
|
|
59
|
+
}
|
|
57
60
|
export function GrpcEnum(option) {
|
|
58
61
|
return GrpcParam({
|
|
59
|
-
|
|
60
|
-
...option,
|
|
62
|
+
...resolveEnumOptions(option),
|
|
61
63
|
required: true,
|
|
62
64
|
decorators: [IsNotEmpty(), IsEnum(option.enum)]
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
export function GrpcEnums(option) {
|
|
66
68
|
return GrpcParam({
|
|
67
|
-
|
|
68
|
-
...option,
|
|
69
|
+
...resolveEnumOptions(option),
|
|
69
70
|
required: true,
|
|
70
71
|
isArray: true,
|
|
71
72
|
decorators: [IsArray(), IsEnum(option.enum, { each: true })]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc-param.decorator.js","sourceRoot":"","sources":["../../../lib/decorators/grpc-param.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAE,8BAA8B,EAAE,+BAA+B,EAAE,MAAM,oCAAoC,CAAC;AACrH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,UAAU,gBAAgB;IAC5B,OAAO,UAAU,MAAc,EAAE,WAA4B,EAAE,UAA8B;QACzF,OAAO,CAAC,cAAc,CAAC,+BAA+B,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACvF,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,MAA2B;IACjD,OAAO,UAAU,MAAc,EAAE,WAA4B,EAAE,cAAsB;QACjF,MAAM,MAAM,GACR,OAAO,CAAC,WAAW,CAAC,8BAA8B,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QACnF,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC;QAC9B,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,EAAE,CAAC;YACjD,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjD,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,IAAI,OAAO,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QACb,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,KAAK;QACf,UAAU,EAAE,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;KACtD,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -4,9 +4,12 @@ import { convertProtoTypeToSwagger } from '../helpers/proto-type.helper.js';
|
|
|
4
4
|
import { addPropertyToStorage } from '../helpers/property.helper.js';
|
|
5
5
|
export function Property(option) {
|
|
6
6
|
return function (target, propertyName) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const isEnum = isEnumProperty(option);
|
|
8
|
+
const isNumber = option.type === Number || option.type === 'number';
|
|
9
|
+
if (isEnum && isNumber && !option.format) {
|
|
10
|
+
option.format = 'int32';
|
|
11
|
+
}
|
|
12
|
+
const apiOptions = isEnum ? { ...option } : { ...option, type: convertProtoTypeToSwagger(option) };
|
|
10
13
|
ApiProperty(apiOptions)(target, propertyName);
|
|
11
14
|
if (option.type == String || option.type == Number) {
|
|
12
15
|
option.type = option.type.name.toLowerCase();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property.decorator.js","sourceRoot":"","sources":["../../../lib/decorators/property.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAMrE,MAAM,UAAU,QAAQ,CAAC,MAA0B;IAC/C,OAAO,UAAU,MAAc,EAAE,YAA6B;
|
|
1
|
+
{"version":3,"file":"property.decorator.js","sourceRoot":"","sources":["../../../lib/decorators/property.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB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AAW,EAAE,YAAsB,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -5,6 +5,6 @@ export declare class MicroserviceDocumentController {
|
|
|
5
5
|
private options;
|
|
6
6
|
private client;
|
|
7
7
|
constructor(options: DocumentModuleOptionType, client: ClientGrpc);
|
|
8
|
-
getDocumentJson(): import("../
|
|
8
|
+
getDocumentJson(): import("../index.js").DocumentType;
|
|
9
9
|
grpcTest(value: GrpcTestDto): Promise<unknown>;
|
|
10
10
|
}
|
package/dto/sort.dto.d.ts
CHANGED
package/dto/sort.dto.js
CHANGED
package/dto/sort.dto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.dto.js","sourceRoot":"","sources":["../../../lib/dto/sort.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,OAAO,OAAO;IAMhB,SAAS,CAAS;IAKlB,aAAa,
|
|
1
|
+
{"version":3,"file":"sort.dto.js","sourceRoot":"","sources":["../../../lib/dto/sort.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,OAAO,OAAO;IAMhB,SAAS,CAAS;IAKlB,aAAa,CAAiB;CACjC;AANG;IALC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,EAAE;IACV,OAAO,CAAC,gBAAgB,EAAE;QACvB,OAAO,EAAE,8EAA8E;KAC1F,CAAC;;0CACgB;AAKlB;IAHC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,EAAE;IACV,MAAM,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;;8CACM"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { SdkBuildConfigType } from '../types/sdk-build-config.type.js';
|
|
2
|
-
export declare function
|
|
1
|
+
import { SdkBuildConfigType, SdkLanguage } from '../types/sdk-build-config.type.js';
|
|
2
|
+
export declare function resolveSdkLanguages(config: SdkBuildConfigType, languages?: SdkLanguage[]): SdkLanguage[];
|
|
3
|
+
export declare function generateSdk(config: SdkBuildConfigType, languages?: SdkLanguage[]): void;
|
|
3
4
|
export declare function generateProtoService(packageName: string, dirPath: string): void;
|
|
4
|
-
export declare function generateDocumentService(packageName: string): import("../
|
|
5
|
+
export declare function generateDocumentService(packageName: string): import("../index.js").DocumentType;
|
|
@@ -1,8 +1,46 @@
|
|
|
1
|
+
import { GenerateDocumentService } from '../services/generate-document.service.js';
|
|
1
2
|
import { GenerateMicroserviceService } from '../services/generate-microservice.service.js';
|
|
2
3
|
import { GenerateProtoService } from '../services/generate-proto.service.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { GoSdkGeneratorService } from '../services/go-sdk-generator.service.js';
|
|
5
|
+
import { ProtocService } from '../services/protoc.service.js';
|
|
6
|
+
import { RustSdkGeneratorService } from '../services/rust-sdk-generator.service.js';
|
|
7
|
+
import { SdkDescriptorService } from '../services/sdk-descriptor.service.js';
|
|
8
|
+
import { SDK_LANGUAGES } from '../types/sdk-build-config.type.js';
|
|
9
|
+
import { assertSdkOutputs } from './sdk-output.helper.js';
|
|
10
|
+
export function resolveSdkLanguages(config, languages) {
|
|
11
|
+
if (!languages?.length) {
|
|
12
|
+
return SDK_LANGUAGES.filter((language) => language === 'ts' || Boolean(config[language]));
|
|
13
|
+
}
|
|
14
|
+
for (const language of languages) {
|
|
15
|
+
if (!SDK_LANGUAGES.includes(language)) {
|
|
16
|
+
throw new Error(`Unknown SDK language "${language}". Use ts, rust or go.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return languages;
|
|
20
|
+
}
|
|
21
|
+
function assertSdkTools(targets) {
|
|
22
|
+
const tools = new Set([
|
|
23
|
+
...(targets.includes('rust') ? RustSdkGeneratorService.requiredTools : []),
|
|
24
|
+
...(targets.includes('go') ? GoSdkGeneratorService.requiredTools : [])
|
|
25
|
+
]);
|
|
26
|
+
if (tools.size) {
|
|
27
|
+
new ProtocService().assertTools([...tools]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function generateSdk(config, languages) {
|
|
31
|
+
const targets = resolveSdkLanguages(config, languages);
|
|
32
|
+
assertSdkOutputs(config, targets);
|
|
33
|
+
assertSdkTools(targets);
|
|
34
|
+
const descriptor = targets.includes('rust') || targets.includes('go') ? new SdkDescriptorService().describe() : undefined;
|
|
35
|
+
if (targets.includes('ts')) {
|
|
36
|
+
new GenerateMicroserviceService(config).generate();
|
|
37
|
+
}
|
|
38
|
+
if (targets.includes('rust')) {
|
|
39
|
+
new RustSdkGeneratorService(config).generate(descriptor);
|
|
40
|
+
}
|
|
41
|
+
if (targets.includes('go')) {
|
|
42
|
+
new GoSdkGeneratorService(config).generate(descriptor);
|
|
43
|
+
}
|
|
6
44
|
}
|
|
7
45
|
export function generateProtoService(packageName, dirPath) {
|
|
8
46
|
new GenerateProtoService(packageName, dirPath).generate();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.helper.js","sourceRoot":"","sources":["../../../lib/helpers/generate.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"generate.helper.js","sourceRoot":"","sources":["../../../lib/helpers/generate.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,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AO,IAAI,uBAAuB,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC/D,CAAC"}
|
|
@@ -30,8 +30,6 @@ export function getReturnType(response) {
|
|
|
30
30
|
if (response.isArray) {
|
|
31
31
|
return `${returnType}[]`;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
return returnType;
|
|
35
|
-
}
|
|
33
|
+
return response.isAllowEmpty ? `${returnType} | null` : returnType;
|
|
36
34
|
}
|
|
37
35
|
//# sourceMappingURL=grpc-method.helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc-method.helper.js","sourceRoot":"","sources":["../../../lib/helpers/grpc-method.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EACH,8BAA8B,EAC9B,+BAA+B,EAC/B,6BAA6B,EAChC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOnD,MAAM,UAAU,mBAAmB,CAAC,WAAqB,EAAE,WAAmB;IAC1E,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAC5F,IAAI,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,8BAA8B,EAAE,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAC3G,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,6BAA6B,EAAE,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAC9G,IAAI,aAAa,CAAC;IAClB,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,CAAC;QAC/B,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC;QAC5C,MAAM,cAAc,GAAG,OAAO,CAC1B,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C3D,CAAC;IACD,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,GAAG,UAAU,IAAI,CAAC;IAC7B,CAAC;IAED,OAAO,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,UAAU,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function splitWords(name: string): string[];
|
|
2
|
+
export declare function toSnakeCase(name: string): string;
|
|
3
|
+
export declare function toUpperCamelCase(name: string): string;
|
|
4
|
+
export declare function toRustIdentifier(name: string): string;
|
|
5
|
+
export declare function enumMemberName(key: string): string;
|
|
6
|
+
export declare function toGoCamelCase(name: string): string;
|
|
7
|
+
export declare function toGoPackageName(module: string): string;
|