From d205e91e672c4a1237c5db4b5784b60ce4bb21b6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 11 Jun 2026 13:49:37 +0000 Subject: [PATCH] [1.x] Publish packages --- .changeset/proud-queens-pull.md | 24 --------------- .changeset/regenerate-nodes-package.md | 17 ----------- .changeset/tough-cats-strive.md | 11 ------- .changeset/wise-otters-hum.md | 7 ----- packages/cli/package.json | 2 +- .../dynamic-address-resolution/package.json | 2 +- packages/dynamic-client/package.json | 2 +- packages/dynamic-codecs/package.json | 2 +- packages/dynamic-instructions/package.json | 2 +- packages/dynamic-parsers/package.json | 2 +- packages/errors/CHANGELOG.md | 7 +++++ packages/errors/package.json | 2 +- packages/fragments/package.json | 2 +- packages/library/CHANGELOG.md | 11 +++++++ packages/library/package.json | 2 +- packages/node-types/CHANGELOG.md | 29 +++++++++++++++++++ packages/node-types/package.json | 2 +- packages/nodes-from-anchor/CHANGELOG.md | 28 ++++++++++++++++++ packages/nodes-from-anchor/package.json | 2 +- packages/nodes/CHANGELOG.md | 22 ++++++++++++++ packages/nodes/package.json | 2 +- packages/renderers-core/CHANGELOG.md | 10 +++++++ packages/renderers-core/package.json | 2 +- packages/validators/CHANGELOG.md | 9 ++++++ packages/validators/package.json | 2 +- packages/visitors-core/CHANGELOG.md | 29 +++++++++++++++++++ packages/visitors-core/package.json | 2 +- packages/visitors/CHANGELOG.md | 9 ++++++ packages/visitors/package.json | 2 +- 29 files changed, 170 insertions(+), 75 deletions(-) delete mode 100644 .changeset/proud-queens-pull.md delete mode 100644 .changeset/regenerate-nodes-package.md delete mode 100644 .changeset/tough-cats-strive.md delete mode 100644 .changeset/wise-otters-hum.md diff --git a/.changeset/proud-queens-pull.md b/.changeset/proud-queens-pull.md deleted file mode 100644 index a4be3e555..000000000 --- a/.changeset/proud-queens-pull.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -'@codama/node-types': minor -'@codama/nodes-from-anchor': patch ---- - -Regenerate the entire `@codama/node-types` source surface from the encoded `@codama/spec` description, via the new private `@codama-internal/spec-generators` package. - -The bulk of the surface lives under `src/generated/` and is produced by the `gen-ts-node-types` generator from the spec. The previously hand-maintained interfaces are gone; every node, union, enumeration, and per-spec shared type is rebuilt from the spec on every `pnpm generate` run. - -A small set of static helpers — the brand types, the `Docs` alias, and the `Version` template-literal type — live as hand-written sibling files at the top of `packages/node-types/src/`, alongside the existing `ProgramVersion` deprecated alias. They are imported by the generated surface but never regenerated, since their content doesn't depend on the spec. The generator wipes only `src/generated/` on every run; hand-written content at the top level survives. The per-spec `CodamaVersion` literal stays generated, in its own `src/generated/shared/codamaVersion.ts` file pinned to the spec version at generation time. - -Most of the rebuild is structural: imports now point at per-file paths (`./linkNodes/PdaLinkNode`) instead of subdirectory barrels, every interface and field carries a JSDoc block sourced from the spec, and array fields are emitted as `Array` rather than `T[]` so an inline-union element type doesn't need extra parentheses to preserve precedence. A handful of named API differences also shake out from this: - -- `accountNode.size` is now typed as `number | undefined` (the previous `| null` arm had no consumer and is dropped). -- `programNode.origin` is now typed as the named `ProgramOrigin` union (`'anchor' | 'shank'`) instead of an inline literal union. -- `instructionAccountNode.isSigner` and `instructionRemainingAccountsNode.isSigner` now read `boolean | 'either'` instead of `true | false | 'either'` (a TypeScript-only readability normalisation; the encoded spec keeps the explicit `true | false` form so other codegen targets can still emit a multi-variant enum). -- `numberTypeNode.format` and `stringTypeNode.encoding` are emitted as named `NumberFormat` / `BytesEncoding` aliases imported from `./shared/`, with the same generic-narrowing behaviour preserved. -- `programNode.version` is now typed as the unified `Version` template-literal alias (`` `${number}.${number}.${number}` ``) — a tighter shape than the previous plain string, so non-conforming literal strings will now surface as TypeScript errors at the call site. The historical `ProgramVersion` name is preserved as a hand-written `@deprecated` re-export so existing consumers continue to compile; `@codama/nodes-from-anchor` is updated to import `Version` directly. -- `docs?` fields use a `Docs = Array` alias mirroring the `'docs'` `TypeExpr` kind in `@codama/spec`. The alias is hand-written and lives at `packages/node-types/src/Docs.ts`. -- Documentation strings that ship as multiple paragraphs in the spec now render as multi-paragraph JSDoc blocks. Affected fields and types include `accountNode.discriminators`, `instructionNode.discriminators`, `instructionAccountNode.isSigner`, `instructionRemainingAccountsNode.isSigner`, `rootNode`, the `ConditionalValueNode` interface and its `condition`, `InstructionInputValueNode`, `ResolverValueNode`, `AmountTypeNode` and its `unit`, `MapTypeNode.size`, `NestedTypeNode`, `StringTypeNode.size`, `EnumValueNode.value`, and `NumberValueNode.number`. - -Alongside the per-node interfaces, the package now exports seven `RegisteredNode` category-registry unions (`RegisteredContextualValueNode`, `RegisteredCountNode`, `RegisteredDiscriminatorNode`, `RegisteredLinkNode`, `RegisteredPdaSeedNode`, `RegisteredTypeNode`, `RegisteredValueNode`) corresponding one-to-one with `@codama/spec`'s category registries, plus a `GetNodeFromKind` helper that resolves to the concrete interface for a given kind. The registry unions are the recommended extension point for downstream packages that need to introduce custom node kinds. - -The generator consumes `@codama/spec@1.6.0-rc.4`, which reshapes the spec into per-category groups (`spec.categories[]`) and renames the `nestedTypeNode` `TypeExpr` kind to `nestedUnion` (with an explicit `alias` field). All `docs?` fields throughout the spec are arrays of paragraph strings rather than single newline-separated strings — the renderer accepts the array shape directly. Internally, the generator's renderers are layout-agnostic: they emit `use(...)` calls keyed by symbolic module strings (e.g. `'node:numberTypeNode'`, `'enumeration:Endianness'`, `'brand:CamelCaseString'`), and a single per-spec `RenderScope` resolves those symbolic keys to concrete file locations at write time. Adding a new file kind to the generator means extending the `RenderScope` symbol map; renderers themselves stay free of file-layout knowledge. diff --git a/.changeset/regenerate-nodes-package.md b/.changeset/regenerate-nodes-package.md deleted file mode 100644 index 0ba72ec59..000000000 --- a/.changeset/regenerate-nodes-package.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -'@codama/nodes': minor -'@codama/visitors-core': patch ---- - -Regenerate the `xxxNodeInput` types and `xxxNode()` constructors of `@codama/nodes` from the encoded `@codama/spec` description, via a new `nodes` generator inside `@codama-internal/spec-generators`. The runtime `*_NODE_KINDS` arrays (`STANDALONE_TYPE_NODE_KINDS`, `REGISTERED_VALUE_NODE_KINDS`, `INSTRUCTION_INPUT_VALUE_NODE_KINDS`, …, and the top-level `REGISTERED_NODE_KINDS`) are now generated from the spec's union definitions instead of being maintained by hand. A new top-level `CODAMA_VERSION` constant, typed as `CodamaVersion` and pinned to the spec version at generation time, is the single source of truth for the version `@codama/nodes` was built against — `rootNode()` reads it directly when tagging the document. - -The bulk of the surface lives under `packages/nodes/src/generated/` and is produced on every `pnpm generate` run. The previously hand-maintained constructors and kinds-arrays are gone; only hand-written helpers (`isNode`, `assertIsNode`, `getAllPrograms`, `getAllInstructions`, `getAllInstructionsWithSubs`, `isScalarEnum`, `isDataEnum`, `isSignedInteger`, the `NestedTypeNode` resolvers, `parseOptionalAccountStrategy`, the legacy `constantValueNodeFromString` / `constantPdaSeedNodeFromString` flavours, etc.) survive at the top of `packages/nodes/src/`. The package's `index.ts` re-exports the generated tree alongside them. - -Two intentional behaviour changes shake out of the rebuild: - -- **`docs` is now omitted entirely from the encoded shape when it would be empty.** Constructors that accept a `docs?: DocsInput` parameter previously emitted `docs: []` on the frozen node when the caller said nothing about docs; they now drop the `docs` key altogether. This matches the Rust side, keeps absent documentation out of serialised IDLs, and aligns with the `docs?: Docs` optional field already declared by `@codama/node-types`. `removeDocsVisitor` in `@codama/visitors-core` is updated to delete the `docs` key rather than blank it to `[]`, following the same convention. -- **`rootNode().version` now reflects the spec version `@codama/nodes` was generated against, not the runtime package version.** The constructor previously read the `__VERSION__` build-time global injected from the package's `npm_package_version`; it now reads the generated `CODAMA_VERSION` constant. In practice the two have always tracked the same release cadence so the change is invisible at HEAD, but it makes the architectural intent explicit: the version pinned in the IDL is the spec version, not the package version. The `__VERSION__` build-time global and its `packages/nodes/src/types/global.d.ts` declaration are removed accordingly. - -The legacy plural-noun constants (`TYPE_NODES`, `VALUE_NODES`, `CONTEXTUAL_VALUE_NODES`, `INSTRUCTION_INPUT_VALUE_NODES`, `COUNT_NODES`, `DISCRIMINATOR_NODES`, `LINK_NODES`, `PDA_SEED_NODES`, `ENUM_VARIANT_TYPE_NODES`) are preserved as alias re-exports of the new canonical `*_NODE_KINDS` names. - -The generator drives almost entirely from the spec, with a minimal per-node configuration table carrying only the conveniences the spec can't express: which spec attributes appear as bare positional parameters (the rest land in a trailing `options` bag), and per-attribute overrides for defaulted values, string-coercion patterns on link targets, and the handful of bespoke body expressions (`instructionByteDeltaNode.withHeader`). The renderer derives signature shapes, generic parameters, return types, the `XxxNodeInput` declarations, the `Partial<>` wrapping decision, the `name: string` relaxation, the `docs?: DocsInput` / drop-if-empty handling, and the conditional-spread of optional attributes from the spec directly. An auto-import scan walks each rendered file and pulls in any spec or hand-written identifier the source references, so the configuration never declares imports. Generic-parameter lifting and ordering rely on the same `narrowableDataAttributes` + `genericParamOrder` tables the `nodeTypes` generator uses, keeping the constructor's generics in lockstep with the interface's. diff --git a/.changeset/tough-cats-strive.md b/.changeset/tough-cats-strive.md deleted file mode 100644 index 462a4e53e..000000000 --- a/.changeset/tough-cats-strive.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -'@codama/visitors-core': minor ---- - -Regenerate `identityVisitor` and `mergeVisitor` from `@codama/spec` via the new `visitorsCore` generator in `@codama-internal/spec-generators`. Both visitors previously lived as ~1100 lines of hand-written per-node dispatch; the mechanical walk now lives under `src/generated/`. `src/identityVisitor.ts` is now a thin wrapper layering six semantic overrides (enum-variant empty-downgrade, hidden-prefix/suffix empty-bypass, conditional-value null-collapse, resolver empty-dependsOn collapse) via `extendVisitor`; `src/mergeVisitor.ts` ships directly from the generated tree. - -Three behaviour changes shake out: - -- **`enumTypeNode.size` and `pdaValueNode.programId` are now actually walked by `identityVisitor`.** The hand-written code passed both through unchanged, silently dropping any caller-applied transforms. -- **Every required-array child attribute now uniformly tolerates `undefined` at runtime.** The hand-written guard previously applied only to `programNode.events` and `programNode.constants`. Making it uniform lets `identityVisitor` safely normalise a partial IDL JSON parsed via `createFromJson`. A follow-up PR will promote the affected `programNode` children to `optionalAttribute(...)` on the spec side, after which the guard becomes naturally derivable from the spec. -- **`enumStructVariantTypeNode.discriminator` and `enumTupleVariantTypeNode.discriminator` are now preserved** when the variant survives the wrapper's empty-downgrade. diff --git a/.changeset/wise-otters-hum.md b/.changeset/wise-otters-hum.md deleted file mode 100644 index 62db58e7f..000000000 --- a/.changeset/wise-otters-hum.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@codama/node-types': patch ---- - -Bump `@codama/spec` from `1.6.0-rc.4` to `1.6.0-rc.6`. The encoded surface in `@codama/node-types` is functionally unchanged; one docstring paragraph on `NestedTypeNode` now reads `nestedTypeNode` instead of `NestedTypeNode` to mirror the spec's new camelCase nested-union alias name. - -Behind the scenes, `@codama-internal/spec-generators` learns about the new `{ kind: 'address' }` `TypeExpr` (rendered as plain `string` on the v1 TS surface — a dedicated `Address` brand may follow in a future spec major), the camelCase rename of every union and enumeration name on the spec side (the generated PascalCase TS identifiers are unaffected since the generator runs each name through `pascalCase()` at render time), and a constructor-signature bug where an attribute that was both `optional` and supplied with a default would emit invalid TS (`param?: T = default`). The bug never triggered against the rc.4 v1 spec but would have surfaced once any future attribute combined `optional: true` with a configured default; the fix is to omit the `?` mark whenever an initializer is present. diff --git a/packages/cli/package.json b/packages/cli/package.json index e4877fd20..734430a39 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@codama/cli", - "version": "1.5.2", + "version": "1.5.3", "description": "A CLI for setting up and managing Codama IDLs", "exports": { "types": "./dist/types/index.d.ts", diff --git a/packages/dynamic-address-resolution/package.json b/packages/dynamic-address-resolution/package.json index 03365a4a2..a7f04a416 100644 --- a/packages/dynamic-address-resolution/package.json +++ b/packages/dynamic-address-resolution/package.json @@ -1,6 +1,6 @@ { "name": "@codama/dynamic-address-resolution", - "version": "0.2.0", + "version": "0.2.1", "description": "Address resolution functionality for instruction accounts in Codama IDLs", "exports": { "types": "./dist/types/index.d.ts", diff --git a/packages/dynamic-client/package.json b/packages/dynamic-client/package.json index 23d5dddba..c921fccf3 100644 --- a/packages/dynamic-client/package.json +++ b/packages/dynamic-client/package.json @@ -1,6 +1,6 @@ { "name": "@codama/dynamic-client", - "version": "0.1.1", + "version": "0.1.2", "description": "Client to dynamically interact with Solana programs using Codama IDLs", "license": "MIT", "repository": { diff --git a/packages/dynamic-codecs/package.json b/packages/dynamic-codecs/package.json index 198dbcb0d..cfd1bfa57 100644 --- a/packages/dynamic-codecs/package.json +++ b/packages/dynamic-codecs/package.json @@ -1,6 +1,6 @@ { "name": "@codama/dynamic-codecs", - "version": "1.2.1", + "version": "1.2.2", "description": "Get codecs on demand for Codama IDLs", "exports": { "types": "./dist/types/index.d.ts", diff --git a/packages/dynamic-instructions/package.json b/packages/dynamic-instructions/package.json index 7e4b7267d..8fc435c72 100644 --- a/packages/dynamic-instructions/package.json +++ b/packages/dynamic-instructions/package.json @@ -1,6 +1,6 @@ { "name": "@codama/dynamic-instructions", - "version": "0.2.0", + "version": "0.2.1", "description": "Runtime instruction creation for Codama IDLs", "exports": { ".": { diff --git a/packages/dynamic-parsers/package.json b/packages/dynamic-parsers/package.json index 0ef1c6b7f..98aaadc8a 100644 --- a/packages/dynamic-parsers/package.json +++ b/packages/dynamic-parsers/package.json @@ -1,6 +1,6 @@ { "name": "@codama/dynamic-parsers", - "version": "1.2.1", + "version": "1.2.2", "description": "Helpers to dynamically identify and parse accounts and instructions", "exports": { "types": "./dist/types/index.d.ts", diff --git a/packages/errors/CHANGELOG.md b/packages/errors/CHANGELOG.md index 5a8fe0e11..58e738296 100644 --- a/packages/errors/CHANGELOG.md +++ b/packages/errors/CHANGELOG.md @@ -1,5 +1,12 @@ # @codama/errors +## 1.8.0 + +### Patch Changes + +- Updated dependencies [[`2f7c443`](https://github.com/codama-idl/codama/commit/2f7c44377520fdb512de7d25b74a03ffd8c1a491), [`8667174`](https://github.com/codama-idl/codama/commit/8667174aabec62aed0a6a11822a87e66c9720246)]: + - @codama/node-types@1.8.0 + ## 1.7.0 ### Patch Changes diff --git a/packages/errors/package.json b/packages/errors/package.json index 3ab92600c..6db76bb54 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -1,6 +1,6 @@ { "name": "@codama/errors", - "version": "1.7.0", + "version": "1.8.0", "description": "Error management for Codama", "exports": { "types": "./dist/types/index.d.ts", diff --git a/packages/fragments/package.json b/packages/fragments/package.json index 0726ee388..64a778688 100644 --- a/packages/fragments/package.json +++ b/packages/fragments/package.json @@ -1,6 +1,6 @@ { "name": "@codama/fragments", - "version": "0.1.0", + "version": "0.1.1", "description": "Composable code-generation fragments and language-aware import maps for Codama renderers", "exports": { ".": { diff --git a/packages/library/CHANGELOG.md b/packages/library/CHANGELOG.md index a7a616306..4fbb7e1bb 100644 --- a/packages/library/CHANGELOG.md +++ b/packages/library/CHANGELOG.md @@ -1,5 +1,16 @@ # codama +## 1.8.0 + +### Patch Changes + +- Updated dependencies [[`0b3a781`](https://github.com/codama-idl/codama/commit/0b3a781c024b27397e17ad456f039f76382cb519)]: + - @codama/nodes@1.8.0 + - @codama/errors@1.8.0 + - @codama/cli@1.5.3 + - @codama/validators@1.8.0 + - @codama/visitors@1.8.0 + ## 1.7.0 ### Patch Changes diff --git a/packages/library/package.json b/packages/library/package.json index c4e0a6bd4..a4d32c616 100644 --- a/packages/library/package.json +++ b/packages/library/package.json @@ -1,6 +1,6 @@ { "name": "codama", - "version": "1.7.0", + "version": "1.8.0", "description": "A Solana framework for building standardised programs", "exports": { "types": "./dist/types/index.d.ts", diff --git a/packages/node-types/CHANGELOG.md b/packages/node-types/CHANGELOG.md index 605c965b1..c98e2608a 100644 --- a/packages/node-types/CHANGELOG.md +++ b/packages/node-types/CHANGELOG.md @@ -1,5 +1,34 @@ # @codama/node-types +## 1.8.0 + +### Minor Changes + +- [#995](https://github.com/codama-idl/codama/pull/995) [`2f7c443`](https://github.com/codama-idl/codama/commit/2f7c44377520fdb512de7d25b74a03ffd8c1a491) Thanks [@lorisleiva](https://github.com/lorisleiva)! - Regenerate the entire `@codama/node-types` source surface from the encoded `@codama/spec` description, via the new private `@codama-internal/spec-generators` package. + + The bulk of the surface lives under `src/generated/` and is produced by the `gen-ts-node-types` generator from the spec. The previously hand-maintained interfaces are gone; every node, union, enumeration, and per-spec shared type is rebuilt from the spec on every `pnpm generate` run. + + A small set of static helpers — the brand types, the `Docs` alias, and the `Version` template-literal type — live as hand-written sibling files at the top of `packages/node-types/src/`, alongside the existing `ProgramVersion` deprecated alias. They are imported by the generated surface but never regenerated, since their content doesn't depend on the spec. The generator wipes only `src/generated/` on every run; hand-written content at the top level survives. The per-spec `CodamaVersion` literal stays generated, in its own `src/generated/shared/codamaVersion.ts` file pinned to the spec version at generation time. + + Most of the rebuild is structural: imports now point at per-file paths (`./linkNodes/PdaLinkNode`) instead of subdirectory barrels, every interface and field carries a JSDoc block sourced from the spec, and array fields are emitted as `Array` rather than `T[]` so an inline-union element type doesn't need extra parentheses to preserve precedence. A handful of named API differences also shake out from this: + - `accountNode.size` is now typed as `number | undefined` (the previous `| null` arm had no consumer and is dropped). + - `programNode.origin` is now typed as the named `ProgramOrigin` union (`'anchor' | 'shank'`) instead of an inline literal union. + - `instructionAccountNode.isSigner` and `instructionRemainingAccountsNode.isSigner` now read `boolean | 'either'` instead of `true | false | 'either'` (a TypeScript-only readability normalisation; the encoded spec keeps the explicit `true | false` form so other codegen targets can still emit a multi-variant enum). + - `numberTypeNode.format` and `stringTypeNode.encoding` are emitted as named `NumberFormat` / `BytesEncoding` aliases imported from `./shared/`, with the same generic-narrowing behaviour preserved. + - `programNode.version` is now typed as the unified `Version` template-literal alias (`` `${number}.${number}.${number}` ``) — a tighter shape than the previous plain string, so non-conforming literal strings will now surface as TypeScript errors at the call site. The historical `ProgramVersion` name is preserved as a hand-written `@deprecated` re-export so existing consumers continue to compile; `@codama/nodes-from-anchor` is updated to import `Version` directly. + - `docs?` fields use a `Docs = Array` alias mirroring the `'docs'` `TypeExpr` kind in `@codama/spec`. The alias is hand-written and lives at `packages/node-types/src/Docs.ts`. + - Documentation strings that ship as multiple paragraphs in the spec now render as multi-paragraph JSDoc blocks. Affected fields and types include `accountNode.discriminators`, `instructionNode.discriminators`, `instructionAccountNode.isSigner`, `instructionRemainingAccountsNode.isSigner`, `rootNode`, the `ConditionalValueNode` interface and its `condition`, `InstructionInputValueNode`, `ResolverValueNode`, `AmountTypeNode` and its `unit`, `MapTypeNode.size`, `NestedTypeNode`, `StringTypeNode.size`, `EnumValueNode.value`, and `NumberValueNode.number`. + + Alongside the per-node interfaces, the package now exports seven `RegisteredNode` category-registry unions (`RegisteredContextualValueNode`, `RegisteredCountNode`, `RegisteredDiscriminatorNode`, `RegisteredLinkNode`, `RegisteredPdaSeedNode`, `RegisteredTypeNode`, `RegisteredValueNode`) corresponding one-to-one with `@codama/spec`'s category registries, plus a `GetNodeFromKind` helper that resolves to the concrete interface for a given kind. The registry unions are the recommended extension point for downstream packages that need to introduce custom node kinds. + + The generator consumes `@codama/spec@1.6.0-rc.4`, which reshapes the spec into per-category groups (`spec.categories[]`) and renames the `nestedTypeNode` `TypeExpr` kind to `nestedUnion` (with an explicit `alias` field). All `docs?` fields throughout the spec are arrays of paragraph strings rather than single newline-separated strings — the renderer accepts the array shape directly. Internally, the generator's renderers are layout-agnostic: they emit `use(...)` calls keyed by symbolic module strings (e.g. `'node:numberTypeNode'`, `'enumeration:Endianness'`, `'brand:CamelCaseString'`), and a single per-spec `RenderScope` resolves those symbolic keys to concrete file locations at write time. Adding a new file kind to the generator means extending the `RenderScope` symbol map; renderers themselves stay free of file-layout knowledge. + +### Patch Changes + +- [#1001](https://github.com/codama-idl/codama/pull/1001) [`8667174`](https://github.com/codama-idl/codama/commit/8667174aabec62aed0a6a11822a87e66c9720246) Thanks [@lorisleiva](https://github.com/lorisleiva)! - Bump `@codama/spec` from `1.6.0-rc.4` to `1.6.0-rc.6`. The encoded surface in `@codama/node-types` is functionally unchanged; one docstring paragraph on `NestedTypeNode` now reads `nestedTypeNode` instead of `NestedTypeNode` to mirror the spec's new camelCase nested-union alias name. + + Behind the scenes, `@codama-internal/spec-generators` learns about the new `{ kind: 'address' }` `TypeExpr` (rendered as plain `string` on the v1 TS surface — a dedicated `Address` brand may follow in a future spec major), the camelCase rename of every union and enumeration name on the spec side (the generated PascalCase TS identifiers are unaffected since the generator runs each name through `pascalCase()` at render time), and a constructor-signature bug where an attribute that was both `optional` and supplied with a default would emit invalid TS (`param?: T = default`). The bug never triggered against the rc.4 v1 spec but would have surfaced once any future attribute combined `optional: true` with a configured default; the fix is to omit the `?` mark whenever an initializer is present. + ## 1.7.0 ### Minor Changes diff --git a/packages/node-types/package.json b/packages/node-types/package.json index 22ab87d4e..1b28c331c 100644 --- a/packages/node-types/package.json +++ b/packages/node-types/package.json @@ -1,6 +1,6 @@ { "name": "@codama/node-types", - "version": "1.7.0", + "version": "1.8.0", "description": "Node specifications for the Codama standard", "exports": { "types": "./dist/types/index.d.ts", diff --git a/packages/nodes-from-anchor/CHANGELOG.md b/packages/nodes-from-anchor/CHANGELOG.md index f7d1f5990..ddaeb0f2d 100644 --- a/packages/nodes-from-anchor/CHANGELOG.md +++ b/packages/nodes-from-anchor/CHANGELOG.md @@ -1,5 +1,33 @@ # @codama/nodes-from-anchor +## 1.5.1 + +### Patch Changes + +- [#995](https://github.com/codama-idl/codama/pull/995) [`2f7c443`](https://github.com/codama-idl/codama/commit/2f7c44377520fdb512de7d25b74a03ffd8c1a491) Thanks [@lorisleiva](https://github.com/lorisleiva)! - Regenerate the entire `@codama/node-types` source surface from the encoded `@codama/spec` description, via the new private `@codama-internal/spec-generators` package. + + The bulk of the surface lives under `src/generated/` and is produced by the `gen-ts-node-types` generator from the spec. The previously hand-maintained interfaces are gone; every node, union, enumeration, and per-spec shared type is rebuilt from the spec on every `pnpm generate` run. + + A small set of static helpers — the brand types, the `Docs` alias, and the `Version` template-literal type — live as hand-written sibling files at the top of `packages/node-types/src/`, alongside the existing `ProgramVersion` deprecated alias. They are imported by the generated surface but never regenerated, since their content doesn't depend on the spec. The generator wipes only `src/generated/` on every run; hand-written content at the top level survives. The per-spec `CodamaVersion` literal stays generated, in its own `src/generated/shared/codamaVersion.ts` file pinned to the spec version at generation time. + + Most of the rebuild is structural: imports now point at per-file paths (`./linkNodes/PdaLinkNode`) instead of subdirectory barrels, every interface and field carries a JSDoc block sourced from the spec, and array fields are emitted as `Array` rather than `T[]` so an inline-union element type doesn't need extra parentheses to preserve precedence. A handful of named API differences also shake out from this: + - `accountNode.size` is now typed as `number | undefined` (the previous `| null` arm had no consumer and is dropped). + - `programNode.origin` is now typed as the named `ProgramOrigin` union (`'anchor' | 'shank'`) instead of an inline literal union. + - `instructionAccountNode.isSigner` and `instructionRemainingAccountsNode.isSigner` now read `boolean | 'either'` instead of `true | false | 'either'` (a TypeScript-only readability normalisation; the encoded spec keeps the explicit `true | false` form so other codegen targets can still emit a multi-variant enum). + - `numberTypeNode.format` and `stringTypeNode.encoding` are emitted as named `NumberFormat` / `BytesEncoding` aliases imported from `./shared/`, with the same generic-narrowing behaviour preserved. + - `programNode.version` is now typed as the unified `Version` template-literal alias (`` `${number}.${number}.${number}` ``) — a tighter shape than the previous plain string, so non-conforming literal strings will now surface as TypeScript errors at the call site. The historical `ProgramVersion` name is preserved as a hand-written `@deprecated` re-export so existing consumers continue to compile; `@codama/nodes-from-anchor` is updated to import `Version` directly. + - `docs?` fields use a `Docs = Array` alias mirroring the `'docs'` `TypeExpr` kind in `@codama/spec`. The alias is hand-written and lives at `packages/node-types/src/Docs.ts`. + - Documentation strings that ship as multiple paragraphs in the spec now render as multi-paragraph JSDoc blocks. Affected fields and types include `accountNode.discriminators`, `instructionNode.discriminators`, `instructionAccountNode.isSigner`, `instructionRemainingAccountsNode.isSigner`, `rootNode`, the `ConditionalValueNode` interface and its `condition`, `InstructionInputValueNode`, `ResolverValueNode`, `AmountTypeNode` and its `unit`, `MapTypeNode.size`, `NestedTypeNode`, `StringTypeNode.size`, `EnumValueNode.value`, and `NumberValueNode.number`. + + Alongside the per-node interfaces, the package now exports seven `RegisteredNode` category-registry unions (`RegisteredContextualValueNode`, `RegisteredCountNode`, `RegisteredDiscriminatorNode`, `RegisteredLinkNode`, `RegisteredPdaSeedNode`, `RegisteredTypeNode`, `RegisteredValueNode`) corresponding one-to-one with `@codama/spec`'s category registries, plus a `GetNodeFromKind` helper that resolves to the concrete interface for a given kind. The registry unions are the recommended extension point for downstream packages that need to introduce custom node kinds. + + The generator consumes `@codama/spec@1.6.0-rc.4`, which reshapes the spec into per-category groups (`spec.categories[]`) and renames the `nestedTypeNode` `TypeExpr` kind to `nestedUnion` (with an explicit `alias` field). All `docs?` fields throughout the spec are arrays of paragraph strings rather than single newline-separated strings — the renderer accepts the array shape directly. Internally, the generator's renderers are layout-agnostic: they emit `use(...)` calls keyed by symbolic module strings (e.g. `'node:numberTypeNode'`, `'enumeration:Endianness'`, `'brand:CamelCaseString'`), and a single per-spec `RenderScope` resolves those symbolic keys to concrete file locations at write time. Adding a new file kind to the generator means extending the `RenderScope` symbol map; renderers themselves stay free of file-layout knowledge. + +- Updated dependencies [[`0b3a781`](https://github.com/codama-idl/codama/commit/0b3a781c024b27397e17ad456f039f76382cb519)]: + - @codama/nodes@1.8.0 + - @codama/errors@1.8.0 + - @codama/visitors@1.8.0 + ## 1.5.0 ### Minor Changes diff --git a/packages/nodes-from-anchor/package.json b/packages/nodes-from-anchor/package.json index 5c2adf10b..c0a8c8c0e 100644 --- a/packages/nodes-from-anchor/package.json +++ b/packages/nodes-from-anchor/package.json @@ -1,6 +1,6 @@ { "name": "@codama/nodes-from-anchor", - "version": "1.5.0", + "version": "1.5.1", "description": "Node specifications and helpers for the Codama standard", "exports": { "types": "./dist/types/index.d.ts", diff --git a/packages/nodes/CHANGELOG.md b/packages/nodes/CHANGELOG.md index e24e6e91e..bf61528bf 100644 --- a/packages/nodes/CHANGELOG.md +++ b/packages/nodes/CHANGELOG.md @@ -1,5 +1,27 @@ # @codama/nodes +## 1.8.0 + +### Minor Changes + +- [#997](https://github.com/codama-idl/codama/pull/997) [`0b3a781`](https://github.com/codama-idl/codama/commit/0b3a781c024b27397e17ad456f039f76382cb519) Thanks [@lorisleiva](https://github.com/lorisleiva)! - Regenerate the `xxxNodeInput` types and `xxxNode()` constructors of `@codama/nodes` from the encoded `@codama/spec` description, via a new `nodes` generator inside `@codama-internal/spec-generators`. The runtime `*_NODE_KINDS` arrays (`STANDALONE_TYPE_NODE_KINDS`, `REGISTERED_VALUE_NODE_KINDS`, `INSTRUCTION_INPUT_VALUE_NODE_KINDS`, …, and the top-level `REGISTERED_NODE_KINDS`) are now generated from the spec's union definitions instead of being maintained by hand. A new top-level `CODAMA_VERSION` constant, typed as `CodamaVersion` and pinned to the spec version at generation time, is the single source of truth for the version `@codama/nodes` was built against — `rootNode()` reads it directly when tagging the document. + + The bulk of the surface lives under `packages/nodes/src/generated/` and is produced on every `pnpm generate` run. The previously hand-maintained constructors and kinds-arrays are gone; only hand-written helpers (`isNode`, `assertIsNode`, `getAllPrograms`, `getAllInstructions`, `getAllInstructionsWithSubs`, `isScalarEnum`, `isDataEnum`, `isSignedInteger`, the `NestedTypeNode` resolvers, `parseOptionalAccountStrategy`, the legacy `constantValueNodeFromString` / `constantPdaSeedNodeFromString` flavours, etc.) survive at the top of `packages/nodes/src/`. The package's `index.ts` re-exports the generated tree alongside them. + + Two intentional behaviour changes shake out of the rebuild: + - **`docs` is now omitted entirely from the encoded shape when it would be empty.** Constructors that accept a `docs?: DocsInput` parameter previously emitted `docs: []` on the frozen node when the caller said nothing about docs; they now drop the `docs` key altogether. This matches the Rust side, keeps absent documentation out of serialised IDLs, and aligns with the `docs?: Docs` optional field already declared by `@codama/node-types`. `removeDocsVisitor` in `@codama/visitors-core` is updated to delete the `docs` key rather than blank it to `[]`, following the same convention. + - **`rootNode().version` now reflects the spec version `@codama/nodes` was generated against, not the runtime package version.** The constructor previously read the `__VERSION__` build-time global injected from the package's `npm_package_version`; it now reads the generated `CODAMA_VERSION` constant. In practice the two have always tracked the same release cadence so the change is invisible at HEAD, but it makes the architectural intent explicit: the version pinned in the IDL is the spec version, not the package version. The `__VERSION__` build-time global and its `packages/nodes/src/types/global.d.ts` declaration are removed accordingly. + + The legacy plural-noun constants (`TYPE_NODES`, `VALUE_NODES`, `CONTEXTUAL_VALUE_NODES`, `INSTRUCTION_INPUT_VALUE_NODES`, `COUNT_NODES`, `DISCRIMINATOR_NODES`, `LINK_NODES`, `PDA_SEED_NODES`, `ENUM_VARIANT_TYPE_NODES`) are preserved as alias re-exports of the new canonical `*_NODE_KINDS` names. + + The generator drives almost entirely from the spec, with a minimal per-node configuration table carrying only the conveniences the spec can't express: which spec attributes appear as bare positional parameters (the rest land in a trailing `options` bag), and per-attribute overrides for defaulted values, string-coercion patterns on link targets, and the handful of bespoke body expressions (`instructionByteDeltaNode.withHeader`). The renderer derives signature shapes, generic parameters, return types, the `XxxNodeInput` declarations, the `Partial<>` wrapping decision, the `name: string` relaxation, the `docs?: DocsInput` / drop-if-empty handling, and the conditional-spread of optional attributes from the spec directly. An auto-import scan walks each rendered file and pulls in any spec or hand-written identifier the source references, so the configuration never declares imports. Generic-parameter lifting and ordering rely on the same `narrowableDataAttributes` + `genericParamOrder` tables the `nodeTypes` generator uses, keeping the constructor's generics in lockstep with the interface's. + +### Patch Changes + +- Updated dependencies [[`2f7c443`](https://github.com/codama-idl/codama/commit/2f7c44377520fdb512de7d25b74a03ffd8c1a491), [`8667174`](https://github.com/codama-idl/codama/commit/8667174aabec62aed0a6a11822a87e66c9720246)]: + - @codama/node-types@1.8.0 + - @codama/errors@1.8.0 + ## 1.7.0 ### Minor Changes diff --git a/packages/nodes/package.json b/packages/nodes/package.json index b24a20960..4b251ee7d 100644 --- a/packages/nodes/package.json +++ b/packages/nodes/package.json @@ -1,6 +1,6 @@ { "name": "@codama/nodes", - "version": "1.7.0", + "version": "1.8.0", "description": "Node specifications and helpers for the Codama standard", "exports": { "types": "./dist/types/index.d.ts", diff --git a/packages/renderers-core/CHANGELOG.md b/packages/renderers-core/CHANGELOG.md index 7169d86ca..1f066b8ba 100644 --- a/packages/renderers-core/CHANGELOG.md +++ b/packages/renderers-core/CHANGELOG.md @@ -1,5 +1,15 @@ # @codama/renderers-core +## 1.3.9 + +### Patch Changes + +- Updated dependencies [[`0b3a781`](https://github.com/codama-idl/codama/commit/0b3a781c024b27397e17ad456f039f76382cb519), [`b1f6a75`](https://github.com/codama-idl/codama/commit/b1f6a75d9ff3a176c8977c6f9938b8a703bbad71)]: + - @codama/nodes@1.8.0 + - @codama/visitors-core@1.8.0 + - @codama/errors@1.8.0 + - @codama/fragments@0.1.1 + ## 1.3.8 ### Patch Changes diff --git a/packages/renderers-core/package.json b/packages/renderers-core/package.json index 92e7232f0..1c24ed2e2 100644 --- a/packages/renderers-core/package.json +++ b/packages/renderers-core/package.json @@ -1,6 +1,6 @@ { "name": "@codama/renderers-core", - "version": "1.3.8", + "version": "1.3.9", "description": "Core types and helpers for Codama renderers to use", "exports": { "types": "./dist/types/index.d.ts", diff --git a/packages/validators/CHANGELOG.md b/packages/validators/CHANGELOG.md index 14188b674..35e0446b5 100644 --- a/packages/validators/CHANGELOG.md +++ b/packages/validators/CHANGELOG.md @@ -1,5 +1,14 @@ # @codama/validators +## 1.8.0 + +### Patch Changes + +- Updated dependencies [[`0b3a781`](https://github.com/codama-idl/codama/commit/0b3a781c024b27397e17ad456f039f76382cb519), [`b1f6a75`](https://github.com/codama-idl/codama/commit/b1f6a75d9ff3a176c8977c6f9938b8a703bbad71)]: + - @codama/nodes@1.8.0 + - @codama/visitors-core@1.8.0 + - @codama/errors@1.8.0 + ## 1.7.0 ### Patch Changes diff --git a/packages/validators/package.json b/packages/validators/package.json index d2950857d..64d0a3699 100644 --- a/packages/validators/package.json +++ b/packages/validators/package.json @@ -1,6 +1,6 @@ { "name": "@codama/validators", - "version": "1.7.0", + "version": "1.8.0", "description": "Validator visitors for the Codama framework", "exports": { "types": "./dist/types/index.d.ts", diff --git a/packages/visitors-core/CHANGELOG.md b/packages/visitors-core/CHANGELOG.md index db1116ce3..2299dde0a 100644 --- a/packages/visitors-core/CHANGELOG.md +++ b/packages/visitors-core/CHANGELOG.md @@ -1,5 +1,34 @@ # @codama/visitors-core +## 1.8.0 + +### Minor Changes + +- [#1000](https://github.com/codama-idl/codama/pull/1000) [`b1f6a75`](https://github.com/codama-idl/codama/commit/b1f6a75d9ff3a176c8977c6f9938b8a703bbad71) Thanks [@lorisleiva](https://github.com/lorisleiva)! - Regenerate `identityVisitor` and `mergeVisitor` from `@codama/spec` via the new `visitorsCore` generator in `@codama-internal/spec-generators`. Both visitors previously lived as ~1100 lines of hand-written per-node dispatch; the mechanical walk now lives under `src/generated/`. `src/identityVisitor.ts` is now a thin wrapper layering six semantic overrides (enum-variant empty-downgrade, hidden-prefix/suffix empty-bypass, conditional-value null-collapse, resolver empty-dependsOn collapse) via `extendVisitor`; `src/mergeVisitor.ts` ships directly from the generated tree. + + Three behaviour changes shake out: + - **`enumTypeNode.size` and `pdaValueNode.programId` are now actually walked by `identityVisitor`.** The hand-written code passed both through unchanged, silently dropping any caller-applied transforms. + - **Every required-array child attribute now uniformly tolerates `undefined` at runtime.** The hand-written guard previously applied only to `programNode.events` and `programNode.constants`. Making it uniform lets `identityVisitor` safely normalise a partial IDL JSON parsed via `createFromJson`. A follow-up PR will promote the affected `programNode` children to `optionalAttribute(...)` on the spec side, after which the guard becomes naturally derivable from the spec. + - **`enumStructVariantTypeNode.discriminator` and `enumTupleVariantTypeNode.discriminator` are now preserved** when the variant survives the wrapper's empty-downgrade. + +### Patch Changes + +- [#997](https://github.com/codama-idl/codama/pull/997) [`0b3a781`](https://github.com/codama-idl/codama/commit/0b3a781c024b27397e17ad456f039f76382cb519) Thanks [@lorisleiva](https://github.com/lorisleiva)! - Regenerate the `xxxNodeInput` types and `xxxNode()` constructors of `@codama/nodes` from the encoded `@codama/spec` description, via a new `nodes` generator inside `@codama-internal/spec-generators`. The runtime `*_NODE_KINDS` arrays (`STANDALONE_TYPE_NODE_KINDS`, `REGISTERED_VALUE_NODE_KINDS`, `INSTRUCTION_INPUT_VALUE_NODE_KINDS`, …, and the top-level `REGISTERED_NODE_KINDS`) are now generated from the spec's union definitions instead of being maintained by hand. A new top-level `CODAMA_VERSION` constant, typed as `CodamaVersion` and pinned to the spec version at generation time, is the single source of truth for the version `@codama/nodes` was built against — `rootNode()` reads it directly when tagging the document. + + The bulk of the surface lives under `packages/nodes/src/generated/` and is produced on every `pnpm generate` run. The previously hand-maintained constructors and kinds-arrays are gone; only hand-written helpers (`isNode`, `assertIsNode`, `getAllPrograms`, `getAllInstructions`, `getAllInstructionsWithSubs`, `isScalarEnum`, `isDataEnum`, `isSignedInteger`, the `NestedTypeNode` resolvers, `parseOptionalAccountStrategy`, the legacy `constantValueNodeFromString` / `constantPdaSeedNodeFromString` flavours, etc.) survive at the top of `packages/nodes/src/`. The package's `index.ts` re-exports the generated tree alongside them. + + Two intentional behaviour changes shake out of the rebuild: + - **`docs` is now omitted entirely from the encoded shape when it would be empty.** Constructors that accept a `docs?: DocsInput` parameter previously emitted `docs: []` on the frozen node when the caller said nothing about docs; they now drop the `docs` key altogether. This matches the Rust side, keeps absent documentation out of serialised IDLs, and aligns with the `docs?: Docs` optional field already declared by `@codama/node-types`. `removeDocsVisitor` in `@codama/visitors-core` is updated to delete the `docs` key rather than blank it to `[]`, following the same convention. + - **`rootNode().version` now reflects the spec version `@codama/nodes` was generated against, not the runtime package version.** The constructor previously read the `__VERSION__` build-time global injected from the package's `npm_package_version`; it now reads the generated `CODAMA_VERSION` constant. In practice the two have always tracked the same release cadence so the change is invisible at HEAD, but it makes the architectural intent explicit: the version pinned in the IDL is the spec version, not the package version. The `__VERSION__` build-time global and its `packages/nodes/src/types/global.d.ts` declaration are removed accordingly. + + The legacy plural-noun constants (`TYPE_NODES`, `VALUE_NODES`, `CONTEXTUAL_VALUE_NODES`, `INSTRUCTION_INPUT_VALUE_NODES`, `COUNT_NODES`, `DISCRIMINATOR_NODES`, `LINK_NODES`, `PDA_SEED_NODES`, `ENUM_VARIANT_TYPE_NODES`) are preserved as alias re-exports of the new canonical `*_NODE_KINDS` names. + + The generator drives almost entirely from the spec, with a minimal per-node configuration table carrying only the conveniences the spec can't express: which spec attributes appear as bare positional parameters (the rest land in a trailing `options` bag), and per-attribute overrides for defaulted values, string-coercion patterns on link targets, and the handful of bespoke body expressions (`instructionByteDeltaNode.withHeader`). The renderer derives signature shapes, generic parameters, return types, the `XxxNodeInput` declarations, the `Partial<>` wrapping decision, the `name: string` relaxation, the `docs?: DocsInput` / drop-if-empty handling, and the conditional-spread of optional attributes from the spec directly. An auto-import scan walks each rendered file and pulls in any spec or hand-written identifier the source references, so the configuration never declares imports. Generic-parameter lifting and ordering rely on the same `narrowableDataAttributes` + `genericParamOrder` tables the `nodeTypes` generator uses, keeping the constructor's generics in lockstep with the interface's. + +- Updated dependencies [[`0b3a781`](https://github.com/codama-idl/codama/commit/0b3a781c024b27397e17ad456f039f76382cb519)]: + - @codama/nodes@1.8.0 + - @codama/errors@1.8.0 + ## 1.7.0 ### Minor Changes diff --git a/packages/visitors-core/package.json b/packages/visitors-core/package.json index 55291e627..885f4eaa2 100644 --- a/packages/visitors-core/package.json +++ b/packages/visitors-core/package.json @@ -1,6 +1,6 @@ { "name": "@codama/visitors-core", - "version": "1.7.0", + "version": "1.8.0", "description": "Core visitors for the Codama framework", "exports": { "types": "./dist/types/index.d.ts", diff --git a/packages/visitors/CHANGELOG.md b/packages/visitors/CHANGELOG.md index 705a35dd9..865789cda 100644 --- a/packages/visitors/CHANGELOG.md +++ b/packages/visitors/CHANGELOG.md @@ -1,5 +1,14 @@ # @codama/visitors +## 1.8.0 + +### Patch Changes + +- Updated dependencies [[`0b3a781`](https://github.com/codama-idl/codama/commit/0b3a781c024b27397e17ad456f039f76382cb519), [`b1f6a75`](https://github.com/codama-idl/codama/commit/b1f6a75d9ff3a176c8977c6f9938b8a703bbad71)]: + - @codama/nodes@1.8.0 + - @codama/visitors-core@1.8.0 + - @codama/errors@1.8.0 + ## 1.7.0 ### Patch Changes diff --git a/packages/visitors/package.json b/packages/visitors/package.json index 1d6f8fcec..822231ca5 100644 --- a/packages/visitors/package.json +++ b/packages/visitors/package.json @@ -1,6 +1,6 @@ { "name": "@codama/visitors", - "version": "1.7.0", + "version": "1.8.0", "description": "All visitors for the Codama framework", "exports": { "types": "./dist/types/index.d.ts",