Skip to content

Commit

Permalink
make more declarative
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Jan 23, 2025
1 parent 94a8ebf commit c7cdd43
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/build/stable/commands/compile/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ export function handleClassApiCanister(): string {
const visibleMethodIdlParamTypes = Object.fromEntries(
Object.entries(exportedCanisterClassInstance._azleCanisterMethodIdlParamTypes)
.filter(([methodName]) => {
const { queries = [], updates = [] } = exportedCanisterClassInstance._azleMethodMeta;
const allMethods = [...queries, ...updates];
const method = allMethods.find(m => m.name === methodName);
return method?.hidden === false;
})
.filter(([methodName]) => isMethodVisible(methodName))
);
const canisterIdlType = IDL.Service(visibleMethodIdlParamTypes);
Expand All @@ -51,6 +46,18 @@ export function handleClassApiCanister(): string {
});
};
/**
* @internal
*
* Determines if a method should be visible in Candid based on its hidden status
*/
function isMethodVisible(methodName) {
const { queries = [], updates = [] } = exportedCanisterClassInstance._azleMethodMeta;
const allMethods = [...queries, ...updates];
const method = allMethods.find(m => m.name === methodName);
return method?.hidden === false;
}
/**
* @internal
*
Expand Down

0 comments on commit c7cdd43

Please sign in to comment.