@umituz/react-native-ai-generation-content 1.0.6 → 1.1.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.0.6",
3
+ "version": "1.1.0",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -40,6 +40,15 @@ class GenerationOrchestratorService {
40
40
  const progressTracker = createProgressTracker();
41
41
  const startTime = Date.now();
42
42
 
43
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
44
+ // eslint-disable-next-line no-console
45
+ console.log("[Orchestrator] Generate started:", {
46
+ model: request.model,
47
+ capability: request.capability,
48
+ provider: provider.providerId,
49
+ });
50
+ }
51
+
43
52
  const updateProgress = (
44
53
  stage: GenerationProgress["stage"],
45
54
  subProgress = 0,
@@ -60,7 +69,10 @@ class GenerationOrchestratorService {
60
69
 
61
70
  if (typeof __DEV__ !== "undefined" && __DEV__) {
62
71
  // eslint-disable-next-line no-console
63
- console.log("[Orchestrator] Job submitted:", submission.requestId);
72
+ console.log("[Orchestrator] Job submitted:", {
73
+ requestId: submission.requestId,
74
+ provider: provider.providerId,
75
+ });
64
76
  }
65
77
 
66
78
  updateProgress("generating");
@@ -74,6 +86,17 @@ class GenerationOrchestratorService {
74
86
 
75
87
  updateProgress("completed");
76
88
 
89
+ const duration = Date.now() - startTime;
90
+
91
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
92
+ // eslint-disable-next-line no-console
93
+ console.log("[Orchestrator] Generate completed:", {
94
+ requestId: submission.requestId,
95
+ duration: `${duration}ms`,
96
+ success: true,
97
+ });
98
+ }
99
+
77
100
  return {
78
101
  success: true,
79
102
  data: result,
@@ -84,7 +107,7 @@ class GenerationOrchestratorService {
84
107
  capability: request.capability,
85
108
  startTime,
86
109
  endTime: Date.now(),
87
- duration: Date.now() - startTime,
110
+ duration,
88
111
  },
89
112
  };
90
113
  } catch (error) {
@@ -5,6 +5,8 @@
5
5
 
6
6
  import { AIErrorType, type AIErrorInfo } from "../../domain/entities";
7
7
 
8
+ declare const __DEV__: boolean;
9
+
8
10
  const NETWORK_ERROR_PATTERNS = [
9
11
  "network",
10
12
  "timeout",
@@ -60,18 +62,38 @@ function getStatusCode(error: unknown): number | undefined {
60
62
  return undefined;
61
63
  }
62
64
 
65
+ function logClassification(info: AIErrorInfo): AIErrorInfo {
66
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
67
+ // eslint-disable-next-line no-console
68
+ console.log("[ErrorClassifier] Classified as:", {
69
+ type: info.type,
70
+ messageKey: info.messageKey,
71
+ retryable: info.retryable,
72
+ });
73
+ }
74
+ return info;
75
+ }
76
+
63
77
  export function classifyError(error: unknown): AIErrorInfo {
64
78
  const message = error instanceof Error ? error.message : String(error);
65
79
  const statusCode = getStatusCode(error);
66
80
 
81
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
82
+ // eslint-disable-next-line no-console
83
+ console.log("[ErrorClassifier] Classifying error:", {
84
+ message: message.slice(0, 100),
85
+ statusCode,
86
+ });
87
+ }
88
+
67
89
  if (statusCode === 429 || matchesPatterns(message, RATE_LIMIT_PATTERNS)) {
68
- return {
90
+ return logClassification({
69
91
  type: AIErrorType.RATE_LIMIT,
70
92
  messageKey: "error.rateLimit",
71
93
  retryable: true,
72
94
  originalError: error,
73
95
  statusCode,
74
- };
96
+ });
75
97
  }
76
98
 
77
99
  if (
@@ -79,65 +101,65 @@ export function classifyError(error: unknown): AIErrorInfo {
79
101
  statusCode === 403 ||
80
102
  matchesPatterns(message, AUTH_ERROR_PATTERNS)
81
103
  ) {
82
- return {
104
+ return logClassification({
83
105
  type: AIErrorType.AUTHENTICATION,
84
106
  messageKey: "error.authentication",
85
107
  retryable: false,
86
108
  originalError: error,
87
109
  statusCode,
88
- };
110
+ });
89
111
  }
90
112
 
91
113
  if (matchesPatterns(message, CONTENT_POLICY_PATTERNS)) {
92
- return {
114
+ return logClassification({
93
115
  type: AIErrorType.CONTENT_POLICY,
94
116
  messageKey: "error.contentPolicy",
95
117
  retryable: false,
96
118
  originalError: error,
97
119
  statusCode,
98
- };
120
+ });
99
121
  }
100
122
 
101
123
  if (matchesPatterns(message, NETWORK_ERROR_PATTERNS)) {
102
- return {
124
+ return logClassification({
103
125
  type: AIErrorType.NETWORK,
104
126
  messageKey: "error.network",
105
127
  retryable: true,
106
128
  originalError: error,
107
129
  statusCode,
108
- };
130
+ });
109
131
  }
110
132
 
111
133
  if (
112
134
  (statusCode && statusCode >= 500) ||
113
135
  matchesPatterns(message, SERVER_ERROR_PATTERNS)
114
136
  ) {
115
- return {
137
+ return logClassification({
116
138
  type: AIErrorType.SERVER,
117
139
  messageKey: "error.server",
118
140
  retryable: true,
119
141
  originalError: error,
120
142
  statusCode,
121
- };
143
+ });
122
144
  }
123
145
 
124
146
  if (message.toLowerCase().includes("timeout")) {
125
- return {
147
+ return logClassification({
126
148
  type: AIErrorType.TIMEOUT,
127
149
  messageKey: "error.timeout",
128
150
  retryable: true,
129
151
  originalError: error,
130
152
  statusCode,
131
- };
153
+ });
132
154
  }
133
155
 
134
- return {
156
+ return logClassification({
135
157
  type: AIErrorType.UNKNOWN,
136
158
  messageKey: "error.unknown",
137
159
  retryable: false,
138
160
  originalError: error,
139
161
  statusCode,
140
- };
162
+ });
141
163
  }
142
164
 
143
165
  export function isTransientError(error: unknown): boolean {
@@ -3,6 +3,8 @@
3
3
  * Validates AI generation job results
4
4
  */
5
5
 
6
+ declare const __DEV__: boolean;
7
+
6
8
  export interface ResultValidation {
7
9
  isValid: boolean;
8
10
  hasError: boolean;
@@ -98,12 +100,24 @@ export function validateResult(
98
100
  const hasError =
99
101
  hasInternalServerError || (isEmpty && !hasOutput && !allowEmpty);
100
102
 
101
- return {
103
+ const validation: ResultValidation = {
102
104
  isValid: !hasError && (hasOutput || allowEmpty),
103
105
  hasError,
104
106
  errorMessage: hasError && errorValue ? String(errorValue) : undefined,
105
107
  hasOutput,
106
108
  };
109
+
110
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
111
+ // eslint-disable-next-line no-console
112
+ console.log("[ResultValidator] Validation result:", {
113
+ isValid: validation.isValid,
114
+ hasOutput: validation.hasOutput,
115
+ hasError: validation.hasError,
116
+ checkedFields: outputFields.join(", "),
117
+ });
118
+ }
119
+
120
+ return validation;
107
121
  }
108
122
 
109
123
  /**