@codama/renderers-js 1.4.2 → 1.4.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.browser.cjs +133 -132
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +51 -50
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.cjs +133 -132
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +51 -50
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.react-native.mjs +51 -50
- package/dist/index.react-native.mjs.map +1 -1
- package/dist/types/fragments/indexPage.d.ts +1 -2
- package/dist/types/fragments/indexPage.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.browser.mjs
CHANGED
|
@@ -266,7 +266,7 @@ function mergeTypeManifests(manifests, options = {}) {
|
|
|
266
266
|
|
|
267
267
|
// src/visitors/getRenderMapVisitor.ts
|
|
268
268
|
import {
|
|
269
|
-
camelCase as
|
|
269
|
+
camelCase as camelCase15,
|
|
270
270
|
getAllAccounts,
|
|
271
271
|
getAllDefinedTypes,
|
|
272
272
|
getAllInstructionsWithSubs as getAllInstructionsWithSubs2,
|
|
@@ -918,9 +918,10 @@ function getIsErrorFunctionFragment(scope) {
|
|
|
918
918
|
}
|
|
919
919
|
|
|
920
920
|
// src/fragments/indexPage.ts
|
|
921
|
+
import { camelCase as camelCase4 } from "@codama/nodes";
|
|
921
922
|
function getIndexPageFragment(items) {
|
|
922
923
|
if (items.length === 0) return;
|
|
923
|
-
const names = items.map((item) => item.name).sort((a, b) => a.localeCompare(b)).map((name) => getExportAllFragment(`./${name}`));
|
|
924
|
+
const names = items.map((item) => camelCase4(item.name)).sort((a, b) => a.localeCompare(b)).map((name) => getExportAllFragment(`./${name}`));
|
|
924
925
|
return mergeFragments(names, (cs) => cs.join("\n"));
|
|
925
926
|
}
|
|
926
927
|
|
|
@@ -975,7 +976,7 @@ function getDefaultAddress(defaultValue, programId, linkables) {
|
|
|
975
976
|
}
|
|
976
977
|
|
|
977
978
|
// src/fragments/instructionByteDelta.ts
|
|
978
|
-
import { assertIsNode, camelCase as
|
|
979
|
+
import { assertIsNode, camelCase as camelCase5, isNode as isNode7 } from "@codama/nodes";
|
|
979
980
|
import { mapFragmentContent as mapFragmentContent2 } from "@codama/renderers-core";
|
|
980
981
|
import { getLastNodeFromPath as getLastNodeFromPath7, pipe as pipe4 } from "@codama/visitors-core";
|
|
981
982
|
function getInstructionByteDeltaFragment(scope) {
|
|
@@ -1019,7 +1020,7 @@ function getNumberValueNodeFragment(byteDelta) {
|
|
|
1019
1020
|
}
|
|
1020
1021
|
function getArgumentValueNodeFragment(byteDelta) {
|
|
1021
1022
|
assertIsNode(byteDelta.value, "argumentValueNode");
|
|
1022
|
-
const argumentName =
|
|
1023
|
+
const argumentName = camelCase5(byteDelta.value.name);
|
|
1023
1024
|
return fragment`Number(args.${argumentName})`;
|
|
1024
1025
|
}
|
|
1025
1026
|
function getAccountLinkNodeFragment(byteDelta, scope) {
|
|
@@ -1075,7 +1076,7 @@ function getInstructionExtraArgsFragment(scope) {
|
|
|
1075
1076
|
}
|
|
1076
1077
|
|
|
1077
1078
|
// src/fragments/instructionFunction.ts
|
|
1078
|
-
import { camelCase as
|
|
1079
|
+
import { camelCase as camelCase10, isNode as isNode12, isNodeFilter as isNodeFilter4, pascalCase as pascalCase5 } from "@codama/nodes";
|
|
1079
1080
|
import { mapFragmentContent as mapFragmentContent7 } from "@codama/renderers-core";
|
|
1080
1081
|
import {
|
|
1081
1082
|
findProgramNodeFromPath as findProgramNodeFromPath3,
|
|
@@ -1084,12 +1085,12 @@ import {
|
|
|
1084
1085
|
} from "@codama/visitors-core";
|
|
1085
1086
|
|
|
1086
1087
|
// src/fragments/instructionInputResolved.ts
|
|
1087
|
-
import { camelCase as
|
|
1088
|
+
import { camelCase as camelCase7, isNode as isNode9, parseOptionalAccountStrategy } from "@codama/nodes";
|
|
1088
1089
|
import { mapFragmentContent as mapFragmentContent5 } from "@codama/renderers-core";
|
|
1089
1090
|
import { getLastNodeFromPath as getLastNodeFromPath10 } from "@codama/visitors-core";
|
|
1090
1091
|
|
|
1091
1092
|
// src/fragments/instructionInputDefault.ts
|
|
1092
|
-
import { camelCase as
|
|
1093
|
+
import { camelCase as camelCase6, isNode as isNode8 } from "@codama/nodes";
|
|
1093
1094
|
import { mapFragmentContent as mapFragmentContent4, setFragmentContent } from "@codama/renderers-core";
|
|
1094
1095
|
import { pipe as pipe5, visit as visit4 } from "@codama/visitors-core";
|
|
1095
1096
|
function getInstructionInputDefaultFragment(scope) {
|
|
@@ -1102,7 +1103,7 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1102
1103
|
}
|
|
1103
1104
|
const { defaultValue } = input;
|
|
1104
1105
|
const defaultFragment = (renderedValue, isWritable) => {
|
|
1105
|
-
const inputName =
|
|
1106
|
+
const inputName = camelCase6(input.name);
|
|
1106
1107
|
if (input.kind === "instructionAccountNode" && isNode8(defaultValue, "resolverValueNode")) {
|
|
1107
1108
|
return fragment`accounts.${inputName} = { ...accounts.${inputName}, ...${renderedValue} };`;
|
|
1108
1109
|
}
|
|
@@ -1116,7 +1117,7 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1116
1117
|
};
|
|
1117
1118
|
switch (defaultValue.kind) {
|
|
1118
1119
|
case "accountValueNode":
|
|
1119
|
-
const name =
|
|
1120
|
+
const name = camelCase6(defaultValue.name);
|
|
1120
1121
|
if (input.kind === "instructionAccountNode" && input.resolvedIsSigner && !input.isSigner) {
|
|
1121
1122
|
return pipe5(
|
|
1122
1123
|
defaultFragment(`expectTransactionSigner(accounts.${name}.value).address`),
|
|
@@ -1160,7 +1161,7 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1160
1161
|
if (isNode8(valueSeed, "accountValueNode")) {
|
|
1161
1162
|
return [
|
|
1162
1163
|
pipe5(
|
|
1163
|
-
fragment`${typeManifest2.encoder}.encode(expectAddress(accounts.${
|
|
1164
|
+
fragment`${typeManifest2.encoder}.encode(expectAddress(accounts.${camelCase6(valueSeed.name)}.value))`,
|
|
1164
1165
|
(f) => addFragmentImports(f, "shared", ["expectAddress"])
|
|
1165
1166
|
)
|
|
1166
1167
|
];
|
|
@@ -1168,7 +1169,7 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1168
1169
|
if (isNode8(valueSeed, "argumentValueNode")) {
|
|
1169
1170
|
return [
|
|
1170
1171
|
pipe5(
|
|
1171
|
-
fragment`${typeManifest2.encoder}.encode(expectSome(args.${
|
|
1172
|
+
fragment`${typeManifest2.encoder}.encode(expectSome(args.${camelCase6(valueSeed.name)}))`,
|
|
1172
1173
|
(f) => addFragmentImports(f, "shared", ["expectSome"])
|
|
1173
1174
|
)
|
|
1174
1175
|
];
|
|
@@ -1192,13 +1193,13 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1192
1193
|
const pdaSeeds = defaultValue.seeds.map((seed) => {
|
|
1193
1194
|
if (isNode8(seed.value, "accountValueNode")) {
|
|
1194
1195
|
return pipe5(
|
|
1195
|
-
fragment`${seed.name}: expectAddress(accounts.${
|
|
1196
|
+
fragment`${seed.name}: expectAddress(accounts.${camelCase6(seed.value.name)}.value)`,
|
|
1196
1197
|
(f) => addFragmentImports(f, "shared", ["expectAddress"])
|
|
1197
1198
|
);
|
|
1198
1199
|
}
|
|
1199
1200
|
if (isNode8(seed.value, "argumentValueNode")) {
|
|
1200
1201
|
return pipe5(
|
|
1201
|
-
fragment`${seed.name}: expectSome(args.${
|
|
1202
|
+
fragment`${seed.name}: expectSome(args.${camelCase6(seed.value.name)})`,
|
|
1202
1203
|
(f) => addFragmentImports(f, "shared", ["expectSome"])
|
|
1203
1204
|
);
|
|
1204
1205
|
}
|
|
@@ -1241,12 +1242,12 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1241
1242
|
return fragment``;
|
|
1242
1243
|
case "accountBumpValueNode":
|
|
1243
1244
|
return pipe5(
|
|
1244
|
-
defaultFragment(`expectProgramDerivedAddress(accounts.${
|
|
1245
|
+
defaultFragment(`expectProgramDerivedAddress(accounts.${camelCase6(defaultValue.name)}.value)[1]`),
|
|
1245
1246
|
(f) => addFragmentImports(f, "shared", ["expectProgramDerivedAddress"])
|
|
1246
1247
|
);
|
|
1247
1248
|
case "argumentValueNode":
|
|
1248
1249
|
return pipe5(
|
|
1249
|
-
defaultFragment(`expectSome(args.${
|
|
1250
|
+
defaultFragment(`expectSome(args.${camelCase6(defaultValue.name)})`),
|
|
1250
1251
|
(f) => addFragmentImports(f, "shared", ["expectSome"])
|
|
1251
1252
|
);
|
|
1252
1253
|
case "resolverValueNode":
|
|
@@ -1290,7 +1291,7 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1290
1291
|
condition = `${conditionalResolverAwait}${conditionalResolverFunction}(resolverScope)`;
|
|
1291
1292
|
condition = negatedCondition ? `!${condition}` : condition;
|
|
1292
1293
|
} else {
|
|
1293
|
-
const comparedInputName = isNode8(defaultValue.condition, "accountValueNode") ? `accounts.${
|
|
1294
|
+
const comparedInputName = isNode8(defaultValue.condition, "accountValueNode") ? `accounts.${camelCase6(defaultValue.condition.name)}.value` : `args.${camelCase6(defaultValue.condition.name)}`;
|
|
1294
1295
|
if (defaultValue.value) {
|
|
1295
1296
|
const comparedValue = visit4(defaultValue.value, typeManifestVisitor).value;
|
|
1296
1297
|
conditionalFragment = mergeFragments([conditionalFragment, comparedValue], (c) => c[0]);
|
|
@@ -1340,7 +1341,7 @@ function getInstructionInputResolvedFragment(scope) {
|
|
|
1340
1341
|
optionalAccountStrategy: parseOptionalAccountStrategy(instructionNode.optionalAccountStrategy)
|
|
1341
1342
|
});
|
|
1342
1343
|
if (!inputFragment.content) return [];
|
|
1343
|
-
const camelName =
|
|
1344
|
+
const camelName = camelCase7(input.name);
|
|
1344
1345
|
return [
|
|
1345
1346
|
mapFragmentContent5(
|
|
1346
1347
|
inputFragment,
|
|
@@ -1360,7 +1361,7 @@ ${c}
|
|
|
1360
1361
|
|
|
1361
1362
|
// src/fragments/instructionInputType.ts
|
|
1362
1363
|
import {
|
|
1363
|
-
camelCase as
|
|
1364
|
+
camelCase as camelCase8,
|
|
1364
1365
|
getAllInstructionArguments,
|
|
1365
1366
|
isNode as isNode10,
|
|
1366
1367
|
pascalCase as pascalCase4
|
|
@@ -1403,7 +1404,7 @@ function getAccountsFragment(scope) {
|
|
|
1403
1404
|
const hasDefaultValue = !!resolvedAccount.defaultValue && !isNode10(resolvedAccount.defaultValue, ["identityValueNode", "payerValueNode"]) && (useAsync || !isAsyncDefaultValue(resolvedAccount.defaultValue, asyncResolvers));
|
|
1404
1405
|
const docs = getDocblockFragment(account.docs ?? [], true);
|
|
1405
1406
|
const optionalSign = hasDefaultValue || resolvedAccount.isOptional ? "?" : "";
|
|
1406
|
-
return fragment`${docs}${
|
|
1407
|
+
return fragment`${docs}${camelCase8(account.name)}${optionalSign}: ${getAccountTypeFragment2(resolvedAccount)};`;
|
|
1407
1408
|
});
|
|
1408
1409
|
return mergeFragments(fragments, (c) => c.join("\n"));
|
|
1409
1410
|
}
|
|
@@ -1459,7 +1460,7 @@ function getArgumentFragment(arg, argsType, resolvedInputs, renamedArgs) {
|
|
|
1459
1460
|
if (arg.defaultValue && arg.defaultValueStrategy === "omitted") return null;
|
|
1460
1461
|
const renamedName = renamedArgs.get(arg.name) ?? arg.name;
|
|
1461
1462
|
const optionalSign = arg.defaultValue || resolvedArg?.defaultValue ? "?" : "";
|
|
1462
|
-
return fragment`${
|
|
1463
|
+
return fragment`${camelCase8(renamedName)}${optionalSign}: ${argsType}["${camelCase8(arg.name)}"];`;
|
|
1463
1464
|
}
|
|
1464
1465
|
function getRemainingAccountsFragment(instructionNode) {
|
|
1465
1466
|
const fragments = (instructionNode.remainingAccounts ?? []).flatMap((remainingAccountsNode) => {
|
|
@@ -1476,7 +1477,7 @@ function getRemainingAccountsFragment(instructionNode) {
|
|
|
1476
1477
|
if (isSigner === "either") return fragment`${signerFragment} | ${addressFragment}`;
|
|
1477
1478
|
return isSigner ? signerFragment : addressFragment;
|
|
1478
1479
|
})();
|
|
1479
|
-
return fragment`${
|
|
1480
|
+
return fragment`${camelCase8(name)}${optionalSign}: Array<${typeFragment}>;`;
|
|
1480
1481
|
});
|
|
1481
1482
|
if (fragments.length === 0) return;
|
|
1482
1483
|
return mergeFragments(fragments, (c) => c.join("\n"));
|
|
@@ -1485,7 +1486,7 @@ function getRemainingAccountsFragment(instructionNode) {
|
|
|
1485
1486
|
// src/fragments/instructionRemainingAccounts.ts
|
|
1486
1487
|
import {
|
|
1487
1488
|
assertIsNode as assertIsNode2,
|
|
1488
|
-
camelCase as
|
|
1489
|
+
camelCase as camelCase9,
|
|
1489
1490
|
getAllInstructionArguments as getAllInstructionArguments2,
|
|
1490
1491
|
isNode as isNode11
|
|
1491
1492
|
} from "@codama/nodes";
|
|
@@ -1519,7 +1520,7 @@ function getRemainingAccountsFragment2(remainingAccounts, scope) {
|
|
|
1519
1520
|
function getArgumentValueNodeFragment2(remainingAccounts, scope) {
|
|
1520
1521
|
const instructionNode = getLastNodeFromPath12(scope.instructionPath);
|
|
1521
1522
|
assertIsNode2(remainingAccounts.value, "argumentValueNode");
|
|
1522
|
-
const argumentName =
|
|
1523
|
+
const argumentName = camelCase9(remainingAccounts.value.name);
|
|
1523
1524
|
const isOptional = remainingAccounts.isOptional ?? false;
|
|
1524
1525
|
const isSigner = remainingAccounts.isSigner ?? false;
|
|
1525
1526
|
const isWritable = remainingAccounts.isWritable ?? false;
|
|
@@ -1626,7 +1627,7 @@ function getAccountsInitializationFragment(instructionNode) {
|
|
|
1626
1627
|
if (instructionNode.accounts.length === 0) return;
|
|
1627
1628
|
const accounts = mergeFragments(
|
|
1628
1629
|
instructionNode.accounts.map((account) => {
|
|
1629
|
-
const name =
|
|
1630
|
+
const name = camelCase10(account.name);
|
|
1630
1631
|
const isWritable = account.isWritable ? "true" : "false";
|
|
1631
1632
|
return fragment`${name}: { value: input.${name} ?? null, isWritable: ${isWritable} }`;
|
|
1632
1633
|
}),
|
|
@@ -1661,7 +1662,7 @@ function getReturnStatementFragment(scope) {
|
|
|
1661
1662
|
const hasLegacyOptionalAccounts = instructionNode.optionalAccountStrategy === "omitted" && instructionNode.accounts.some((account) => account.isOptional);
|
|
1662
1663
|
const getAccountMeta = hasAccounts ? fragment`const getAccountMeta = ${use("getAccountMetaFactory", "shared")}(programAddress, '${optionalAccountStrategy}');` : "";
|
|
1663
1664
|
const accountItems = [
|
|
1664
|
-
...instructionNode.accounts.map((account) => `getAccountMeta(accounts.${
|
|
1665
|
+
...instructionNode.accounts.map((account) => `getAccountMeta(accounts.${camelCase10(account.name)})`),
|
|
1665
1666
|
...hasRemainingAccounts ? ["...remainingAccounts"] : []
|
|
1666
1667
|
].join(", ");
|
|
1667
1668
|
let accounts;
|
|
@@ -1710,7 +1711,7 @@ function getInstructionTypeFragment(scope) {
|
|
|
1710
1711
|
const instructionTypeName = nameApi.instructionType(instructionNode.name);
|
|
1711
1712
|
const accountTypeParamsFragments = instructionNode.accounts.map((account) => {
|
|
1712
1713
|
const typeParam = fragment`TAccount${pascalCase5(account.name)}`;
|
|
1713
|
-
const camelName =
|
|
1714
|
+
const camelName = camelCase10(account.name);
|
|
1714
1715
|
if (account.isSigner === "either") {
|
|
1715
1716
|
const signerRole = use(
|
|
1716
1717
|
account.isWritable ? "type WritableSignerAccount" : "type ReadonlySignerAccount",
|
|
@@ -1739,7 +1740,7 @@ function getInputTypeCallFragment(scope) {
|
|
|
1739
1740
|
|
|
1740
1741
|
// src/fragments/instructionPage.ts
|
|
1741
1742
|
import { logWarn } from "@codama/errors";
|
|
1742
|
-
import { camelCase as
|
|
1743
|
+
import { camelCase as camelCase12, definedTypeNode as definedTypeNode2, structTypeNodeFromInstructionArgumentNodes as structTypeNodeFromInstructionArgumentNodes3 } from "@codama/nodes";
|
|
1743
1744
|
import {
|
|
1744
1745
|
findProgramNodeFromPath as findProgramNodeFromPath6,
|
|
1745
1746
|
getLastNodeFromPath as getLastNodeFromPath16,
|
|
@@ -1747,7 +1748,7 @@ import {
|
|
|
1747
1748
|
} from "@codama/visitors-core";
|
|
1748
1749
|
|
|
1749
1750
|
// src/fragments/instructionParseFunction.ts
|
|
1750
|
-
import { camelCase as
|
|
1751
|
+
import { camelCase as camelCase11 } from "@codama/nodes";
|
|
1751
1752
|
import { findProgramNodeFromPath as findProgramNodeFromPath4, getLastNodeFromPath as getLastNodeFromPath14, pipe as pipe9 } from "@codama/visitors-core";
|
|
1752
1753
|
function getInstructionParseFunctionFragment(scope) {
|
|
1753
1754
|
const instructionNode = getLastNodeFromPath14(scope.instructionPath);
|
|
@@ -1772,7 +1773,7 @@ function getTypeFragment2(scope) {
|
|
|
1772
1773
|
const accounts = mergeFragments(
|
|
1773
1774
|
scope.instructionNode.accounts.map((account, i) => {
|
|
1774
1775
|
const docs = getDocblockFragment(account.docs ?? [], true);
|
|
1775
|
-
const name =
|
|
1776
|
+
const name = camelCase11(account.name);
|
|
1776
1777
|
return fragment`${docs}${name}${account.isOptional ? "?" : ""}: TAccountMetas[${i}]${account.isOptional ? " | undefined" : ""};`;
|
|
1777
1778
|
}),
|
|
1778
1779
|
(cs) => hasAccounts ? `
|
|
@@ -1844,7 +1845,7 @@ const getNextOptionalAccount = () => {
|
|
|
1844
1845
|
}
|
|
1845
1846
|
const accounts = mergeFragments(
|
|
1846
1847
|
scope.instructionNode.accounts.map(
|
|
1847
|
-
(account) => account.isOptional ? fragment`${
|
|
1848
|
+
(account) => account.isOptional ? fragment`${camelCase11(account.name)}: getNextOptionalAccount()` : fragment`${camelCase11(account.name)}: getNextAccount()`
|
|
1848
1849
|
),
|
|
1849
1850
|
(cs) => hasAccounts ? `, accounts: { ${cs.join(", ")} }` : ""
|
|
1850
1851
|
);
|
|
@@ -1949,11 +1950,11 @@ function getRenamedArgsMap(instruction) {
|
|
|
1949
1950
|
logWarn(
|
|
1950
1951
|
`[JavaScript] Accounts and args of instruction [${instruction.name}] have the following conflicting attributes [${duplicates.join(", ")}]. Thus, the arguments have been renamed to avoid conflicts in the input type.`
|
|
1951
1952
|
);
|
|
1952
|
-
return new Map(duplicates.map((name) => [
|
|
1953
|
+
return new Map(duplicates.map((name) => [camelCase12(name), camelCase12(`${name}Arg`)]));
|
|
1953
1954
|
}
|
|
1954
1955
|
|
|
1955
1956
|
// src/fragments/pdaFunction.ts
|
|
1956
|
-
import { camelCase as
|
|
1957
|
+
import { camelCase as camelCase13, isNode as isNode13, isNodeFilter as isNodeFilter5 } from "@codama/nodes";
|
|
1957
1958
|
import { findProgramNodeFromPath as findProgramNodeFromPath7, getLastNodeFromPath as getLastNodeFromPath17, visit as visit6 } from "@codama/visitors-core";
|
|
1958
1959
|
function getPdaFunctionFragment(scope) {
|
|
1959
1960
|
const pdaNode = getLastNodeFromPath17(scope.pdaPath);
|
|
@@ -1998,7 +1999,7 @@ function getFunctionFragment2(seeds, scope) {
|
|
|
1998
1999
|
function parsePdaSeedNodes(seeds, scope) {
|
|
1999
2000
|
return seeds.map((seed) => {
|
|
2000
2001
|
if (isNode13(seed, "variablePdaSeedNode")) {
|
|
2001
|
-
const name =
|
|
2002
|
+
const name = camelCase13(seed.name);
|
|
2002
2003
|
const docs = getDocblockFragment(seed.docs ?? [], true);
|
|
2003
2004
|
const { encoder: encoder2, looseType } = visit6(seed.type, scope.typeManifestVisitor);
|
|
2004
2005
|
return {
|
|
@@ -2388,7 +2389,7 @@ function getTypePageFragment(scope) {
|
|
|
2388
2389
|
|
|
2389
2390
|
// src/visitors/getTypeManifestVisitor.ts
|
|
2390
2391
|
import {
|
|
2391
|
-
camelCase as
|
|
2392
|
+
camelCase as camelCase14,
|
|
2392
2393
|
isNode as isNode15,
|
|
2393
2394
|
isNodeFilter as isNodeFilter6,
|
|
2394
2395
|
isScalarEnum,
|
|
@@ -2523,7 +2524,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2523
2524
|
});
|
|
2524
2525
|
},
|
|
2525
2526
|
visitEnumEmptyVariantType(enumEmptyVariantType) {
|
|
2526
|
-
const discriminator = nameApi.discriminatedUnionDiscriminator(
|
|
2527
|
+
const discriminator = nameApi.discriminatedUnionDiscriminator(camelCase14(parentName?.strict ?? ""));
|
|
2527
2528
|
const name = nameApi.discriminatedUnionVariant(enumEmptyVariantType.name);
|
|
2528
2529
|
const kindAttribute = `${discriminator}: "${name}"`;
|
|
2529
2530
|
return typeManifest({
|
|
@@ -2536,7 +2537,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2536
2537
|
visitEnumStructVariantType(enumStructVariantType, { self }) {
|
|
2537
2538
|
const currentParentName = parentName;
|
|
2538
2539
|
const discriminator = nameApi.discriminatedUnionDiscriminator(
|
|
2539
|
-
|
|
2540
|
+
camelCase14(currentParentName?.strict ?? "")
|
|
2540
2541
|
);
|
|
2541
2542
|
const name = nameApi.discriminatedUnionVariant(enumStructVariantType.name);
|
|
2542
2543
|
const kindAttribute = `${discriminator}: "${name}"`;
|
|
@@ -2560,7 +2561,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2560
2561
|
visitEnumTupleVariantType(enumTupleVariantType, { self }) {
|
|
2561
2562
|
const currentParentName = parentName;
|
|
2562
2563
|
const discriminator = nameApi.discriminatedUnionDiscriminator(
|
|
2563
|
-
|
|
2564
|
+
camelCase14(currentParentName?.strict ?? "")
|
|
2564
2565
|
);
|
|
2565
2566
|
const name = nameApi.discriminatedUnionVariant(enumTupleVariantType.name);
|
|
2566
2567
|
const kindAttribute = `${discriminator}: "${name}"`;
|
|
@@ -2598,7 +2599,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2598
2599
|
decoderOptions.push(fragment`size: ${sizeManifest.decoder}`);
|
|
2599
2600
|
}
|
|
2600
2601
|
const discriminator = nameApi.discriminatedUnionDiscriminator(
|
|
2601
|
-
|
|
2602
|
+
camelCase14(currentParentName?.strict ?? "")
|
|
2602
2603
|
);
|
|
2603
2604
|
if (!isScalarEnum(enumType) && discriminator !== "__kind") {
|
|
2604
2605
|
encoderOptions.push(fragment`discriminator: '${discriminator}'`);
|
|
@@ -2967,7 +2968,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2967
2968
|
});
|
|
2968
2969
|
},
|
|
2969
2970
|
visitStructFieldType(structFieldType, { self }) {
|
|
2970
|
-
const name =
|
|
2971
|
+
const name = camelCase14(structFieldType.name);
|
|
2971
2972
|
const originalChildManifest = visit8(structFieldType.type, self);
|
|
2972
2973
|
let docs = getDocblockFragment(structFieldType.docs ?? [], true);
|
|
2973
2974
|
docs = docs ? fragment`\n${docs}` : docs;
|
|
@@ -3022,9 +3023,9 @@ function getTypeManifestVisitor(input) {
|
|
|
3022
3023
|
const fieldDiscriminators = discriminators.filter(isNodeFilter6("fieldDiscriminatorNode"));
|
|
3023
3024
|
const defaultValues = mergeFragments(
|
|
3024
3025
|
optionalFields.map((f) => {
|
|
3025
|
-
const key =
|
|
3026
|
+
const key = camelCase14(f.name);
|
|
3026
3027
|
if (fieldDiscriminators.some((d) => d.name === f.name)) {
|
|
3027
|
-
const constantName = nameApi.constant(
|
|
3028
|
+
const constantName = nameApi.constant(camelCase14(`${discriminatorPrefix}_${f.name}`));
|
|
3028
3029
|
return f.defaultValueStrategy === "omitted" ? fragment`${key}: ${constantName}` : fragment`${key}: value.${key} ?? ${constantName}`;
|
|
3029
3030
|
}
|
|
3030
3031
|
const defaultValue = f.defaultValue;
|
|
@@ -3125,20 +3126,20 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3125
3126
|
const customAccountData = parseCustomDataOptions(options.customAccountData ?? [], "AccountData");
|
|
3126
3127
|
const customInstructionData = parseCustomDataOptions(options.customInstructionData ?? [], "InstructionData");
|
|
3127
3128
|
const renderScopeWithTypeManifestVisitor = {
|
|
3128
|
-
asyncResolvers: (options.asyncResolvers ?? []).map(
|
|
3129
|
+
asyncResolvers: (options.asyncResolvers ?? []).map(camelCase15),
|
|
3129
3130
|
customAccountData,
|
|
3130
3131
|
customInstructionData,
|
|
3131
3132
|
dependencyMap: options.dependencyMap ?? {},
|
|
3132
3133
|
getImportFrom: getImportFromFactory(options.linkOverrides ?? {}, customAccountData, customInstructionData),
|
|
3133
3134
|
linkables,
|
|
3134
3135
|
nameApi: getNameApi({ ...DEFAULT_NAME_TRANSFORMERS, ...options.nameTransformers }),
|
|
3135
|
-
nonScalarEnums: (options.nonScalarEnums ?? []).map(
|
|
3136
|
+
nonScalarEnums: (options.nonScalarEnums ?? []).map(camelCase15),
|
|
3136
3137
|
renderParentInstructions: options.renderParentInstructions ?? false,
|
|
3137
3138
|
useGranularImports: options.useGranularImports ?? false
|
|
3138
3139
|
};
|
|
3139
3140
|
const typeManifestVisitor = getTypeManifestVisitor({ ...renderScopeWithTypeManifestVisitor, stack });
|
|
3140
3141
|
const renderScope = { ...renderScopeWithTypeManifestVisitor, typeManifestVisitor };
|
|
3141
|
-
const internalNodes = (options.internalNodes ?? []).map(
|
|
3142
|
+
const internalNodes = (options.internalNodes ?? []).map(camelCase15);
|
|
3142
3143
|
const resolvedInstructionInputVisitor = getResolvedInstructionInputsVisitor();
|
|
3143
3144
|
const byteSizeVisitor = getByteSizeVisitor(linkables, { stack });
|
|
3144
3145
|
const asPage = (fragment2, dependencyMap = {}) => {
|
|
@@ -3155,7 +3156,7 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3155
3156
|
(v) => extendVisitor2(v, {
|
|
3156
3157
|
visitAccount(node) {
|
|
3157
3158
|
return createRenderMap(
|
|
3158
|
-
`accounts/${
|
|
3159
|
+
`accounts/${camelCase15(node.name)}.ts`,
|
|
3159
3160
|
asPage(
|
|
3160
3161
|
getAccountPageFragment({
|
|
3161
3162
|
...renderScope,
|
|
@@ -3167,7 +3168,7 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3167
3168
|
},
|
|
3168
3169
|
visitDefinedType(node) {
|
|
3169
3170
|
return createRenderMap(
|
|
3170
|
-
`types/${
|
|
3171
|
+
`types/${camelCase15(node.name)}.ts`,
|
|
3171
3172
|
asPage(getTypePageFragment({ ...renderScope, node, size: visit9(node, byteSizeVisitor) }), {
|
|
3172
3173
|
generatedTypes: "."
|
|
3173
3174
|
})
|
|
@@ -3175,7 +3176,7 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3175
3176
|
},
|
|
3176
3177
|
visitInstruction(node) {
|
|
3177
3178
|
return createRenderMap(
|
|
3178
|
-
`instructions/${
|
|
3179
|
+
`instructions/${camelCase15(node.name)}.ts`,
|
|
3179
3180
|
asPage(
|
|
3180
3181
|
getInstructionPageFragment({
|
|
3181
3182
|
...renderScope,
|
|
@@ -3188,7 +3189,7 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3188
3189
|
},
|
|
3189
3190
|
visitPda(node) {
|
|
3190
3191
|
return createRenderMap(
|
|
3191
|
-
`pdas/${
|
|
3192
|
+
`pdas/${camelCase15(node.name)}.ts`,
|
|
3192
3193
|
asPage(getPdaPageFragment({ ...renderScope, pdaPath: stack.getPath("pdaNode") }))
|
|
3193
3194
|
);
|
|
3194
3195
|
},
|
|
@@ -3200,8 +3201,8 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3200
3201
|
const scope = { ...renderScope, programNode: node };
|
|
3201
3202
|
return mergeRenderMaps([
|
|
3202
3203
|
createRenderMap({
|
|
3203
|
-
[`programs/${
|
|
3204
|
-
[`errors/${
|
|
3204
|
+
[`programs/${camelCase15(node.name)}.ts`]: asPage(getProgramPageFragment(scope)),
|
|
3205
|
+
[`errors/${camelCase15(node.name)}.ts`]: node.errors.length > 0 ? asPage(getErrorPageFragment(scope)) : void 0
|
|
3205
3206
|
}),
|
|
3206
3207
|
...node.pdas.map((p) => visit9(p, self)),
|
|
3207
3208
|
...node.accounts.map((a) => visit9(a, self)),
|