@macalinao/codama-rename-visitor 0.3.3 → 0.4.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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export type { ProgramRenameOptions } from "./types.js";
2
- export { renameAccountsVisitor, renameAccountTransform, } from "./rename-accounts-visitor.js";
3
- export { renameDefinedTypesVisitor, renameDefinedTypeTransform, } from "./rename-defined-types-visitor.js";
4
- export { renameInstructionsVisitor, renameInstructionTransform, } from "./rename-instructions-visitor.js";
5
- export { renameVisitor } from "./rename-visitor.js";
6
- //# sourceMappingURL=index.d.ts.map
1
+ import { ProgramRenameOptions } from "./types.js";
2
+ import { renameAccountTransform, renameAccountsVisitor } from "./rename-accounts-visitor.js";
3
+ import { renameDefinedTypeTransform, renameDefinedTypesVisitor } from "./rename-defined-types-visitor.js";
4
+ import { renameInstructionTransform, renameInstructionsVisitor } from "./rename-instructions-visitor.js";
5
+ import { renameVisitor } from "./rename-visitor.js";
6
+ export { type ProgramRenameOptions, renameAccountTransform, renameAccountsVisitor, renameDefinedTypeTransform, renameDefinedTypesVisitor, renameInstructionTransform, renameInstructionsVisitor, renameVisitor };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { renameAccountsVisitor, renameAccountTransform, } from "./rename-accounts-visitor.js";
2
- export { renameDefinedTypesVisitor, renameDefinedTypeTransform, } from "./rename-defined-types-visitor.js";
3
- export { renameInstructionsVisitor, renameInstructionTransform, } from "./rename-instructions-visitor.js";
4
- export { renameVisitor } from "./rename-visitor.js";
5
- //# sourceMappingURL=index.js.map
1
+ import { renameAccountTransform, renameAccountsVisitor } from "./rename-accounts-visitor.js";
2
+ import { renameDefinedTypeTransform, renameDefinedTypesVisitor } from "./rename-defined-types-visitor.js";
3
+ import { renameInstructionTransform, renameInstructionsVisitor } from "./rename-instructions-visitor.js";
4
+ import { renameVisitor } from "./rename-visitor.js";
5
+ export { renameAccountTransform, renameAccountsVisitor, renameDefinedTypeTransform, renameDefinedTypesVisitor, renameInstructionTransform, renameInstructionsVisitor, renameVisitor };
@@ -1,26 +1,30 @@
1
- import type { AccountNode, Node, rootNodeVisitor } from "codama";
1
+ import { AccountNode, Node, Visitor } from "codama";
2
+
3
+ //#region src/rename-accounts-visitor.d.ts
2
4
  /**
3
- * Transform function that renames an account node based on a mapping.
4
- *
5
- * @param node - The node to transform
6
- * @param mapping - Object mapping old account names to new account names
7
- * @returns The transformed account node
8
- */
9
- export declare function renameAccountTransform(node: Node, mapping: Record<string, string>): AccountNode;
5
+ * Transform function that renames an account node based on a mapping.
6
+ *
7
+ * @param node - The node to transform
8
+ * @param mapping - Object mapping old account names to new account names
9
+ * @returns The transformed account node
10
+ */
11
+ declare function renameAccountTransform(node: Node, mapping: Record<string, string>): AccountNode;
10
12
  /**
11
- * Creates a visitor that renames accounts in a Codama IDL.
12
- *
13
- * @param mapping - Object mapping old account names to new account names
14
- * @returns A root node visitor that renames accounts
15
- *
16
- * @example
17
- * ```typescript
18
- * const visitor = renameAccountsVisitor({
19
- * "userAccount": "user",
20
- * "configAccount": "config"
21
- * });
22
- * codama.update(visitor);
23
- * ```
24
- */
25
- export declare function renameAccountsVisitor(mapping: Record<string, string>): ReturnType<typeof rootNodeVisitor>;
13
+ * Creates a visitor that renames accounts in a Codama IDL.
14
+ *
15
+ * @param mapping - Object mapping old account names to new account names
16
+ * @returns A root node visitor that renames accounts
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const visitor = renameAccountsVisitor({
21
+ * "userAccount": "user",
22
+ * "configAccount": "config"
23
+ * });
24
+ * codama.update(visitor);
25
+ * ```
26
+ */
27
+ declare function renameAccountsVisitor(mapping: Record<string, string>): Visitor<Node | null, "rootNode">;
28
+ //#endregion
29
+ export { renameAccountTransform, renameAccountsVisitor };
26
30
  //# sourceMappingURL=rename-accounts-visitor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rename-accounts-visitor.d.ts","sourceRoot":"","sources":["../src/rename-accounts-visitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAGjE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,WAAW,CAUb;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,UAAU,CAAC,OAAO,eAAe,CAAC,CAOpC"}
1
+ {"version":3,"file":"rename-accounts-visitor.d.ts","names":[],"sources":["../src/rename-accounts-visitor.ts"],"mappings":";;;;;AAUA;;;;;iBAAgB,sBAAA,CACd,IAAA,EAAM,IAAA,EACN,OAAA,EAAS,MAAA,mBACR,WAAA;;;;;;;;;AAAA;AA2BH;;;;;;iBAAgB,qBAAA,CACd,OAAA,EAAS,MAAA,mBACR,OAAA,CAAQ,IAAA"}
@@ -1,43 +1,43 @@
1
1
  import { assertIsNode, bottomUpTransformerVisitor, camelCase } from "codama";
2
+ //#region src/rename-accounts-visitor.ts
2
3
  /**
3
- * Transform function that renames an account node based on a mapping.
4
- *
5
- * @param node - The node to transform
6
- * @param mapping - Object mapping old account names to new account names
7
- * @returns The transformed account node
8
- */
9
- export function renameAccountTransform(node, mapping) {
10
- assertIsNode(node, "accountNode");
11
- const newName = mapping[node.name];
12
- if (!newName) {
13
- return node;
14
- }
15
- return {
16
- ...node,
17
- name: camelCase(newName),
18
- };
4
+ * Transform function that renames an account node based on a mapping.
5
+ *
6
+ * @param node - The node to transform
7
+ * @param mapping - Object mapping old account names to new account names
8
+ * @returns The transformed account node
9
+ */
10
+ function renameAccountTransform(node, mapping) {
11
+ assertIsNode(node, "accountNode");
12
+ const newName = mapping[node.name];
13
+ if (!newName) return node;
14
+ return {
15
+ ...node,
16
+ name: camelCase(newName)
17
+ };
19
18
  }
20
19
  /**
21
- * Creates a visitor that renames accounts in a Codama IDL.
22
- *
23
- * @param mapping - Object mapping old account names to new account names
24
- * @returns A root node visitor that renames accounts
25
- *
26
- * @example
27
- * ```typescript
28
- * const visitor = renameAccountsVisitor({
29
- * "userAccount": "user",
30
- * "configAccount": "config"
31
- * });
32
- * codama.update(visitor);
33
- * ```
34
- */
35
- export function renameAccountsVisitor(mapping) {
36
- return bottomUpTransformerVisitor([
37
- {
38
- select: "[accountNode]",
39
- transform: (node) => renameAccountTransform(node, mapping),
40
- },
41
- ]);
20
+ * Creates a visitor that renames accounts in a Codama IDL.
21
+ *
22
+ * @param mapping - Object mapping old account names to new account names
23
+ * @returns A root node visitor that renames accounts
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const visitor = renameAccountsVisitor({
28
+ * "userAccount": "user",
29
+ * "configAccount": "config"
30
+ * });
31
+ * codama.update(visitor);
32
+ * ```
33
+ */
34
+ function renameAccountsVisitor(mapping) {
35
+ return bottomUpTransformerVisitor([{
36
+ select: "[accountNode]",
37
+ transform: (node) => renameAccountTransform(node, mapping)
38
+ }]);
42
39
  }
