@codesoul-co/hypha-tools / common-tools
- Package index:
@codesoul-co/hypha-tools - Source:
packages/tools/src/common-tools.ts - Exports: 17
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
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
| Symbol | Kind | Signature | Description |
|---|---|---|---|
COMMON_TOOL_LIMITS | constant | const 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. |
commonUtilityToolSpecs | constant | const commonUtilityToolSpecs: readonly [ToolSpec, ToolSpec, ToolSpec, ToolSpec] | Common Utility Tool Specs constant exported by the common-tools module. |
hashUtilityToolSpec | constant | const hashUtilityToolSpec: ToolSpec | Hash Utility Tool Spec constant exported by the common-tools module. |
jsonUtilityToolSpec | constant | const jsonUtilityToolSpec: ToolSpec | JSON Utility Tool Spec constant exported by the common-tools module. |
textUtilityToolSpec | constant | const textUtilityToolSpec: ToolSpec | Text Utility Tool Spec constant exported by the common-tools module. |
timeUtilityToolSpec | constant | const timeUtilityToolSpec: ToolSpec | Time Utility Tool Spec constant exported by the common-tools module. |
executeHashUtility | function | executeHashUtility(input: HashUtilityInput): Record<string, unknown> | Execute Hash Utility function with 1 public call signature; parameters and return types are listed below. |
executeJsonUtility | function | executeJsonUtility(input: JsonUtilityInput): Record<string, unknown> | Execute JSON Utility function with 1 public call signature; parameters and return types are listed below. |
executeTextUtility | function | executeTextUtility(input: TextUtilityInput): Record<string, unknown> | Execute Text Utility function with 1 public call signature; parameters and return types are listed below. |
executeTimeUtility | function | executeTimeUtility(input: TimeUtilityInput, now?: () => Date): Record<string, unknown> | Execute Time Utility function with 1 public call signature; parameters and return types are listed below. |
sanitizeJsonValue | function | sanitizeJsonValue(value: unknown): JsonValue | Sanitize JSON Value function with 1 public call signature; parameters and return types are listed below. |
JsonObject | interface | interface JsonObject | JSON Object interface with 0 public fields or methods. |
TextUtilityInput | interface | interface TextUtilityInput | Text Utility Input interface with 11 public fields or methods. |
HashUtilityInput | type | type 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. |
JsonUtilityInput | type | 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; } | Public type alias for JSON Utility Input; the declaration contains its complete type expression. |
JsonValue | type | type JsonValue = null | boolean | number | string | JsonValue[] | JsonObject | Public type alias for JSON Value; the declaration contains its complete type expression. |
TimeUtilityInput | type | type 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
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
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
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
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
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
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
export declare function executeHashUtility(input: HashUtilityInput): Record<string, unknown>;Call signature
executeHashUtility(input: HashUtilityInput): Record<string, unknown>Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input | HashUtilityInput | Yes | Required 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
export declare function executeJsonUtility(input: JsonUtilityInput): Record<string, unknown>;Call signature
executeJsonUtility(input: JsonUtilityInput): Record<string, unknown>Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input | JsonUtilityInput | Yes | Required 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
export declare function executeTextUtility(input: TextUtilityInput): Record<string, unknown>;Call signature
executeTextUtility(input: TextUtilityInput): Record<string, unknown>Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input | TextUtilityInput | Yes | Required 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
export declare function executeTimeUtility(input: TimeUtilityInput, now?: () => Date): Record<string, unknown>;Call signature
executeTimeUtility(input: TimeUtilityInput, now?: () => Date): Record<string, unknown>Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input | TimeUtilityInput | Yes | Required parameter; accepted values are defined by the type column. |
now | () => Date | No | Optional 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
export declare function sanitizeJsonValue(value: unknown): JsonValue;Call signature
sanitizeJsonValue(value: unknown): JsonValueParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
value | unknown | Yes | Required 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
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
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
| Member | Kind | Signature | Description |
|---|---|---|---|
caseSensitive | property | caseSensitive?: boolean | Public property; its type, readonly modifier and optionality are shown in the signature. |
end | property | end?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
maxResults | property | maxResults?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
mode | property | mode?: "spaces" | "lines" | Public property; its type, readonly modifier and optionality are shown in the signature. |
operation | property | operation: "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. |
parts | property | parts?: string[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
query | property | query?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
replacement | property | replacement?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
separator | property | separator?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
start | property | start?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
text | property | text?: string | Public 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
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
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
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
export type TimeUtilityInput = {
operation: 'now';
} | {
operation: 'parse';
value: string;
} | {
operation: 'format';
value: string | number;
timeZone?: string;
locale?: string;
};