@macalinao/codama-rename-visitor 0.2.1 → 0.2.3

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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ export type { ProgramRenameOptions } from "./types.js";
1
2
  export { renameAccountsVisitor, renameAccountTransform, } from "./rename-accounts-visitor.js";
2
3
  export { renameDefinedTypesVisitor, renameDefinedTypeTransform, } from "./rename-defined-types-visitor.js";
3
4
  export { renameInstructionsVisitor, renameInstructionTransform, } from "./rename-instructions-visitor.js";
4
5
  export { renameVisitor } from "./rename-visitor.js";
5
- export type { ProgramRenameOptions } from "./types.js";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export {\n renameAccountsVisitor,\n renameAccountTransform,\n} from \"./rename-accounts-visitor.js\";\nexport {\n renameDefinedTypesVisitor,\n renameDefinedTypeTransform,\n} from \"./rename-defined-types-visitor.js\";\nexport {\n renameInstructionsVisitor,\n renameInstructionTransform,\n} from \"./rename-instructions-visitor.js\";\nexport { renameVisitor } from \"./rename-visitor.js\";\nexport type { ProgramRenameOptions } from \"./types.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export type { ProgramRenameOptions } from \"./types.js\";\nexport {\n renameAccountsVisitor,\n renameAccountTransform,\n} from \"./rename-accounts-visitor.js\";\nexport {\n renameDefinedTypesVisitor,\n renameDefinedTypeTransform,\n} from \"./rename-defined-types-visitor.js\";\nexport {\n renameInstructionsVisitor,\n renameInstructionTransform,\n} from \"./rename-instructions-visitor.js\";\nexport { renameVisitor } from \"./rename-visitor.js\";\n"]}
@@ -1,5 +1,5 @@
1
- import { rootNodeVisitor } from "codama";
2
1
  import type { ProgramRenameOptions } from "./types.js";
