Skip to content

Commit 3fd5459

Browse files
committed
[ Edit ] applied changes from the server to match the new impl
1 parent e110a73 commit 3fd5459

File tree

9 files changed

+31
-26
lines changed

9 files changed

+31
-26
lines changed

lib/src/commands/config_command/sub_commands/create_command.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ class ConfigCreateCommand extends Command<int> {
190190
progress: creationProgress,
191191
update:
192192
'Something went wrong while creating the ${configFileController.configFileName} file, please try again.',
193+
stacktrace: stacktrace,
193194
);
194195

195196
try {

lib/src/commands/start_command/start_command.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class StartCommand extends Command<int> {
8181
logger.customErr(
8282
progress: configFilesValidationProgress,
8383
update: 'Something went wrong while validating your config file.',
84+
stacktrace: stacktrace,
8485
error: e,
8586
);
8687

@@ -119,14 +120,14 @@ class StartCommand extends Command<int> {
119120
logger
120121
..info('\n')
121122
..warn(
122-
'The ID of this operation is: ${jsonPartitionRes.partitionId}. in case of any issues, please contact us providing this ID so we can help.',
123+
'The ID of this operation is: ${jsonPartitionRes.operationId}. in case of any issues, please contact us providing this ID so we can help.',
123124
);
124125

125126
final result = await aIProcessResult(
126127
apiKey: apiKey,
127128
langs: asConfig.langs,
128129
languageLocalizationMaxDelay: asConfig.languageLocalizationMaxDelay,
129-
partitionId: jsonPartitionRes.partitionId,
130+
operationId: jsonPartitionRes.operationId,
130131
);
131132

132133
logger
@@ -137,14 +138,14 @@ class StartCommand extends Command<int> {
137138

138139
final outputList =
139140
await NetClient.instance.retrieveJsonPartitionWithOutput(
140-
outputPartitionId: result.outputPartitionId,
141+
outputoperationId: result.outputoperationId,
141142
apiKey: apiKey,
142143
);
143144

144145
await _writeNewLocalizationFiles(
145146
outputList: outputList,
146147
outputDir: Directory(asConfig.outputDir),
147-
partitionId: jsonPartitionRes.partitionId,
148+
operationId: jsonPartitionRes.operationId,
148149
);
149150

150151
logger.success('All done!');
@@ -153,6 +154,7 @@ class StartCommand extends Command<int> {
153154
} catch (e, stacktrace) {
154155
logger.customErr(
155156
error: e,
157+
stacktrace: stacktrace,
156158
progress: savingSourceFileProgress,
157159
update: 'Something went wrong, try again!',
158160
);
@@ -197,7 +199,7 @@ class StartCommand extends Command<int> {
197199
Future<void> _writeNewLocalizationFiles({
198200
required List<LangOutput> outputList,
199201
required Directory outputDir,
200-
required String partitionId,
202+
required String operationId,
201203
}) async {
202204
for (var index = 0; index < outputList.length; index++) {
203205
final current = outputList[index];
@@ -224,7 +226,7 @@ class StartCommand extends Command<int> {
224226
{
225227
'message':
226228
'Please, if you think that this is an unexpected bug in LangSync, contact us so we can help',
227-
'partitionId': partitionId,
229+
'operationId': operationId,
228230
'processedResponse': current.jsonFormattedResponse,
229231
'target_language': current.lang,
230232
'success_file_name': '${current.lang}.json',
@@ -265,15 +267,15 @@ class StartCommand extends Command<int> {
265267
Future<LangSyncServerResultSSE> aIProcessResult({
266268
required String apiKey,
267269
required Iterable<String> langs,
268-
required String partitionId,
270+
required String operationId,
269271
required int? languageLocalizationMaxDelay,
270272
}) async {
271273
final completer = Completer<LangSyncServerResultSSE>();
272274

273275
final processStream = NetClient.instance.startAIProcess(
274276
apiKey: apiKey,
275277
langs: langs,
276-
operationId: partitionId,
278+
operationId: operationId,
277279
languageLocalizationMaxDelay: languageLocalizationMaxDelay,
278280
);
279281

lib/src/etc/extensions.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ extension LoggerExt on Logger {
7171
required Progress progress,
7272
required String update,
7373
required Object error,
74+
StackTrace? stacktrace,
7475
}) {
7576
info('\n');
7677

7778
if (utils.isDebugMode) {
7879
progress.fail(error.toString());
80+
if (stacktrace != null) info(stacktrace.toString());
7981
} else {
8082
progress.fail(update);
8183
}

lib/src/etc/models/Localization_doc.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import 'package:equatable/equatable.dart';
33
class LocalizationDoc extends Equatable {
44
const LocalizationDoc({
55
required this.createdAt,
6-
required this.partitionId,
6+
required this.operationId,
77
required this.jsonPartsLength,
88
this.outputLangs,
99
});
1010

1111
factory LocalizationDoc.fromJson(Map<String, dynamic> json) {
1212
return LocalizationDoc(
1313
createdAt: DateTime.parse(json['createdAt'] as String),
14-
partitionId: json['partitionId'] as String,
14+
operationId: json['operationId'] as String,
1515
jsonPartsLength: json['jsonPartsLength'] is int
1616
? json['jsonPartsLength'] as int
1717
: int.parse(json['jsonPartsLength'] as String),
@@ -24,14 +24,14 @@ class LocalizationDoc extends Equatable {
2424
}
2525

2626
final DateTime createdAt;
27-
final String partitionId;
27+
final String operationId;
2828
final int jsonPartsLength;
2929
final List<String>? outputLangs;
3030

3131
@override
3232
List<Object?> get props => [
3333
createdAt,
34-
partitionId,
34+
operationId,
3535
jsonPartsLength,
3636
outputLangs,
3737
];

lib/src/etc/models/partition.dart renamed to lib/src/etc/models/operation.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
import 'package:equatable/equatable.dart';
33

44
class PartitionResponse extends Equatable {
5-
final String partitionId;
5+
final String operationId;
66

77
const PartitionResponse({
8-
required this.partitionId,
8+
required this.operationId,
99
});
1010

1111
factory PartitionResponse.fromJson(Map<String, dynamic> json) {
1212
return PartitionResponse(
13-
partitionId: json['partitionId'] as String,
13+
operationId: json['operationId'] as String,
1414
);
1515
}
1616

1717
@override
1818
List<Object?> get props => [
19-
partitionId,
19+
operationId,
2020
];
2121
}

lib/src/etc/models/result_locale.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ class LangSyncServerSSE extends Equatable {
4646
}
4747

4848
class LangSyncServerResultSSE extends LangSyncServerSSE {
49-
final String outputPartitionId;
49+
final String outputoperationId;
5050

5151
const LangSyncServerResultSSE({
52-
required this.outputPartitionId,
52+
required this.outputoperationId,
5353
required super.message,
5454
required super.type,
5555
required super.statusCode,
@@ -61,7 +61,7 @@ class LangSyncServerResultSSE extends LangSyncServerSSE {
6161
final decoded = jsonDecode(message) as Map<String, dynamic>;
6262

6363
return LangSyncServerResultSSE(
64-
outputPartitionId: decoded['partitionId'] as String,
64+
outputoperationId: decoded['operationId'] as String,
6565
message: message,
6666
statusCode: res['statusCode'] as int,
6767
type: // this is hardcoded, butsince we are sure that it is correct.
@@ -74,7 +74,7 @@ class LangSyncServerResultSSE extends LangSyncServerSSE {
7474

7575
@override
7676
List<Object?> get props => [
77-
outputPartitionId,
77+
outputoperationId,
7878
super.message,
7979
super.type,
8080
super.statusCode,

lib/src/etc/models/user_info.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class UserInfo extends Equatable {
4848
'Available API keys': apiKeysLength,
4949
'Processed Localizations': localizationDocs.length,
5050
'Most Recent Localization ID': localizationDocs.isNotEmpty
51-
? localizationDocs.last.partitionId
51+
? localizationDocs.last.operationId
5252
: 'You have no processed localizations.',
5353
'Most Recent Localization Date': localizationDocs.isNotEmpty
5454
? '${localizationDocs.last.createdAt.toProperHumanReadableDate()} - ${localizationDocs.last.createdAt.toIso8601String()}'

lib/src/etc/networking/client.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'dart:convert';
22
import 'dart:io';
33
import 'package:langsync/src/etc/models/api_key_res.dart';
44
import 'package:langsync/src/etc/models/lang_output.dart';
5-
import 'package:langsync/src/etc/models/partition.dart';
5+
import 'package:langsync/src/etc/models/operation.dart';
66
import 'package:langsync/src/etc/models/result_locale.dart';
77
import 'package:langsync/src/etc/models/user_info.dart';
88
import 'package:langsync/src/etc/networking/client_boilerplate.dart';
@@ -61,7 +61,7 @@ class NetClient extends NetClientBoilerPlate {
6161
}
6262

6363
Future<List<LangOutput>> retrieveJsonPartitionWithOutput({
64-
required String outputPartitionId,
64+
required String outputoperationId,
6565
required String apiKey,
6666
}) {
6767
return makeRes(
@@ -71,7 +71,7 @@ class NetClient extends NetClientBoilerPlate {
7171
'Authorization': 'Bearer ${apiKey}',
7272
},
7373
{
74-
'operationId': outputPartitionId,
74+
'operationId': outputoperationId,
7575
},
7676
(res) {
7777
final output = (res['output'] as List)

lib/src/etc/utils.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import 'package:mason_logger/mason_logger.dart';
88
final utils = Utils();
99

1010
class Utils {
11-
final isDebugMode = false;
11+
final isDebugMode = true;
1212

1313
//! notice the "/"
1414
String get baseUrl =>
15-
isDebugMode ? 'http://192.168.0.4:5559' : 'http://api.langsync.app';
15+
isDebugMode ? 'http://192.168.0.11:5559' : 'http://api.langsync.app';
1616

1717
bool isValidApiKeyFormatted(String apiKey) {
1818
final isNotEmpty = apiKey.isNotEmpty;

0 commit comments

Comments
 (0)