-
Notifications
You must be signed in to change notification settings - Fork 0
Add CoreAPI to getAdoApi and getAdoApiWithAzCli return objects #196
Copy link
Copy link
Open
Description
Problem
getAdoApi() and getAdoApiWithAzCli() in src/ado.js only return workAPI and workItemAPI. Consumers that need the Core API (e.g. to list projects) must create a separate WebApi connection manually, duplicating auth logic.
See: https://github.com/beauraines/ado-utilities/pull/27#discussion_r2835588502
Proposed Change
Add coreAPI to the returned object from both functions. The WebApi connection is already created — just add one more getCoreApi() call.
In getAdoApi() (~line 27):
const coreAPI = await connection.getCoreApi();
return {
workAPI,
workItemAPI,
coreAPI,
teamContext,
config
}In getAdoApiWithAzCli() (~line 73):
const coreAPI = await connection.getCoreApi();
return {
workAPI,
workItemAPI,
coreAPI,
teamContext,
config
}Consumer Impact
Once released, ado-utilities/src/getProjects.js can be simplified from:
const ado = require('@beauraines/node-helpers').ado;
const azdev = require('azure-devops-node-api');
async function listProjects() {
const { config } = await ado.getAdoApiWithAzCli(configFile)
const authHandler = azdev.getBearerHandler(config.token);
const connection = new azdev.WebApi(config.org, authHandler);
const coreApi = await connection.getCoreApi();
const result = await coreApi.getProjects();
}To:
const ado = require('@beauraines/node-helpers').ado;
async function listProjects() {
const { coreAPI } = await ado.getAdoApiWithAzCli(configFile)
const result = await coreAPI.getProjects();
}This is a non-breaking change — existing destructuring patterns will continue to work.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels