@itwin/core-bentley 5.1.0-dev.9 → 5.2.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAmB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAOhE;;GAEG;AACH,MAAM,CAAN,IAAY,QAWX;AAXD,WAAY,QAAQ;IAClB,wCAAwC;IACxC,yCAAK,CAAA;IACL,8BAA8B;IAC9B,uCAAI,CAAA;IACJ,4BAA4B;IAC5B,6CAAO,CAAA;IACP,6BAA6B;IAC7B,yCAAK,CAAA;IACL,+EAA+E;IAC/E,uCAAI,CAAA;AACN,CAAC,EAXW,QAAQ,KAAR,QAAQ,QAWnB;AAmCD;;;GAGG;AACH,MAAM,OAAO,MAAM;IACP,MAAM,CAAC,SAAS,CAA0B;IAC1C,MAAM,CAAC,WAAW,CAA0B;IAC5C,MAAM,CAAC,QAAQ,CAA0B;IACzC,MAAM,CAAC,SAAS,CAA0B;IAE5C,MAAM,CAAC,kBAAkB,CAAkC;IAC3D,MAAM,CAAC,eAAe,GAAG,IAAI,GAAG,EAA2B,CAAC;IAEpE,8EAA8E;IACvE,MAAM,KAAK,iBAAiB;QACjC,iJAAiJ;QACjJ,IAAI,SAAS,KAAK,MAAM,CAAC,kBAAkB,EAAE,CAAC;YAC5C,MAAM,CAAC,kBAAkB,GAAG,IAAI,OAAO,EAAc,CAAC;QACxD,CAAC;QAED,OAAO,MAAM,CAAC,kBAAkB,CAAC;IACnC,CAAC;IAEO,MAAM,CAAC,eAAe,GAAqD,EAAE,CAAC;IAEtF;;;OAGG;I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AAM,CAAC,SAAS,CAAC,qBAAqB,CAAC,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC;YAC5E,OAAO;QAET,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,UAAU,MAAM,EAAE,GAAG,EAAE;YAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7E,OAAO;gBACL,GAAG,KAAK,EAAE,WAAW,EAAE,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,2DAA2D;aACxH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,uDAAuD;IAChD,OAAO;QACZ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Logging\n */\n\nimport { BeEvent } from \"./BeEvent\";\nimport { BentleyError, IModelStatus, LoggingMetaData } from \"./BentleyError\";\nimport { BentleyLoggerCategory } from \"./BentleyLoggerCategory\";\n\n/** Defines the *signature* for a log function.\n * @public\n */\nexport type LogFunction = (category: string, message: string, metaData: LoggingMetaData) => void;\n\n/** Use to categorize logging messages by severity.\n * @public\n */\nexport enum LogLevel {\n /** Tracing and debugging - low level */\n Trace,\n /** Information - mid level */\n Info,\n /** Warnings - high level */\n Warning,\n /** Errors - highest level */\n Error,\n /** Higher than any real logging level. This is used to turn a category off. */\n None,\n}\n\n/** Identifies a logging category and the LogLevel that should be used for it. The LogLevel is specified by its string name.\n * @public\n */\nexport interface LoggerCategoryAndLevel {\n category: string;\n logLevel: string;\n}\n\n/** Specifies logging levels, including the default logging level and a set of categories and levels for them.\n * @public\n */\nexport interface LoggerLevelsConfig {\n defaultLevel?: string;\n categoryLevels?: LoggerCategoryAndLevel[];\n}\n\n/** A global set of metadata that should be included with every log message.\n * You can provide an object representing the metadata, or a function to be invoked to obtain the metadata object each\n * time a message is logged.\n * Each key-value pair of the object will be stringified and combined with the log message's per-call metadata.\n * The keys you provide to each method is used solely to identify your entries so that you can later update or delete them - these keys\n * are **not** included in log messages. Don't modify or remove metadata associated with keys that belong to someone else.\n * @note Each extra bit of metadata adds cost and overhead to the logging system. Avoid adding unnecessary or unnecessarily verbose metadata.\n * @see [[Logger.staticMetaData]] to access the global metadata.\n * @beta\n */\nexport interface StaticLoggerMetaData {\n /** Add or update some metadata to be included with every logged message. */\n set(key: string, metadata: LoggingMetaData): void;\n /** Remove metadata previously [[set]] using the specified `key`, so it will no longer be included with every logged message. */\n delete(key: string): void;\n}\n\n/** Logger allows libraries and apps to report potentially useful information about operations, and it allows apps and users to control\n * how or if the logged information is displayed or collected. See [Learning about Logging]($docs/learning/common/Logging.md).\n * @public\n */\nexport class Logger {\n protected static _logError: LogFunction | undefined;\n protected static _logWarning: LogFunction | undefined;\n protected static _logInfo: LogFunction | undefined;\n protected static _logTrace: LogFunction | undefined;\n\n private static _onLogLevelChanged: BeEvent<() => void> | undefined;\n private static _staticMetaData = new Map<string, LoggingMetaData>();\n\n /** An event raised whenever [[setLevel]] or [[setLevelDefault]] is called. */\n public static get onLogLevelChanged(): BeEvent<() => void> {\n // We have to lazily initialize because it's static and BeEvent imports UnexpectedErrors which imports Logger which wants to instantiate BeEvent.\n if (undefined === Logger._onLogLevelChanged) {\n Logger._onLogLevelChanged = new BeEvent<() => void>();\n }\n\n return Logger._onLogLevelChanged;\n }\n\n private static _categoryFilter: { [categoryName: string]: LogLevel | undefined } = {};\n\n /** Maps category names to the least severe level at which messages in that category should be displayed,\n * or `undefined` if a minimum has not been defined.\n * @see [[setLevel]] to change the minimum logging level for a category.\n */\n public static get categoryFilter(): Readonly<{ [categoryName: string]: LogLevel | undefined }> {\n // NOTE: this property is accessed by native code.\n return this._categoryFilter;\n }\n\n private static _minLevel: LogLevel | undefined;\n\n /** The least severe level at which messages should be displayed by default.\n * @see [[setLevelDefault]] to change this default.\n * @see [[setLevel]] to override this default for specific categories.\n */\n public static get minLevel(): LogLevel | undefined {\n // NOTE: this property is accessed by native code. */\n return this._minLevel;\n }\n\n /** Should the call stack be included when an exception is logged? */\n public static logExceptionCallstacks = false;\n\n /** Contains metadata that should be included with every logged message.\n * @beta\n */\n public static get staticMetaData(): StaticLoggerMetaData {\n return this._staticMetaData;\n }\n\n /** Initialize the logger streams. Should be called at application initialization time. */\n public static initialize(logError?: LogFunction, logWarning?: LogFunction, logInfo?: LogFunction, logTrace?: LogFunction): void {\n Logger._logError = logError;\n Logger._logWarning = logWarning;\n Logger._logInfo = logInfo;\n Logger._logTrace = logTrace;\n Logger.turnOffLevelDefault();\n Logger.turnOffCategories();\n }\n\n /** Initialize the logger to output to the console. */\n public static initializeToConsole(): void {\n const logConsole = (level: string) => (category: string, message: string, metaData: LoggingMetaData) =>\n console.log(`${level} | ${category} | ${message} ${Logger.stringifyMetaData(metaData)}`); // eslint-disable-line no-console\n\n Logger.initialize(logConsole(\"Error\"), logConsole(\"Warning\"), logConsole(\"Info\"), logConsole(\"Trace\"));\n }\n\n /** merge the supplied metadata with all static metadata into one object */\n public static getMetaData(metaData?: LoggingMetaData): object {\n const metaObj = {};\n for (const meta of this._staticMetaData) {\n const val = BentleyError.getMetaData(meta[1]);\n if (val)\n Object.assign(metaObj, val);\n }\n Object.assign(metaObj, BentleyError.getMetaData(metaData)); // do this last so user supplied values take precedence\n return metaObj;\n }\n\n /** stringify the metadata for a log message by merging the supplied metadata with all static metadata into one object that is then `JSON.stringify`ed. */\n public static stringifyMetaData(metaData?: LoggingMetaData): string {\n const metaObj = this.getMetaData(metaData);\n return Object.keys(metaObj).length > 0 ? JSON.stringify(metaObj) : \"\";\n }\n\n /** Set the least severe level at which messages should be displayed by default. Call setLevel to override this default setting for specific categories. */\n public static setLevelDefault(minLevel: LogLevel): void {\n this._minLevel = minLevel;\n this.onLogLevelChanged.raiseEvent();\n }\n\n /** Set the minimum logging level for the specified category. The minimum level is least severe level at which messages in the\n * specified category should be displayed.\n */\n public static setLevel(category: string, minLevel: LogLevel) {\n Logger._categoryFilter[category] = minLevel;\n this.onLogLevelChanged.raiseEvent();\n }\n\n /** Interpret a string as the name of a LogLevel */\n public static parseLogLevel(str: string): LogLevel {\n switch (str.toUpperCase()) {\n case \"EXCEPTION\": return LogLevel.Error;\n case \"FATAL\": return LogLevel.Error;\n case \"ERROR\": return LogLevel.Error;\n case \"WARNING\": return LogLevel.Warning;\n case \"INFO\": return LogLevel.Info;\n case \"TRACE\": return LogLevel.Trace;\n case \"DEBUG\": return LogLevel.Trace;\n }\n return LogLevel.None;\n }\n\n /** Set the log level for multiple categories at once. Also see [[validateProps]] */\n public static configureLevels(cfg: LoggerLevelsConfig) {\n Logger.validateProps(cfg);\n if (cfg.defaultLevel !== undefined) {\n this.setLevelDefault(Logger.parseLogLevel(cfg.defaultLevel));\n }\n if (cfg.categoryLevels !== undefined) {\n for (const cl of cfg.categoryLevels) {\n this.setLevel(cl.category, Logger.parseLogLevel(cl.logLevel));\n }\n }\n }\n\n private static isLogLevel(v: string) {\n return LogLevel.hasOwnProperty(v);\n }\n\n /** Check that the specified object is a valid LoggerLevelsConfig. This is useful when reading a config from a .json file. */\n public static validateProps(config: any) {\n const validProps = [\"defaultLevel\", \"categoryLevels\"];\n for (const prop of Object.keys(config)) {\n if (!validProps.includes(prop))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig - unrecognized property: ${prop}`);\n if (prop === \"defaultLevel\") {\n if (!Logger.isLogLevel(config.defaultLevel))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.defaultLevel must be a LogLevel. Invalid value: ${JSON.stringify(config.defaultLevel)}`);\n } else if (prop === \"categoryLevels\") {\n const value = config[prop];\n if (!Array.isArray(value))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels must be an array. Invalid value: ${JSON.stringify(value)}`);\n for (const item of config[prop]) {\n if (!item.hasOwnProperty(\"category\") || !item.hasOwnProperty(\"logLevel\"))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item must be a LoggerCategoryAndLevel {category: logLevel:}. Invalid value: ${JSON.stringify(item)}`);\n if (!Logger.isLogLevel(item.logLevel))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item's logLevel property must be a LogLevel. Invalid value: ${JSON.stringify(item.logLevel)}`);\n }\n }\n }\n }\n\n /** Get the minimum logging level for the specified category. */\n public static getLevel(category: string): LogLevel | undefined {\n // Prefer the level set for this category specifically\n const minLevelForThisCategory = Logger.categoryFilter[category];\n if (minLevelForThisCategory !== undefined)\n return minLevelForThisCategory;\n\n // Fall back on the level set for the parent of this category.\n const parent = category.lastIndexOf(\".\");\n if (parent !== -1)\n return Logger.getLevel(category.slice(0, parent));\n\n // Fall back on the default level.\n return Logger.minLevel;\n }\n\n /** Turns off the least severe level at which messages should be displayed by default.\n * This turns off logging for all messages for which no category minimum level is defined.\n */\n public static turnOffLevelDefault(): void {\n Logger._minLevel = undefined;\n }\n\n /** Turns off all category level filters previously defined with [[Logger.setLevel]].\n */\n public static turnOffCategories(): void {\n Logger._categoryFilter = {};\n }\n\n /** Check if messages in the specified category should be displayed at this level of severity. */\n public static isEnabled(category: string, level: LogLevel): boolean {\n const minLevel = Logger.getLevel(category);\n return (minLevel !== undefined) && (level >= minLevel);\n }\n\n /** Log the specified message to the **error** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logError(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logError && Logger.isEnabled(category, LogLevel.Error))\n Logger._logError(category, message, metaData);\n }\n\n private static getExceptionMessage(err: unknown): string {\n if (err === undefined) {\n return \"Error: err is undefined.\";\n }\n if (err === null) {\n return \"Error: err is null.\";\n }\n const stack = Logger.logExceptionCallstacks ? `\\n${BentleyError.getErrorStack(err)}` : \"\";\n return BentleyError.getErrorMessage(err) + stack;\n }\n\n /** Log the specified exception.\n * For legacy [[BentleyError]] exceptions, the special \"exceptionType\" property will be added as metadata. Otherwise, all enumerable members of the exception are logged as metadata.\n * @param category The category of the message.\n * @param err The exception object.\n * @param log The logger output function to use - defaults to Logger.logError\n */\n public static logException(category: string, err: any, log: LogFunction = (_category, message, metaData) => Logger.logError(_category, message, metaData)): void {\n log(category, Logger.getExceptionMessage(err), () => {\n // For backwards compatibility, log BentleyError old way\n if (BentleyError.isError(err))\n return { ...BentleyError.getErrorMetadata(err), exceptionType: err?.constructor?.name ?? \"<Unknown>\" };\n\n // return a copy of the error, with non-enumerable members `message` and `stack` removed, as \"metadata\" for log.\n return { ...err };\n });\n }\n\n /** Log the specified message to the **warning** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logWarning(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logWarning && Logger.isEnabled(category, LogLevel.Warning))\n Logger._logWarning(category, message, metaData);\n }\n\n /** Log the specified message to the **info** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logInfo(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logInfo && Logger.isEnabled(category, LogLevel.Info))\n Logger._logInfo(category, message, metaData);\n }\n\n /** Log the specified message to the **trace** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logTrace(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logTrace && Logger.isEnabled(category, LogLevel.Trace))\n Logger._logTrace(category, message, metaData);\n }\n}\n\n/** Simple performance diagnostics utility.\n * It measures the time from construction to disposal. On disposal it logs the routine name along with\n * the duration in milliseconds.\n * It also logs the routine name at construction time so that nested calls can be disambiguated.\n *\n * The timings are logged using the log category **Performance** and log severity [[LogLevel.INFO]].\n * Enable those, if you want to capture timings.\n * @public\n */\nexport class PerfLogger implements Disposable {\n private static _severity: LogLevel = LogLevel.Info;\n\n private _operation: string;\n private _metaData?: LoggingMetaData;\n private _startTimeStamp: number;\n\n public constructor(operation: string, metaData?: LoggingMetaData) {\n this._operation = operation;\n this._metaData = metaData;\n\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity)) {\n this._startTimeStamp = 0;\n return;\n }\n\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},START`, this._metaData);\n this._startTimeStamp = new Date().getTime(); // take timestamp\n }\n\n private logMessage(): void {\n const endTimeStamp: number = new Date().getTime();\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity))\n return;\n\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},END`, () => {\n const mdata = this._metaData ? BentleyError.getMetaData(this._metaData) : {};\n return {\n ...mdata, TimeElapsed: endTimeStamp - this._startTimeStamp, // eslint-disable-line @typescript-eslint/naming-convention\n };\n });\n }\n\n public [Symbol.dispose](): void {\n this.logMessage();\n }\n\n /** @deprecated in 5.0 Use [Symbol.dispose] instead. */\n public dispose(): void {\n this[Symbol.dispose]();\n }\n}\n\n"]}
1
+ {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAmB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAOhE;;GAEG;AACH,MAAM,CAAN,IAAY,QAWX;AAXD,WAAY,QAAQ;IAClB,wCAAwC;IACxC,yCAAK,CAAA;IACL,8BAA8B;IAC9B,uCAAI,CAAA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AAE,CAAC;IACpB,CAAC;IAED,qGAAqG;IAC9F,OAAO;QACZ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Logging\n */\n\nimport { BeEvent } from \"./BeEvent\";\nimport { BentleyError, IModelStatus, LoggingMetaData } from \"./BentleyError\";\nimport { BentleyLoggerCategory } from \"./BentleyLoggerCategory\";\n\n/** Defines the *signature* for a log function.\n * @public\n */\nexport type LogFunction = (category: string, message: string, metaData: LoggingMetaData) => void;\n\n/** Use to categorize logging messages by severity.\n * @public\n */\nexport enum LogLevel {\n /** Tracing and debugging - low level */\n Trace,\n /** Information - mid level */\n Info,\n /** Warnings - high level */\n Warning,\n /** Errors - highest level */\n Error,\n /** Higher than any real logging level. This is used to turn a category off. */\n None,\n}\n\n/** Identifies a logging category and the LogLevel that should be used for it. The LogLevel is specified by its string name.\n * @public\n */\nexport interface LoggerCategoryAndLevel {\n category: string;\n logLevel: string;\n}\n\n/** Specifies logging levels, including the default logging level and a set of categories and levels for them.\n * @public\n */\nexport interface LoggerLevelsConfig {\n defaultLevel?: string;\n categoryLevels?: LoggerCategoryAndLevel[];\n}\n\n/** A global set of metadata that should be included with every log message.\n * You can provide an object representing the metadata, or a function to be invoked to obtain the metadata object each\n * time a message is logged.\n * Each key-value pair of the object will be stringified and combined with the log message's per-call metadata.\n * The keys you provide to each method is used solely to identify your entries so that you can later update or delete them - these keys\n * are **not** included in log messages. Don't modify or remove metadata associated with keys that belong to someone else.\n * @note Each extra bit of metadata adds cost and overhead to the logging system. Avoid adding unnecessary or unnecessarily verbose metadata.\n * @see [[Logger.staticMetaData]] to access the global metadata.\n * @beta\n */\nexport interface StaticLoggerMetaData {\n /** Add or update some metadata to be included with every logged message. */\n set(key: string, metadata: LoggingMetaData): void;\n /** Remove metadata previously [[set]] using the specified `key`, so it will no longer be included with every logged message. */\n delete(key: string): void;\n}\n\n/** Logger allows libraries and apps to report potentially useful information about operations, and it allows apps and users to control\n * how or if the logged information is displayed or collected. See [Learning about Logging]($docs/learning/common/Logging.md).\n * @public\n */\nexport class Logger {\n protected static _logError: LogFunction | undefined;\n protected static _logWarning: LogFunction | undefined;\n protected static _logInfo: LogFunction | undefined;\n protected static _logTrace: LogFunction | undefined;\n\n private static _onLogLevelChanged: BeEvent<() => void> | undefined;\n private static _staticMetaData = new Map<string, LoggingMetaData>();\n\n /** An event raised whenever [[setLevel]] or [[setLevelDefault]] is called. */\n public static get onLogLevelChanged(): BeEvent<() => void> {\n // We have to lazily initialize because it's static and BeEvent imports UnexpectedErrors which imports Logger which wants to instantiate BeEvent.\n if (undefined === Logger._onLogLevelChanged) {\n Logger._onLogLevelChanged = new BeEvent<() => void>();\n }\n\n return Logger._onLogLevelChanged;\n }\n\n private static _categoryFilter: { [categoryName: string]: LogLevel | undefined } = {};\n\n /** Maps category names to the least severe level at which messages in that category should be displayed,\n * or `undefined` if a minimum has not been defined.\n * @see [[setLevel]] to change the minimum logging level for a category.\n */\n public static get categoryFilter(): Readonly<{ [categoryName: string]: LogLevel | undefined }> {\n // NOTE: this property is accessed by native code.\n return this._categoryFilter;\n }\n\n private static _minLevel: LogLevel | undefined;\n\n /** The least severe level at which messages should be displayed by default.\n * @see [[setLevelDefault]] to change this default.\n * @see [[setLevel]] to override this default for specific categories.\n */\n public static get minLevel(): LogLevel | undefined {\n // NOTE: this property is accessed by native code. */\n return this._minLevel;\n }\n\n /** Should the call stack be included when an exception is logged? */\n public static logExceptionCallstacks = false;\n\n /** Contains metadata that should be included with every logged message.\n * @beta\n */\n public static get staticMetaData(): StaticLoggerMetaData {\n return this._staticMetaData;\n }\n\n /** Initialize the logger streams. Should be called at application initialization time. */\n public static initialize(logError?: LogFunction, logWarning?: LogFunction, logInfo?: LogFunction, logTrace?: LogFunction): void {\n Logger._logError = logError;\n Logger._logWarning = logWarning;\n Logger._logInfo = logInfo;\n Logger._logTrace = logTrace;\n Logger.turnOffLevelDefault();\n Logger.turnOffCategories();\n }\n\n /** Initialize the logger to output to the console. */\n public static initializeToConsole(): void {\n const logConsole = (level: string) => (category: string, message: string, metaData: LoggingMetaData) =>\n console.log(`${level} | ${category} | ${message} ${Logger.stringifyMetaData(metaData)}`); // eslint-disable-line no-console\n\n Logger.initialize(logConsole(\"Error\"), logConsole(\"Warning\"), logConsole(\"Info\"), logConsole(\"Trace\"));\n }\n\n /** merge the supplied metadata with all static metadata into one object */\n public static getMetaData(metaData?: LoggingMetaData): object {\n const metaObj = {};\n for (const meta of this._staticMetaData) {\n const val = BentleyError.getMetaData(meta[1]);\n if (val)\n Object.assign(metaObj, val);\n }\n Object.assign(metaObj, BentleyError.getMetaData(metaData)); // do this last so user supplied values take precedence\n return metaObj;\n }\n\n /** stringify the metadata for a log message by merging the supplied metadata with all static metadata into one object that is then `JSON.stringify`ed. */\n public static stringifyMetaData(metaData?: LoggingMetaData): string {\n const metaObj = this.getMetaData(metaData);\n return Object.keys(metaObj).length > 0 ? JSON.stringify(metaObj) : \"\";\n }\n\n /** Set the least severe level at which messages should be displayed by default. Call setLevel to override this default setting for specific categories. */\n public static setLevelDefault(minLevel: LogLevel): void {\n this._minLevel = minLevel;\n this.onLogLevelChanged.raiseEvent();\n }\n\n /** Set the minimum logging level for the specified category. The minimum level is least severe level at which messages in the\n * specified category should be displayed.\n */\n public static setLevel(category: string, minLevel: LogLevel) {\n Logger._categoryFilter[category] = minLevel;\n this.onLogLevelChanged.raiseEvent();\n }\n\n /** Interpret a string as the name of a LogLevel */\n public static parseLogLevel(str: string): LogLevel {\n switch (str.toUpperCase()) {\n case \"EXCEPTION\": return LogLevel.Error;\n case \"FATAL\": return LogLevel.Error;\n case \"ERROR\": return LogLevel.Error;\n case \"WARNING\": return LogLevel.Warning;\n case \"INFO\": return LogLevel.Info;\n case \"TRACE\": return LogLevel.Trace;\n case \"DEBUG\": return LogLevel.Trace;\n }\n return LogLevel.None;\n }\n\n /** Set the log level for multiple categories at once. Also see [[validateProps]] */\n public static configureLevels(cfg: LoggerLevelsConfig) {\n Logger.validateProps(cfg);\n if (cfg.defaultLevel !== undefined) {\n this.setLevelDefault(Logger.parseLogLevel(cfg.defaultLevel));\n }\n if (cfg.categoryLevels !== undefined) {\n for (const cl of cfg.categoryLevels) {\n this.setLevel(cl.category, Logger.parseLogLevel(cl.logLevel));\n }\n }\n }\n\n private static isLogLevel(v: string) {\n return LogLevel.hasOwnProperty(v);\n }\n\n /** Check that the specified object is a valid LoggerLevelsConfig. This is useful when reading a config from a .json file. */\n public static validateProps(config: any) {\n const validProps = [\"defaultLevel\", \"categoryLevels\"];\n for (const prop of Object.keys(config)) {\n if (!validProps.includes(prop))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig - unrecognized property: ${prop}`);\n if (prop === \"defaultLevel\") {\n if (!Logger.isLogLevel(config.defaultLevel))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.defaultLevel must be a LogLevel. Invalid value: ${JSON.stringify(config.defaultLevel)}`);\n } else if (prop === \"categoryLevels\") {\n const value = config[prop];\n if (!Array.isArray(value))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels must be an array. Invalid value: ${JSON.stringify(value)}`);\n for (const item of config[prop]) {\n if (!item.hasOwnProperty(\"category\") || !item.hasOwnProperty(\"logLevel\"))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item must be a LoggerCategoryAndLevel {category: logLevel:}. Invalid value: ${JSON.stringify(item)}`);\n if (!Logger.isLogLevel(item.logLevel))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item's logLevel property must be a LogLevel. Invalid value: ${JSON.stringify(item.logLevel)}`);\n }\n }\n }\n }\n\n /** Get the minimum logging level for the specified category. */\n public static getLevel(category: string): LogLevel | undefined {\n // Prefer the level set for this category specifically\n const minLevelForThisCategory = Logger.categoryFilter[category];\n if (minLevelForThisCategory !== undefined)\n return minLevelForThisCategory;\n\n // Fall back on the level set for the parent of this category.\n const parent = category.lastIndexOf(\".\");\n if (parent !== -1)\n return Logger.getLevel(category.slice(0, parent));\n\n // Fall back on the default level.\n return Logger.minLevel;\n }\n\n /** Turns off the least severe level at which messages should be displayed by default.\n * This turns off logging for all messages for which no category minimum level is defined.\n */\n public static turnOffLevelDefault(): void {\n Logger._minLevel = undefined;\n }\n\n /** Turns off all category level filters previously defined with [[Logger.setLevel]].\n */\n public static turnOffCategories(): void {\n Logger._categoryFilter = {};\n }\n\n /** Check if messages in the specified category should be displayed at this level of severity. */\n public static isEnabled(category: string, level: LogLevel): boolean {\n const minLevel = Logger.getLevel(category);\n return (minLevel !== undefined) && (level >= minLevel);\n }\n\n /** Log the specified message to the **error** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logError(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logError && Logger.isEnabled(category, LogLevel.Error))\n Logger._logError(category, message, metaData);\n }\n\n private static getExceptionMessage(err: unknown): string {\n if (err === undefined) {\n return \"Error: err is undefined.\";\n }\n if (err === null) {\n return \"Error: err is null.\";\n }\n const stack = Logger.logExceptionCallstacks ? `\\n${BentleyError.getErrorStack(err)}` : \"\";\n return BentleyError.getErrorMessage(err) + stack;\n }\n\n /** Log the specified exception.\n * For legacy [[BentleyError]] exceptions, the special \"exceptionType\" property will be added as metadata. Otherwise, all enumerable members of the exception are logged as metadata.\n * @param category The category of the message.\n * @param err The exception object.\n * @param log The logger output function to use - defaults to Logger.logError\n */\n public static logException(category: string, err: any, log: LogFunction = (_category, message, metaData) => Logger.logError(_category, message, metaData)): void {\n log(category, Logger.getExceptionMessage(err), () => {\n // For backwards compatibility, log BentleyError old way\n if (BentleyError.isError(err))\n return { ...BentleyError.getErrorMetadata(err), exceptionType: err?.constructor?.name ?? \"<Unknown>\" };\n\n // return a copy of the error, with non-enumerable members `message` and `stack` removed, as \"metadata\" for log.\n return { ...err };\n });\n }\n\n /** Log the specified message to the **warning** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logWarning(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logWarning && Logger.isEnabled(category, LogLevel.Warning))\n Logger._logWarning(category, message, metaData);\n }\n\n /** Log the specified message to the **info** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logInfo(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logInfo && Logger.isEnabled(category, LogLevel.Info))\n Logger._logInfo(category, message, metaData);\n }\n\n /** Log the specified message to the **trace** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logTrace(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logTrace && Logger.isEnabled(category, LogLevel.Trace))\n Logger._logTrace(category, message, metaData);\n }\n}\n\n/** Simple performance diagnostics utility.\n * It measures the time from construction to disposal. On disposal it logs the routine name along with\n * the duration in milliseconds.\n * It also logs the routine name at construction time so that nested calls can be disambiguated.\n *\n * The timings are logged using the log category **Performance** and log severity [[LogLevel.INFO]].\n * Enable those, if you want to capture timings.\n * @public\n */\nexport class PerfLogger implements Disposable {\n private static _severity: LogLevel = LogLevel.Info;\n\n private _operation: string;\n private _metaData?: LoggingMetaData;\n private _startTimeStamp: number;\n\n public constructor(operation: string, metaData?: LoggingMetaData) {\n this._operation = operation;\n this._metaData = metaData;\n\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity)) {\n this._startTimeStamp = 0;\n return;\n }\n\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},START`, this._metaData);\n this._startTimeStamp = new Date().getTime(); // take timestamp\n }\n\n private logMessage(): void {\n const endTimeStamp: number = new Date().getTime();\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity))\n return;\n\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},END`, () => {\n const mdata = this._metaData ? BentleyError.getMetaData(this._metaData) : {};\n return {\n ...mdata, TimeElapsed: endTimeStamp - this._startTimeStamp, // eslint-disable-line @typescript-eslint/naming-convention\n };\n });\n }\n\n public [Symbol.dispose](): void {\n this.logMessage();\n }\n\n /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */\n public dispose(): void {\n this[Symbol.dispose]();\n }\n}\n\n"]}
@@ -5,7 +5,7 @@ import type { SpanAttributes, SpanContext, SpanOptions, Tracer } from "@opentele
5
5
  /**
6
6
  * Mirrors the SpanKind enum from [@opentelemetry/api](https://open-telemetry.github.io/opentelemetry-js/enums/_opentelemetry_api.SpanKind.html)
7
7
  * @public
8
- * @deprecated in 4.4 - OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly.
8
+ * @deprecated in 4.4 - will not be removed until after 2026-06-13. OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly.
9
9
  */