40
+ //#endregion
41
+ export { renameAccountTransform, renameAccountsVisitor };
42
+
43
43
  //# sourceMappingURL=rename-accounts-visitor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rename-accounts-visitor.js","sourceRoot":"","sources":["../src/rename-accounts-visitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAAU,EACV,OAA+B;IAE/B,YAAY,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC;KACzB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAA+B;IAE/B,OAAO,0BAA0B,CAAC;QAChC;YACE,MAAM,EAAE,eAAe;YACvB,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC;SAC3D;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { AccountNode, Node, rootNodeVisitor } from \"codama\";\nimport { assertIsNode, bottomUpTransformerVisitor, camelCase } from \"codama\";\n\n/**\n * Transform function that renames an account node based on a mapping.\n *\n * @param node - The node to transform\n * @param mapping - Object mapping old account names to new account names\n * @returns The transformed account node\n */\nexport function renameAccountTransform(\n node: Node,\n mapping: Record<string, string>,\n): AccountNode {\n assertIsNode(node, \"accountNode\");\n const newName = mapping[node.name];\n if (!newName) {\n return node;\n }\n return {\n ...node,\n name: camelCase(newName),\n };\n}\n\n/**\n * Creates a visitor that renames accounts in a Codama IDL.\n *\n * @param mapping - Object mapping old account names to new account names\n * @returns A root node visitor that renames accounts\n *\n * @example\n * ```typescript\n * const visitor = renameAccountsVisitor({\n * \"userAccount\": \"user\",\n * \"configAccount\": \"config\"\n * });\n * codama.update(visitor);\n * ```\n */\nexport function renameAccountsVisitor(\n mapping: Record<string, string>,\n): ReturnType<typeof rootNodeVisitor> {\n return bottomUpTransformerVisitor([\n {\n select: \"[accountNode]\",\n transform: (node) => renameAccountTransform(node, mapping),\n },\n ]);\n}\n"]}
