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

Getting Org connection from Salesforce Extensions services #55

Merged
merged 3 commits into from
Nov 29, 2023

Conversation

khawkins
Copy link
Collaborator

This PR tacks to a design pattern recommended by the Salesforce Extensions team, for consuming the services that their extension exports for Org-based administration, connections, etc. With the previous implementation, we weren't successfully able to bootstrap a connection to the user's default Org, for retrieving sObject metadata.

@khawkins khawkins requested a review from a team as a code owner November 29, 2023 05:42
const getWorkspaceDirStub = sinon.stub(
WorkspaceUtils,
'getStaticResourcesDir'
);
getWorkspaceDirStub.returns(Promise.resolve('.'));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach was breaking for me locally. Always dicey to use . as a working directory, as it's hard to know where the code is executed from. Moved to creating a temporary directory for this I/O.

@@ -13,37 +13,51 @@ import {
NoWorkspaceError,
WorkspaceUtils
} from '../../../utils/workspaceUtils';
import { TempProjectDirManager } from '../../TestHelper';
import {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the changes in this file are just refactors to optimize the existing code. No new testing here, otherwise.

@@ -48,8 +49,8 @@ export type SObjectCompactLayout = {
export class OrgUtils {
public static async getSobjects(): Promise<SObject[]> {
try {
const org = await Org.create();
const conn = org.getConnection();
const conn =
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this file represent the entry points for the heart of the changes. Most of the other changes were either in the implementation of the backing Salesforce Extensions service connector code, or the supporting code in the tests.

Copy link
Collaborator

@dbreese dbreese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Glad you figured this out!

@khawkins khawkins merged commit 5556d76 into salesforce:main Nov 29, 2023
9 checks passed
@khawkins khawkins deleted the org_connection branch November 29, 2023 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants