@chenchaolong/plugin-trade-compliance-workbench 1.0.20 → 1.0.21
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/lib/adapters/translation.provider.d.ts +1 -0
- package/dist/lib/adapters/translation.provider.d.ts.map +1 -1
- package/dist/lib/adapters/translation.provider.js +1 -1
- package/dist/lib/adapters/translation.provider.js.map +1 -1
- package/dist/lib/workbench.service.js +11 -11
- package/dist/lib/workbench.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation.provider.d.ts","sourceRoot":"","sources":["../../../src/lib/adapters/translation.provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAG/F,MAAM,MAAM,yBAAyB,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"translation.provider.d.ts","sourceRoot":"","sources":["../../../src/lib/adapters/translation.provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAG/F,MAAM,MAAM,yBAAyB,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5G,qBACa,mBAAmB;IACgC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;gBAAf,cAAc,CAAC,EAAE,qBAAqB,YAAA;IAE/G,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,GAAG,SAAS,EAAE,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAyBhI,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAErF,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAG5F"}
|
|
@@ -10,7 +10,7 @@ let TranslationProvider = class TranslationProvider {
|
|
|
10
10
|
const text = value.trim();
|
|
11
11
|
if (!text)
|
|
12
12
|
return '';
|
|
13
|
-
const config = resolveTradeComplianceConfig(this.configResolver).translation;
|
|
13
|
+
const config = resolveTradeComplianceConfig(this.configResolver, options.organizationId).translation;
|
|
14
14
|
const endpoint = config.endpoint;
|
|
15
15
|
if (!endpoint)
|
|
16
16
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation.provider.js","sourceRoot":"","sources":["../../../src/lib/adapters/translation.provider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,EAAE,4BAA4B,EAA8B,MAAM,sBAAsB,CAAA;AAC/F,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAA;AAKrE,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,YAA+E,cAAsC;QAAtC,mBAAc,GAAd,cAAc,CAAwB;IAAG,CAAC;IAEzH,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,cAAqC,EAAE,UAAqC,EAAE;QAC3G,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;QACzB,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,CAAA;QACpB,MAAM,MAAM,GAAG,4BAA4B,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"translation.provider.js","sourceRoot":"","sources":["../../../src/lib/adapters/translation.provider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,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AE,OAAmC;QAChE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;IAClD,CAAC;CACF,CAAA;AAjCY,mBAAmB;IAD/B,UAAU,EAAE;IAEE,WAAA,QAAQ,EAAE,CAAA;IAAE,WAAA,MAAM,CAAC,4BAA4B,CAAC,CAAA;;GADlD,mBAAmB,CAiC/B"}
|
|
@@ -226,7 +226,7 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
226
226
|
const pendingRows = await this.pendingControlledCatalogRows(scope, claim.batch, input.rows);
|
|
227
227
|
if (!pendingRows.length)
|
|
228
228
|
return this.completeControlledCatalogPostProcessing(scope, claim.batch);
|
|
229
|
-
const localizedRows = await this.localizeControlledCatalogRows(pendingRows);
|
|
229
|
+
const localizedRows = await this.localizeControlledCatalogRows(pendingRows, scope.organizationId);
|
|
230
230
|
const appended = await this.appendCompletedControlledCatalog(scope, { ...input, rows: pendingRows }, localizedRows, claim.batch.id);
|
|
231
231
|
return this.completeControlledCatalogPostProcessing(scope, appended);
|
|
232
232
|
}
|
|
@@ -238,7 +238,7 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
238
238
|
try {
|
|
239
239
|
let result;
|
|
240
240
|
try {
|
|
241
|
-
const localizedRows = await this.localizeControlledCatalogRows(input.rows, claim.deadline, heartbeat.signal);
|
|
241
|
+
const localizedRows = await this.localizeControlledCatalogRows(input.rows, scope.organizationId, claim.deadline, heartbeat.signal);
|
|
242
242
|
heartbeat.assertOwned();
|
|
243
243
|
result = await this.persistControlledCatalog(scope, input, localizedRows, claim.claimId);
|
|
244
244
|
}
|
|
@@ -469,7 +469,7 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
469
469
|
batch.riskRecalculatedAt = result.riskRecalculatedAt ?? new Date();
|
|
470
470
|
return batch;
|
|
471
471
|
}
|
|
472
|
-
async localizeControlledCatalogRows(rows, deadline = Date.now() + CONTROLLED_CATALOG_TRANSLATION_TIMEOUT_MS, ownerSignal) {
|
|
472
|
+
async localizeControlledCatalogRows(rows, organizationId, deadline = Date.now() + CONTROLLED_CATALOG_TRANSLATION_TIMEOUT_MS, ownerSignal) {
|
|
473
473
|
const localized = new Array(rows.length);
|
|
474
474
|
const controller = new AbortController();
|
|
475
475
|
const abortFromOwner = () => controller.abort(ownerSignal?.reason);
|
|
@@ -483,7 +483,7 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
483
483
|
while (nextIndex < rows.length) {
|
|
484
484
|
const index = nextIndex;
|
|
485
485
|
nextIndex += 1;
|
|
486
|
-
localized[index] = await this.localizeControlledCatalogRow(rows[index], deadline, controller.signal);
|
|
486
|
+
localized[index] = await this.localizeControlledCatalogRow(rows[index], organizationId, deadline, controller.signal);
|
|
487
487
|
}
|
|
488
488
|
};
|
|
489
489
|
try {
|
|
@@ -495,7 +495,7 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
495
495
|
ownerSignal?.removeEventListener('abort', abortFromOwner);
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
|
-
async localizeControlledCatalogRow(row, deadline, signal) {
|
|
498
|
+
async localizeControlledCatalogRow(row, organizationId, deadline, signal) {
|
|
499
499
|
const originalProductName = String(row.originalProductName ?? '').trim() || null;
|
|
500
500
|
const originalControlDescription = String(row.originalControlDescription ?? '').trim() || null;
|
|
501
501
|
let productName = String(row.productName ?? '').trim();
|
|
@@ -508,13 +508,13 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
508
508
|
if (!productName) {
|
|
509
509
|
if (!originalProductName)
|
|
510
510
|
return { productName: '', controlDescription, originalProductName, originalControlDescription, translationSource, error: '商品名称为空' };
|
|
511
|
-
productName = await this.translateCatalogValue(originalProductName, deadline, signal) ?? '';
|
|
511
|
+
productName = await this.translateCatalogValue(originalProductName, organizationId, deadline, signal) ?? '';
|
|
512
512
|
if (!productName)
|
|
513
513
|
return { productName: '', controlDescription, originalProductName, originalControlDescription, translationSource, error: '商品名称翻译失败' };
|
|
514
514
|
serviceTranslated = true;
|
|
515
515
|
}
|
|
516
516
|
if (!controlDescription && originalControlDescription) {
|
|
517
|
-
controlDescription = await this.translateCatalogValue(originalControlDescription, deadline, signal);
|
|
517
|
+
controlDescription = await this.translateCatalogValue(originalControlDescription, organizationId, deadline, signal);
|
|
518
518
|
if (!controlDescription)
|
|
519
519
|
return { productName, controlDescription: null, originalProductName, originalControlDescription, translationSource, error: '管控说明翻译失败' };
|
|
520
520
|
serviceTranslated = true;
|
|
@@ -525,11 +525,11 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
525
525
|
translationSource = 'SERVICE_TRANSLATED';
|
|
526
526
|
return { productName, controlDescription, originalProductName, originalControlDescription, translationSource };
|
|
527
527
|
}
|
|
528
|
-
async translateCatalogValue(value, deadline, signal) {
|
|
528
|
+
async translateCatalogValue(value, organizationId, deadline, signal) {
|
|
529
529
|
const remaining = deadline - Date.now();
|
|
530
530
|
if (!this.translation || remaining <= 0 || signal.aborted)
|
|
531
531
|
return null;
|
|
532
|
-
const translated = Promise.resolve(this.translation.toChinese(value, { signal, deadline }))
|
|
532
|
+
const translated = Promise.resolve(this.translation.toChinese(value, { signal, deadline, organizationId }))
|
|
533
533
|
.then(result => String(result ?? '').trim() || null, () => null);
|
|
534
534
|
let onAbort;
|
|
535
535
|
try {
|
|
@@ -761,7 +761,7 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
761
761
|
const controlledRows = input.candidates.flatMap(candidate => candidate.kind === 'CONTROLLED'
|
|
762
762
|
? candidateToControlledRows(candidate)
|
|
763
763
|
: []);
|
|
764
|
-
const localizedRows = controlledRows.length ? await this.localizeControlledCatalogRows(controlledRows) : [];
|
|
764
|
+
const localizedRows = controlledRows.length ? await this.localizeControlledCatalogRows(controlledRows, scope.organizationId) : [];
|
|
765
765
|
return this.dataSource.transaction(async (manager) => {
|
|
766
766
|
const taskRepo = manager.getRepository(ImportTask);
|
|
767
767
|
const task = await required(taskRepo.findOne({
|
|
@@ -984,7 +984,7 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
|
|
|
984
984
|
const batchRepo = manager.getRepository(ControlledCatalogBatch);
|
|
985
985
|
const batch = await required(batchRepo.findOne({ where: { ...activeScope(scope), id: task.resultEntityId } }), '管控目录批次不存在');
|
|
986
986
|
const rows = acceptedCandidates.flatMap(candidateToControlledRows);
|
|
987
|
-
const localized = await this.localizeControlledCatalogRows(rows);
|
|
987
|
+
const localized = await this.localizeControlledCatalogRows(rows, scope.organizationId);
|
|
988
988
|
await this.appendControlledCatalogRows(manager, scope, batch, rows, localized);
|
|
989
989
|
await batchRepo.save(batch);
|
|
990
990
|
task.progress.successCount = batch.successCount;
|