@hodfords/nestjs-grpc-helper 12.3.0 → 12.4.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.
Files changed (53) hide show
  1. package/README.md +194 -1
  2. package/commands/generate-sdk.command.js +8 -2
  3. package/commands/generate-sdk.command.js.map +1 -1
  4. package/constants/sdk-toolchain.const.d.ts +25 -0
  5. package/constants/sdk-toolchain.const.js +38 -0
  6. package/constants/sdk-toolchain.const.js.map +1 -0
  7. package/decorators/grpc-param.decorator.js +5 -4
  8. package/decorators/grpc-param.decorator.js.map +1 -1
  9. package/decorators/property.decorator.js +6 -3
  10. package/decorators/property.decorator.js.map +1 -1
  11. package/helpers/generate.helper.d.ts +3 -2
  12. package/helpers/generate.helper.js +56 -3
  13. package/helpers/generate.helper.js.map +1 -1
  14. package/helpers/sdk-naming.helper.d.ts +7 -0
  15. package/helpers/sdk-naming.helper.js +197 -0
  16. package/helpers/sdk-naming.helper.js.map +1 -0
  17. package/helpers/sdk-output.helper.d.ts +6 -0
  18. package/helpers/sdk-output.helper.js +84 -0
  19. package/helpers/sdk-output.helper.js.map +1 -0
  20. package/helpers/shell.helper.d.ts +4 -0
  21. package/helpers/shell.helper.js +36 -0
  22. package/helpers/shell.helper.js.map +1 -1
  23. package/package.json +12 -10
  24. package/services/generate-proto.service.d.ts +1 -1
  25. package/services/generate-proto.service.js +7 -3
  26. package/services/generate-proto.service.js.map +1 -1
  27. package/services/go-sdk-generator.service.d.ts +26 -0
  28. package/services/go-sdk-generator.service.js +223 -0
  29. package/services/go-sdk-generator.service.js.map +1 -0
  30. package/services/protoc.service.d.ts +5 -0
  31. package/services/protoc.service.js +26 -0
  32. package/services/protoc.service.js.map +1 -0
  33. package/services/rust-sdk-generator.service.d.ts +24 -0
  34. package/services/rust-sdk-generator.service.js +197 -0
  35. package/services/rust-sdk-generator.service.js.map +1 -0
  36. package/services/sdk-descriptor.service.d.ts +13 -0
  37. package/services/sdk-descriptor.service.js +171 -0
  38. package/services/sdk-descriptor.service.js.map +1 -0
  39. package/templates/go/client.hbs +163 -0
  40. package/templates/go/enums.hbs +14 -0
  41. package/templates/go/errors.hbs +55 -0
  42. package/templates/go/go-mod.hbs +8 -0
  43. package/templates/rust/cargo-toml.hbs +13 -0
  44. package/templates/rust/client.hbs +90 -0
  45. package/templates/rust/enums.hbs +61 -0
  46. package/templates/rust/error.hbs +52 -0
  47. package/templates/rust/lib.hbs +17 -0
  48. package/types/sdk-build-config.type.d.ts +15 -0
  49. package/types/sdk-build-config.type.js +1 -1
  50. package/types/sdk-build-config.type.js.map +1 -1
  51. package/types/sdk-descriptor.type.d.ts +30 -0
  52. package/types/sdk-descriptor.type.js +2 -0
  53. package/types/sdk-descriptor.type.js.map +1 -0
package/README.md CHANGED
@@ -156,9 +156,14 @@ accepted):
156
156
  | `isArray` | Marks the field as repeated |
157
157
  | `required` | `false` makes the field optional in the proto and SDK |
158
158
  | `description` | Description used in documentation and the AI skill |
159
- | `format` | Refines numbers (`'int32'`, `'float'`, …) or marks a string as dynamic JSON (`'any'`) |
159
+ | `format` | Number type (`'int32'`, `'float'`, …; required for numbers) or `'any'` for dynamic JSON |
160
160
  | `enum` / `enumName` | Declares an enum field; `enumName` names the generated enum |
161
161
 
162
+ > **Upgrading:** a `number` property without a `format` now fails proto generation (`make-sdk` and `make:proto`) with
163
+ > the class and property name. Such a proto used `number` as a field type and could never be loaded, so only the error
164
+ > moved earlier. A numeric enum without a `format` (`@Property({ type: Number, enum, enumName })`, `@GrpcEnum`,
165
+ > `@GrpcEnums`) now defaults to `int32`.
166
+
162
167
  ### Dynamic (`any`) fields
