@settlemint/sdk-utils
Advanced tools
Comparing version
@@ -24,2 +24,17 @@ /** | ||
declare function tryParseJson<T>(value: string, defaultValue?: T | null): T | null; | ||
/** | ||
* Extracts a JSON object from a string. | ||
* | ||
* @param value - The string to extract the JSON object from | ||
* @returns The parsed JSON object, or null if no JSON object is found | ||
* @throws {Error} If the input string is too long (longer than 5000 characters) | ||
* @example | ||
* import { extractJsonObject } from "@settlemint/sdk-utils"; | ||
* | ||
* const json = extractJsonObject<{ port: number }>( | ||
* 'port info: {"port": 3000}', | ||
* ); | ||
* // Returns: { port: 3000 } | ||
*/ | ||
declare function extractJsonObject<T>(value: string): T | null; | ||
@@ -95,2 +110,2 @@ /** | ||
export { camelCaseToWords, capitalizeFirstLetter, replaceUnderscoresAndHyphensWithSpaces, retryWhenFailed, truncate, tryParseJson }; | ||
export { camelCaseToWords, capitalizeFirstLetter, extractJsonObject, replaceUnderscoresAndHyphensWithSpaces, retryWhenFailed, truncate, tryParseJson }; |
@@ -45,2 +45,17 @@ import { SpawnOptionsWithoutStdio } from 'node:child_process'; | ||
/** | ||
* Error class for command execution errors | ||
* @extends Error | ||
*/ | ||
declare class CommandError extends Error { | ||
readonly code: number; | ||
readonly output: string[]; | ||
/** | ||
* Constructs a new CommandError | ||
* @param message - The error message | ||
* @param code - The exit code of the command | ||
* @param output - The output of the command | ||
*/ | ||
constructor(message: string, code: number, output: string[]); | ||
} | ||
/** | ||
* Executes a command with the given arguments in a child process. | ||
@@ -54,3 +69,3 @@ * Pipes stdin to the child process and captures stdout/stderr output. | ||
* @returns Array of output strings from stdout and stderr | ||
* @throws {Error} If the process fails to start or exits with non-zero code | ||
* @throws {CommandError} If the process fails to start or exits with non-zero code | ||
* @example | ||
@@ -206,2 +221,2 @@ * import { executeCommand } from "@settlemint/sdk-utils/terminal"; | ||
export { CancelError, type ExecuteCommandOptions, SpinnerError, type SpinnerOptions, ascii, cancel, executeCommand, intro, list, maskTokens, note, outro, spinner, table }; | ||
export { CancelError, CommandError, type ExecuteCommandOptions, SpinnerError, type SpinnerOptions, ascii, cancel, executeCommand, intro, list, maskTokens, note, outro, spinner, table }; |
{ | ||
"name": "@settlemint/sdk-utils", | ||
"description": "Shared utilities and helper functions for SettleMint SDK modules", | ||
"version": "2.1.4-pr6b1dbf80", | ||
"version": "2.1.4-pr6bd6160a", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "private": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
592330
3.31%4097
2.2%2063
5.47%