Skip to content

feat(dynamic-client): types generation split [3]#25

Open
mikhd wants to merge 8 commits into
feat/pr3-typesgen-splitfrom
feat/pr3-typesgen-split-dev
Open

feat(dynamic-client): types generation split [3]#25
mikhd wants to merge 8 commits into
feat/pr3-typesgen-splitfrom
feat/pr3-typesgen-split-dev

Conversation

@mikhd
Copy link
Copy Markdown

@mikhd mikhd commented May 6, 2026

Description

This PR splits types generation among dynamic-instructions, dynamic-address-resolution, dynamic-client with slight commander template duplicated code overhead. Before this dynamic-client contained the whole types generation.

Changeset will be added to external PR to codama org.

Change

  • Moved type generation methods into aproppriate package. Exported by separate /codegen path.
  • Updated dynamic-client types generation.
  • Added minimal tests

Commands:

dynamic-address-resolution:

npx @codama/dynamic-address-resolution generate-types <path/to/idl.json> <output-dir>

dynamic-instructions:

npx @codama/dynamic-instructions generate-types <path/to/idl.json> <output-dir>

dynamic-client:

Unchanged. Same npx @codama/dynamic-instructions command

@mikhd mikhd requested a review from Copilot May 6, 2026 11:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR splits the type-generation logic that previously lived in @codama/dynamic-client into dedicated, reusable /codegen entrypoints for @codama/dynamic-address-resolution and @codama/dynamic-instructions, and adds CLIs for those packages to generate types directly from a Codama IDL JSON.

Changes:

  • Added @codama/dynamic-address-resolution/codegen utilities for generating PDA + instruction args/accounts/resolvers types and a shared “generate types from file” helper.
  • Added @codama/dynamic-instructions/codegen utilities for instruction builder maps + signer types, plus a new dynamic-instructions generate-types CLI.
  • Refactored @codama/dynamic-client generate-client-types to compose the new shared codegen utilities instead of duplicating generation logic.

Reviewed changes

