Skip to content

Commit 61ac0a6

Browse files
authored
Integrate @codama/spec@1.8.0 (#1023)
This PR integrates `@codama/spec@1.8.0`, threading the new `pluginNode` and `json` type expression through the TypeScript reference implementation. The node-types, nodes, and visitors-core packages are regenerated: `pluginNode` gains its interface and `pluginNode(name, payload?)` factory, `instructionNode` gains an optional `plugins` array, and the `json` type expression renders as `unknown`. A `PluginNode` visitor test fixture is added to satisfy the coverage gate. All changes are additive and optional.
1 parent 62af2ed commit 61ac0a6

22 files changed

Lines changed: 103 additions & 11 deletions

File tree

.changeset/plugin-nodes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@codama/nodes': minor
3+
---
4+
5+
Integrate `@codama/spec@1.8.0`, adding the `pluginNode` to the node meta-model. A `pluginNode` attaches named, plugin-specific data to a node: it carries a `name` that uniquely identifies the plugin and an optional opaque `payload`. The payload is typed by the new `json` type expression, which renders as `unknown` in TypeScript. `instructionNode` gains an optional `plugins` field holding an array of `pluginNode`. All changes are additive and optional.

packages/node-types/src/generated/InstructionNode.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { InstructionArgumentNode } from './InstructionArgumentNode';
77
import type { InstructionByteDeltaNode } from './InstructionByteDeltaNode';
88
import type { InstructionRemainingAccountsNode } from './InstructionRemainingAccountsNode';
99
import type { InstructionStatusNode } from './InstructionStatusNode';
10+
import type { PluginNode } from './PluginNode';
1011
import type { ProvidedNode } from './ProvidedNode';
1112
import type { OptionalAccountStrategy } from './shared/optionalAccountStrategy';
1213

@@ -26,6 +27,7 @@ export interface InstructionNode<
2627
TStatus extends InstructionStatusNode | undefined = InstructionStatusNode | undefined,
2728
TProvides extends Array<ProvidedNode> | undefined = Array<ProvidedNode> | undefined,
2829
TDisplay extends InstructionDisplayNode | undefined = InstructionDisplayNode | undefined,
30+
TPlugins extends Array<PluginNode> | undefined = Array<PluginNode> | undefined,
2931
> {
3032
readonly kind: 'instructionNode';
3133

@@ -64,4 +66,6 @@ export interface InstructionNode<
6466
readonly provides?: TProvides;
6567
/** Display metadata describing how the instruction is presented. */
6668
readonly display?: TDisplay;
69+
/** Namespaced plugins with custom structured data. */
70+
readonly plugins?: TPlugins;
6771
}

packages/node-types/src/generated/Node.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type { InstructionStatusNode } from './InstructionStatusNode';
1616
import type { RegisteredLinkNode } from './linkNodes/RegisteredLinkNode';
1717
import type { PdaNode } from './PdaNode';
1818
import type { RegisteredPdaSeedNode } from './pdaSeedNodes/RegisteredPdaSeedNode';
19+
import type { PluginNode } from './PluginNode';
1920
import type { ProgramNode } from './ProgramNode';
2021
import type { ProvidedNode } from './ProvidedNode';
2122
import type { RootNode } from './RootNode';
@@ -37,6 +38,7 @@ export type Node =
3738
| InstructionRemainingAccountsNode
3839
| InstructionStatusNode
3940
| PdaNode
41+
| PluginNode
4042
| ProgramNode
4143
| ProvidedNode
4244
| RegisteredContextualValueNode
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { CamelCaseString } from '../brands';
2+
3+
/**
4+
* Attaches named, plugin-specific data to a node.
5+
* A plugin is uniquely identified by its `name`; the optional `payload` carries arbitrary, consumer-defined data that only the matching plugin knows how to interpret. Codama itself treats the payload as opaque.
6+
*/
7+
export interface PluginNode {
8+
readonly kind: 'pluginNode';
9+
10+
// Data.
11+
/** The unique name identifying the plugin this data belongs to. */
12+
readonly name: CamelCaseString;
13+
/** Arbitrary, plugin-specific data. Its shape is defined by the plugin, not by Codama, and is carried through the graph verbatim. */
14+
readonly payload?: unknown;
15+
}

packages/node-types/src/generated/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export * from './InstructionRemainingAccountsValue';
1313
export * from './InstructionStatusNode';
1414
export * from './Node';
1515
export * from './PdaNode';
16+
export * from './PluginNode';
1617
export * from './ProgramNode';
1718
export * from './ProvidedNode';
1819
export * from './RootNode';

packages/node-types/src/generated/shared/codamaVersion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
* version of the spec at generation time; documents conforming to this
44
* version of the spec carry this exact string.
55
*/
6-
export type CodamaVersion = '1.7.0';
6+
export type CodamaVersion = '1.8.0';

packages/nodes/src/generated/InstructionNode.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
InstructionNode,
88
InstructionRemainingAccountsNode,
99
InstructionStatusNode,
10+
PluginNode,
1011
ProvidedNode,
1112
} from '@codama/node-types';
1213
import { camelCase, DocsInput, parseDocs } from '../shared';
@@ -24,6 +25,7 @@ export type InstructionNodeInput<
2425
TStatus extends InstructionStatusNode | undefined = InstructionStatusNode | undefined,
2526
TProvides extends Array<ProvidedNode> | undefined = Array<ProvidedNode> | undefined,
2627
TDisplay extends InstructionDisplayNode | undefined = InstructionDisplayNode | undefined,
28+
TPlugins extends Array<PluginNode> | undefined = Array<PluginNode> | undefined,
2729
> = Omit<
2830
Partial<
2931
InstructionNode<
@@ -36,7 +38,8 @@ export type InstructionNodeInput<
3638
TSubInstructions,
3739
TStatus,
3840
TProvides,
39-
TDisplay
41+
TDisplay,
42+
TPlugins
4043
>
4144
>,
4245
'docs' | 'kind' | 'name'
@@ -57,6 +60,7 @@ export function instructionNode<
5760
const TStatus extends InstructionStatusNode | undefined = undefined,
5861
const TProvides extends Array<ProvidedNode> | undefined = undefined,
5962
const TDisplay extends InstructionDisplayNode | undefined = undefined,
63+
const TPlugins extends Array<PluginNode> | undefined = undefined,
6064
>(
6165
input: InstructionNodeInput<
6266
TAccounts,
@@ -68,7 +72,8 @@ export function instructionNode<
6872
TSubInstructions,
6973
TStatus,
7074
TProvides,
71-
TDisplay
75+
TDisplay,
76+
TPlugins
7277
>,
7378
): InstructionNode<
7479
TAccounts,
@@ -80,7 +85,8 @@ export function instructionNode<
8085
TSubInstructions,
8186
TStatus,
8287
TProvides,
83-
TDisplay
88+
TDisplay,
89+
TPlugins
8490
> {
8591
const parsedDocs = parseDocs(input.docs);
8692
return Object.freeze({
@@ -102,5 +108,6 @@ export function instructionNode<
102108
...(input.subInstructions !== undefined && { subInstructions: input.subInstructions }),
103109
...(input.provides !== undefined && { provides: input.provides }),
104110
...(input.display !== undefined && { display: input.display }),
111+
...(input.plugins !== undefined && { plugins: input.plugins }),
105112
});
106113
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { PluginNode } from '@codama/node-types';
2+
import { camelCase } from '../shared';
3+
4+
/**
5+
* Attaches named, plugin-specific data to a node.
6+
* A plugin is uniquely identified by its `name`; the optional `payload` carries arbitrary, consumer-defined data that only the matching plugin knows how to interpret. Codama itself treats the payload as opaque.
7+
*/
8+
export function pluginNode(name: string, payload?: unknown): PluginNode {
9+
return Object.freeze({
10+
kind: 'pluginNode',
11+
12+
// Data.
13+
name: camelCase(name),
14+
...(payload !== undefined && { payload }),
15+
});
16+
}

packages/nodes/src/generated/codamaVersion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ import type { CodamaVersion } from '@codama/node-types';
88
* that need to compare an IDL document's `version` against the spec
99
* shape `@codama/nodes` understands.
1010
*/
11-
export const CODAMA_VERSION: CodamaVersion = '1.7.0';
11+
export const CODAMA_VERSION: CodamaVersion = '1.8.0';

packages/nodes/src/generated/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export * from './InstructionRemainingAccountsValue';
1414
export * from './InstructionStatusNode';
1515
export * from './nodeKinds';
1616
export * from './PdaNode';
17+
export * from './PluginNode';
1718
export * from './ProgramNode';
1819
export * from './ProvidedNode';
1920
export * from './RootNode';

0 commit comments

Comments
 (0)