163
168
 
164
169
  For values without a fixed schema, combine `format: 'any'` with `@AnyType`. The value is serialized to JSON on the wire
@@ -357,6 +362,194 @@ The generated package contains the proto file, a typed service class per microse
357
362
  module for registration, and a mock module for testing. It is published under the name and version from your
358
363
  `package.json`, and its method names, arguments, and response types match your service definitions exactly.
359
364
 
365
+ ### Generating Rust and Go SDKs
366
+
367
+ `make-sdk` can also build a Rust crate and a Go module from the same proto. Add a `rust` and/or `go` block to
368
+ `sdk-config.json`; the existing fields keep describing the TypeScript SDK.
369
+
370
+ ```json
371
+ {
372
+ "name": "sdkName",
373
+ "packageName": "@hodfords/package-name",
374
+ "output": "sdk",
375
+ "rust": {
376
+ "crateName": "sdk-name",
377
+ "version": "1.0.0",
378
+ "output": "../sdk-rust",
379
+ "build": true
380
+ },
381
+ "go": {
382
+ "module": "github.com/org/sdk-name-go",
383
+ "output": "../sdk-go",
384
+ "build": true
385
+ }
386
+ }
387
+ ```
388
+
389
+ | Field | Description |
390
+ | ---------------- | -------------------------------------------------------------------------------------- |
391
+ | `rust.crateName` | Crate name written to `Cargo.toml` |
392
+ | `rust.version` | Crate version. Defaults to `0.1.0` |
393
+ | `rust.output` | Output directory of the crate |
394
+ | `rust.build` | Run `cargo check` after generation and fail if it does not compile. Default `false` |
395
+ | `go.module` | Go module path written to `go.mod`. Go modules are versioned by git tag |
396
+ | `go.output` | Output directory of the module |
397
+ | `go.build` | Run `go build ./...` after generation and fail if it does not compile. Default `false` |
398
+
399
+ Without `--lang`, TypeScript is always built, plus Rust and Go when their block is present. Pass `--lang` to build one
400
+ language only (`ts`, `rust` or `go`):
401
+
402
+ ```shell
403
+ npm run wz-command make-sdk
404
+ npm run wz-command make-sdk -- --lang=rust
405
+ ```
406
+
407
+ The stubs are generated when you run `make-sdk`, so the machine that runs it needs `protoc` and the plugins below;
408
+ projects that consume the SDK do not. Building the Rust crate (`rust.build`) needs Rust 1.85 or newer, and building the
409
+ Go module (`go.build`) needs Go 1.23 or newer. With `rust.build` / `go.build` an older toolchain is reported as an
410
+ error; the check runs in the build step, after the files are written. `protoc` and the plugins are checked first:
411
+ when one is missing or has an unsupported version, `make-sdk` fails before any SDK, including the TypeScript one, is
412
+ written, and the error lists every missing tool.
413
+
414
+ ```shell
415
+ brew install protobuf # Debian/Ubuntu: apt-get install -y protobuf-compiler libprotobuf-dev
416
+ cargo install protoc-gen-prost@0.4.0 --locked
417
+ cargo install protoc-gen-tonic@0.4.1 --locked
418
+ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.6
419
+ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1
420
+ ```
421
+
422
+ The output directory is never wiped. Only the generated paths are replaced (`Cargo.toml`, `microservice.proto` and
423
+ `src/` for Rust; `go.mod`, `microservice.proto`, `pb/`, `client.go`, `errors.go` and `enums.go` for Go), so the
424
+ directory can be its own git repository. Each run generates the proto, the stubs and the wrapper in a temporary
425
+ directory next to the output and replaces the generated paths only when all of that succeeded, so a failure while
426
+ generating leaves the previous SDK as it was. Formatting, `go mod tidy` and the optional `rust.build` / `go.build`
427
+ compile run after the replacement, so a failure there leaves the newly generated files in place.
428
+ An output may not be the working directory or any of its parent directories,
429
+ and may not be shared with, nested inside, or contain the TypeScript `output` / `outputBuild` or the other SDK's output
430
+ (the TypeScript generator deletes its directories on every run); a sibling directory such as `../sdk-go` is fine.
431
+ `rust.crateName` and `go.module` are required for the languages being built.
432
+
433
+ After generation the output is formatted with `cargo fmt` / `gofmt`. If the formatter is missing or fails, a warning is
434
+ logged and generation still succeeds. `go.mod` and `Cargo.toml` are rewritten on every run, so dependencies, `replace`
435
+ lines or features added there by hand are lost. `go.sum` is kept, and `make-sdk` runs `go mod tidy` in the Go output
436
+ itself when Go 1.23 or newer is on PATH; otherwise, or when `go mod tidy` fails (for example without network), it logs a
437
+ warning and you need to run `go mod tidy` before the module builds. With `go.build` a failing `go mod tidy` is an error.
438
+
439
+ Each microservice gets a client whose methods return the unwrapped value: a list, a native value, or an optional
440
+ model instead of the wire envelope. Client and method names follow the language: `AppMicroserviceClient::find_many` in
441
+ Rust, `NewAppMicroserviceClient` and `FindMany` in Go.
442
+
443
+ ```rust
444
+ use sdk_name::{pb, AppMicroserviceClient, CallOptions, ClientOptions};
445
+
446
+ #[tokio::main]
447
+ async fn main() -> Result<(), Box<dyn std::error::Error>> {
448
+ let client = AppMicroserviceClient::connect("http://localhost:50059", ClientOptions::default()).await?;
449
+
450
+ let mut options = CallOptions::default();
451
+ options.metadata.insert("workspace-id", "workspace-1".parse()?);
452
+
453
+ let users: Vec<pb::UserResponse> = client.find_many(pb::FindManyDto::default(), options).await?;
454
+ println!("{} users", users.len());
455
+ Ok(())
456
+ }
457
+ ```
458
+
459
+ The crate root re-exports `pb`, `SdkError`, `SdkStream`, `ClientOptions`, `CallOptions` and every client; the enum
460
+ types live in `sdk_name::enums`. A crate name with hyphens is imported with underscores, and the consuming crate needs
461
+ `tokio` (with the `macros` and `rt-multi-thread` features) for the example above.
462
+
463
+ ```go
464
+ package main
465
+
466
+ import (
467
+ "context"
468
+ "errors"
469
+ "fmt"
470
+ "time"
471
+
472
+ "google.golang.org/grpc"
473
+ "google.golang.org/grpc/credentials/insecure"
474
+ "google.golang.org/grpc/metadata"
475
+
476
+ sdk "github.com/org/sdk-name-go"
477
+ "github.com/org/sdk-name-go/pb"
478
+ )
479
+
480
+ func main() {
481
+ conn, err := grpc.NewClient("localhost:50059", grpc.WithTransportCredentials(insecure.NewCredentials()))
482
+ if err != nil {
483
+ panic(err)
484
+ }
485
+ defer conn.Close()
486
+
487
+ client := sdk.NewAppMicroserviceClient(conn, sdk.WithTimeout(5*time.Second))
488
+ users, err := client.FindMany(context.Background(), &pb.FindManyDto{},
489
+ sdk.WithMetadata(metadata.Pairs("workspace-id", "workspace-1")))
490
+
491
+ var serviceErr *sdk.Error
492
+ if errors.As(err, &serviceErr) {
493
+ fmt.Println("business error", serviceErr.Code, serviceErr.Message)
494
+ return
495
+ }
496
+ if err != nil {
497
+ panic(err)
498
+ }
499
+ fmt.Println(len(users), "users")
500
+ }
501
+ ```
502
+
503
+ The Go package is named after the last segment of the module path, with characters that are not valid in an identifier
504
+ removed and the rest lower-cased (`github.com/org/sdk-name-go` becomes `sdknamego`), so import it with an alias as above.
505
+ A major-version suffix is skipped, as in Go (`github.com/org/sdk-go/v2` becomes `sdkgo`), and a name that is a Go
506
+ keyword gets an `sdk` suffix (`github.com/org/user-sdk/go` becomes `gosdk`).
507
+ `WithMetadata` can be passed to a constructor (as a default) and to a call; a later value for the same key replaces the
508
+ earlier one, and keys are lower-cased.
509
+
510
+ Business errors (gRPC `ABORTED` carrying `{ message, code, errors }`) become `SdkError::Service` in Rust and
511
+ `*sdk.Error` in Go; every other status is returned unchanged. A client-side timeout is reported as `DEADLINE_EXCEEDED`
512
+ in both languages. In Rust the timeout of a streaming call bounds only the wait for the first response (the response
513
+ headers), not the whole stream; in Go it bounds the whole stream.
514
+
515
+ Streaming methods return `SdkStream<T>` in Rust (a pinned, boxed `tokio_stream::Stream` of `Result<T, SdkError>`) and
516
+ `*Stream[T]` in Go. In Go, `Recv` returns `io.EOF` when the server has finished, and `Close` must be called when you stop
517
+ reading early.
518
+
519
+ Differences from the TypeScript SDK:
520
+
521
+ - Methods take the whole request message. `@SdkFlattenParams` and `@GrpcId`-style parameters are not flattened into
522
+ arguments.
523
+ - Enum fields keep their wire type (string or integer). The allowed values are generated in `enums.rs` (Rust enums with
524
+ `value()` / `as_str()` and `from_value()` helpers) and `enums.go` (typed constants). An enum that cannot be rendered
525
+ safely — member names that collide or are empty once converted, mixed string and number values, a non-integer,
526
+ out-of-int32-range or repeated value, or `type: Number` with non-numeric values — is left out of both files with a
527
+ warning.
528
+ - `format: 'any'` fields are JSON strings; encode and decode them yourself.
529
+ - Metadata parameters (`@GrpcMetadata`, `@GrpcMetadataId`) are set through the per-call metadata option. The generated
530
+ doc comment of each method lists the keys the server reads.
531
+ - A primitive response declared nullable returns the primitive type; it cannot express "no value". When Rust or Go is
532
+ built, `make-sdk` logs a warning for every rpc that declares one.
533
+ - There is no mock client and no AI skill file.
534
+ - `Number` responses (`@ResponseModel(Number)`) are `f32` in Rust and `float32` in Go, because the proto carries them as
535
+ `float`.
536
+ - A `number` property must declare a `format` (`int32`, `int64`, `float` or `double`) in every SDK; `make-sdk` and
537
+ `make:proto` fail with the class and property name otherwise. A numeric enum (`@Property` with `enum` / `enumName`,
538
+ `@GrpcEnum`, `@GrpcEnums`) without a `format` defaults to `int32`.
539
+ - Rust method and enum variant names that are keywords follow prost / tonic: an rpc `move` is `r#move`, and an enum
540
+ member `SELF` is the variant `Self_`. An rpc whose Rust name is `connect`, `new`, `with_origin`,
541
+ `with_interceptor`, `send_compressed`, `accept_compressed`, `max_decoding_message_size` or
542
+ `max_encoding_message_size` clashes with methods of the client or of tonic's generated client and fails generation;
543
+ rename it.
544
+
545
+ #### Trying the Rust and Go SDKs
546
+
547
+ The repository has a runnable example for each language: `pnpm run build:sample-sdk:native` generates both SDKs from
548
+ the `sample` app using `sample/sdk-config.native.json` (it also rewrites the TypeScript SDK in `sdk/`; add `--lang go`
549
+ or `--lang rust` to build one language), and the consumers call every rpc of the sample server and print the results.
550
+ Follow [`sample/consumer-go/README.md`](sample/consumer-go/README.md) or
551
+ [`sample/consumer-rust/README.md`](sample/consumer-rust/README.md) for the prerequisites, commands and expected output.
552
+
360
553
  ### Generating only the proto file
