Skip to content

Migrate protobuf layer to @teslemetry/tesla-protocol (ts-proto API)#4

Merged
Bre77 merged 1 commit into
mainfrom
fm/nlib-proto-migrate
Jul 22, 2026
Merged

Migrate protobuf layer to @teslemetry/tesla-protocol (ts-proto API)#4
Bre77 merged 1 commit into
mainfrom
fm/nlib-proto-migrate

Conversation

@Bre77

@Bre77 Bre77 commented Jul 22, 2026

Copy link
Copy Markdown
Member

What

  • Replace the bundled src/pb2/* protobuf types + google-protobuf runtime with the published @teslemetry/tesla-protocol package.
    • @teslemetry/tesla-protocol is ts-proto generated: plain-object messages with Type.create() / Type.encode().finish() / Type.decode(), not google-protobuf's .setX()/.serializeBinary() classes.
    • The only real protobuf call site in the library is Session in src/vehiclesigned.ts (builds/tags the HMAC-personalized signature for signed commands); it's ported to the new API and HMAC_Personalized_Signature_Data is now HMACPersonalizedSignatureData from @teslemetry/tesla-protocol/command/signatures.
    • src/pb2/* and the google-protobuf/ts-protoc-gen dependencies are removed.
  • Fix three pre-existing bugs that left the repo unable to build or typecheck at all (found while reproducing a green build for this migration, all from the same "loadPrivateKey" commit):
    • src/vehiclesigned.ts had a stray closing brace that ended the VehicleSigned class early, leaving every command method declared outside any class.
    • src/teslafleetapi.ts had an unbalanced brace in loadPrivateKey, leaving TeslaFleetApi's class body unclosed.
    • src/vehiclesigned.ts and src/vehiclespecific.ts imported FleetTelemetryConfig from a ./types/fleet_telemetry_config.js module that doesn't exist (the type actually lives in ./types/commands.js); once the import path was fixed, a second latent bug surfaced where the wrapper type ({ vins, config }) was used in place of just its config field.
  • Add moduleResolution: NodeNext alongside module: NodeNext in tsconfig.json. Without it, TypeScript's classic resolution can't see the exports map that scoped packages like @teslemetry/tesla-protocol (and even @types/node's own internals) gate their subpath types behind, so nothing in node_modules resolved.
  • Bump typescript/@types/node to versions whose Uint8Array typings are generic, matching what @teslemetry/tesla-protocol's own @bufbuild/protobuf runtime dependency expects.

No public API or behavior change - this is an internal proto-source swap. pnpm install (which runs tsc via prepare) and npx tsc --noEmit are both clean; there's no test suite in this repo yet.

…y/tesla-protocol

Ports the Session HMAC signing code (the only real protobuf call site) from
google-protobuf's setter API to tesla-protocol's ts-proto-generated
create/encode/decode API, and removes src/pb2 and google-protobuf. Also fixes
three pre-existing bugs (two unbalanced-brace syntax errors and a bad import
path) and a missing tsconfig moduleResolution setting that left the repo
unable to build or typecheck at all.
@Bre77
Bre77 merged commit 3d7075e into main Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant