Skip to content

@codesoul-co/hypha-tools / common-tools

Using this module

Use the Common tools module for using the public contracts and operations for this capability boundary. It exports 6 constants, 5 functions, 2 interfaces, 4 types.

Import from the package entrypoint

ts
import {
  COMMON_TOOL_LIMITS,
  commonUtilityToolSpecs,
  hashUtilityToolSpec,
  jsonUtilityToolSpec,
  textUtilityToolSpec,
  timeUtilityToolSpec,
  executeHashUtility,
  executeJsonUtility,
} from '@codesoul-co/hypha-tools';

import type {
  JsonObject,
  TextUtilityInput,
  HashUtilityInput,
  JsonUtilityInput,
  JsonValue,
  TimeUtilityInput,
} from '@codesoul-co/hypha-tools';

// The complete export list is documented below.

Usage patterns

  • Use the 6 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 5 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.
  • The 6 constant/enum exports provide stable values, schemas, definitions, or defaults. Reuse these exports instead of copying internal values into an application.

Public exports

SymbolKindSignatureDescription
COMMON_TOOL_LIMITSconstantconst COMMON_TOOL_LIMITS: Readonly<{ maxTextCharacters: 1000000; maxJsonDepth: 64; maxJsonNodes: 100000; maxPointerSegments: 128; maxMatches: 1000; maxQueryCharacters: 4096; }>COMMON TOOL LIMITS constant exported by the common-tools module.
commonUtilityToolSpecsconstantconst commonUtilityToolSpecs: readonly [ToolSpec, ToolSpec, ToolSpec, ToolSpec]Common Utility Tool Specs constant exported by the common-tools module.
hashUtilityToolSpecconstantconst hashUtilityToolSpec: ToolSpecHash Utility Tool Spec constant exported by the common-tools module.
jsonUtilityToolSpecconstantconst jsonUtilityToolSpec: ToolSpecJSON Utility Tool Spec constant exported by the common-tools module.
textUtilityToolSpecconstantconst textUtilityToolSpec: ToolSpecText Utility Tool Spec constant exported by the common-tools module.
timeUtilityToolSpecconstantconst timeUtilityToolSpec: ToolSpecTime Utility Tool Spec constant exported by the common-tools module.
executeHashUtilityfunctionexecuteHashUtility(input: HashUtilityInput): Record<string, unknown>Execute Hash Utility function with 1 public call signature; parameters and return types are listed below.
executeJsonUtilityfunctionexecuteJsonUtility(input: JsonUtilityInput): Record<string, unknown>Execute JSON Utility function with 1 public call signature; parameters and return types are listed below.
executeTextUtilityfunctionexecuteTextUtility(input: TextUtilityInput): Record<string, unknown>Execute Text Utility function with 1 public call signature; parameters and return types are listed below.
executeTimeUtilityfunctionexecuteTimeUtility(input: TimeUtilityInput, now?: () => Date): Record<string, unknown>Execute Time Utility function with 1 public call signature; parameters and return types are listed below.
sanitizeJsonValuefunctionsanitizeJsonValue(value: unknown): JsonValueSanitize JSON Value function with 1 public call signature; parameters and return types are listed below.
JsonObjectinterfaceinterface JsonObjectJSON Object interface with 0 public fields or methods.
TextUtilityInputinterfaceinterface TextUtilityInputText Utility Input interface with 11 public fields or methods.
HashUtilityInputtypetype HashUtilityInput = { operation: 'sha256_text'; text: string; } | { operation: 'sha256_json'; value: unknown; }Public type alias for Hash Utility Input; the declaration contains its complete type expression.
JsonUtilityInputtypetype JsonUtilityInput = { operation: 'parse'; text: string; } | { operation: 'stringify'; value: unknown; pretty?: boolean; } | { operation: 'get'; value: unknown; pointer: string; } | { operation: 'keys'; value: unknown; } | { operation: 'validate'; value: unknown; schema: JsonSchema; }Public type alias for JSON Utility Input; the declaration contains its complete type expression.
JsonValuetypetype JsonValue = null | boolean | number | string | JsonValue[] | JsonObjectPublic type alias for JSON Value; the declaration contains its complete type expression.
TimeUtilityInputtypetype TimeUtilityInput = { operation: 'now'; } | { operation: 'parse'; value: string; } | { operation: 'format'; value: string | number; timeZone?: string; locale?: string; }Public type alias for Time Utility Input; the declaration contains its complete type expression.

COMMON_TOOL_LIMITS

COMMON TOOL LIMITS constant exported by the common-tools module.

  • Kind: constant
  • Import: import { COMMON_TOOL_LIMITS } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export declare const COMMON_TOOL_LIMITS: Readonly<{ maxTextCharacters: 1000000; maxJsonDepth: 64; maxJsonNodes: 100000; maxPointerSegments: 128; maxMatches: 1000; maxQueryCharacters: 4096; }>;

commonUtilityToolSpecs

Common Utility Tool Specs constant exported by the common-tools module.

  • Kind: constant
  • Import: import { commonUtilityToolSpecs } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export declare const commonUtilityToolSpecs: readonly [ToolSpec, ToolSpec, ToolSpec, ToolSpec];

hashUtilityToolSpec

Hash Utility Tool Spec constant exported by the common-tools module.

  • Kind: constant
  • Import: import { hashUtilityToolSpec } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export declare const hashUtilityToolSpec: ToolSpec;

jsonUtilityToolSpec