Copilot reviewed 32 out of 35 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds commander to the relevant workspace importers for new CLIs.
packages/dynamic-instructions/tsup.config.ts Builds package + CLI + new node-only codegen entrypoints (CJS/ESM).
packages/dynamic-instructions/src/codegen/index.ts New public /codegen barrel exports for instruction type generation helpers.
packages/dynamic-instructions/src/codegen/generate-types.ts Generates a full instruction-types TS file by composing dar + signer + builder-map generators.
packages/dynamic-instructions/src/codegen/generate-signer-types.ts Generates per-instruction *Signers aliases for isSigner: 'either' accounts.
packages/dynamic-instructions/src/codegen/generate-instruction-builder.ts Generates ${Program}InstructionBuilders map typing for instruction builders.
packages/dynamic-instructions/src/cli/program.ts Adds commander program setup for the new dynamic-instructions CLI.
packages/dynamic-instructions/src/cli/index.ts Adds CLI entrypoint with “print help when no args” behavior.
packages/dynamic-instructions/src/cli/commands/index.ts Registers CLI subcommands.
packages/dynamic-instructions/src/cli/commands/generate-types/register-command.ts Adds generate-types CLI command definition and args.
packages/dynamic-instructions/src/cli/commands/generate-types/generate-types-from-file.ts Implements generate-types by delegating to shared dar file-based generator helper.
packages/dynamic-instructions/README.md Documents new CLI + programmatic @codama/dynamic-instructions/codegen usage.
packages/dynamic-instructions/package.json Exposes ./codegen export and ships a dynamic-instructions bin.
packages/dynamic-instructions/bin/cli.cjs Adds executable shim invoking built dist/cli.cjs.
packages/dynamic-client/src/cli/commands/generate-client-types/generate-client-types.ts Switches client type generation to reuse dar + instructions codegen helpers.
packages/dynamic-client/src/cli/commands/generate-client-types/generate-client-types-from-file.ts Refactors CLI file IO to use dar’s shared generateTypesFromFile.
packages/dynamic-address-resolution/tsup.config.ts Builds package + CLI + new node-only codegen entrypoints (CJS/ESM).
packages/dynamic-address-resolution/tsconfig.declarations.json Ensures /codegen types are included in declaration output.
packages/dynamic-address-resolution/src/codegen/is-account-auto-resolvable.ts Extracts account “auto-resolvable default” logic into shared codegen helper.
packages/dynamic-address-resolution/src/codegen/index.ts New public /codegen barrel exports for dar generators + helpers.
packages/dynamic-address-resolution/src/codegen/generate-types.ts Generates a full address-resolution types TS file (PDA + instruction types).
packages/dynamic-address-resolution/src/codegen/generate-types-from-file.ts Adds shared file-based generator helper (used by multiple CLIs).
packages/dynamic-address-resolution/src/codegen/generate-pda-types.ts Adds shared generator for PDA seed types + ${Program}Pdas map type.
packages/dynamic-address-resolution/src/codegen/generate-instruction-types.ts Adds shared generator for *Args/*Accounts/*Resolvers per-instruction types.
packages/dynamic-address-resolution/src/codegen/collect-resolver-names.ts Extracts resolver-name discovery into reusable helper.
packages/dynamic-address-resolution/src/codegen/collect-pda-nodes.ts Extracts PDA discovery logic into reusable helper.
packages/dynamic-address-resolution/src/codegen/codama-type-to-ts.ts Extracts Codama type → TS type-string conversion into reusable helper.
packages/dynamic-address-resolution/src/cli/program.ts Adds commander program setup for new dynamic-address-resolution CLI.
packages/dynamic-address-resolution/src/cli/index.ts Adds CLI entrypoint with “print help when no args” behavior.
packages/dynamic-address-resolution/src/cli/commands/index.ts Registers CLI subcommands.
packages/dynamic-address-resolution/src/cli/commands/generate-types/register-command.ts Adds generate-types command for address-resolution type generation.
packages/dynamic-address-resolution/src/cli/commands/generate-types/generate-types-from-file.ts Wires CLI command to codegen generator + shared file helper.
packages/dynamic-address-resolution/README.md Documents new CLI + programmatic @codama/dynamic-address-resolution/codegen usage.
packages/dynamic-address-resolution/package.json Exposes ./codegen export and ships a dynamic-address-resolution bin.
packages/dynamic-address-resolution/bin/cli.cjs Adds executable shim invoking built dist/cli.cjs.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/dynamic-address-resolution/src/codegen/generate-types-from-file.ts Outdated
@mikhd mikhd requested a review from Copilot May 6, 2026 11:37
@mikhd mikhd mentioned this pull request May 6, 2026
5 tasks
@mikhd mikhd changed the title feat: types generation split feat(dynamic-client): types generation split May 6, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 39 out of 42 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/dynamic-address-resolution/src/codegen/generate-types-from-file.ts Outdated
Comment thread packages/dynamic-address-resolution/README.md Outdated
@mikhd mikhd force-pushed the feat/pr3-typesgen-split-dev branch from 3868ea0 to 53fb415 Compare May 6, 2026 12:22
@mikhd mikhd requested a review from Copilot May 6, 2026 12:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 44 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/dynamic-address-resolution/src/codegen/generate-types-from-file.ts Outdated
@mikhd mikhd force-pushed the feat/pr3-typesgen-split-dev branch from 53fb415 to 668f763 Compare May 6, 2026 12:45
@mikhd mikhd requested a review from Copilot May 6, 2026 12:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 44 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@mikhd mikhd force-pushed the feat/pr3-typesgen-split-dev branch from 1e4d1bb to 6fa1fe3 Compare May 7, 2026 08:15
@mikhd mikhd self-assigned this May 7, 2026
@mikhd mikhd linked an issue May 7, 2026 that may be closed by this pull request
5 tasks
@mikhd mikhd marked this pull request as ready for review May 7, 2026 08:26
@mikhd mikhd requested review from askov and rogaldh May 7, 2026 08:26
@mikhd mikhd changed the title feat(dynamic-client): types generation split feat(dynamic-client): types generation split [3] May 7, 2026
@mikhd mikhd force-pushed the feat/pr3-typesgen-split-dev branch from 6fa1fe3 to 487a3d2 Compare May 12, 2026 08:53
@mikhd mikhd force-pushed the feat/pr3-typesgen-split branch from 4c96ab3 to 3e143c3 Compare May 12, 2026 08:53
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.

Feat: split dynamic-client

2 participants