@dcsv-io/d2-protos
v0.1.2
Published
<!-- Copyright (c) DCSV. Licensed under the Apache License, Version 2.0. -->
Readme
@dcsv-io/d2-protos
Buf-generated TS modules + gRPC client stubs from contracts/protos/.
Mirrors DcsvIo.D2.Protos (.NET — generated via Grpc.Tools at csproj
build time).
Install
pnpm add @dcsv-io/d2-protosPublic API
The package re-exports every generated module under src/generated/. The
generation workflow (Buf + ts-proto) runs via pnpm generate and writes
output that is committed to git so consumers don't need to run codegen on
first build. Each contracts/protos/{namespace}/v1/*.proto file
auto-generates into src/generated/{namespace}/v1/{name}.ts via the
build's generate step.
Current re-exports from src/index.ts:
| Export | Source file | Purpose |
| ------------------- | --------------------------------------- | ------------------------------------------------------------------------- |
| D2ResultProto | generated/common/v1/d2_result.ts | Full D2Result wire envelope (success, status, errorCode, category, …). |
| TKMessageProto | generated/common/v1/d2_result.ts | Translation-key message with map<string,string> params. |
| InputErrorProto | generated/common/v1/d2_result.ts | Field-level validation error: field name + TKMessageProto[] errors. |
The codec (d2ResultToProto / d2ResultFromProto / handleGrpcCall) that
converts between D2Result and D2ResultProto is host-supplied,
not here — this package is the generated-stub layer only.
Dependencies
@bufbuild/protobuf— runtime types for proto-generated code.@grpc/grpc-js— gRPC client transport.@bufbuild/buf(devDep) — codegen tooling.ts-proto(devDep) — protoc plugin emitting TS.
Generation workflow
pnpm --filter @dcsv-io/d2-protos generatebuf.gen.yaml configures ts-proto with these options:
esModuleInterop=true, outputServices=grpc-js, useExactTypes=false,
oneof=unions, useOptionals=messages. Output is per-file under
src/generated/{namespace}/v1/{name}.ts.
Parity with .NET
Every .proto file generates into BOTH:
- .NET:
DcsvIo.D2.Protos(viaGrpc.Tools+ csproj<Protobuf Include>) - TS:
@dcsv-io/d2-protos/src/generated/...(via Buf + ts-proto)
The contracts/protos/ directory is the single source of truth — neither
side hand-writes proto modules.
Edge cases
- Codegen idempotency: re-running
pnpm generateproduces zero diff if no.protochanges. Spec drift surfaces in PR review. - Generated code is committed to git so consumers don't pay a generate-on-first-build penalty.
- Generated code is excluded from coverage thresholds and from ESLint
formatting (lives in
src/generated/).
