Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't use tooling api to get flow id #836

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/commands/org/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,17 @@ export interface OrgOpenOutput {
orgId: string;
}

/** query the tooling API to turn a flow's filepath into a FlowId (starts with 301) */
/** query the rest API to turn a flow's filepath into a FlowId (starts with 301) */
const flowFileNameToId = async (conn: Connection, filePath: string): Promise<string> => {
const result = await conn.tooling.query<{ Id: string; FullName: string }>(
'select id, MasterLabel, FullName from Flow'
);
const fullName = path.basename(filePath).replace('.flow-meta.xml', '');
// https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_flow.htm
// unfortunately, you can't query based on the fullname because `field 'FullName' can not be filtered in a query call`
// so we get all the flows and then filter.
const match = (result.records ?? []).find((r) => r.FullName === fullName)?.Id;
if (match) {
return match;
try {
const flow = await conn.singleRecordQuery<{ DurableId: string }>(
`SELECT DurableId FROM FlowVersionView WHERE FlowDefinitionView.ApiName = '${path.basename(
filePath,
'.flow-meta.xml'
)}' ORDER BY VersionNumber DESC LIMIT 1`
);
return flow.DurableId;
} catch (error) {
throw messages.createError('FlowIdNotFound', [filePath]);
}
throw messages.createError('FlowIdNotFound', [filePath]);
};
Loading