feat(ts): ember-ts client — 65+ methods, full api parity - #309
Merged
Conversation
adds clients/ember-ts/ with Makefile, package.json, and tsconfig.json. wires the root Makefile proto-ts target to delegate to the new client Makefile, matching the proto-go and proto-py pattern. generates 160 TypeScript type definitions from ember.proto via @grpc/proto-loader's proto-loader-gen-types.
adds the hand-written layer on top of the generated proto stubs: - src/types.ts: all exported interfaces (ClientOptions, SetOptions, ScoreMember, VSimResult, ScanPage, HScanPage, ZScanPage, SScanPage, SlowLogEntry, SubscribeEvent, TimeResult, VGetResult, VInfoResult, etc.) - src/client.ts: EmberClient class with 65+ async methods covering strings, keys, lists, hashes, sets, sorted sets, vectors, pub/sub, server, and slowlog commands. subscribe() returns an AsyncIterable<SubscribeEvent> backed by a buffered promise queue so for-await works cleanly. - src/index.ts: re-exports EmberClient and all public types - README.md: full api table, quickstart, auth example, scan/leaderboard examples, and type reference - package.json: exports map, engines (>=18), files list (dist/ + proto/), keywords, @types/node devDep - Makefile: build target + proto copy step - proto/ember/v1/ember.proto: bundled copy so the package is self-contained without requiring the repo's proto/ directory zero tsc errors, builds cleanly with tsc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
the
ember-tspackage had 160 generated proto type definitions but zero hand-written code. this PR adds the client implementation and ships it as a production-quality npm package.src/types.ts— all exported user-facing interfaces:ClientOptions,SetOptions,GetExOptions,ScanOptions,ZAddOptions,ScoreMember,VSimResult,SlowLogEntry,SubscribeEvent,ScanPage,HScanPage,ZScanPage,SScanPage,TimeResult,VGetResult,VInfoResult, and moresrc/client.ts—EmberClientclass with 65+ async methods covering strings, keys, lists, hashes, sets, sorted sets, vectors, pub/sub, server, and slowlog commands.subscribe()returnsAsyncIterable<SubscribeEvent>backed by a buffered promise queue sofor awaitworks naturally without backpressure issuessrc/index.ts— clean re-export of the client and all public typesREADME.md— full api table (method, args, returns) for all 65+ methods, quickstart, auth example, scan iteration example, leaderboard example, and type referencepackage.json—exportsmap,engines: { node: ">=18" },files: ["dist/", "proto/"],@types/nodedev dep, keywordsMakefile— addedbuildtarget and proto copy stepproto/ember/v1/ember.proto— bundled inside the package so it is self-contained without requiring the repo'sproto/directory at runtimewhat was tested
npm install && npm run build— zero tsc errors, all 65+ methods compile cleanlydist/containsindex.js,index.d.ts,client.js,client.d.ts,types.js,types.d.tsproto/ember/v1/ember.protois present and loadable viapath.join(__dirname, '../proto/...')design considerations
proto bundling:
@grpc/proto-loaderrequires the.protofile on disk at runtime. rather than referencing../../proto/(which breaks once published to npm), the proto is copied intoproto/ember/v1/and loaded viapath.join(__dirname, '../proto/ember/v1/ember.proto')— works from bothsrc/(ts-node) anddist/(compiled).streaming: the
subscribe()method wraps the gRPC server-streaming call in a buffered async iterable. events that arrive before the caller callsnext()are queued; the iterator can be cancelled cleanly by breaking out offor awaitor callingreturn().api shape: follows the Go client conventions (Buffer instead of []byte, no context arg, option objects instead of variadic option functions) adapted to TypeScript idioms.