10
10
  export declare enum SpanKind {
11
11
  INTERNAL = 0,
@@ -17,7 +17,7 @@ export declare enum SpanKind {
17
17
  /**
18
18
  * Enables OpenTelemetry tracing in addition to traditional logging.
19
19
  * @public
20
- * @deprecated in 4.4 - OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly.
20
+ * @deprecated in 4.4 - will not be removed until after 2026-06-13. OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly.
21
21
  */
22
22
  export declare class Tracing {
23
23
  private static _tracer?;
@@ -10,7 +10,7 @@ import { Logger, LogLevel } from "./Logger";
10
10
  /**
11
11
  * Mirrors the SpanKind enum from [@opentelemetry/api](https://open-telemetry.github.io/opentelemetry-js/enums/_opentelemetry_api.SpanKind.html)
12
12
  * @public
13
- * @deprecated in 4.4 - OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly.
13
+ * @deprecated in 4.4 - will not be removed until after 2026-06-13. OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly.
14
14
  */
15
15
  export var SpanKind;
16
16
  (function (SpanKind) {
@@ -70,7 +70,7 @@ function flattenObject(obj) {
70
70
  /**
71
71
  * Enables OpenTelemetry tracing in addition to traditional logging.
72
72
  * @public
73
- * @deprecated in 4.4 - OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly.
73
+ * @deprecated in 4.4 - will not be removed until after 2026-06-13. OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly.
74
74
  */
75
75
  export class Tracing {
76
76
  static _tracer;
@@ -1 +1 @@
1
- {"version":3,"file":"Tracing.js","sourceRoot":"","sources":["../../src/Tracing.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAe,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzD,kGAAkG;AAClG;;;;GAIG;AACH,MAAM,CAAN,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,+CAAY,CAAA;IACZ,2CAAU,CAAA;IACV,2CAAU,CAAA;IACV,+CAAY,CAAA;IACZ,+CAAY,CAAA;AACd,CAAC,EANW,QAAQ,KAAR,QAAQ,QAMnB;AAED,SAAS,gBAAgB,CAAC,GAAY;IACpC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,SAAS,CAAC;AACxF,CAAC;AAED,6GAA6G;AAC7G,iJAAiJ;AACjJ,SAAS,qBAAqB,CAAC,GAAY;IACzC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QACrB,OAAO,KAAK,CAAC;IAEf,IAAI,QAAQ,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KA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DAAyD;oBACzD,QAAQ,EAAE,WAAW,EAAE,OAAO;oBAC9B,OAAO,EAAE,WAAW,EAAE,MAAM;oBAC5B,WAAW,EAAE,WAAW,EAAE,UAAU;oBACpC,wDAAwD;iBACzD,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,aAAa,CAAC,UAA0B;QACpD,OAAO,CAAC,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAC5G,CAAC;CACF;AAED,oDAAoD","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Logging\n */\n\nimport type { ContextAPI, SpanAttributes, SpanAttributeValue, SpanContext, SpanOptions, TraceAPI, Tracer } from \"@opentelemetry/api\";\nimport { LogFunction, Logger, LogLevel } from \"./Logger\";\n\n// re-export so that consumers can construct full SpanOptions object without external dependencies\n/**\n * Mirrors the SpanKind enum from [@opentelemetry/api](https://open-telemetry.github.io/opentelemetry-js/enums/_opentelemetry_api.SpanKind.html)\n * @public\n * @deprecated in 4.4 - OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly.\n */\nexport enum SpanKind {\n INTERNAL = 0,\n SERVER = 1,\n CLIENT = 2,\n PRODUCER = 3,\n CONSUMER = 4\n}\n\nfunction isValidPrimitive(val: unknown): val is SpanAttributeValue {\n return typeof val === \"string\" || typeof val === \"number\" || typeof val === \"boolean\";\n}\n\n// Only _homogenous_ arrays of strings, numbers, or booleans are supported as OpenTelemetry Attribute values.\n// Per the spec (https://opentelemetry.io/docs/reference/specification/common/common/#attribute), empty arrays and null values are supported too.\nfunction isValidPrimitiveArray(val: unknown): val is SpanAttributeValue {\n if (!Array.isArray(val))\n return false;\n\n let itemType;\n for (const x of val) {\n if (x === undefined || x === null)\n continue;\n\n if (!itemType) {\n itemType = typeof x;\n if (!isValidPrimitive(x))\n return false;\n }\n\n if (typeof x !== itemType)\n return false;\n }\n return true;\n}\n\nfunction isPlainObject(obj: unknown): obj is object {\n return typeof obj === \"object\" && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;\n}\n\nfunction* getFlatEntries(obj: unknown, path = \"\"): Iterable<[string, SpanAttributeValue]> {\n if (isValidPrimitiveArray(obj)) {\n yield [path, obj];\n return;\n }\n\n // Prefer JSON serialization over flattening for any non-POJO types.\n // There's just too many ways trying to flatten those can go wrong (Dates, Buffers, TypedArrays, etc.)\n if (!isPlainObject(obj) && !Array.isArray(obj)) {\n yield [path, isValidPrimitive(obj) ? obj : JSON.stringify(obj)];\n return;\n }\n\n // Always serialize empty objects/arrays as empty array values\n const entries = Object.entries(obj);\n if (entries.length === 0)\n yield [path, []];\n\n for (const [key, val] of entries)\n yield* getFlatEntries(val, (path === \"\") ? key : `${path}.${key}`);\n}\n\nfunction flattenObject(obj: object): SpanAttributes {\n return Object.fromEntries(getFlatEntries(obj));\n}\n\n/* eslint-disable @typescript-eslint/no-deprecated -- lots of self-references here... */\n\n/**\n * Enables OpenTelemetry tracing in addition to traditional logging.\n * @public\n * @deprecated in 4.4 - OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly.\n */\nexport class Tracing {\n private static _tracer?: Tracer;\n private static _openTelemetry?: { trace: Pick<TraceAPI, \"setSpan\" | \"setSpanContext\" | \"getSpan\">, context: Pick<ContextAPI, \"active\" | \"with\"> };\n\n /**\n * If OpenTelemetry tracing is enabled, creates a new span and runs the provided function in it.\n * If OpenTelemetry tracing is _not_ enabled, runs the provided function.\n * @param name name of the new span\n * @param fn function to run inside the new span\n * @param options span options\n * @param parentContext optional context used to retrieve parent span id\n */\n public static async withSpan<T>(name: string, fn: () => Promise<T>, options?: SpanOptions, parentContext?: SpanContext): Promise<T> {\n if (Tracing._tracer === undefined || Tracing._openTelemetry === undefined)\n return fn();\n\n // this case is for context propagation - parentContext is typically constructed from HTTP headers\n const parent = parentContext === undefined\n ? Tracing._openTelemetry.context.active()\n : Tracing._openTelemetry.trace.setSpanContext(Tracing._openTelemetry.context.active(), parentContext);\n\n return Tracing._openTelemetry.context.with(\n Tracing._openTelemetry.trace.setSpan(\n parent,\n Tracing._tracer.startSpan(name, options, Tracing._openTelemetry.context.active()),\n ),\n async () => {\n try {\n return await fn();\n } catch (err) {\n if (err instanceof Error) // ignore non-Error throws, such as RpcControlResponse\n Tracing._openTelemetry?.trace.getSpan(Tracing._openTelemetry.context.active())?.setAttribute(\"error\", true);\n throw err;\n } finally {\n Tracing._openTelemetry?.trace.getSpan(Tracing._openTelemetry.context.active())?.end();\n }\n },\n );\n }\n\n /**\n * Adds a span event describing a runtime exception, as advised in OpenTelemetry documentation\n * @param e error (exception) object\n */\n public static recordException(e: Error) {\n Tracing._openTelemetry?.trace.getSpan(Tracing._openTelemetry.context.active())?.recordException(e);\n }\n\n /**\n * Enable logging to OpenTelemetry. [[Tracing.withSpan]] will be enabled, all log entries will be attached to active span as span events.\n * [IModelHost.startup]($backend) will call this automatically if the `enableOpenTelemetry` option is enabled and it succeeds in requiring `@opentelemetry/api`.\n * @note Node.js OpenTelemetry SDK should be initialized by the user.\n */\n public static enableOpenTelemetry(tracer: Tracer, api: typeof Tracing._openTelemetry) {\n Tracing._tracer = tracer;\n Tracing._openTelemetry = api;\n Logger.logTrace = Tracing.withOpenTelemetry(LogLevel.Trace, Logger.logTrace.bind(Logger)).bind(Logger);\n Logger.logInfo = Tracing.withOpenTelemetry(LogLevel.Info, Logger.logInfo.bind(Logger)).bind(Logger);\n Logger.logWarning = Tracing.withOpenTelemetry(LogLevel.Warning, Logger.logWarning.bind(Logger)).bind(Logger);\n Logger.logError = Tracing.withOpenTelemetry(LogLevel.Error, Logger.logError.bind(Logger)).bind(Logger);\n }\n\n private static withOpenTelemetry(level: LogLevel, base: LogFunction, isError: boolean = false): LogFunction {\n return (category, message, metaData) => {\n const oTelContext = Tracing._openTelemetry?.context.active();\n if(Tracing._openTelemetry === undefined || oTelContext === undefined)\n return base(category, message, metaData);\n\n const serializedMetadata = Logger.getMetaData(metaData);\n if(Logger.isEnabled(category, level)) {\n try {\n Tracing._openTelemetry?.trace\n .getSpan(Tracing._openTelemetry.context.active())\n ?.addEvent(message, {\n ...flattenObject(serializedMetadata),\n error: isError,\n loggerCategory: category,\n });\n } catch { } // avoid throwing random errors (with stack trace mangled by async hooks) when openTelemetry collector doesn't work\n\n const spanContext = Tracing._openTelemetry.trace.getSpan(oTelContext)?.spanContext();\n base(category, message, {\n ...serializedMetadata,\n /* eslint-disable @typescript-eslint/naming-convention */\n trace_id: spanContext?.traceId,\n span_id: spanContext?.spanId,\n trace_flags: spanContext?.traceFlags,\n /* eslint-enable @typescript-eslint/naming-convention */\n });\n }\n };\n }\n\n /** Set attributes on currently active openTelemetry span. Doesn't do anything if openTelemetry logging is not initialized.\n * @param attributes The attributes to set\n */\n public static setAttributes(attributes: SpanAttributes) {\n Tracing._openTelemetry?.trace.getSpan(Tracing._openTelemetry.context.active())?.setAttributes(attributes);\n }\n}\n\n/* eslint-enable @typescript-eslint/no-deprecated */\n"]}
1
+ {"version":3,"file":"Tracing.js","sourceRoot":"","sources":["../../src/Tracing.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAe,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzD,kGAAkG;AAClG;;;;GAIG;AACH,MAAM,CAAN,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,+CAAY,CAAA;IACZ,2CAAU,CAAA;IACV,2CAAU,CAAA;IACV,+CAAY,CAAA;IACZ,+CAAY,CAAA;AACd,CAAC,EANW,QAAQ,KAAR,QAAQ,QAMnB;AAED,SAAS,gBAAgB,CAAC,GAAY;IACpC,OAAO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OAAO,EAAE;wBAClB,GAAG,aAAa,CAAC,kBAAkB,CAAC;wBACpC,KAAK,EAAE,OAAO;wBACd,cAAc,EAAE,QAAQ;qBACzB,CAAC,CAAC;gBACP,CAAC;gBAAC,MAAM,CAAC,CAAC,CAAC,CAAC,mHAAmH;gBAE/H,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;gBACrF,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE;oBACtB,GAAG,kBAAkB;oBACrB,yDAAyD;oBACzD,QAAQ,EAAE,WAAW,EAAE,OAAO;oBAC9B,OAAO,EAAE,WAAW,EAAE,MAAM;oBAC5B,WAAW,EAAE,WAAW,EAAE,UAAU;oBACpC,wDAAwD;iBACzD,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,aAAa,CAAC,UAA0B;QACpD,OAAO,CAAC,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAC5G,CAAC;CACF;AAED,oDAAoD","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Logging\n */\n\nimport type { ContextAPI, SpanAttributes, SpanAttributeValue, SpanContext, SpanOptions, TraceAPI, Tracer } from \"@opentelemetry/api\";\nimport { LogFunction, Logger, LogLevel } from \"./Logger\";\n\n// re-export so that consumers can construct full SpanOptions object without external dependencies\n/**\n * Mirrors the SpanKind enum from [@opentelemetry/api](https://open-telemetry.github.io/opentelemetry-js/enums/_opentelemetry_api.SpanKind.html)\n * @public\n * @deprecated in 4.4 - will not be removed until after 2026-06-13. OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly.\n */\nexport enum SpanKind {\n INTERNAL = 0,\n SERVER = 1,\n CLIENT = 2,\n PRODUCER = 3,\n CONSUMER = 4\n}\n\nfunction isValidPrimitive(val: unknown): val is SpanAttributeValue {\n return typeof val === \"string\" || typeof val === \"number\" || typeof val === \"boolean\";\n}\n\n// Only _homogenous_ arrays of strings, numbers, or booleans are supported as OpenTelemetry Attribute values.\n// Per the spec (https://opentelemetry.io/docs/reference/specification/common/common/#attribute), empty arrays and null values are supported too.\nfunction isValidPrimitiveArray(val: unknown): val is SpanAttributeValue {\n if (!Array.isArray(val))\n return false;\n\n let itemType;\n for (const x of val) {\n if (x === undefined || x === null)\n continue;\n\n if (!itemType) {\n itemType = typeof x;\n if (!isValidPrimitive(x))\n return false;\n }\n\n if (typeof x !== itemType)\n return false;\n }\n return true;\n}\n\nfunction isPlainObject(obj: unknown): obj is object {\n return typeof obj === \"object\" && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;\n}\n\nfunction* getFlatEntries(obj: unknown, path = \"\"): Iterable<[string, SpanAttributeValue]> {\n if (isValidPrimitiveArray(obj)) {\n yield [path, obj];\n return;\n }\n\n // Prefer JSON serialization over flattening for any non-POJO types.\n // There's just too many ways trying to flatten those can go wrong (Dates, Buffers, TypedArrays, etc.)\n if (!isPlainObject(obj) && !Array.isArray(obj)) {\n yield [path, isValidPrimitive(obj) ? obj : JSON.stringify(obj)];\n return;\n }\n\n // Always serialize empty objects/arrays as empty array values\n const entries = Object.entries(obj);\n if (entries.length === 0)\n yield [path, []];\n\n for (const [key, val] of entries)\n yield* getFlatEntries(val, (path === \"\") ? key : `${path}.${key}`);\n}\n\nfunction flattenObject(obj: object): SpanAttributes {\n return Object.fromEntries(getFlatEntries(obj));\n}\n\n/* eslint-disable @typescript-eslint/no-deprecated -- lots of self-references here... */\n\n/**\n * Enables OpenTelemetry tracing in addition to traditional logging.\n * @public\n * @deprecated in 4.4 - will not be removed until after 2026-06-13. OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly.\n */\nexport class Tracing {\n private static _tracer?: Tracer;\n private static _openTelemetry?: { trace: Pick<TraceAPI, \"setSpan\" | \"setSpanContext\" | \"getSpan\">, context: Pick<ContextAPI, \"active\" | \"with\"> };\n\n /**\n * If OpenTelemetry tracing is enabled, creates a new span and runs the provided function in it.\n * If OpenTelemetry tracing is _not_ enabled, runs the provided function.\n * @param name name of the new span\n * @param fn function to run inside the new span\n * @param options span options\n * @param parentContext optional context used to retrieve parent span id\n */\n public static async withSpan<T>(name: string, fn: () => Promise<T>, options?: SpanOptions, parentContext?: SpanContext): Promise<T> {\n if (Tracing._tracer === undefined || Tracing._openTelemetry === undefined)\n return fn();\n\n // this case is for context propagation - parentContext is typically constructed from HTTP headers\n const parent = parentContext === undefined\n ? Tracing._openTelemetry.context.active()\n : Tracing._openTelemetry.trace.setSpanContext(Tracing._openTelemetry.context.active(), parentContext);\n\n return Tracing._openTelemetry.context.with(\n Tracing._openTelemetry.trace.setSpan(\n parent,\n Tracing._tracer.startSpan(name, options, Tracing._openTelemetry.context.active()),\n ),\n async () => {\n try {\n return await fn();\n } catch (err) {\n if (err instanceof Error) // ignore non-Error throws, such as RpcControlResponse\n Tracing._openTelemetry?.trace.getSpan(Tracing._openTelemetry.context.active())?.setAttribute(\"error\", true);\n throw err;\n } finally {\n Tracing._openTelemetry?.trace.getSpan(Tracing._openTelemetry.context.active())?.end();\n }\n },\n );\n }\n\n /**\n * Adds a span event describing a runtime exception, as advised in OpenTelemetry documentation\n * @param e error (exception) object\n */\n public static recordException(e: Error) {\n Tracing._openTelemetry?.trace.getSpan(Tracing._openTelemetry.context.active())?.recordException(e);\n }\n\n /**\n * Enable logging to OpenTelemetry. [[Tracing.withSpan]] will be enabled, all log entries will be attached to active span as span events.\n * [IModelHost.startup]($backend) will call this automatically if the `enableOpenTelemetry` option is enabled and it succeeds in requiring `@opentelemetry/api`.\n * @note Node.js OpenTelemetry SDK should be initialized by the user.\n */\n public static enableOpenTelemetry(tracer: Tracer, api: typeof Tracing._openTelemetry) {\n Tracing._tracer = tracer;\n Tracing._openTelemetry = api;\n Logger.logTrace = Tracing.withOpenTelemetry(LogLevel.Trace, Logger.logTrace.bind(Logger)).bind(Logger);\n Logger.logInfo = Tracing.withOpenTelemetry(LogLevel.Info, Logger.logInfo.bind(Logger)).bind(Logger);\n Logger.logWarning = Tracing.withOpenTelemetry(LogLevel.Warning, Logger.logWarning.bind(Logger)).bind(Logger);\n Logger.logError = Tracing.withOpenTelemetry(LogLevel.Error, Logger.logError.bind(Logger)).bind(Logger);\n }\n\n private static withOpenTelemetry(level: LogLevel, base: LogFunction, isError: boolean = false): LogFunction {\n return (category, message, metaData) => {\n const oTelContext = Tracing._openTelemetry?.context.active();\n if (Tracing._openTelemetry === undefined || oTelContext === undefined)\n return base(category, message, metaData);\n\n const serializedMetadata = Logger.getMetaData(metaData);\n if (Logger.isEnabled(category, level)) {\n try {\n Tracing._openTelemetry?.trace\n .getSpan(Tracing._openTelemetry.context.active())\n ?.addEvent(message, {\n ...flattenObject(serializedMetadata),\n error: isError,\n loggerCategory: category,\n });\n } catch { } // avoid throwing random errors (with stack trace mangled by async hooks) when openTelemetry collector doesn't work\n\n const spanContext = Tracing._openTelemetry.trace.getSpan(oTelContext)?.spanContext();\n base(category, message, {\n ...serializedMetadata,\n /* eslint-disable @typescript-eslint/naming-convention */\n trace_id: spanContext?.traceId,\n span_id: spanContext?.spanId,\n trace_flags: spanContext?.traceFlags,\n /* eslint-enable @typescript-eslint/naming-convention */\n });\n }\n };\n }\n\n /** Set attributes on currently active openTelemetry span. Doesn't do anything if openTelemetry logging is not initialized.\n * @param attributes The attributes to set\n */\n public static setAttributes(attributes: SpanAttributes) {\n Tracing._openTelemetry?.trace.getSpan(Tracing._openTelemetry.context.active())?.setAttributes(attributes);\n }\n}\n\n/* eslint-enable @typescript-eslint/no-deprecated */\n"]}
@@ -1,6 +1,20 @@
1
1
  /** @packageDocumentation
2
2
  * @module Utils
3
3
  */
4
+ /**
5
+ * A type that recursively makes all properties of object `T` required, including all properties of nested objects.
6
+ * @public
7
+ */
8
+ export type DeepRequiredObject<T> = T extends object ? {
9
+ [K in keyof T]-?: DeepRequiredObject<T[K]>;
10
+ } : T;
11
+ /**
12
+ * A type that recursively makes all properties of object `T` readonly, including all properties of nested objects.
13
+ * @public
14
+ */
15
+ export type DeepReadonlyObject<T> = T extends object ? {
16
+ readonly [K in keyof T]: DeepReadonlyObject<T[K]>;
17
+ } : T;
4
18
  /** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.
5
19
  * @public
6
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"UtilityTypes.d.ts","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IACvB,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEnF;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,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EAAE,IAAO;IAClF,MAAM,KAAK,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,IAAI;QACpB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utils\n */\n\n/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.\n * @public\n */\nexport type Mutable<T> = {\n -readonly [K in keyof T]: T[K];\n};\n\n/** Make a new type from an existing type `T`, with set of required properties `K` optional.\n * @public\n */\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\n/** Make a new type from an existing type `T`, with set of optional properties `K` required.\n * @public\n */\nexport type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;\n\n/** Generically represents a class `T`, for use in type annotations.\n * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.\n * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.\n * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.\n * @public\n */\nexport type Constructor<T> = new (...args: any[]) => T;\n\n/** Returns true if `obj` is an object of class `T`.\n * @see [[asInstanceOf]] to cast `obj` to class `T`.\n * @public\n */\nexport function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean {\n return \"object\" === typeof obj && obj instanceof constructor;\n}\n\n/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.\n * @see [[isInstanceOf]] to query whether `obj` is of class `T`.\n * @public\n */\nexport function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined {\n return isInstanceOf<T>(obj, constructor) ? obj as T : undefined;\n}\n\n/** Extracts the names of all public properties of `T` that are not of type `function`.\n * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with\n * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,\n * so too does the type that TypeScript infers from that operator.\n * `get` syntax. For example:\n * ```ts\n * class Thing {\n * private _a = \"a\"; // a private variable\n * public b = \"b\"; // a public variable\n * public get c() { return \"c\"; } // a public property\n * public d() { return \"d\"; } // a public method\n * public e = () => \"e\"; // a public variable of type `function`\n * }\n *\n * // The following can have the values \"b\" or \"c\" - those are the public, non-function properties of Thing.\n * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = \"c\";\n *\n * // The following produces an error: \"Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'\"\n * const thing1 = new Thing();\n * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };\n * ```\n * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.\n * @public\n */\nexport type NonFunctionPropertyNamesOf<T> = {\n [K in keyof T]: T[K] extends (...args: any) => any ? never : K;\n}[keyof T];\n\n/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.\n * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.\n * @public\n */\nexport type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;\n\n/** Any function returning a Promise.\n * @see [[AsyncMethodsOf]] to extract all async methods from a type.\n * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.\n * @public\n */\nexport type AsyncFunction = (...args: any[]) => Promise<unknown>;\n\n/** The members of `T` that are async functions (functions that return a promise), and no other properties\n * @public\n */\nexport type PickAsyncMethods<T> = { [P in keyof T]: T[P] extends AsyncFunction ? T[P] : never; };\n\n/** Extracts the names of all function properties of `T` that return a Promise.\n * @public\n */\nexport type AsyncMethodsOf<T> = { [P in keyof T]: T[P] extends AsyncFunction ? P : never }[keyof T];\n\n/** A type that is either `T` or `Promise<T>`.\n * @public\n */\nexport type MaybePromise<T> = T | Promise<T>;\n\n/** Extracts the type to which the Promise returned by an async function resolves.\n * @public\n */\nexport type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;\n\n/** The members of `T` that are functions and no other properties\n * @public\n */\nexport type PickMethods<T> = { [P in keyof T]: T[P] extends (...args: any) => any ? T[P] : never; };\n\n/** The members of `T` that are functions that do not return a Promise\n * @public\n */\nexport type PickSyncMethods<T> = Omit<PickMethods<T>, AsyncMethodsOf<T>>;\n\n/** A runtime property omitter, makes a shallow copy of the given object without the specified properties\n * Compatible with the typescript `Omit` mapped type:\n * ```js\n * const testvar: Omit<{x: string, y: object}, \"y\"> = omit({x: \"hello\", y: {}}, [\"y\"]);\n * ```\n * @public\n */\nexport function omit<T extends object, K extends readonly (keyof T)[]>(t: T, keys: K): Omit<T, K[number]> {\n const clone = { ...t };\n for (const key of keys)\n delete clone[key];\n return clone;\n}\n\n/** Defines a type wherein at least one of the properties of T is required to exist.\n * In the following example, paying for a coffee requires a customer to have either a credit card, some cash, or both in their wallet.\n * ```ts\n * interface Wallet {\n * cash?: number;\n * card?: CreditCard;\n * }\n *\n * function payForCoffee(wallet: RequireAtLeastOne<Wallet>) { ... }\n * ```\n * Source: [@azure/keyvault-certificates](https://learn.microsoft.com/en-us/javascript/api/@azure/keyvault-certificates/requireatleastone?view=azure-node-latest).\n * @public\n */\nexport type RequireAtLeastOne<T> = {\n [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;\n}[keyof T];\n"]}
1
+ {"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA2CH;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAyED;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAmD,CAAI,EAAE,IAAO;IAClF,MAAM,KAAK,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,IAAI;QACpB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utils\n */\n\n/**\n * A type that recursively makes all properties of object `T` required, including all properties of nested objects.\n * @public\n */\nexport type DeepRequiredObject<T> = T extends object\n ? { [K in keyof T]-?: DeepRequiredObject<T[K]> }\n : T\n\n/**\n * A type that recursively makes all properties of object `T` readonly, including all properties of nested objects.\n * @public\n */\nexport type DeepReadonlyObject<T> = T extends object\n ? { readonly [K in keyof T]: DeepReadonlyObject<T[K]> } :\n T\n\n/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.\n * @public\n */\nexport type Mutable<T> = {\n -readonly [K in keyof T]: T[K];\n};\n\n/** Make a new type from an existing type `T`, with set of required properties `K` optional.\n * @public\n */\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\n/** Make a new type from an existing type `T`, with set of optional properties `K` required.\n * @public\n */\nexport type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;\n\n/** Generically represents a class `T`, for use in type annotations.\n * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.\n * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.\n * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.\n * @public\n */\nexport type Constructor<T> = new (...args: any[]) => T;\n\n/** Returns true if `obj` is an object of class `T`.\n * @see [[asInstanceOf]] to cast `obj` to class `T`.\n * @public\n */\nexport function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean {\n return \"object\" === typeof obj && obj instanceof constructor;\n}\n\n/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.\n * @see [[isInstanceOf]] to query whether `obj` is of class `T`.\n * @public\n */\nexport function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined {\n return isInstanceOf<T>(obj, constructor) ? obj as T : undefined;\n}\n\n/** Extracts the names of all public properties of `T` that are not of type `function`.\n * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with\n * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,\n * so too does the type that TypeScript infers from that operator.\n * `get` syntax. For example:\n * ```ts\n * class Thing {\n * private _a = \"a\"; // a private variable\n * public b = \"b\"; // a public variable\n * public get c() { return \"c\"; } // a public property\n * public d() { return \"d\"; } // a public method\n * public e = () => \"e\"; // a public variable of type `function`\n * }\n *\n * // The following can have the values \"b\" or \"c\" - those are the public, non-function properties of Thing.\n * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = \"c\";\n *\n * // The following produces an error: \"Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'\"\n * const thing1 = new Thing();\n * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };\n * ```\n * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.\n * @public\n */\nexport type NonFunctionPropertyNamesOf<T> = {\n [K in keyof T]: T[K] extends (...args: any) => any ? never : K;\n}[keyof T];\n\n/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.\n * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.\n * @public\n */\nexport type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;\n\n/** Any function returning a Promise.\n * @see [[AsyncMethodsOf]] to extract all async methods from a type.\n * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.\n * @public\n */\nexport type AsyncFunction = (...args: any[]) => Promise<unknown>;\n\n/** The members of `T` that are async functions (functions that return a promise), and no other properties\n * @public\n */\nexport type PickAsyncMethods<T> = { [P in keyof T]: T[P] extends AsyncFunction ? T[P] : never; };\n\n/** Extracts the names of all function properties of `T` that return a Promise.\n * @public\n */\nexport type AsyncMethodsOf<T> = { [P in keyof T]: T[P] extends AsyncFunction ? P : never }[keyof T];\n\n/** A type that is either `T` or `Promise<T>`.\n * @public\n */\nexport type MaybePromise<T> = T | Promise<T>;\n\n/** Extracts the type to which the Promise returned by an async function resolves.\n * @public\n */\nexport type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;\n\n/** The members of `T` that are functions and no other properties\n * @public\n */\nexport type PickMethods<T> = { [P in keyof T]: T[P] extends (...args: any) => any ? T[P] : never; };\n\n/** The members of `T` that are functions that do not return a Promise\n * @public\n */\nexport type PickSyncMethods<T> = Omit<PickMethods<T>, AsyncMethodsOf<T>>;\n\n/** A runtime property omitter, makes a shallow copy of the given object without the specified properties\n * Compatible with the typescript `Omit` mapped type:\n * ```js\n * const testvar: Omit<{x: string, y: object}, \"y\"> = omit({x: \"hello\", y: {}}, [\"y\"]);\n * ```\n * @public\n */\nexport function omit<T extends object, K extends readonly (keyof T)[]>(t: T, keys: K): Omit<T, K[number]> {\n const clone = { ...t };\n for (const key of keys)\n delete clone[key];\n return clone;\n}\n\n/** Defines a type wherein at least one of the properties of T is required to exist.\n * In the following example, paying for a coffee requires a customer to have either a credit card, some cash, or both in their wallet.\n * ```ts\n * interface Wallet {\n * cash?: number;\n * card?: CreditCard;\n * }\n *\n * function payForCoffee(wallet: RequireAtLeastOne<Wallet>) { ... }\n * ```\n * Source: [@azure/keyvault-certificates](https://learn.microsoft.com/en-us/javascript/api/@azure/keyvault-certificates/requireatleastone?view=azure-node-latest).\n * @public\n */\nexport type RequireAtLeastOne<T> = {\n [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;\n}[keyof T];\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-bentley",
3
- "version": "5.1.0-dev.9",
3
+ "version": "5.2.0-dev.2",
4
4
  "description": "Bentley JavaScript core components",
5
5
  "main": "lib/cjs/core-bentley.js",
6
6
  "module": "lib/esm/core-bentley.js",
@@ -22,15 +22,15 @@
22
22
  "url": "http://www.bentley.com"
23
23
  },
24
24
  "devDependencies": {
25
- "@itwin/eslint-plugin": "5.0.0-dev.1",
25
+ "@itwin/eslint-plugin": "5.2.2-dev.2",
26
26
  "@opentelemetry/api": "1.0.4",
27
27
  "@types/node": "~20.17.0",
28
28
  "@vitest/coverage-v8": "^3.0.6",
29
- "eslint": "^9.13.0",
29
+ "eslint": "^9.31.0",
30
30
  "rimraf": "^6.0.1",
31
31
  "typescript": "~5.6.2",
32
32
  "vitest": "^3.0.6",
33
- "@itwin/build-tools": "5.1.0-dev.9"
33
+ "@itwin/build-tools": "5.2.0-dev.2"
34
34
  },
35
35
  "nyc": {
36
36
  "extends": "./node_modules/@itwin/build-tools/.nycrc"
@@ -45,6 +45,7 @@
45
45
  "docs": "betools docs --json=../../generated-docs/core/core-bentley/file.json --tsIndexFile=core-bentley.ts --onlyJson",
46
46
  "cover": "vitest --run --coverage",
47
47
  "lint": "eslint \"./src/**/*.ts\" 1>&2",
48
- "lint-fix": "eslint --fix -f visualstudio \"./src/**/*.ts\" 1>&2"
48
+ "lint-fix": "eslint --fix -f visualstudio \"./src/**/*.ts\" 1>&2",
49
+ "lint-deprecation": "eslint --fix -f visualstudio --no-inline-config -c ../../common/config/eslint/eslint.config.deprecation-policy.js \"./src/**/*.ts\""
49
50
  }
50
51
  }