361
554
 
362
555
  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"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAOtB,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,WAAW;IACxC,MAAM;QACT,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,UAAU,GAAG,iBAAiB,CAAC;QACnC,CAAC;QAID,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,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,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC7C,CAAC;CACJ,CAAA;AAdY,kBAAkB;IAL9B,OAAO,CAAC;QACL,SAAS,EAAE,uBAAu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C,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
- type: getEnumType(option.enum),
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
- type: getEnumType(option.enum),
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,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AS,CAAC;QACb,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC;KAC5D,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,QAAQ;IACpB,OAAO,SAAS,CAAC;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 apiOptions = isEnumProperty(option)
8
- ? { ...option }
9
- : { ...option, type: convertProtoTypeToSwagger(option) };
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,C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AM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;QACpE,IAAI,MAAM,IAAI,QAAQ,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACvC,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC;QAC5B,CAAC;QAMD,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,yBAAyB,CAAC,MAAM,CAAC,EAAE,CAAC;QACnG,WAAW,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAE9C,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,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,GAAG,SAAS,CAAC;QAC5B,CAAC;QAGD,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,EAAE,OAAO,KAAK,KAAK,EAAE,CAAC;YACxD,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC;QACxB,CAAC;QAED,oBAAoB,CAAC,MAAM,CAAC,WAAW,EAAE,YAAsB,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC,CAAC;AACN,CAAC"}
@@ -1,4 +1,5 @@
1
- import { SdkBuildConfigType } from '../types/sdk-build-config.type.js';
2
- export declare function generateSdk(config: SdkBuildConfigType): void;
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
5
  export declare function generateDocumentService(packageName: string): import("../types/document.type.js").DocumentType;
