@juspay/neurolink 7.14.2 → 7.14.3
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.
- package/CHANGELOG.md +6 -0
- package/dist/cli/commands/config.d.ts +66 -66
- package/dist/core/baseProvider.d.ts +12 -7
- package/dist/core/baseProvider.js +118 -125
- package/dist/core/constants.d.ts +5 -0
- package/dist/core/constants.js +6 -0
- package/dist/core/dynamicModels.d.ts +4 -4
- package/dist/core/factory.d.ts +2 -4
- package/dist/core/types.d.ts +8 -22
- package/dist/index.d.ts +1 -4
- package/dist/lib/core/baseProvider.d.ts +12 -7
- package/dist/lib/core/baseProvider.js +118 -125
- package/dist/lib/core/constants.d.ts +5 -0
- package/dist/lib/core/constants.js +6 -0
- package/dist/lib/core/dynamicModels.d.ts +8 -8
- package/dist/lib/core/factory.d.ts +2 -4
- package/dist/lib/core/types.d.ts +8 -22
- package/dist/lib/index.d.ts +1 -4
- package/dist/lib/mcp/contracts/mcpContract.d.ts +6 -19
- package/dist/lib/mcp/externalServerManager.d.ts +2 -4
- package/dist/lib/mcp/externalServerManager.js +7 -8
- package/dist/lib/mcp/factory.d.ts +61 -7
- package/dist/lib/mcp/factory.js +36 -23
- package/dist/lib/mcp/mcpClientFactory.d.ts +2 -1
- package/dist/lib/mcp/mcpClientFactory.js +73 -26
- package/dist/lib/mcp/registry.d.ts +1 -1
- package/dist/lib/mcp/toolDiscoveryService.d.ts +1 -1
- package/dist/lib/mcp/toolDiscoveryService.js +50 -19
- package/dist/lib/mcp/toolRegistry.d.ts +23 -1
- package/dist/lib/mcp/toolRegistry.js +108 -17
- package/dist/lib/models/modelResolver.js +2 -1
- package/dist/lib/neurolink.d.ts +12 -8
- package/dist/lib/neurolink.js +130 -134
- package/dist/lib/providers/amazonBedrock.d.ts +2 -2
- package/dist/lib/providers/anthropic.d.ts +3 -3
- package/dist/lib/providers/googleAiStudio.d.ts +2 -2
- package/dist/lib/providers/mistral.d.ts +3 -3
- package/dist/lib/providers/ollama.d.ts +2 -2
- package/dist/lib/providers/openAI.d.ts +3 -3
- package/dist/lib/providers/openaiCompatible.d.ts +2 -2
- package/dist/lib/providers/sagemaker/client.d.ts +2 -5
- package/dist/lib/providers/sagemaker/language-model.d.ts +4 -6
- package/dist/lib/providers/sagemaker/parsers.js +5 -4
- package/dist/lib/sdk/toolRegistration.d.ts +6 -6
- package/dist/lib/sdk/toolRegistration.js +17 -56
- package/dist/lib/types/generateTypes.d.ts +9 -9
- package/dist/lib/types/streamTypes.d.ts +4 -4
- package/dist/lib/types/tools.d.ts +15 -7
- package/dist/lib/types/typeAliases.d.ts +412 -0
- package/dist/lib/types/typeAliases.js +48 -0
- package/dist/lib/utils/factoryProcessing.d.ts +2 -1
- package/dist/lib/utils/factoryProcessing.js +4 -3
- package/dist/lib/utils/parameterValidation.d.ts +97 -0
- package/dist/lib/utils/parameterValidation.js +452 -0
- package/dist/lib/utils/transformationUtils.d.ts +204 -0
- package/dist/lib/utils/transformationUtils.js +334 -0
- package/dist/lib/utils/typeUtils.d.ts +77 -0
- package/dist/lib/utils/typeUtils.js +97 -0
- package/dist/mcp/contracts/mcpContract.d.ts +6 -19
- package/dist/mcp/externalServerManager.d.ts +2 -4
- package/dist/mcp/externalServerManager.js +7 -8
- package/dist/mcp/factory.d.ts +61 -7
- package/dist/mcp/factory.js +36 -23
- package/dist/mcp/mcpClientFactory.d.ts +2 -1
- package/dist/mcp/mcpClientFactory.js +73 -26
- package/dist/mcp/registry.d.ts +1 -1
- package/dist/mcp/toolDiscoveryService.d.ts +1 -1
- package/dist/mcp/toolDiscoveryService.js +50 -19
- package/dist/mcp/toolRegistry.d.ts +23 -1
- package/dist/mcp/toolRegistry.js +108 -17
- package/dist/models/modelResolver.js +2 -1
- package/dist/neurolink.d.ts +12 -8
- package/dist/neurolink.js +130 -134
- package/dist/providers/amazonBedrock.d.ts +2 -2
- package/dist/providers/anthropic.d.ts +3 -3
- package/dist/providers/googleAiStudio.d.ts +2 -2
- package/dist/providers/mistral.d.ts +3 -3
- package/dist/providers/ollama.d.ts +2 -2
- package/dist/providers/openAI.d.ts +3 -3
- package/dist/providers/openaiCompatible.d.ts +2 -2
- package/dist/providers/sagemaker/client.d.ts +2 -5
- package/dist/providers/sagemaker/language-model.d.ts +4 -6
- package/dist/providers/sagemaker/parsers.js +5 -4
- package/dist/sdk/toolRegistration.d.ts +6 -6
- package/dist/sdk/toolRegistration.js +17 -56
- package/dist/types/generateTypes.d.ts +9 -9
- package/dist/types/streamTypes.d.ts +4 -4
- package/dist/types/tools.d.ts +15 -7
- package/dist/types/typeAliases.d.ts +412 -0
- package/dist/types/typeAliases.js +48 -0
- package/dist/utils/factoryProcessing.d.ts +2 -1
- package/dist/utils/factoryProcessing.js +4 -3
- package/dist/utils/parameterValidation.d.ts +97 -0
- package/dist/utils/parameterValidation.js +452 -0
- package/dist/utils/transformationUtils.d.ts +204 -0
- package/dist/utils/transformationUtils.js +334 -0
- package/dist/utils/typeUtils.d.ts +77 -0
- package/dist/utils/typeUtils.js +97 -0
- package/package.json +1 -1
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object Transformation Utilities
|
|
3
|
+
* Centralizes repeated object transformation patterns to improve code reuse and maintainability
|
|
4
|
+
*/
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// TOOL EXECUTION TRANSFORMATIONS
|
|
7
|
+
// ============================================================================
|
|
8
|
+
/**
|
|
9
|
+
* Transform tool execution results from AI SDK format to NeuroLink GenerateResult format
|
|
10
|
+
* Handles both single execution and array formats with robust type checking
|
|
11
|
+
*
|
|
12
|
+
* @param toolExecutions - Array of tool execution results from AI SDK (optional)
|
|
13
|
+
* @returns Array of standardized tool execution objects with name, input, output, and duration
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const executions = transformToolExecutions([
|
|
18
|
+
* { name: "calculator", input: { a: 5, b: 3 }, output: 8, duration: 150 }
|
|
19
|
+
* ]);
|
|
20
|
+
* // Returns: [{ name: "calculator", input: { a: 5, b: 3 }, output: 8, duration: 150 }]
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function transformToolExecutions(toolExecutions) {
|
|
24
|
+
if (!toolExecutions || !Array.isArray(toolExecutions)) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
return toolExecutions.map((te) => {
|
|
28
|
+
const teRecord = te;
|
|
29
|
+
return {
|
|
30
|
+
name: teRecord.name || "",
|
|
31
|
+
input: teRecord.input || {},
|
|
32
|
+
output: teRecord.output || "success",
|
|
33
|
+
duration: teRecord.duration || 0,
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Transform tool execution results from AI SDK format to internal format (for MCP generation)
|
|
39
|
+
* Used in tryMCPGeneration method
|
|
40
|
+
*/
|
|
41
|
+
export function transformToolExecutionsForMCP(toolExecutions) {
|
|
42
|
+
if (!toolExecutions || !Array.isArray(toolExecutions)) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
return toolExecutions.map((te) => {
|
|
46
|
+
const teRecord = te;
|
|
47
|
+
return {
|
|
48
|
+
toolName: teRecord.name || "",
|
|
49
|
+
executionTime: teRecord.duration || 0,
|
|
50
|
+
success: true, // Assume success if tool executed (AI providers handle failures differently)
|
|
51
|
+
serverId: teRecord.serverId || undefined,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// AVAILABLE TOOLS TRANSFORMATIONS
|
|
57
|
+
// ============================================================================
|
|
58
|
+
/**
|
|
59
|
+
* Transform available tools from internal format to GenerateResult format
|
|
60
|
+
* Ensures consistent tool information structure across the API with schema normalization
|
|
61
|
+
*
|
|
62
|
+
* @param availableTools - Array of tool definitions from various sources (MCP servers, builtin tools, etc.)
|
|
63
|
+
* @returns Array of normalized tool descriptions with consistent schema format
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const tools = transformAvailableTools([
|
|
68
|
+
* { name: "calculator", description: "Math tool", server: "builtin", inputSchema: {...} }
|
|
69
|
+
* ]);
|
|
70
|
+
* // Returns: [{ name: "calculator", description: "Math tool", serverId: "builtin", schema: {...} }]
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function transformAvailableTools(availableTools) {
|
|
74
|
+
if (!availableTools || !Array.isArray(availableTools)) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
return availableTools.map((tool) => {
|
|
78
|
+
const toolRecord = tool;
|
|
79
|
+
return {
|
|
80
|
+
name: tool.name || "",
|
|
81
|
+
description: tool.description || "",
|
|
82
|
+
server: tool.server || "",
|
|
83
|
+
parameters: toolRecord.inputSchema ||
|
|
84
|
+
toolRecord.parameters ||
|
|
85
|
+
toolRecord.schema ||
|
|
86
|
+
{},
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Transform tools for MCP generation format
|
|
92
|
+
* Simple transformation for internal MCP tool lists
|
|
93
|
+
*/
|
|
94
|
+
export function transformToolsForMCP(availableTools) {
|
|
95
|
+
return availableTools.map((tool) => ({
|
|
96
|
+
name: tool.name,
|
|
97
|
+
description: tool.description,
|
|
98
|
+
server: tool.server,
|
|
99
|
+
category: tool.category,
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Transform tools to expected format with required properties
|
|
104
|
+
* Used in getAllAvailableTools method for final output
|
|
105
|
+
*/
|
|
106
|
+
export function transformToolsToExpectedFormat(tools) {
|
|
107
|
+
return tools.map((tool) => ({
|
|
108
|
+
name: tool.name,
|
|
109
|
+
description: tool.description || "No description available",
|
|
110
|
+
server: tool.serverId || "unknown",
|
|
111
|
+
category: tool.category,
|
|
112
|
+
inputSchema: tool.inputSchema,
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
// ============================================================================
|
|
116
|
+
// STRING AND ARRAY TRANSFORMATIONS
|
|
117
|
+
// ============================================================================
|
|
118
|
+
/**
|
|
119
|
+
* Extract tool names from tool objects
|
|
120
|
+
* Common pattern for creating arrays of tool names
|
|
121
|
+
*/
|
|
122
|
+
export function extractToolNames(tools) {
|
|
123
|
+
return tools.map((tool) => tool.name);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Extract object keys as a comma-separated string
|
|
127
|
+
* Common pattern for logging and debugging
|
|
128
|
+
*/
|
|
129
|
+
export function getKeysAsString(obj, fallback = "none") {
|
|
130
|
+
const keys = Object.keys(obj);
|
|
131
|
+
return keys.length > 0 ? keys.join(", ") : fallback;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Count object properties
|
|
135
|
+
* Common pattern for metrics and logging
|
|
136
|
+
*/
|
|
137
|
+
export function getKeyCount(obj) {
|
|
138
|
+
return Object.keys(obj).length;
|
|
139
|
+
}
|
|
140
|
+
// ============================================================================
|
|
141
|
+
// SCHEMA TRANSFORMATIONS
|
|
142
|
+
// ============================================================================
|
|
143
|
+
/**
|
|
144
|
+
* Transform schema properties to parameter descriptions
|
|
145
|
+
* Used in tool-aware system prompt generation
|
|
146
|
+
*/
|
|
147
|
+
export function transformSchemaToParameterDescription(schema) {
|
|
148
|
+
if (!schema?.properties) {
|
|
149
|
+
return "";
|
|
150
|
+
}
|
|
151
|
+
const requiredParams = new Set(schema.required || []);
|
|
152
|
+
return Object.entries(schema.properties)
|
|
153
|
+
.map(([key, value]) => {
|
|
154
|
+
const typedValue = value;
|
|
155
|
+
const required = requiredParams.has(key) ? " (required)" : "";
|
|
156
|
+
return ` - ${key}: ${typedValue.type || "unknown"}${required}`;
|
|
157
|
+
})
|
|
158
|
+
.join("\n");
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Transform tools to tool descriptions for system prompts
|
|
162
|
+
* Consolidated pattern for creating tool-aware prompts
|
|
163
|
+
*/
|
|
164
|
+
export function transformToolsToDescriptions(availableTools) {
|
|
165
|
+
return availableTools
|
|
166
|
+
.map((tool) => {
|
|
167
|
+
const schema = tool.inputSchema;
|
|
168
|
+
let params = "";
|
|
169
|
+
if (schema?.properties) {
|
|
170
|
+
params = transformSchemaToParameterDescription(schema);
|
|
171
|
+
}
|
|
172
|
+
return `- ${tool.name}: ${tool.description} (from ${tool.server})\n${params}`;
|
|
173
|
+
})
|
|
174
|
+
.join("\n\n");
|
|
175
|
+
}
|
|
176
|
+
// ============================================================================
|
|
177
|
+
// VALIDATION TRANSFORMATIONS
|
|
178
|
+
// ============================================================================
|
|
179
|
+
/**
|
|
180
|
+
* Transform parameters for validation
|
|
181
|
+
* Common pattern when logging or checking parameter structures
|
|
182
|
+
*/
|
|
183
|
+
export function transformParamsForLogging(params) {
|
|
184
|
+
if (!params || typeof params !== "object") {
|
|
185
|
+
return String(params);
|
|
186
|
+
}
|
|
187
|
+
const record = params;
|
|
188
|
+
return `${Object.keys(record).length} params`;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Safe property extraction from unknown objects
|
|
192
|
+
* Common pattern for safely accessing properties from unknown structures
|
|
193
|
+
*/
|
|
194
|
+
export function safeExtractProperty(obj, key, fallback) {
|
|
195
|
+
if (!obj || typeof obj !== "object" || obj === null) {
|
|
196
|
+
return fallback;
|
|
197
|
+
}
|
|
198
|
+
const record = obj;
|
|
199
|
+
const value = record[key];
|
|
200
|
+
return value !== undefined ? value : fallback;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Safe extraction of string properties
|
|
204
|
+
* Specialized version for string properties with fallback
|
|
205
|
+
*/
|
|
206
|
+
export function safeExtractString(obj, key, fallback = "") {
|
|
207
|
+
const value = safeExtractProperty(obj, key, fallback);
|
|
208
|
+
return typeof value === "string" ? value : fallback;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Safe extraction of number properties
|
|
212
|
+
* Specialized version for number properties with fallback
|
|
213
|
+
*/
|
|
214
|
+
export function safeExtractNumber(obj, key, fallback = 0) {
|
|
215
|
+
const value = safeExtractProperty(obj, key, fallback);
|
|
216
|
+
return typeof value === "number" ? value : fallback;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Safe extraction of boolean properties
|
|
220
|
+
* Specialized version for boolean properties with fallback
|
|
221
|
+
*/
|
|
222
|
+
export function safeExtractBoolean(obj, key, fallback = false) {
|
|
223
|
+
const value = safeExtractProperty(obj, key, fallback);
|
|
224
|
+
return typeof value === "boolean" ? value : fallback;
|
|
225
|
+
}
|
|
226
|
+
// ============================================================================
|
|
227
|
+
// COLLECTION TRANSFORMATIONS
|
|
228
|
+
// ============================================================================
|
|
229
|
+
/**
|
|
230
|
+
* Transform Map to array of values
|
|
231
|
+
* Common pattern for converting tool maps to arrays
|
|
232
|
+
*/
|
|
233
|
+
export function mapToArray(map) {
|
|
234
|
+
return Array.from(map.values());
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Transform Map to array of key-value pairs
|
|
238
|
+
* Common pattern for processing map entries
|
|
239
|
+
*/
|
|
240
|
+
export function mapToEntries(map) {
|
|
241
|
+
return Array.from(map.entries());
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Group array items by a key
|
|
245
|
+
* Common pattern for organizing tools or other objects by category
|
|
246
|
+
*/
|
|
247
|
+
export function groupBy(items, keyFn) {
|
|
248
|
+
const groups = new Map();
|
|
249
|
+
for (const item of items) {
|
|
250
|
+
const key = keyFn(item);
|
|
251
|
+
const existing = groups.get(key) || [];
|
|
252
|
+
existing.push(item);
|
|
253
|
+
groups.set(key, existing);
|
|
254
|
+
}
|
|
255
|
+
return groups;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Remove undefined properties from objects
|
|
259
|
+
* Common pattern for cleaning up object structures
|
|
260
|
+
*/
|
|
261
|
+
export function removeUndefinedProperties(obj) {
|
|
262
|
+
const cleaned = {};
|
|
263
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
264
|
+
if (value !== undefined) {
|
|
265
|
+
cleaned[key] = value;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return cleaned;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Merge objects with undefined handling
|
|
272
|
+
* Common pattern for combining configuration objects
|
|
273
|
+
*/
|
|
274
|
+
export function mergeWithUndefinedHandling(target, ...sources) {
|
|
275
|
+
const result = { ...target };
|
|
276
|
+
for (const source of sources) {
|
|
277
|
+
for (const [key, value] of Object.entries(source)) {
|
|
278
|
+
if (value !== undefined) {
|
|
279
|
+
result[key] = value;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return result;
|
|
284
|
+
}
|
|
285
|
+
// ============================================================================
|
|
286
|
+
// TOOL OPTIMIZATION UTILITIES
|
|
287
|
+
// ============================================================================
|
|
288
|
+
/**
|
|
289
|
+
* Optimize tool information for collection with minimal object creation
|
|
290
|
+
* Consolidates repeated optimization patterns across different tool sources
|
|
291
|
+
*
|
|
292
|
+
* @param tool - Tool information to optimize
|
|
293
|
+
* @param defaults - Default values to apply if missing
|
|
294
|
+
* @returns Optimized tool with minimal object creation
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* const optimized = optimizeToolForCollection(tool, {
|
|
299
|
+
* serverId: "builtin",
|
|
300
|
+
* category: "math"
|
|
301
|
+
* });
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
export function optimizeToolForCollection(tool, defaults) {
|
|
305
|
+
// Check what properties actually need modification
|
|
306
|
+
const needsDescription = !tool.description && defaults.description;
|
|
307
|
+
const needsServerId = !tool.serverId && defaults.serverId;
|
|
308
|
+
const needsCategory = !tool.category && defaults.category;
|
|
309
|
+
const needsInputSchema = !tool.inputSchema && defaults.inputSchema;
|
|
310
|
+
const hasParametersConflict = tool.inputSchema && "parameters" in tool;
|
|
311
|
+
// Only create new object if modifications are actually needed
|
|
312
|
+
if (!needsDescription &&
|
|
313
|
+
!needsServerId &&
|
|
314
|
+
!needsCategory &&
|
|
315
|
+
!needsInputSchema &&
|
|
316
|
+
!hasParametersConflict) {
|
|
317
|
+
return tool; // Return original tool without modification
|
|
318
|
+
}
|
|
319
|
+
// Create optimized tool with only necessary changes
|
|
320
|
+
const optimizedTool = {
|
|
321
|
+
...tool,
|
|
322
|
+
...(needsDescription && { description: defaults.description }),
|
|
323
|
+
...(needsServerId && { serverId: defaults.serverId }),
|
|
324
|
+
...(needsCategory && { category: defaults.category }),
|
|
325
|
+
...(needsInputSchema && { inputSchema: defaults.inputSchema }),
|
|
326
|
+
};
|
|
327
|
+
// Clean up schema conflicts if present
|
|
328
|
+
if (hasParametersConflict) {
|
|
329
|
+
const cleanedTool = { ...optimizedTool };
|
|
330
|
+
delete cleanedTool.parameters;
|
|
331
|
+
return cleanedTool;
|
|
332
|
+
}
|
|
333
|
+
return optimizedTool;
|
|
334
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Utilities - Centralized type checking functions
|
|
3
|
+
*
|
|
4
|
+
* Consolidates common type checking patterns to reduce code duplication
|
|
5
|
+
* and provide consistent type guards across the codebase.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if a value is a non-null object
|
|
9
|
+
* Excludes arrays and null values
|
|
10
|
+
*
|
|
11
|
+
* @param value - Value to check
|
|
12
|
+
* @returns true if value is a non-null object (excluding arrays)
|
|
13
|
+
*/
|
|
14
|
+
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to check if a value is a non-null object (including arrays)
|
|
17
|
+
*
|
|
18
|
+
* @param value - Value to check
|
|
19
|
+
* @returns true if value is a non-null object (including arrays)
|
|
20
|
+
*/
|
|
21
|
+
export declare function isNonNullObject(value: unknown): value is object;
|
|
22
|
+
/**
|
|
23
|
+
* Type guard to check if a value is a plain object with string keys
|
|
24
|
+
*
|
|
25
|
+
* @param value - Value to check
|
|
26
|
+
* @returns true if value is a plain object with string keys
|
|
27
|
+
*/
|
|
28
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Type guard to check if a value is an array
|
|
31
|
+
*
|
|
32
|
+
* @param value - Value to check
|
|
33
|
+
* @returns true if value is an array
|
|
34
|
+
*/
|
|
35
|
+
export declare function isArray(value: unknown): value is unknown[];
|
|
36
|
+
/**
|
|
37
|
+
* Type guard to check if a value is a string
|
|
38
|
+
*
|
|
39
|
+
* @param value - Value to check
|
|
40
|
+
* @returns true if value is a string
|
|
41
|
+
*/
|
|
42
|
+
export declare function isString(value: unknown): value is string;
|
|
43
|
+
/**
|
|
44
|
+
* Type guard to check if a value is a number
|
|
45
|
+
*
|
|
46
|
+
* @param value - Value to check
|
|
47
|
+
* @returns true if value is a number and not NaN
|
|
48
|
+
*/
|
|
49
|
+
export declare function isNumber(value: unknown): value is number;
|
|
50
|
+
/**
|
|
51
|
+
* Type guard to check if a value is a boolean
|
|
52
|
+
*
|
|
53
|
+
* @param value - Value to check
|
|
54
|
+
* @returns true if value is a boolean
|
|
55
|
+
*/
|
|
56
|
+
export declare function isBoolean(value: unknown): value is boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Type guard to check if a value is a function
|
|
59
|
+
*
|
|
60
|
+
* @param value - Value to check
|
|
61
|
+
* @returns true if value is a function
|
|
62
|
+
*/
|
|
63
|
+
export declare function isFunction(value: unknown): value is Function;
|
|
64
|
+
/**
|
|
65
|
+
* Type guard to check if a value is null or undefined
|
|
66
|
+
*
|
|
67
|
+
* @param value - Value to check
|
|
68
|
+
* @returns true if value is null or undefined
|
|
69
|
+
*/
|
|
70
|
+
export declare function isNullish(value: unknown): value is null | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Type guard to check if a value is defined (not undefined)
|
|
73
|
+
*
|
|
74
|
+
* @param value - Value to check
|
|
75
|
+
* @returns true if value is not undefined
|
|
76
|
+
*/
|
|
77
|
+
export declare function isDefined<T>(value: T | undefined): value is T;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Utilities - Centralized type checking functions
|
|
3
|
+
*
|
|
4
|
+
* Consolidates common type checking patterns to reduce code duplication
|
|
5
|
+
* and provide consistent type guards across the codebase.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if a value is a non-null object
|
|
9
|
+
* Excludes arrays and null values
|
|
10
|
+
*
|
|
11
|
+
* @param value - Value to check
|
|
12
|
+
* @returns true if value is a non-null object (excluding arrays)
|
|
13
|
+
*/
|
|
14
|
+
export function isObject(value) {
|
|
15
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to check if a value is a non-null object (including arrays)
|
|
19
|
+
*
|
|
20
|
+
* @param value - Value to check
|
|
21
|
+
* @returns true if value is a non-null object (including arrays)
|
|
22
|
+
*/
|
|
23
|
+
export function isNonNullObject(value) {
|
|
24
|
+
return typeof value === "object" && value !== null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a value is a plain object with string keys
|
|
28
|
+
*
|
|
29
|
+
* @param value - Value to check
|
|
30
|
+
* @returns true if value is a plain object with string keys
|
|
31
|
+
*/
|
|
32
|
+
export function isPlainObject(value) {
|
|
33
|
+
return isObject(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Type guard to check if a value is an array
|
|
37
|
+
*
|
|
38
|
+
* @param value - Value to check
|
|
39
|
+
* @returns true if value is an array
|
|
40
|
+
*/
|
|
41
|
+
export function isArray(value) {
|
|
42
|
+
return Array.isArray(value);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Type guard to check if a value is a string
|
|
46
|
+
*
|
|
47
|
+
* @param value - Value to check
|
|
48
|
+
* @returns true if value is a string
|
|
49
|
+
*/
|
|
50
|
+
export function isString(value) {
|
|
51
|
+
return typeof value === "string";
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Type guard to check if a value is a number
|
|
55
|
+
*
|
|
56
|
+
* @param value - Value to check
|
|
57
|
+
* @returns true if value is a number and not NaN
|
|
58
|
+
*/
|
|
59
|
+
export function isNumber(value) {
|
|
60
|
+
return typeof value === "number" && !isNaN(value);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Type guard to check if a value is a boolean
|
|
64
|
+
*
|
|
65
|
+
* @param value - Value to check
|
|
66
|
+
* @returns true if value is a boolean
|
|
67
|
+
*/
|
|
68
|
+
export function isBoolean(value) {
|
|
69
|
+
return typeof value === "boolean";
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Type guard to check if a value is a function
|
|
73
|
+
*
|
|
74
|
+
* @param value - Value to check
|
|
75
|
+
* @returns true if value is a function
|
|
76
|
+
*/
|
|
77
|
+
export function isFunction(value) {
|
|
78
|
+
return typeof value === "function";
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Type guard to check if a value is null or undefined
|
|
82
|
+
*
|
|
83
|
+
* @param value - Value to check
|
|
84
|
+
* @returns true if value is null or undefined
|
|
85
|
+
*/
|
|
86
|
+
export function isNullish(value) {
|
|
87
|
+
return value === null || value === undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Type guard to check if a value is defined (not undefined)
|
|
91
|
+
*
|
|
92
|
+
* @param value - Value to check
|
|
93
|
+
* @returns true if value is not undefined
|
|
94
|
+
*/
|
|
95
|
+
export function isDefined(value) {
|
|
96
|
+
return value !== undefined;
|
|
97
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "7.14.
|
|
3
|
+
"version": "7.14.3",
|
|
4
4
|
"description": "Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with 9 major providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Juspay Technologies",
|