1
+ {"version":3,"file":"rename-accounts-visitor.js","names":[],"sources":["../src/rename-accounts-visitor.ts"],"sourcesContent":["import type { AccountNode, Node, Visitor } from \"codama\";\nimport { assertIsNode, bottomUpTransformerVisitor, camelCase } from \"codama\";\n\n/**\n * Transform function that renames an account node based on a mapping.\n *\n * @param node - The node to transform\n * @param mapping - Object mapping old account names to new account names\n * @returns The transformed account node\n */\nexport function renameAccountTransform(\n node: Node,\n mapping: Record<string, string>,\n): AccountNode {\n assertIsNode(node, \"accountNode\");\n const newName = mapping[node.name];\n if (!newName) {\n return node;\n }\n return {\n ...node,\n name: camelCase(newName),\n };\n}\n\n/**\n * Creates a visitor that renames accounts in a Codama IDL.\n *\n * @param mapping - Object mapping old account names to new account names\n * @returns A root node visitor that renames accounts\n *\n * @example\n * ```typescript\n * const visitor = renameAccountsVisitor({\n * \"userAccount\": \"user\",\n * \"configAccount\": \"config\"\n * });\n * codama.update(visitor);\n * ```\n */\nexport function renameAccountsVisitor(\n mapping: Record<string, string>,\n): Visitor<Node | null, \"rootNode\"> {\n return bottomUpTransformerVisitor([\n {\n select: \"[accountNode]\",\n transform: (node) => renameAccountTransform(node, mapping),\n },\n ]);\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,uBACd,MACA,SACa;CACb,aAAa,MAAM,aAAa;CAChC,MAAM,UAAU,QAAQ,KAAK;CAC7B,IAAI,CAAC,SACH,OAAO;CAET,OAAO;EACL,GAAG;EACH,MAAM,UAAU,OAAO;CACzB;AACF;;;;;;;;;;;;;;;;AAiBA,SAAgB,sBACd,SACkC;CAClC,OAAO,2BAA2B,CAChC;EACE,QAAQ;EACR,YAAY,SAAS,uBAAuB,MAAM,OAAO;CAC3D,CACF,CAAC;AACH"}
@@ -1,27 +1,30 @@
1
- import type { DefinedTypeNode, Node } from "codama";
2
- import { rootNodeVisitor } from "codama";
1
+ import { DefinedTypeNode, Node, Visitor } from "codama";
2
+
3
+ //#region src/rename-defined-types-visitor.d.ts
3
4
  /**
4
- * Transform function that renames a defined type node based on a mapping.
5
- *
6
- * @param node - The node to transform
7
- * @param mapping - Object mapping old defined type names to new defined type names
8
- * @returns The transformed defined type node
9
- */
10
- export declare function renameDefinedTypeTransform(node: Node, mapping: Record<string, string>): DefinedTypeNode;
5
+ * Transform function that renames a defined type node based on a mapping.
6
+ *
7
+ * @param node - The node to transform
8
+ * @param mapping - Object mapping old defined type names to new defined type names
9
+ * @returns The transformed defined type node
10
+ */
11
+ declare function renameDefinedTypeTransform(node: Node, mapping: Record<string, string>): DefinedTypeNode;
11
12
  /**
12
- * Creates a visitor that renames defined types in a Codama IDL.
13
- *
14
- * @param mapping - Object mapping old defined type names to new defined type names
15
- * @returns A root node visitor that renames defined types
16
- *
17
- * @example
18
- * ```typescript
19
- * const visitor = renameDefinedTypesVisitor({
20
- * "counter": "counterAccount",
21
- * "config": "programConfig"
22
- * });
23
- * codama.update(visitor);
24
- * ```
25
- */
26
- export declare function renameDefinedTypesVisitor(mapping: Record<string, string>): ReturnType<typeof rootNodeVisitor>;
13
+ * Creates a visitor that renames defined types in a Codama IDL.
14
+ *
15
+ * @param mapping - Object mapping old defined type names to new defined type names
16
+ * @returns A root node visitor that renames defined types
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const visitor = renameDefinedTypesVisitor({
21
+ * "counter": "counterAccount",
22
+ * "config": "programConfig"
23
+ * });
24
+ * codama.update(visitor);
25
+ * ```
26
+ */
27
+ declare function renameDefinedTypesVisitor(mapping: Record<string, string>): Visitor<Node | null, "rootNode">;
28
+ //#endregion
29
+ export { renameDefinedTypeTransform, renameDefinedTypesVisitor };
27
30
  //# sourceMappingURL=rename-defined-types-visitor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rename-defined-types-visitor.d.ts","sourceRoot":"","sources":["../src/rename-defined-types-visitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAIL,eAAe,EAEhB,MAAM,QAAQ,CAAC;AAEhB;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,eAAe,CAUjB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,UAAU,CAAC,OAAO,eAAe,CAAC,CAUpC"}
1
+ {"version":3,"file":"rename-defined-types-visitor.d.ts","names":[],"sources":["../src/rename-defined-types-visitor.ts"],"mappings":";;;;;AAgBA;;;;;iBAAgB,0BAAA,CACd,IAAA,EAAM,IAAA,EACN,OAAA,EAAS,MAAA,mBACR,eAAA;;;;;;;;;AAAA;AA2BH;;;;;;iBAAgB,yBAAA,CACd,OAAA,EAAS,MAAA,mBACR,OAAA,CAAQ,IAAA"}
@@ -1,46 +1,45 @@
1
- import { assertIsNode, bottomUpTransformerVisitor, camelCase, rootNodeVisitor, visit, } from "codama";
1
+ import { assertIsNode, bottomUpTransformerVisitor, camelCase, rootNodeVisitor, visit } from "codama";
2
+ //#region src/rename-defined-types-visitor.ts
2
3
  /**
3
- * Transform function that renames a defined type node based on a mapping.
4
- *
5
- * @param node - The node to transform
6
- * @param mapping - Object mapping old defined type names to new defined type names
7
- * @returns The transformed defined type node
8
- */
9
- export function renameDefinedTypeTransform(node, mapping) {
10
- assertIsNode(node, "definedTypeNode");
11
- const newName = mapping[node.name];
12
- if (!newName) {
13
- return node;
14
- }
15
- return {
16
- ...node,
17
- name: camelCase(newName),
18
- };
4
+ * Transform function that renames a defined type node based on a mapping.
5
+ *
6
+ * @param node - The node to transform
7
+ * @param mapping - Object mapping old defined type names to new defined type names
8
+ * @returns The transformed defined type node
9
+ */
10
+ function renameDefinedTypeTransform(node, mapping) {
11
+ assertIsNode(node, "definedTypeNode");
12
+ const newName = mapping[node.name];
13
+ if (!newName) return node;
14
+ return {
15
+ ...node,
16
+ name: camelCase(newName)
17
+ };
19
18
  }
20
19
  /**
21
- * Creates a visitor that renames defined types in a Codama IDL.
22
- *
23
- * @param mapping - Object mapping old defined type names to new defined type names
24
- * @returns A root node visitor that renames defined types
25
- *
26
- * @example
27
- * ```typescript
28
- * const visitor = renameDefinedTypesVisitor({
29
- * "counter": "counterAccount",
30
- * "config": "programConfig"
31
- * });
32
- * codama.update(visitor);
33
- * ```
34
- */
35
- export function renameDefinedTypesVisitor(mapping) {
36
- return rootNodeVisitor((root) => {
37
- const typeVisitor = bottomUpTransformerVisitor([
38
- {
39
- select: "[definedTypeNode]",
40
- transform: (node) => renameDefinedTypeTransform(node, mapping),
41
- },
42
- ]);
43
- return visit(root, typeVisitor);
44
- });
20
+ * Creates a visitor that renames defined types in a Codama IDL.
21
+ *
22
+ * @param mapping - Object mapping old defined type names to new defined type names
23
+ * @returns A root node visitor that renames defined types
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const visitor = renameDefinedTypesVisitor({
28
+ * "counter": "counterAccount",
29
+ * "config": "programConfig"
30
+ * });
31
+ * codama.update(visitor);
32
+ * ```
33
+ */
34
+ function renameDefinedTypesVisitor(mapping) {
35
+ return rootNodeVisitor((root) => {
36
+ return visit(root, bottomUpTransformerVisitor([{
37
+ select: "[definedTypeNode]",
38
+ transform: (node) => renameDefinedTypeTransform(node, mapping)
39
+ }]));
40
+ });
45
41
  }
42
+ //#endregion
43
+ export { renameDefinedTypeTransform, renameDefinedTypesVisitor };
44
+
46
45
  //# sourceMappingURL=rename-defined-types-visitor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rename-defined-types-visitor.js","sourceRoot":"","sources":["../src/rename-defined-types-visitor.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,0BAA0B,EAC1B,SAAS,EACT,eAAe,EACf,KAAK,GACN,MAAM,QAAQ,CAAC;AAEhB;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,IAAU,EACV,OAA+B;IAE/B,YAAY,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC;KACzB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAA+B;IAE/B,OAAO,eAAe,CAAC,CAAC,IAAI,EAAE,EAAE;QAC9B,MAAM,WAAW,GAAG,0BAA0B,CAAC;YAC7C;gBACE,MAAM,EAAE,mBAAmB;gBAC3B,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,0BAA0B,CAAC,IAAI,EAAE,OAAO,CAAC;aAC/D;SACF,CAAC,CAAC;QACH,OAAO,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { DefinedTypeNode, Node } from \"codama\";\nimport {\n assertIsNode,\n bottomUpTransformerVisitor,\n camelCase,\n rootNodeVisitor,\n visit,\n} from \"codama\";\n\n/**\n * Transform function that renames a defined type node based on a mapping.\n *\n * @param node - The node to transform\n * @param mapping - Object mapping old defined type names to new defined type names\n * @returns The transformed defined type node\n */\nexport function renameDefinedTypeTransform(\n node: Node,\n mapping: Record<string, string>,\n): DefinedTypeNode {\n assertIsNode(node, \"definedTypeNode\");\n const newName = mapping[node.name];\n if (!newName) {\n return node;\n }\n return {\n ...node,\n name: camelCase(newName),\n };\n}\n\n/**\n * Creates a visitor that renames defined types in a Codama IDL.\n *\n * @param mapping - Object mapping old defined type names to new defined type names\n * @returns A root node visitor that renames defined types\n *\n * @example\n * ```typescript\n * const visitor = renameDefinedTypesVisitor({\n * \"counter\": \"counterAccount\",\n * \"config\": \"programConfig\"\n * });\n * codama.update(visitor);\n * ```\n */\nexport function renameDefinedTypesVisitor(\n mapping: Record<string, string>,\n): ReturnType<typeof rootNodeVisitor> {\n return rootNodeVisitor((root) => {\n const typeVisitor = bottomUpTransformerVisitor([\n {\n select: \"[definedTypeNode]\",\n transform: (node) => renameDefinedTypeTransform(node, mapping),\n },\n ]);\n return visit(root, typeVisitor);\n });\n}\n"]}
1
+ {"version":3,"file":"rename-defined-types-visitor.js","names":[],"sources":["../src/rename-defined-types-visitor.ts"],"sourcesContent":["import type { DefinedTypeNode, Node, Visitor } from \"codama\";\nimport {\n assertIsNode,\n bottomUpTransformerVisitor,\n camelCase,\n rootNodeVisitor,\n visit,\n} from \"codama\";\n\n/**\n * Transform function that renames a defined type node based on a mapping.\n *\n * @param node - The node to transform\n * @param mapping - Object mapping old defined type names to new defined type names\n * @returns The transformed defined type node\n */\nexport function renameDefinedTypeTransform(\n node: Node,\n mapping: Record<string, string>,\n): DefinedTypeNode {\n assertIsNode(node, \"definedTypeNode\");\n const newName = mapping[node.name];\n if (!newName) {\n return node;\n }\n return {\n ...node,\n name: camelCase(newName),\n };\n}\n\n/**\n * Creates a visitor that renames defined types in a Codama IDL.\n *\n * @param mapping - Object mapping old defined type names to new defined type names\n * @returns A root node visitor that renames defined types\n *\n * @example\n * ```typescript\n * const visitor = renameDefinedTypesVisitor({\n * \"counter\": \"counterAccount\",\n * \"config\": \"programConfig\"\n * });\n * codama.update(visitor);\n * ```\n */\nexport function renameDefinedTypesVisitor(\n mapping: Record<string, string>,\n): Visitor<Node | null, \"rootNode\"> {\n return rootNodeVisitor<Node | null>((root) => {\n const typeVisitor = bottomUpTransformerVisitor([\n {\n select: \"[definedTypeNode]\",\n transform: (node) => renameDefinedTypeTransform(node, mapping),\n },\n ]);\n return visit(root, typeVisitor);\n });\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAgB,2BACd,MACA,SACiB;CACjB,aAAa,MAAM,iBAAiB;CACpC,MAAM,UAAU,QAAQ,KAAK;CAC7B,IAAI,CAAC,SACH,OAAO;CAET,OAAO;EACL,GAAG;EACH,MAAM,UAAU,OAAO;CACzB;AACF;;;;;;;;;;;;;;;;AAiBA,SAAgB,0BACd,SACkC;CAClC,OAAO,iBAA8B,SAAS;EAO5C,OAAO,MAAM,MANO,2BAA2B,CAC7C;GACE,QAAQ;GACR,YAAY,SAAS,2BAA2B,MAAM,OAAO;EAC/D,CACF,CAC6B,CAAC;CAChC,CAAC;AACH"}
@@ -1,26 +1,30 @@
1
- import type { InstructionNode, Node, NodeKind, Visitor } from "codama";
1
+ import { InstructionNode, Node, NodeKind, Visitor } from "codama";
2
+
3
+ //#region src/rename-instructions-visitor.d.ts
2
4
  /**
3
- * Transform function that renames an instruction node based on a mapping.
4
- *
5
- * @param node - The node to transform
6
- * @param mapping - Object mapping old instruction names to new instruction names
7
- * @returns The transformed instruction node
8
- */
9
- export declare function renameInstructionTransform(node: Node, mapping: Record<string, string>): InstructionNode;
5
+ * Transform function that renames an instruction node based on a mapping.
6
+ *
7
+ * @param node - The node to transform
8
+ * @param mapping - Object mapping old instruction names to new instruction names
9
+ * @returns The transformed instruction node
10
+ */
11
+ declare function renameInstructionTransform(node: Node, mapping: Record<string, string>): InstructionNode;
10
12
  /**
11
- * Creates a visitor that renames instructions in a Codama IDL.
12
- *
13
- * @param mapping - Object mapping old instruction names to new instruction names
14
- * @returns A root node visitor that renames instructions
15
- *
16
- * @example
17
- * ```typescript
18
- * const visitor = renameInstructionsVisitor({
19
- * "transfer": "transferTokens",
20
- * "mint": "mintNft"
21
- * });
22
- * codama.update(visitor);
23
- * ```
24
- */
25
- export declare function renameInstructionsVisitor<TNodeKind extends NodeKind = NodeKind>(mapping: Record<string, string>): Visitor<Node | null, TNodeKind>;
13
+ * Creates a visitor that renames instructions in a Codama IDL.
14
+ *
15
+ * @param mapping - Object mapping old instruction names to new instruction names
16
+ * @returns A root node visitor that renames instructions
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const visitor = renameInstructionsVisitor({
21
+ * "transfer": "transferTokens",
22
+ * "mint": "mintNft"
23
+ * });
24
+ * codama.update(visitor);
25
+ * ```
26
+ */
27
+ declare function renameInstructionsVisitor<TNodeKind extends NodeKind = NodeKind>(mapping: Record<string, string>): Visitor<Node | null, TNodeKind>;
28
+ //#endregion
29
+ export { renameInstructionTransform, renameInstructionsVisitor };
26
30
  //# sourceMappingURL=rename-instructions-visitor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rename-instructions-visitor.d.ts","sourceRoot":"","sources":["../src/rename-instructions-visitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGvE;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,eAAe,CAUjB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,SAAS,QAAQ,GAAG,QAAQ,EACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,EAAE,SAAS,CAAC,CAOlE"}
1
+ {"version":3,"file":"rename-instructions-visitor.d.ts","names":[],"sources":["../src/rename-instructions-visitor.ts"],"mappings":";;;;;AAUA;;;;;iBAAgB,0BAAA,CACd,IAAA,EAAM,IAAA,EACN,OAAA,EAAS,MAAA,mBACR,eAAA;;;;;;;;;AAAA;AA2BH;;;;;;iBAAgB,yBAAA,mBACI,QAAA,GAAW,QAAA,EAC7B,OAAA,EAAS,MAAA,mBAAyB,OAAA,CAAQ,IAAA,SAAa,SAAA"}
@@ -1,43 +1,43 @@
1
1
  import { assertIsNode, bottomUpTransformerVisitor, camelCase } from "codama";
2
+ //#region src/rename-instructions-visitor.ts
2
3
  /**
3
- * Transform function that renames an instruction node based on a mapping.
4
- *
5
- * @param node - The node to transform
6
- * @param mapping - Object mapping old instruction names to new instruction names
7
- * @returns The transformed instruction node
8
- */
9
- export function renameInstructionTransform(node, mapping) {
10
- assertIsNode(node, "instructionNode");
11
- const newName = mapping[node.name];
12
- if (!newName) {
13
- return node;
14
- }
15
- return {
16
- ...node,
17
- name: camelCase(newName),
18
- };
4
+ * Transform function that renames an instruction node based on a mapping.
5
+ *
6
+ * @param node - The node to transform
7
+ * @param mapping - Object mapping old instruction names to new instruction names
8
+ * @returns The transformed instruction node
9
+ */
10
+ function renameInstructionTransform(node, mapping) {
11
+ assertIsNode(node, "instructionNode");
12
+ const newName = mapping[node.name];
13
+ if (!newName) return node;
14
+ return {
15
+ ...node,
16
+ name: camelCase(newName)
17
+ };
19
18
  }
20
19
  /**
21
- * Creates a visitor that renames instructions in a Codama IDL.
22
- *
23
- * @param mapping - Object mapping old instruction names to new instruction names
24
- * @returns A root node visitor that renames instructions
25
- *
26
- * @example
27
- * ```typescript
28
- * const visitor = renameInstructionsVisitor({
29
- * "transfer": "transferTokens",
30
- * "mint": "mintNft"
31
- * });
32
- * codama.update(visitor);
33
- * ```
34
- */
35
- export function renameInstructionsVisitor(mapping) {
36
- return bottomUpTransformerVisitor([
37
- {
38
- select: "[instructionNode]",
39
- transform: (node) => renameInstructionTransform(node, mapping),
40
- },
41
- ]);
20
+ * Creates a visitor that renames instructions in a Codama IDL.
21
+ *
22
+ * @param mapping - Object mapping old instruction names to new instruction names
23
+ * @returns A root node visitor that renames instructions
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const visitor = renameInstructionsVisitor({
28
+ * "transfer": "transferTokens",
29
+ * "mint": "mintNft"
30
+ * });
31
+ * codama.update(visitor);
32
+ * ```
33
+ */
34
+ function renameInstructionsVisitor(mapping) {
35
+ return bottomUpTransformerVisitor([{
36
+ select: "[instructionNode]",
37
+ transform: (node) => renameInstructionTransform(node, mapping)
38
+ }]);
42
39
  }
40
+ //#endregion
41
+ export { renameInstructionTransform, renameInstructionsVisitor };
42
+
43
43
  //# sourceMappingURL=rename-instructions-visitor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rename-instructions-visitor.js","sourceRoot":"","sources":["../src/rename-instructions-visitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,IAAU,EACV,OAA+B;IAE/B,YAAY,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC;KACzB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,yBAAyB,CAEvC,OAA+B;IAC/B,OAAO,0BAA0B,CAAC;QAChC;YACE,MAAM,EAAE,mBAAmB;YAC3B,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,0BAA0B,CAAC,IAAI,EAAE,OAAO,CAAC;SAC/D;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { InstructionNode, Node, NodeKind, Visitor } from \"codama\";\nimport { assertIsNode, bottomUpTransformerVisitor, camelCase } from \"codama\";\n\n/**\n * Transform function that renames an instruction node based on a mapping.\n *\n * @param node - The node to transform\n * @param mapping - Object mapping old instruction names to new instruction names\n * @returns The transformed instruction node\n */\nexport function renameInstructionTransform(\n node: Node,\n mapping: Record<string, string>,\n): InstructionNode {\n assertIsNode(node, \"instructionNode\");\n const newName = mapping[node.name];\n if (!newName) {\n return node;\n }\n return {\n ...node,\n name: camelCase(newName),\n };\n}\n\n/**\n * Creates a visitor that renames instructions in a Codama IDL.\n *\n * @param mapping - Object mapping old instruction names to new instruction names\n * @returns A root node visitor that renames instructions\n *\n * @example\n * ```typescript\n * const visitor = renameInstructionsVisitor({\n * \"transfer\": \"transferTokens\",\n * \"mint\": \"mintNft\"\n * });\n * codama.update(visitor);\n * ```\n */\nexport function renameInstructionsVisitor<\n TNodeKind extends NodeKind = NodeKind,\n>(mapping: Record<string, string>): Visitor<Node | null, TNodeKind> {\n return bottomUpTransformerVisitor([\n {\n select: \"[instructionNode]\",\n transform: (node) => renameInstructionTransform(node, mapping),\n },\n ]);\n}\n"]}
1
+ {"version":3,"file":"rename-instructions-visitor.js","names":[],"sources":["../src/rename-instructions-visitor.ts"],"sourcesContent":["import type { InstructionNode, Node, NodeKind, Visitor } from \"codama\";\nimport { assertIsNode, bottomUpTransformerVisitor, camelCase } from \"codama\";\n\n/**\n * Transform function that renames an instruction node based on a mapping.\n *\n * @param node - The node to transform\n * @param mapping - Object mapping old instruction names to new instruction names\n * @returns The transformed instruction node\n */\nexport function renameInstructionTransform(\n node: Node,\n mapping: Record<string, string>,\n): InstructionNode {\n assertIsNode(node, \"instructionNode\");\n const newName = mapping[node.name];\n if (!newName) {\n return node;\n }\n return {\n ...node,\n name: camelCase(newName),\n };\n}\n\n/**\n * Creates a visitor that renames instructions in a Codama IDL.\n *\n * @param mapping - Object mapping old instruction names to new instruction names\n * @returns A root node visitor that renames instructions\n *\n * @example\n * ```typescript\n * const visitor = renameInstructionsVisitor({\n * \"transfer\": \"transferTokens\",\n * \"mint\": \"mintNft\"\n * });\n * codama.update(visitor);\n * ```\n */\nexport function renameInstructionsVisitor<\n TNodeKind extends NodeKind = NodeKind,\n>(mapping: Record<string, string>): Visitor<Node | null, TNodeKind> {\n return bottomUpTransformerVisitor([\n {\n select: \"[instructionNode]\",\n transform: (node) => renameInstructionTransform(node, mapping),\n },\n ]);\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,2BACd,MACA,SACiB;CACjB,aAAa,MAAM,iBAAiB;CACpC,MAAM,UAAU,QAAQ,KAAK;CAC7B,IAAI,CAAC,SACH,OAAO;CAET,OAAO;EACL,GAAG;EACH,MAAM,UAAU,OAAO;CACzB;AACF;;;;;;;;;;;;;;;;AAiBA,SAAgB,0BAEd,SAAkE;CAClE,OAAO,2BAA2B,CAChC;EACE,QAAQ;EACR,YAAY,SAAS,2BAA2B,MAAM,OAAO;CAC/D,CACF,CAAC;AACH"}
@@ -1,35 +1,8 @@
1
- import type { ProgramRenameOptions } from "./types.js";
2
- import { rootNodeVisitor } from "codama";
3
- /**
4
- * Creates a visitor that renames accounts, instructions, and defined types in specific programs.
5
- * This follows the same pattern as addPdasVisitor from Codama.
6
- *
7
- * @param renamesByProgram - Object mapping program names to their rename configurations
8
- * @returns A root node visitor that performs all specified renames
9
- *
10
- * @example
11
- * ```typescript
12
- * const visitor = renameVisitor({
13
- * quarryMine: {
14
- * instructions: {
15
- * claimRewards: "claimRewardsMine"
16
- * },
17
- * accounts: {
18
- * miner: "minerAccount"
19
- * }
20
- * },
21
- * token: {
22
- * instructions: {
23
- * transfer: "transferTokens",
24
- * mint: "mintNft"
25
- * },
26
- * definedTypes: {
27
- * tokenData: "tokenMetadata"
28
- * }
29
- * }
30
- * });
31
- * codama.update(visitor);
32
- * ```
33
- */
34
- export declare function renameVisitor(renamesByProgram: Record<string, ProgramRenameOptions>): ReturnType<typeof rootNodeVisitor>;
1
+ import { ProgramRenameOptions } from "./types.js";
2
+ import { Node, Visitor } from "codama";
3
+
4
+ //#region src/rename-visitor.d.ts
5
+ declare function renameVisitor(renamesByProgram: Record<string, ProgramRenameOptions>): Visitor<Node | null, "rootNode">;
6
+ //#endregion
7
+ export { renameVisitor };
35
8
  //# sourceMappingURL=rename-visitor.d.ts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"rename-visitor.d.ts","names":[],"sources":["../src/rename-visitor.ts"],"mappings":";;;;iBA8DgB,aAAA,CACd,gBAAA,EAAkB,MAAA,SAAe,oBAAA,IAChC,OAAA,CAAQ,IAAA"}