mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-22 15:02:22 +00:00
22 lines
500 B
TypeScript
22 lines
500 B
TypeScript
|
import { BalenaSDK } from 'balena-sdk';
|
||
|
import memoize = require('lodash/memoize');
|
||
|
|
||
|
export const serviceIdToName = memoize(
|
||
|
async (sdk: BalenaSDK, serviceId: number): Promise<string | undefined> => {
|
||
|
const serviceName = await sdk.pine.get({
|
||
|
resource: 'service',
|
||
|
id: serviceId,
|
||
|
options: {
|
||
|
$select: 'service_name',
|
||
|
},
|
||
|
});
|
||
|
|
||
|
if (serviceName != null) {
|
||
|
return serviceName.service_name;
|
||
|
}
|
||
|
return;
|
||
|
},
|
||
|
// Memoize the call based on service id
|
||
|
(_sdk, id) => id.toString(),
|
||
|
);
|