@@ -1,8 +1,61 @@
1
+ import { Logger } from '@nestjs/common';
2
+ import { GenerateDocumentService } from '../services/generate-document.service.js';
1
3
  import { GenerateMicroserviceService } from '../services/generate-microservice.service.js';
2
4
  import { GenerateProtoService } from '../services/generate-proto.service.js';
3
- import { GenerateDocumentService } from '../services/generate-document.service.js';
4
- export function generateSdk(config) {
5
- new GenerateMicroserviceService(config).generate();
5
+ import { GoSdkGeneratorService } from '../services/go-sdk-generator.service.js';
6
+ import { ProtocService } from '../services/protoc.service.js';
7
+ import { RustSdkGeneratorService } from '../services/rust-sdk-generator.service.js';
8
+ import { SdkDescriptorService } from '../services/sdk-descriptor.service.js';
9
+ import { SDK_LANGUAGES } from '../types/sdk-build-config.type.js';
10
+ import { assertSdkOutputs } from './sdk-output.helper.js';
11
+ export function resolveSdkLanguages(config, languages) {
12
+ if (!languages?.length) {
13
+ return SDK_LANGUAGES.filter((language) => language === 'ts' || Boolean(config[language]));
14
+ }
15
+ for (const language of languages) {
16
+ if (!SDK_LANGUAGES.includes(language)) {
17
+ throw new Error(`Unknown SDK language "${language}". Use ts, rust or go.`);
18
+ }
19
+ }
20
+ return languages;
21
+ }
22
+ function warnNullablePrimitives(descriptor) {
23
+ const logger = new Logger('GenerateSdk');
24
+ for (const service of descriptor.services) {
25
+ for (const method of service.methods) {
26
+ if (method.isNullablePrimitive) {
27
+ logger.warn(`${service.name}.${method.name} declares a nullable primitive response. The proto cannot carry ` +
28
+ `"no value" for it, so the Rust and Go SDKs return the primitive type.`);
29
+ }
30
+ }
31
+ }
32
+ }
33
+ function assertSdkTools(targets) {
34
+ const tools = new Set([
35
+ ...(targets.includes('rust') ? RustSdkGeneratorService.requiredTools : []),
36
+ ...(targets.includes('go') ? GoSdkGeneratorService.requiredTools : [])
37
+ ]);
38
+ if (tools.size) {
39
+ new ProtocService().assertTools([...tools]);
40
+ }
41
+ }
42
+ export function generateSdk(config, languages) {
43
+ const targets = resolveSdkLanguages(config, languages);
44
+ assertSdkOutputs(config, targets);
45
+ assertSdkTools(targets);
46
+ const descriptor = targets.includes('rust') || targets.includes('go') ? new SdkDescriptorService().describe() : undefined;
47
+ if (descriptor) {
48
+ warnNullablePrimitives(descriptor);
49
+ }
50
+ if (targets.includes('ts')) {
51
+ new GenerateMicroserviceService(config).generate();
52
+ }
53
+ if (targets.includes('rust')) {
54
+ new RustSdkGeneratorService(config).generate(descriptor);
55
+ }
56
+ if (targets.includes('go')) {
57
+ new GoSdkGeneratorService(config).generate(descriptor);
58
+ }
6
59
  }
7
60
  export function generateProtoService(packageName, dirPath) {
8
61
  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,0CAA0C,CAAC;AAGnF,MAAM,UAAU,WAAW,CAAC,MAA0B;IAClD,IAAI,2BAA2B,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,WAAmB,EAAE,OAAe;IACrE,IAAI,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,WAAmB;IACvD,OAAO,IAAI,uBAAuB,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC/D,CAAC"}
1
+ {"version":3,"file":"generate.helper.js","sourceRoot":"","sources":["../../../lib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AAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,IAAI,2BAA2B,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvD,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC3D,CAAC;AACL,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,WAAmB,EAAE,OAAe;IACrE,IAAI,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,WAAmB;IACvD,OAAO,IAAI,uBAAuB,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC/D,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;