@umituz/react-native-ai-groq-provider 1.0.3 → 1.0.5
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/dist/domain/entities/error.types.d.ts +34 -0
- package/dist/domain/entities/error.types.d.ts.map +1 -0
- package/dist/domain/entities/error.types.js +57 -0
- package/dist/domain/entities/error.types.js.map +1 -0
- package/dist/domain/entities/groq.types.d.ts +222 -0
- package/dist/domain/entities/groq.types.d.ts.map +1 -0
- package/dist/domain/entities/groq.types.js +37 -0
- package/dist/domain/entities/groq.types.js.map +1 -0
- package/dist/domain/entities/index.d.ts +7 -0
- package/dist/domain/entities/index.d.ts.map +1 -0
- package/dist/domain/entities/index.js +23 -0
- package/dist/domain/entities/index.js.map +1 -0
- package/dist/domain/entities/models.d.ts +50 -0
- package/dist/domain/entities/models.d.ts.map +1 -0
- package/dist/domain/entities/models.js +178 -0
- package/dist/domain/entities/models.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/services/ChatSession.d.ts +95 -0
- package/dist/infrastructure/services/ChatSession.d.ts.map +1 -0
- package/dist/infrastructure/services/ChatSession.js +177 -0
- package/dist/infrastructure/services/ChatSession.js.map +1 -0
- package/dist/infrastructure/services/GroqClient.d.ts +52 -0
- package/dist/infrastructure/services/GroqClient.d.ts.map +1 -0
- package/dist/infrastructure/services/GroqClient.js +258 -0
- package/dist/infrastructure/services/GroqClient.js.map +1 -0
- package/dist/infrastructure/services/Streaming.d.ts +27 -0
- package/dist/infrastructure/services/Streaming.d.ts.map +1 -0
- package/dist/infrastructure/services/Streaming.js +84 -0
- package/dist/infrastructure/services/Streaming.js.map +1 -0
- package/dist/infrastructure/services/StructuredText.d.ts +20 -0
- package/dist/infrastructure/services/StructuredText.d.ts.map +1 -0
- package/dist/infrastructure/services/StructuredText.js +204 -0
- package/dist/infrastructure/services/StructuredText.js.map +1 -0
- package/dist/infrastructure/services/TextGeneration.d.ts +18 -0
- package/dist/infrastructure/services/TextGeneration.d.ts.map +1 -0
- package/dist/infrastructure/services/TextGeneration.js +127 -0
- package/dist/infrastructure/services/TextGeneration.js.map +1 -0
- package/dist/infrastructure/services/index.d.ts +9 -0
- package/dist/infrastructure/services/index.d.ts.map +1 -0
- package/dist/infrastructure/services/index.js +24 -0
- package/dist/infrastructure/services/index.js.map +1 -0
- package/dist/infrastructure/telemetry/TelemetryHooks.d.ts +48 -0
- package/dist/infrastructure/telemetry/TelemetryHooks.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/TelemetryHooks.js +70 -0
- package/dist/infrastructure/telemetry/TelemetryHooks.js.map +1 -0
- package/dist/infrastructure/telemetry/index.d.ts +5 -0
- package/dist/infrastructure/telemetry/index.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/index.js +10 -0
- package/dist/infrastructure/telemetry/index.js.map +1 -0
- package/dist/infrastructure/utils/async/execute-state.util.d.ts +27 -0
- package/dist/infrastructure/utils/async/execute-state.util.d.ts.map +1 -0
- package/dist/infrastructure/utils/async/execute-state.util.js +50 -0
- package/dist/infrastructure/utils/async/execute-state.util.js.map +1 -0
- package/dist/infrastructure/utils/async/index.d.ts +6 -0
- package/dist/infrastructure/utils/async/index.d.ts.map +1 -0
- package/dist/infrastructure/utils/async/index.js +10 -0
- package/dist/infrastructure/utils/async/index.js.map +1 -0
- package/dist/infrastructure/utils/content-mapper.util.d.ts +34 -0
- package/dist/infrastructure/utils/content-mapper.util.d.ts.map +1 -0
- package/dist/infrastructure/utils/content-mapper.util.js +84 -0
- package/dist/infrastructure/utils/content-mapper.util.js.map +1 -0
- package/dist/infrastructure/utils/error-mapper.util.d.ts +21 -0
- package/dist/infrastructure/utils/error-mapper.util.d.ts.map +1 -0
- package/dist/infrastructure/utils/error-mapper.util.js +73 -0
- package/dist/infrastructure/utils/error-mapper.util.js.map +1 -0
- package/dist/infrastructure/utils/index.d.ts +7 -0
- package/dist/infrastructure/utils/index.d.ts.map +1 -0
- package/dist/infrastructure/utils/index.js +23 -0
- package/dist/infrastructure/utils/index.js.map +1 -0
- package/dist/presentation/hooks/useGroq.d.ts +42 -0
- package/dist/presentation/hooks/useGroq.d.ts.map +1 -0
- package/dist/presentation/hooks/useGroq.js +153 -0
- package/dist/presentation/hooks/useGroq.js.map +1 -0
- package/dist/presentation/hooks/useOperationManager.d.ts +34 -0
- package/dist/presentation/hooks/useOperationManager.d.ts.map +1 -0
- package/dist/presentation/hooks/useOperationManager.js +76 -0
- package/dist/presentation/hooks/useOperationManager.js.map +1 -0
- package/dist/providers/ConfigBuilder.d.ts +86 -0
- package/dist/providers/ConfigBuilder.d.ts.map +1 -0
- package/dist/providers/ConfigBuilder.js +147 -0
- package/dist/providers/ConfigBuilder.js.map +1 -0
- package/dist/providers/ProviderFactory.d.ts +56 -0
- package/dist/providers/ProviderFactory.d.ts.map +1 -0
- package/dist/providers/ProviderFactory.js +75 -0
- package/dist/providers/ProviderFactory.js.map +1 -0
- package/dist/providers/index.d.ts +7 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +15 -0
- package/dist/providers/index.js.map +1 -0
- package/package.json +1 -1
- package/src/infrastructure/services/GroqClient.ts +61 -1
- package/src/infrastructure/services/StructuredText.ts +94 -1
- package/src/infrastructure/services/TextGeneration.ts +70 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Text Generation Service
|
|
4
|
+
* Handles basic text generation using Groq API
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.textGeneration = textGeneration;
|
|
8
|
+
exports.chatGeneration = chatGeneration;
|
|
9
|
+
const GroqClient_1 = require("./GroqClient");
|
|
10
|
+
const entities_1 = require("../../domain/entities");
|
|
11
|
+
const error_types_1 = require("../../domain/entities/error.types");
|
|
12
|
+
/**
|
|
13
|
+
* Generate text from a simple prompt
|
|
14
|
+
*/
|
|
15
|
+
async function textGeneration(prompt, options = {}) {
|
|
16
|
+
const startTime = Date.now();
|
|
17
|
+
const model = options.model || entities_1.DEFAULT_MODELS.TEXT;
|
|
18
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
19
|
+
console.log("[Groq] textGeneration called:", {
|
|
20
|
+
model,
|
|
21
|
+
promptLength: prompt.length,
|
|
22
|
+
promptPreview: prompt.substring(0, 100) + "...",
|
|
23
|
+
options: options.generationConfig,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const messages = [
|
|
27
|
+
{
|
|
28
|
+
role: "user",
|
|
29
|
+
content: prompt,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
const request = {
|
|
33
|
+
model,
|
|
34
|
+
messages,
|
|
35
|
+
temperature: options.generationConfig?.temperature || 0.7,
|
|
36
|
+
max_tokens: options.generationConfig?.maxTokens || 1024,
|
|
37
|
+
top_p: options.generationConfig?.topP,
|
|
38
|
+
n: options.generationConfig?.n,
|
|
39
|
+
stop: options.generationConfig?.stop,
|
|
40
|
+
frequency_penalty: options.generationConfig?.frequencyPenalty,
|
|
41
|
+
presence_penalty: options.generationConfig?.presencePenalty,
|
|
42
|
+
};
|
|
43
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
44
|
+
console.log("[Groq] Sending request to API:", {
|
|
45
|
+
endpoint: "/v1/chat/completions",
|
|
46
|
+
requestBody: {
|
|
47
|
+
model: request.model,
|
|
48
|
+
messageCount: request.messages.length,
|
|
49
|
+
temperature: request.temperature,
|
|
50
|
+
max_tokens: request.max_tokens,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const apiStartTime = Date.now();
|
|
55
|
+
const response = await GroqClient_1.groqHttpClient.chatCompletion(request);
|
|
56
|
+
const apiDuration = Date.now() - apiStartTime;
|
|
57
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
58
|
+
console.log("[Groq] API response received:", {
|
|
59
|
+
apiDuration: `${apiDuration}ms`,
|
|
60
|
+
hasChoices: !!response.choices?.length,
|
|
61
|
+
choiceCount: response.choices?.length || 0,
|
|
62
|
+
usage: response.usage,
|
|
63
|
+
finishReason: response.choices?.[0]?.finish_reason,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const content = response.choices[0]?.message?.content;
|
|
67
|
+
if (!content) {
|
|
68
|
+
throw new error_types_1.GroqError(error_types_1.GroqErrorType.UNKNOWN_ERROR, "No content generated from Groq API");
|
|
69
|
+
}
|
|
70
|
+
const totalDuration = Date.now() - startTime;
|
|
71
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
72
|
+
console.log("[Groq] textGeneration complete:", {
|
|
73
|
+
totalDuration: `${totalDuration}ms`,
|
|
74
|
+
responseLength: content.length,
|
|
75
|
+
responsePreview: content.substring(0, 200) + "...",
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return content;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Generate text from an array of messages
|
|
82
|
+
*/
|
|
83
|
+
async function chatGeneration(messages, options = {}) {
|
|
84
|
+
const startTime = Date.now();
|
|
85
|
+
const model = options.model || entities_1.DEFAULT_MODELS.TEXT;
|
|
86
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
87
|
+
console.log("[Groq] chatGeneration called:", {
|
|
88
|
+
model,
|
|
89
|
+
messageCount: messages.length,
|
|
90
|
+
options: options.generationConfig,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const request = {
|
|
94
|
+
model,
|
|
95
|
+
messages,
|
|
96
|
+
temperature: options.generationConfig?.temperature || 0.7,
|
|
97
|
+
max_tokens: options.generationConfig?.maxTokens || 1024,
|
|
98
|
+
top_p: options.generationConfig?.topP,
|
|
99
|
+
n: options.generationConfig?.n,
|
|
100
|
+
stop: options.generationConfig?.stop,
|
|
101
|
+
frequency_penalty: options.generationConfig?.frequencyPenalty,
|
|
102
|
+
presence_penalty: options.generationConfig?.presencePenalty,
|
|
103
|
+
};
|
|
104
|
+
const apiStartTime = Date.now();
|
|
105
|
+
const response = await GroqClient_1.groqHttpClient.chatCompletion(request);
|
|
106
|
+
const apiDuration = Date.now() - apiStartTime;
|
|
107
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
108
|
+
console.log("[Groq] chatGeneration API response:", {
|
|
109
|
+
apiDuration: `${apiDuration}ms`,
|
|
110
|
+
usage: response.usage,
|
|
111
|
+
finishReason: response.choices?.[0]?.finish_reason,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const content = response.choices[0]?.message?.content;
|
|
115
|
+
if (!content) {
|
|
116
|
+
throw new error_types_1.GroqError(error_types_1.GroqErrorType.UNKNOWN_ERROR, "No content generated from Groq API");
|
|
117
|
+
}
|
|
118
|
+
const totalDuration = Date.now() - startTime;
|
|
119
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
120
|
+
console.log("[Groq] chatGeneration complete:", {
|
|
121
|
+
totalDuration: `${totalDuration}ms`,
|
|
122
|
+
responseLength: content.length,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return content;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=TextGeneration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextGeneration.js","sourceRoot":"","sources":["../../../src/infrastructure/services/TextGeneration.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAoBH,wCA+EC;AAKD,wCAwDC;AAxJD,6CAA8C;AAC9C,oDAAuD;AACvD,mEAA6E;AAO7E;;GAEG;AACI,KAAK,UAAU,cAAc,CAClC,MAAc,EACd,UAAiC,EAAE;IAEnC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,yBAAc,CAAC,IAAI,CAAC;IAEnD,IAAI,OAAO,OAAO,KAAK,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;SACnD,CAAC,CAAC;IACL,CAAC;IAED,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC;IACtD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,uBAAS,CACjB,2BAAa,CAAC,aAAa,EAC3B,oCAAoC,CACrC,CAAC;IACJ,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IAC7C,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,EAAE,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE;YAC7C,aAAa,EAAE,GAAG,aAAa,IAAI;YACnC,cAAc,EAAE,OAAO,CAAC,MAAM;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Infrastructure Services
|
|
3
|
+
*/
|
|
4
|
+
export { groqHttpClient } from "./GroqClient";
|
|
5
|
+
export { textGeneration, chatGeneration } from "./TextGeneration";
|
|
6
|
+
export { structuredText, structuredChat } from "./StructuredText";
|
|
7
|
+
export { streaming, streamingChat, type StreamingCallbacks, type StreamingOptions } from "./Streaming";
|
|
8
|
+
export { chatSessionService, createChatSession, sendChatMessage, buildChatHistory, trimChatHistory, type ChatSession, type SendChatMessageOptions, type ChatSendResult, type ChatHistoryMessage, } from "./ChatSession";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/services/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACvG,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Infrastructure Services
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.trimChatHistory = exports.buildChatHistory = exports.sendChatMessage = exports.createChatSession = exports.chatSessionService = exports.streamingChat = exports.streaming = exports.structuredChat = exports.structuredText = exports.chatGeneration = exports.textGeneration = exports.groqHttpClient = void 0;
|
|
7
|
+
var GroqClient_1 = require("./GroqClient");
|
|
8
|
+
Object.defineProperty(exports, "groqHttpClient", { enumerable: true, get: function () { return GroqClient_1.groqHttpClient; } });
|
|
9
|
+
var TextGeneration_1 = require("./TextGeneration");
|
|
10
|
+
Object.defineProperty(exports, "textGeneration", { enumerable: true, get: function () { return TextGeneration_1.textGeneration; } });
|
|
11
|
+
Object.defineProperty(exports, "chatGeneration", { enumerable: true, get: function () { return TextGeneration_1.chatGeneration; } });
|
|
12
|
+
var StructuredText_1 = require("./StructuredText");
|
|
13
|
+
Object.defineProperty(exports, "structuredText", { enumerable: true, get: function () { return StructuredText_1.structuredText; } });
|
|
14
|
+
Object.defineProperty(exports, "structuredChat", { enumerable: true, get: function () { return StructuredText_1.structuredChat; } });
|
|
15
|
+
var Streaming_1 = require("./Streaming");
|
|
16
|
+
Object.defineProperty(exports, "streaming", { enumerable: true, get: function () { return Streaming_1.streaming; } });
|
|
17
|
+
Object.defineProperty(exports, "streamingChat", { enumerable: true, get: function () { return Streaming_1.streamingChat; } });
|
|
18
|
+
var ChatSession_1 = require("./ChatSession");
|
|
19
|
+
Object.defineProperty(exports, "chatSessionService", { enumerable: true, get: function () { return ChatSession_1.chatSessionService; } });
|
|
20
|
+
Object.defineProperty(exports, "createChatSession", { enumerable: true, get: function () { return ChatSession_1.createChatSession; } });
|
|
21
|
+
Object.defineProperty(exports, "sendChatMessage", { enumerable: true, get: function () { return ChatSession_1.sendChatMessage; } });
|
|
22
|
+
Object.defineProperty(exports, "buildChatHistory", { enumerable: true, get: function () { return ChatSession_1.buildChatHistory; } });
|
|
23
|
+
Object.defineProperty(exports, "trimChatHistory", { enumerable: true, get: function () { return ChatSession_1.trimChatHistory; } });
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/services/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,2CAA8C;AAArC,4GAAA,cAAc,OAAA;AACvB,mDAAkE;AAAzD,gHAAA,cAAc,OAAA;AAAE,gHAAA,cAAc,OAAA;AACvC,mDAAkE;AAAzD,gHAAA,cAAc,OAAA;AAAE,gHAAA,cAAc,OAAA;AACvC,yCAAuG;AAA9F,sGAAA,SAAS,OAAA;AAAE,0GAAA,aAAa,OAAA;AACjC,6CAUuB;AATrB,iHAAA,kBAAkB,OAAA;AAClB,gHAAA,iBAAiB,OAAA;AACjB,8GAAA,eAAe,OAAA;AACf,+GAAA,gBAAgB,OAAA;AAChB,8GAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telemetry Hooks
|
|
3
|
+
* Simple telemetry tracking for Groq operations
|
|
4
|
+
*/
|
|
5
|
+
type TelemetryEvent = {
|
|
6
|
+
name: string;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
data?: Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
declare class Telemetry {
|
|
11
|
+
private events;
|
|
12
|
+
private enabled;
|
|
13
|
+
/**
|
|
14
|
+
* Log a telemetry event
|
|
15
|
+
*/
|
|
16
|
+
log(name: string, data?: Record<string, unknown>): void;
|
|
17
|
+
/**
|
|
18
|
+
* Get all events
|
|
19
|
+
*/
|
|
20
|
+
getEvents(): TelemetryEvent[];
|
|
21
|
+
/**
|
|
22
|
+
* Clear all events
|
|
23
|
+
*/
|
|
24
|
+
clear(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Enable/disable telemetry
|
|
27
|
+
*/
|
|
28
|
+
setEnabled(enabled: boolean): void;
|
|
29
|
+
/**
|
|
30
|
+
* Check if telemetry is enabled
|
|
31
|
+
*/
|
|
32
|
+
isEnabled(): boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Singleton instance
|
|
36
|
+
*/
|
|
37
|
+
export declare const telemetry: Telemetry;
|
|
38
|
+
/**
|
|
39
|
+
* Hook to use telemetry in components
|
|
40
|
+
*/
|
|
41
|
+
export declare function useTelemetry(): {
|
|
42
|
+
log: any;
|
|
43
|
+
getEvents: any;
|
|
44
|
+
clear: any;
|
|
45
|
+
isEnabled: any;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=TelemetryHooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TelemetryHooks.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/telemetry/TelemetryHooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,cAAM,SAAS;IACb,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,OAAO,CAAW;IAE1B;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAgBvD;;OAEG;IACH,SAAS,IAAI,cAAc,EAAE;IAI7B;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIlC;;OAEG;IACH,SAAS,IAAI,OAAO;CAGrB;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,WAAkB,CAAC;AAEzC;;GAEG;AACH,wBAAgB,YAAY;;;;;EAO3B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Telemetry Hooks
|
|
4
|
+
* Simple telemetry tracking for Groq operations
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.telemetry = void 0;
|
|
8
|
+
exports.useTelemetry = useTelemetry;
|
|
9
|
+
class Telemetry {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.events = [];
|
|
12
|
+
this.enabled = __DEV__;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Log a telemetry event
|
|
16
|
+
*/
|
|
17
|
+
log(name, data) {
|
|
18
|
+
if (!this.enabled)
|
|
19
|
+
return;
|
|
20
|
+
const event = {
|
|
21
|
+
name,
|
|
22
|
+
timestamp: Date.now(),
|
|
23
|
+
data,
|
|
24
|
+
};
|
|
25
|
+
this.events.push(event);
|
|
26
|
+
if (__DEV__) {
|
|
27
|
+
console.log(`[Groq Telemetry] ${name}`, data);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get all events
|
|
32
|
+
*/
|
|
33
|
+
getEvents() {
|
|
34
|
+
return [...this.events];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Clear all events
|
|
38
|
+
*/
|
|
39
|
+
clear() {
|
|
40
|
+
this.events = [];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Enable/disable telemetry
|
|
44
|
+
*/
|
|
45
|
+
setEnabled(enabled) {
|
|
46
|
+
this.enabled = enabled;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Check if telemetry is enabled
|
|
50
|
+
*/
|
|
51
|
+
isEnabled() {
|
|
52
|
+
return this.enabled;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Singleton instance
|
|
57
|
+
*/
|
|
58
|
+
exports.telemetry = new Telemetry();
|
|
59
|
+
/**
|
|
60
|
+
* Hook to use telemetry in components
|
|
61
|
+
*/
|
|
62
|
+
function useTelemetry() {
|
|
63
|
+
return {
|
|
64
|
+
log: exports.telemetry.log.bind(exports.telemetry),
|
|
65
|
+
getEvents: exports.telemetry.getEvents.bind(exports.telemetry),
|
|
66
|
+
clear: exports.telemetry.clear.bind(exports.telemetry),
|
|
67
|
+
isEnabled: exports.telemetry.isEnabled.bind(exports.telemetry),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=TelemetryHooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TelemetryHooks.js","sourceRoot":"","sources":["../../../src/infrastructure/telemetry/TelemetryHooks.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAoEH,oCAOC;AAnED,MAAM,SAAS;IAAf;QACU,WAAM,GAAqB,EAAE,CAAC;QAC9B,YAAO,GAAG,OAAO,CAAC;IAgD5B,CAAC;IA9CC;;OAEG;IACH,GAAG,CAAC,IAAY,EAAE,IAA8B;QAC9C,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO;QAE1B,MAAM,KAAK,GAAmB;YAC5B,IAAI;YACJ,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,IAAI;SACL,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAExB,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAAgB;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAED;;GAEG;AACU,QAAA,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;AAEzC;;GAEG;AACH,SAAgB,YAAY;IAC1B,OAAO;QACL,GAAG,EAAE,iBAAS,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAS,CAAC;QAClC,SAAS,EAAE,iBAAS,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAS,CAAC;QAC9C,KAAK,EAAE,iBAAS,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAC;QACtC,SAAS,EAAE,iBAAS,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAS,CAAC;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/telemetry/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Telemetry
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useTelemetry = exports.telemetry = void 0;
|
|
7
|
+
var TelemetryHooks_1 = require("./TelemetryHooks");
|
|
8
|
+
Object.defineProperty(exports, "telemetry", { enumerable: true, get: function () { return TelemetryHooks_1.telemetry; } });
|
|
9
|
+
Object.defineProperty(exports, "useTelemetry", { enumerable: true, get: function () { return TelemetryHooks_1.useTelemetry; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/telemetry/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,mDAA2D;AAAlD,2GAAA,SAAS,OAAA;AAAE,8GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async State Utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* State setters for async operations
|
|
6
|
+
*/
|
|
7
|
+
export interface AsyncStateSetters<T> {
|
|
8
|
+
setLoading: (loading: boolean) => void;
|
|
9
|
+
setError: (error: string | null) => void;
|
|
10
|
+
setData?: (data: T | null) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Callbacks for async operations
|
|
14
|
+
*/
|
|
15
|
+
export interface AsyncCallbacks<T> {
|
|
16
|
+
onSuccess?: (data: T) => void;
|
|
17
|
+
onError?: (error: Error) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Execute async function with state management
|
|
21
|
+
*/
|
|
22
|
+
export declare function executeWithState<T>(setters: AsyncStateSetters<T>, asyncFn: () => Promise<T>, callbacks?: AsyncCallbacks<T>): Promise<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Execute async function with retry logic
|
|
25
|
+
*/
|
|
26
|
+
export declare function executeWithRetry<T>(asyncFn: () => Promise<T>, maxRetries?: number, delayMs?: number): Promise<T>;
|
|
27
|
+
//# sourceMappingURL=execute-state.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-state.util.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/utils/async/execute-state.util.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC9B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC7B,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACzB,SAAS,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAC5B,OAAO,CAAC,CAAC,CAAC,CAqBZ;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACzB,UAAU,GAAE,MAAU,EACtB,OAAO,GAAE,MAAa,GACrB,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Async State Utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.executeWithState = executeWithState;
|
|
7
|
+
exports.executeWithRetry = executeWithRetry;
|
|
8
|
+
/**
|
|
9
|
+
* Execute async function with state management
|
|
10
|
+
*/
|
|
11
|
+
async function executeWithState(setters, asyncFn, callbacks) {
|
|
12
|
+
const { setLoading, setError, setData } = setters;
|
|
13
|
+
try {
|
|
14
|
+
setLoading(true);
|
|
15
|
+
setError(null);
|
|
16
|
+
const result = await asyncFn();
|
|
17
|
+
setData?.(result);
|
|
18
|
+
callbacks?.onSuccess?.(result);
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
23
|
+
setError(errorMessage);
|
|
24
|
+
callbacks?.onError?.(error);
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
setLoading(false);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Execute async function with retry logic
|
|
33
|
+
*/
|
|
34
|
+
async function executeWithRetry(asyncFn, maxRetries = 3, delayMs = 1000) {
|
|
35
|
+
let lastError = null;
|
|
36
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
37
|
+
try {
|
|
38
|
+
return await asyncFn();
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
lastError = error;
|
|
42
|
+
if (attempt < maxRetries - 1) {
|
|
43
|
+
// Wait before retrying with exponential backoff
|
|
44
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs * Math.pow(2, attempt)));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
throw lastError;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=execute-state.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-state.util.js","sourceRoot":"","sources":["../../../../src/infrastructure/utils/async/execute-state.util.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAsBH,4CAyBC;AAKD,4CAqBC;AAtDD;;GAEG;AACI,KAAK,UAAU,gBAAgB,CACpC,OAA6B,EAC7B,OAAyB,EACzB,SAA6B;IAE7B,MAAM,EAAE,UAAU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AAC;YACtF,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,SAAS,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/utils/async/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Async utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.executeWithRetry = exports.executeWithState = void 0;
|
|
7
|
+
var execute_state_util_1 = require("./execute-state.util");
|
|
8
|
+
Object.defineProperty(exports, "executeWithState", { enumerable: true, get: function () { return execute_state_util_1.executeWithState; } });
|
|
9
|
+
Object.defineProperty(exports, "executeWithRetry", { enumerable: true, get: function () { return execute_state_util_1.executeWithRetry; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/infrastructure/utils/async/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,2DAA0E;AAAjE,sHAAA,gBAAgB,OAAA;AAAE,sHAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Mapper Utility
|
|
3
|
+
* Utilities for working with message content
|
|
4
|
+
*/
|
|
5
|
+
import type { GroqMessage } from "../../domain/entities";
|
|
6
|
+
/**
|
|
7
|
+
* Create a user message
|
|
8
|
+
*/
|
|
9
|
+
export declare function createUserMessage(content: string): GroqMessage;
|
|
10
|
+
/**
|
|
11
|
+
* Create an assistant message
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAssistantMessage(content: string): GroqMessage;
|
|
14
|
+
/**
|
|
15
|
+
* Create a system message
|
|
16
|
+
*/
|
|
17
|
+
export declare function createSystemMessage(content: string): GroqMessage;
|
|
18
|
+
/**
|
|
19
|
+
* Create a text message (defaults to user role)
|
|
20
|
+
*/
|
|
21
|
+
export declare function createTextMessage(content: string, role?: "user" | "assistant" | "system"): GroqMessage;
|
|
22
|
+
/**
|
|
23
|
+
* Convert a simple prompt string to an array of messages
|
|
24
|
+
*/
|
|
25
|
+
export declare function promptToMessages(prompt: string, systemPrompt?: string): GroqMessage[];
|
|
26
|
+
/**
|
|
27
|
+
* Extract text content from an array of messages
|
|
28
|
+
*/
|
|
29
|
+
export declare function extractTextFromMessages(messages: GroqMessage[]): string;
|
|
30
|
+
/**
|
|
31
|
+
* Format messages for display in UI
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatMessagesForDisplay(messages: GroqMessage[]): string;
|
|
34
|
+
//# sourceMappingURL=content-mapper.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-mapper.util.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/utils/content-mapper.util.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAK9D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAKnE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAKhE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,GAAG,WAAW,GAAG,QAAiB,GAAG,WAAW,CAK9G;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAgBrF;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,CAEvE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,CAOxE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Content Mapper Utility
|
|
4
|
+
* Utilities for working with message content
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createUserMessage = createUserMessage;
|
|
8
|
+
exports.createAssistantMessage = createAssistantMessage;
|
|
9
|
+
exports.createSystemMessage = createSystemMessage;
|
|
10
|
+
exports.createTextMessage = createTextMessage;
|
|
11
|
+
exports.promptToMessages = promptToMessages;
|
|
12
|
+
exports.extractTextFromMessages = extractTextFromMessages;
|
|
13
|
+
exports.formatMessagesForDisplay = formatMessagesForDisplay;
|
|
14
|
+
/**
|
|
15
|
+
* Create a user message
|
|
16
|
+
*/
|
|
17
|
+
function createUserMessage(content) {
|
|
18
|
+
return {
|
|
19
|
+
role: "user",
|
|
20
|
+
content,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create an assistant message
|
|
25
|
+
*/
|
|
26
|
+
function createAssistantMessage(content) {
|
|
27
|
+
return {
|
|
28
|
+
role: "assistant",
|
|
29
|
+
content,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a system message
|
|
34
|
+
*/
|
|
35
|
+
function createSystemMessage(content) {
|
|
36
|
+
return {
|
|
37
|
+
role: "system",
|
|
38
|
+
content,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a text message (defaults to user role)
|
|
43
|
+
*/
|
|
44
|
+
function createTextMessage(content, role = "user") {
|
|
45
|
+
return {
|
|
46
|
+
role,
|
|
47
|
+
content,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Convert a simple prompt string to an array of messages
|
|
52
|
+
*/
|
|
53
|
+
function promptToMessages(prompt, systemPrompt) {
|
|
54
|
+
const messages = [];
|
|
55
|
+
if (systemPrompt) {
|
|
56
|
+
messages.push({
|
|
57
|
+
role: "system",
|
|
58
|
+
content: systemPrompt,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
messages.push({
|
|
62
|
+
role: "user",
|
|
63
|
+
content: prompt,
|
|
64
|
+
});
|
|
65
|
+
return messages;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Extract text content from an array of messages
|
|
69
|
+
*/
|
|
70
|
+
function extractTextFromMessages(messages) {
|
|
71
|
+
return messages.map((m) => `[${m.role}]: ${m.content}`).join("\n\n");
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Format messages for display in UI
|
|
75
|
+
*/
|
|
76
|
+
function formatMessagesForDisplay(messages) {
|
|
77
|
+
return messages
|
|
78
|
+
.map((m) => {
|
|
79
|
+
const role = m.role === "system" ? "System" : m.role === "user" ? "You" : "Assistant";
|
|
80
|
+
return `${role}:\n${m.content}`;
|
|
81
|
+
})
|
|
82
|
+
.join("\n\n---\n\n");
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=content-mapper.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-mapper.util.js","sourceRoot":"","sources":["../../../src/infrastructure/utils/content-mapper.util.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAOH,8CAKC;AAKD,wDAKC;AAKD,kDAKC;AAKD,8CAKC;AAKD,4CAgBC;AAKD,0DAEC;AAKD,4DAOC;AA9ED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,OAAO;KACR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C,CAAC,WAAW,CAAC;QACtF,OAAO,GAAG,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC,CAAC;SACD,IAAI,CAAC,aAAa,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Mapper Utility
|
|
3
|
+
* Utilities for handling and mapping errors
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Get user-friendly error message
|
|
7
|
+
*/
|
|
8
|
+
export declare function getUserFriendlyError(error: unknown): string;
|
|
9
|
+
/**
|
|
10
|
+
* Check if error is retryable
|
|
11
|
+
*/
|
|
12
|
+
export declare function isRetryableError(error: unknown): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Check if error is authentication related
|
|
15
|
+
*/
|
|
16
|
+
export declare function isAuthError(error: unknown): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Format error for logging
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatErrorForLogging(error: unknown): string;
|
|
21
|
+
//# sourceMappingURL=error-mapper.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-mapper.util.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/utils/error-mapper.util.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CA2B3D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CASxD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKnD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAU5D"}
|