JSON Utility Tool Spec constant exported by the common-tools module.

  • Kind: constant
  • Import: import { jsonUtilityToolSpec } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export declare const jsonUtilityToolSpec: ToolSpec;

textUtilityToolSpec

Text Utility Tool Spec constant exported by the common-tools module.

  • Kind: constant
  • Import: import { textUtilityToolSpec } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export declare const textUtilityToolSpec: ToolSpec;

timeUtilityToolSpec

Time Utility Tool Spec constant exported by the common-tools module.

  • Kind: constant
  • Import: import { timeUtilityToolSpec } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export declare const timeUtilityToolSpec: ToolSpec;

executeHashUtility

Execute Hash Utility function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { executeHashUtility } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export declare function executeHashUtility(input: HashUtilityInput): Record<string, unknown>;

Call signature

text
executeHashUtility(input: HashUtilityInput): Record<string, unknown>

Parameters

ParameterTypeRequiredDescription
inputHashUtilityInputYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: Record<string, unknown>
  • Description: The return contract is defined by the type shown above.

executeJsonUtility

Execute JSON Utility function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { executeJsonUtility } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export declare function executeJsonUtility(input: JsonUtilityInput): Record<string, unknown>;

Call signature

text
executeJsonUtility(input: JsonUtilityInput): Record<string, unknown>

Parameters

ParameterTypeRequiredDescription
inputJsonUtilityInputYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: Record<string, unknown>
  • Description: The return contract is defined by the type shown above.

executeTextUtility

Execute Text Utility function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { executeTextUtility } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export declare function executeTextUtility(input: TextUtilityInput): Record<string, unknown>;

Call signature

text
executeTextUtility(input: TextUtilityInput): Record<string, unknown>

Parameters

ParameterTypeRequiredDescription
inputTextUtilityInputYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: Record<string, unknown>
  • Description: The return contract is defined by the type shown above.

executeTimeUtility

Execute Time Utility function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { executeTimeUtility } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export declare function executeTimeUtility(input: TimeUtilityInput, now?: () => Date): Record<string, unknown>;

Call signature

text
executeTimeUtility(input: TimeUtilityInput, now?: () => Date): Record<string, unknown>

Parameters

ParameterTypeRequiredDescription
inputTimeUtilityInputYesRequired parameter; accepted values are defined by the type column.
now() => DateNoOptional parameter; accepted values are defined by the type column.

Returns

  • Type: Record<string, unknown>
  • Description: The return contract is defined by the type shown above.

sanitizeJsonValue

Sanitize JSON Value function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { sanitizeJsonValue } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export declare function sanitizeJsonValue(value: unknown): JsonValue;

Call signature

text
sanitizeJsonValue(value: unknown): JsonValue

Parameters

ParameterTypeRequiredDescription
valueunknownYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: JsonValue
  • Description: The return contract is defined by the type shown above.

JsonObject

JSON Object interface with 0 public fields or methods.

  • Kind: interface
  • Import: import type { JsonObject } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export interface JsonObject {
    [key: string]: JsonValue;
}

TextUtilityInput

Text Utility Input interface with 11 public fields or methods.

  • Kind: interface
  • Import: import type { TextUtilityInput } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export interface TextUtilityInput {
    operation: 'length' | 'line_select' | 'literal_find' | 'literal_replace' | 'slice' | 'normalize_whitespace' | 'split' | 'join';
    text?: string;
    parts?: string[];
    separator?: string;
    start?: number;
    end?: number;
    query?: string;
    replacement?: string;
    caseSensitive?: boolean;
    maxResults?: number;
    mode?: 'spaces' | 'lines';
}

Contract members

MemberKindSignatureDescription
caseSensitivepropertycaseSensitive?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
endpropertyend?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxResultspropertymaxResults?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
modepropertymode?: "spaces" | "lines"Public property; its type, readonly modifier and optionality are shown in the signature.
operationpropertyoperation: "length" | "line_select" | "literal_find" | "literal_replace" | "slice" | "normalize_whitespace" | "split" | "join"Public property; its type, readonly modifier and optionality are shown in the signature.
partspropertyparts?: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
querypropertyquery?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
replacementpropertyreplacement?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
separatorpropertyseparator?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
startpropertystart?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
textpropertytext?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

HashUtilityInput

Public type alias for Hash Utility Input; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { HashUtilityInput } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export type HashUtilityInput = {
    operation: 'sha256_text';
    text: string;
} | {
    operation: 'sha256_json';
    value: unknown;
};

JsonUtilityInput

Public type alias for JSON Utility Input; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { JsonUtilityInput } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export type JsonUtilityInput = {
    operation: 'parse';
    text: string;
} | {
    operation: 'stringify';
    value: unknown;
    pretty?: boolean;
} | {
    operation: 'get';
    value: unknown;
    pointer: string;
} | {
    operation: 'keys';
    value: unknown;
} | {
    operation: 'validate';
    value: unknown;
    schema: JsonSchema;
};

JsonValue

Public type alias for JSON Value; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { JsonValue } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export type JsonValue = null | boolean | number | string | JsonValue[] | JsonObject;

TimeUtilityInput

Public type alias for Time Utility Input; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { TimeUtilityInput } from '@codesoul-co/hypha-tools';
  • Source module: common-tools

Declaration

text
export type TimeUtilityInput = {
    operation: 'now';
} | {
    operation: 'parse';
    value: string;
} | {
    operation: 'format';
    value: string | number;
    timeZone?: string;
    locale?: string;
};