[RFC] @alchemy/data-apis MVP — Data SDK vertical slice#2539
Closed
blakecduncan wants to merge 6 commits into
Closed
[RFC] @alchemy/data-apis MVP — Data SDK vertical slice#2539blakecduncan wants to merge 6 commits into
blakecduncan wants to merge 6 commits into
Conversation
…nnels Vertical-slice prototype of the Data SDK architecture: - 3 actions, one per seam: portfolio.getTokensByAddress (REST, multi-network body via AlchemyRestClient), nft.getNftsForOwner (REST, network-scoped URL with per-request override), transfers.getAssetTransfers (JSON-RPC over AlchemyTransport, override via derived transport instance) - dataActions decorator + createAlchemyDataClient convenience wrapper - common: resolveNetwork accepting viem Chain | slug | CAIP-2, derived from the existing daikon-generated ALCHEMY_RPC_MAPPING; AlchemyRestClient exported See packages/data/README.md for scope and deliberate omissions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Matches the wallet-apis package naming standard. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
14-test script covering all three methods (portfolio, nft, transfers), all three network input formats (viem Chain, slug, CAIP-2), per-request network overrides, and the raw decorator path — all verified green. Run with: ALCHEMY_API_KEY=<key> pnpm --filter @alchemy/data-apis smoke-test Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Package is already namespaced to Alchemy; the prefix is redundant. Mirrors the wallet-apis pattern of dropping the brand prefix from the factory function name. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds @alchemy/api-codegen (private workspace package) implementing the two-stage pipeline from the data SDK codegen plan: - snapshot (network): bundles specs from a local docs checkout using the docs repo's own tooling (redocly / generate:rpc), commits them under specs/ with a lockfile pinning the docs commit SHA + sha256 checksums - generate (offline, deterministic): emits committed TypeScript into packages/data-apis/src/generated — openapi-typescript output + RestRequestSchema entries for REST, json-schema-to-typescript params/ result types + viem RpcSchema entries for OpenRPC The hand-maintained codegen.manifest.ts maps spec operations to the generated surface; a renamed/removed spec operation hard-fails generate (drift alarm), uncovered operations are reported for visibility. data-apis schema/rest.ts, schema/rpc.ts, and types.ts are now thin hand-reviewed aliases over generated internals. Runtime action code is untouched; public types adopt spec-accurate optionality (transfers/ ownedNfts/totalCount/category optional) and richer fields. The spec's "Not Found (null)" string result branch is deliberately collapsed. Repo wiring: turbo generate task (was referenced by root scripts but undefined), nx generate outputs, prettier/eslint handling (generated files carry a file-level eslint-disable and are self-formatted with the repo prettier config; spec snapshots are ignored). Verified: 15 generator unit tests, 4 data-apis unit tests, build + typecheck clean, pnpm generate idempotent, 14/14 live smoke tests pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jun 10, 2026
Collaborator
Author
|
Superseded by #2541. This RFC did its job: it proved the actions architecture and the codegen pipeline, and the coupling analysis it enabled is what made the standalone-core pivot (decision doc) a bounded refactor instead of a rewrite. The viem decorator pattern explored here lives on as the parked /viem adapter. |
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.
What
A vertical-slice prototype of the Data SDK (
@alchemy/data-apis) to prove the architecture discussed in #tx-eng before scaling to the full v1 surface (Portfolio, Prices, NFT, Token, Transfers). Not intended to merge as-is — this is the concrete artifact for the direction discussion.One action per architectural seam:
portfolio.getTokensByAddressapi.g.alchemy.com/data/v1AlchemyRestClient; networks are payload, client chain uninvolvednft.getNftsForOwner{network}.g.alchemy.com/nft/v3networkoverride with client default fallbacktransfers.getAssetTransfersAlchemyTransportclient.transport.configTwo equivalent entry points (tested):
Network identity (the thread's three-format proposal, working)
resolveNetwork()in@alchemy/commonaccepts a viemChain, an Alchemy slug ("eth-mainnet"), or CAIP-2 ("eip155:1","solana:mainnet"). The slug ↔ chain-ID maps are derived from the existing daikon-generatedALCHEMY_RPC_MAPPING— no second registry, no new exported chain objects. The proper version is a ws-tools generator change emitting{ slug, chainId, caip2 }entries + a generatedKnownAlchemyNetworkunion.Codegen: type internals generated from the docs specs
@alchemy/api-codegen(private workspace package) implements a two-stage pipeline:snapshot(network, run rarely): bundles specs from a localalchemyplatform/docscheckout using the docs repo's own tooling (redocly for OpenAPI, itsgenerate:rpcfor OpenRPC), commits the bundled JSON underspecs/with a lockfile pinning the docs commit SHA + sha256 checksums.generate(offline, deterministic,pnpm generate): emits committed TypeScript intopackages/data-apis/src/generated— openapi-typescript output +RestRequestSchemaentries for REST; json-schema-to-typescript params/results + viemRpcSchemaentries for OpenRPC.The hand-maintained
codegen.manifest.tsmaps spec operations → SDK surface; a renamed/removed spec operation hard-fails generation (drift alarm), uncovered spec operations are reported (new-endpoint visibility). Public types intypes.tsare hand-reviewed aliases over generated internals — generated names never leak into the semver surface.pnpm generate && git diff --exit-codeis CI-gate-ready (not wired into workflows in this PR).Deliberate public-type deltas from generating (spec-accurate):
transfers/ownedNfts/totalCount/categorybecame optional (specs declare norequiredlists); portfolio tokens gained spec fields (e.g.error); the spec's"Not Found (null)"string result branch on transfers is collapsed away.@alchemy/common changes
networks/networkRegistry.ts—resolveNetwork+ network input typesAlchemyRestClientexported (built for signer v5, previously unexported)Deliberately out of scope (tracked in the data SDK scope plan)
Open questions for reviewers
{apiKey}path segments accordingly.)createDataClientlives here long-term or gets re-exported from a future top-levelalchemypackage.@alchemy/api-specsto npm (mirrors@alchemy/wallet-api-types)? The snapshot stage swaps sources cleanly if so.Test plan
packages/api-codegen: 15 unit tests (fixture-driven: path normalization, REST/RPC emitters, manifest drift hard-errors)packages/data-apis: 4 unit tests (stubbed fetch) covering all three actions through both entry pointspackages/common: 6resolveNetworktests; full common suite passespnpm generateidempotent (run twice → no diff); snapshot deterministic; build + typecheck cleanscripts/smoke-test.ts): 14/14 pass against the real API on the generated internals — all three methods, all three network input formats, per-request overrides, raw decorator path🤖 Generated with Claude Code
PR-Codex overview
This PR introduces significant updates to the
@alchemy/api-codegenand@alchemy/data-apispackages, enhancing TypeScript configuration, adding autogenerated files, and refining the API client structure for better functionality and maintainability.Detailed summary
tsconfig.jsonfiles for TypeScript configuration.VERSIONexport insrc/version.ts.CodegenErrorclass for error handling.normalizePathfunction for path normalization.README.mdfiles.