Files
cloud-code/claude-code-source/node_modules/@azure/msal-common/dist/utils/FunctionWrappers.mjs
janlaywss a192e187e8 fix: keep only source-map extracted node_modules, exclude pnpm artifacts
Restore node_modules to exact state from cli.js.map extraction:
- Move .ignored/ and .ignored_* files back to original package paths
- Remove pnpm symlinks (replaced by real source-map directories)
- Update .gitignore: only exclude /dist/, .pnpm/, .bin/, .ignored* dirs
- All package dist/ folders are now preserved as part of source-map files

After clone, run `pnpm install` to get pnpm-managed symlinks for building.
The committed node_modules contains the original TypeScript/JS source files
as bundled in cli.js.
2026-03-31 21:09:32 +08:00

100 lines
3.4 KiB
JavaScript

/*! @azure/msal-common v15.13.1 2025-10-29 */
'use strict';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Wraps a function with a performance measurement.
* Usage: invoke(functionToCall, performanceClient, "EventName", "correlationId")(...argsToPassToFunction)
* @param callback
* @param eventName
* @param logger
* @param telemetryClient
* @param correlationId
* @returns
* @internal
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const invoke = (callback, eventName, logger, telemetryClient, correlationId) => {
return (...args) => {
logger.trace(`Executing function ${eventName}`);
const inProgressEvent = telemetryClient?.startMeasurement(eventName, correlationId);
if (correlationId) {
// Track number of times this API is called in a single request
const eventCount = eventName + "CallCount";
telemetryClient?.incrementFields({ [eventCount]: 1 }, correlationId);
}
try {
const result = callback(...args);
inProgressEvent?.end({
success: true,
});
logger.trace(`Returning result from ${eventName}`);
return result;
}
catch (e) {
logger.trace(`Error occurred in ${eventName}`);
try {
logger.trace(JSON.stringify(e));
}
catch (e) {
logger.trace("Unable to print error message.");
}
inProgressEvent?.end({
success: false,
}, e);
throw e;
}
};
};
/**
* Wraps an async function with a performance measurement.
* Usage: invokeAsync(functionToCall, performanceClient, "EventName", "correlationId")(...argsToPassToFunction)
* @param callback
* @param eventName
* @param logger
* @param telemetryClient
* @param correlationId
* @returns
* @internal
*
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId) => {
return (...args) => {
logger.trace(`Executing function ${eventName}`);
const inProgressEvent = telemetryClient?.startMeasurement(eventName, correlationId);
if (correlationId) {
// Track number of times this API is called in a single request
const eventCount = eventName + "CallCount";
telemetryClient?.incrementFields({ [eventCount]: 1 }, correlationId);
}
telemetryClient?.setPreQueueTime(eventName, correlationId);
return callback(...args)
.then((response) => {
logger.trace(`Returning result from ${eventName}`);
inProgressEvent?.end({
success: true,
});
return response;
})
.catch((e) => {
logger.trace(`Error occurred in ${eventName}`);
try {
logger.trace(JSON.stringify(e));
}
catch (e) {
logger.trace("Unable to print error message.");
}
inProgressEvent?.end({
success: false,
}, e);
throw e;
});
};
};
export { invoke, invokeAsync };
//# sourceMappingURL=FunctionWrappers.mjs.map