2
+ import { rootNodeVisitor } from "codama";
3
3
  /**
4
4
  * Creates a visitor that renames accounts, instructions, and defined types in specific programs.
5
5
  * This follows the same pattern as addPdasVisitor from Codama.
@@ -1 +1 @@
1
- {"version":3,"file":"rename-visitor.d.ts","sourceRoot":"","sources":["../src/rename-visitor.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,eAAe,EAAS,MAAM,QAAQ,CAAC;AAI5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAC3B,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GACrD,UAAU,CAAC,OAAO,eAAe,CAAC,CAqDpC"}
1
+ {"version":3,"file":"rename-visitor.d.ts","sourceRoot":"","sources":["../src/rename-visitor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAA8B,eAAe,EAAS,MAAM,QAAQ,CAAC;AAK5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAC3B,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GACrD,UAAU,CAAC,OAAO,eAAe,CAAC,CAqDpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rename-visitor.js","sourceRoot":"","sources":["../src/rename-visitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAG9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,YAAY,IAAI,EAAE,CAAC,CAAC,OAAO,CACtD,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE;oBACrB,UAAU,CAAC,IAAI,CAAC;wBACd,MAAM,EAAE,gBAAgB,WAAW,qBAAqB,OAAO,EAAE;wBACjE,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,0BAA0B,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;qBAC3D,CAAC,CAAC;gBACL,CAAC,CACF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;QACvD,OAAO,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Node } from \"codama\";\nimport { bottomUpTransformerVisitor, rootNodeVisitor, visit } from \"codama\";\nimport { renameAccountTransform } from \"./rename-accounts-visitor.js\";\nimport { renameDefinedTypeTransform } from \"./rename-defined-types-visitor.js\";\nimport { renameInstructionTransform } from \"./rename-instructions-visitor.js\";\nimport type { ProgramRenameOptions } from \"./types.js\";\n\n/**\n * Creates a visitor that renames accounts, instructions, and defined types in specific programs.\n * This follows the same pattern as addPdasVisitor from Codama.\n *\n * @param renamesByProgram - Object mapping program names to their rename configurations\n * @returns A root node visitor that performs all specified renames\n *\n * @example\n * ```typescript\n * const visitor = renameVisitor({\n * quarryMine: {\n * instructions: {\n * claimRewards: \"claimRewardsMine\"\n * },\n * accounts: {\n * miner: \"minerAccount\"\n * }\n * },\n * token: {\n * instructions: {\n * transfer: \"transferTokens\",\n * mint: \"mintNft\"\n * },\n * definedTypes: {\n * tokenData: \"tokenMetadata\"\n * }\n * }\n * });\n * codama.update(visitor);\n * ```\n */\nexport function renameVisitor(\n renamesByProgram: Record<string, ProgramRenameOptions>,\n): ReturnType<typeof rootNodeVisitor> {\n return rootNodeVisitor((root) => {\n const transforms: {\n select: string;\n transform: (node: Node) => Node | null;\n }[] = [];\n\n // Process each program's rename configuration\n Object.entries(renamesByProgram).forEach(([programName, renameOptions]) => {\n // Add instruction renames for this program\n if (renameOptions.instructions) {\n Object.entries(renameOptions.instructions).forEach(\n ([oldName, newName]) => {\n transforms.push({\n select: `[programNode]${programName}.[instructionNode]${oldName}`,\n transform: (node) =>\n renameInstructionTransform(node, { [oldName]: newName }),\n });\n },\n );\n }\n\n if (renameOptions.accounts) {\n Object.entries(renameOptions.accounts).forEach(([oldName, newName]) => {\n transforms.push({\n select: `[programNode]${programName}.[accountNode]${oldName}`,\n transform: (node) =>\n renameAccountTransform(node, { [oldName]: newName }),\n });\n });\n }\n\n // Add defined type renames for this program\n if (renameOptions.definedTypes) {\n Object.entries(renameOptions.definedTypes ?? {}).forEach(\n ([oldName, newName]) => {\n transforms.push({\n select: `[programNode]${programName}.[definedTypeNode]${oldName}`,\n transform: (node) =>\n renameDefinedTypeTransform(node, { [oldName]: newName }),\n });\n },\n );\n }\n });\n\n if (transforms.length === 0) {\n return root;\n }\n\n const visitor = bottomUpTransformerVisitor(transforms);\n return visit(root, visitor);\n });\n}\n"]}
1
+ {"version":3,"file":"rename-visitor.js","sourceRoot":"","sources":["../src/rename-visitor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,aAAa,CAC3B,gBAAsD;IAEtD,O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OAAO,EAAE,OAAO,CAAC,EAAE,EAAE;oBACrB,UAAU,CAAC,IAAI,CAAC;wBACd,MAAM,EAAE,gBAAgB,WAAW,qBAAqB,OAAO,EAAE;wBACjE,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,0BAA0B,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;qBAC3D,CAAC,CAAC;gBACL,CAAC,CACF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;QACvD,OAAO,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Node } from \"codama\";\nimport type { ProgramRenameOptions } from \"./types.js\";\nimport { bottomUpTransformerVisitor, rootNodeVisitor, visit } from \"codama\";\nimport { renameAccountTransform } from \"./rename-accounts-visitor.js\";\nimport { renameDefinedTypeTransform } from \"./rename-defined-types-visitor.js\";\nimport { renameInstructionTransform } from \"./rename-instructions-visitor.js\";\n\n/**\n * Creates a visitor that renames accounts, instructions, and defined types in specific programs.\n * This follows the same pattern as addPdasVisitor from Codama.\n *\n * @param renamesByProgram - Object mapping program names to their rename configurations\n * @returns A root node visitor that performs all specified renames\n *\n * @example\n * ```typescript\n * const visitor = renameVisitor({\n * quarryMine: {\n * instructions: {\n * claimRewards: \"claimRewardsMine\"\n * },\n * accounts: {\n * miner: \"minerAccount\"\n * }\n * },\n * token: {\n * instructions: {\n * transfer: \"transferTokens\",\n * mint: \"mintNft\"\n * },\n * definedTypes: {\n * tokenData: \"tokenMetadata\"\n * }\n * }\n * });\n * codama.update(visitor);\n * ```\n */\nexport function renameVisitor(\n renamesByProgram: Record<string, ProgramRenameOptions>,\n): ReturnType<typeof rootNodeVisitor> {\n return rootNodeVisitor((root) => {\n const transforms: {\n select: string;\n transform: (node: Node) => Node | null;\n }[] = [];\n\n // Process each program's rename configuration\n Object.entries(renamesByProgram).forEach(([programName, renameOptions]) => {\n // Add instruction renames for this program\n if (renameOptions.instructions) {\n Object.entries(renameOptions.instructions).forEach(\n ([oldName, newName]) => {\n transforms.push({\n select: `[programNode]${programName}.[instructionNode]${oldName}`,\n transform: (node) =>\n renameInstructionTransform(node, { [oldName]: newName }),\n });\n },\n );\n }\n\n if (renameOptions.accounts) {\n Object.entries(renameOptions.accounts).forEach(([oldName, newName]) => {\n transforms.push({\n select: `[programNode]${programName}.[accountNode]${oldName}`,\n transform: (node) =>\n renameAccountTransform(node, { [oldName]: newName }),\n });\n });\n }\n\n // Add defined type renames for this program\n if (renameOptions.definedTypes) {\n Object.entries(renameOptions.definedTypes ?? {}).forEach(\n ([oldName, newName]) => {\n transforms.push({\n select: `[programNode]${programName}.[definedTypeNode]${oldName}`,\n transform: (node) =>\n renameDefinedTypeTransform(node, { [oldName]: newName }),\n });\n },\n );\n }\n });\n\n if (transforms.length === 0) {\n return root;\n }\n\n const visitor = bottomUpTransformerVisitor(transforms);\n return visit(root, visitor);\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macalinao/codama-rename-visitor",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Codama visitor for renaming instructions and events within a program",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -48,16 +48,9 @@
48
48
  "codama": "^1.3.3"
49
49
  },
50
50
  "devDependencies": {
51
- "@macalinao/eslint-config": "^5",
51
+ "@macalinao/eslint-config": "^6",
52
52
  "@macalinao/tsconfig": "^3.2.3",
53
53
  "eslint": "^9.33.0",
54
54
  "typescript": "^5.9.2"
55
- },
56
- "lint-staged": {
57
- "*.{js,jsx,ts,tsx,cjs,mjs,cts,mts}": [
58
- "biome check --write --no-errors-on-unmatched",
59
- "eslint --fix --cache"
60
- ],
61
- "*.{json,jsonc,html}": "biome format --write --no-errors-on-unmatched"
62
55
  }
63
56
  }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export type { ProgramRenameOptions } from "./types.js";
1
2
  export {
2
3
  renameAccountsVisitor,
3
4
  renameAccountTransform,
@@ -11,4 +12,3 @@ export {
11
12
  renameInstructionTransform,
12
13
  } from "./rename-instructions-visitor.js";
13
14
  export { renameVisitor } from "./rename-visitor.js";
14
- export type { ProgramRenameOptions } from "./types.js";
@@ -1,6 +1,7 @@
1
1
  /// <reference types="bun-types" />
2
- import { describe, expect, it } from "bun:test";
2
+
3
3
  import type { ProgramNode, RootNode } from "codama";
4
+ import { describe, expect, it } from "bun:test";
4
5
  import {
5
6
  camelCase,
6
7
  definedTypeNode,
@@ -1,6 +1,7 @@
1
1
  /// <reference types="bun-types" />
2
- import { describe, expect, it } from "bun:test";
2
+
3
3
  import type { ProgramNode, RootNode } from "codama";
4
+ import { describe, expect, it } from "bun:test";
4
5
  import {
5
6
  camelCase,
6
7
  instructionAccountNode,
@@ -1,6 +1,7 @@
1
1
  /// <reference types="bun-types" />
2
- import { describe, expect, it } from "bun:test";
2
+
3
3
  import type { ProgramNode, RootNode } from "codama";
4
+ import { describe, expect, it } from "bun:test";
4
5
  import {
5
6
  camelCase,
6
7
  definedTypeNode,
@@ -1,9 +1,9 @@
1
1
  import type { Node } from "codama";
2
+ import type { ProgramRenameOptions } from "./types.js";
2
3
  import { bottomUpTransformerVisitor, rootNodeVisitor, visit } from "codama";
3
4
  import { renameAccountTransform } from "./rename-accounts-visitor.js";
4
5
  import { renameDefinedTypeTransform } from "./rename-defined-types-visitor.js";
5
6
  import { renameInstructionTransform } from "./rename-instructions-visitor.js";
6
- import type { ProgramRenameOptions } from "./types.js";
7
7
 
8
8
  /**
9
9
  * Creates a visitor that renames accounts, instructions, and defined types in specific programs.