@macalinao/codama-rename-visitor 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +12 -116
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -3,142 +3,38 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@macalinao/codama-rename-visitor.svg)](https://www.npmjs.com/package/@macalinao/codama-rename-visitor)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/@macalinao/codama-rename-visitor.svg)](https://www.npmjs.com/package/@macalinao/codama-rename-visitor)
5
5
 
6
- A Codama visitor for renaming instructions and events within a Solana program.
6
+ A Codama visitor for renaming accounts, instructions, and defined types within Solana programs.
7
7
 
8
- ## Quick Start with Coda CLI
8
+ ## Documentation
9
9
 
10
- This visitor works seamlessly with the [Coda CLI](https://coda.ianm.com) for automated client generation:
10
+ Full documentation and examples are available at [coda.ianm.com/docs/packages/codama-rename-visitor](https://coda.ianm.com/docs/packages/codama-rename-visitor).
11
11
 
12
- ```bash
13
- # Install Coda CLI
14
- bun add -D @macalinao/coda
15
-
16
- # Initialize configuration
17
- coda init
18
-
19
- # Add this visitor to your coda.config.mjs
20
- ```
21
-
22
- Coda provides zero-config client generation with powerful customization through visitors like this one. Learn more at [coda.ianm.com](https://coda.ianm.com).
23
-
24
- ## Installation
25
-
26
- For direct usage:
12
+ ## Quick Start
27
13
 
28
14
  ```bash
29
15
  npm install @macalinao/codama-rename-visitor
30
16
  ```
31
17
 
32
- ## Usage
33
-
34
- This visitor allows you to rename instructions and events in your Codama IDL. It's particularly useful when you want to change the naming conventions of your program without modifying the original IDL.
35
-
36
- ### Renaming Instructions
37
-
38
- ```typescript
39
- import { renameInstructionsVisitor } from "@macalinao/codama-rename-visitor";
40
- import { visit } from "codama";
41
-
42
- // Rename specific instructions
43
- const visitor = renameInstructionsVisitor({
44
- oldInstructionName: "newInstructionName",
45
- transfer: "transferTokens",
46
- mint: "mintNft"
47
- });
48
-
49
- const updatedRoot = visit(root, visitor);
50
- ```
51
-
52
- ### Renaming Events
53
-
54
- ```typescript
55
- import { renameEventsVisitor } from "@macalinao/codama-rename-visitor";
56
- import { visit } from "codama";
57
-
58
- // Rename specific events (as defined types)
59
- const visitor = renameEventsVisitor({
60
- oldEventName: "newEventName",
61
- tokenMinted: "nftMinted",
62
- transferComplete: "transferFinished"
63
- });
64
-
65
- const updatedRoot = visit(root, visitor);
66
- ```
67
-
68
- ### Program-Specific Renaming (Recommended)
69
-
70
- The `renameVisitor` follows the same pattern as Codama's `addPdasVisitor`, where you specify renames for specific programs:
71
-
72
18
  ```typescript
73
19
  import { renameVisitor } from "@macalinao/codama-rename-visitor";
74
- import { visit } from "codama";
75
20
 
76
- // Rename elements in specific programs
77
21
  const visitor = renameVisitor({
78
- quarryMine: {
79
- instructions: {
80
- claimRewards: "claimRewardsMine"
81
- }
82
- },
83
- token: {
22
+ myProgram: {
84
23
  instructions: {
85
- transfer: "transferTokens",
86
- mint: "mintNft"
24
+ oldName: "newName"
87
25
  },
88
- events: {
89
- tokenMinted: "nftMinted"
26
+ accounts: {
27
+ oldAccount: "newAccount"
28
+ },
29
+ definedTypes: {
30
+ oldType: "newType"
90
31
  }
91
32
  }
92
33
  });
93
-
94
- const updatedRoot = visit(root, visitor);
95
- ```
96
-
97
- ### Legacy Single-Program Renaming
98
-
99
- For backward compatibility, you can still use the legacy format for single-program renaming:
100
-
101
- ```typescript
102
- import { renameVisitor } from "@macalinao/codama-rename-visitor";
103
- import { visit } from "codama";
104
-
105
- // Legacy format: rename in the current program
106
- const visitor = renameVisitor({
107
- instructions: {
108
- transfer: "transferTokens",
109
- mint: "mintNft"
110
- },
111
- events: {
112
- tokenMinted: "nftMinted",
113
- transferComplete: "transferFinished"
114
- }
115
- });
116
-
117
- const updatedRoot = visit(root, visitor);
118
34
  ```
119
35
 
120
- ## API
121
-
122
- ### `renameVisitor(renamesByProgram: Record<string, ProgramRenameOptions>)`
123
-
124
- Creates a visitor that renames instructions, events, and defined types in specific programs. This is the recommended API.
125
-
126
- - `renamesByProgram`: Object mapping program names to their rename configurations
127
- - Each program can specify:
128
- - `instructions`: Mapping of old instruction names to new names
129
- - `events`: Mapping of old event names to new names
130
- - `definedTypes`: Mapping of old defined type names to new names
131
-
132
- ### `renameInstructionsVisitor(mapping: Record<string, string>)`
133
-
134
- Creates a visitor that renames instructions based on the provided mapping. Applies to all programs.
135
-
136
- ### `renameEventsVisitor(mapping: Record<string, string>)`
137
-
138
- Creates a visitor that renames events (defined types) based on the provided mapping. Applies to all programs.
139
-
140
36
  ## License
141
37
 
142
38
  Copyright © 2025 Ian Macalinao
143
39
 
144
- Licensed under the Apache License, Version 2.0
40
+ Licensed under the Apache License, Version 2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macalinao/codama-rename-visitor",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Codama visitor for renaming instructions and events within a program",
5
5
  "type": "module",
6
6
  "sideEffects": false,