@chenchaolong/plugin-trade-compliance-workbench 1.0.3 → 1.0.4

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.
Files changed (93) hide show
  1. package/README.md +5 -3
  2. package/dist/lib/demo-data.service.d.ts.map +1 -1
  3. package/dist/lib/demo-data.service.js +1 -3
  4. package/dist/lib/demo-data.service.js.map +1 -1
  5. package/dist/lib/entities/index.d.ts +2 -2
  6. package/dist/lib/entities/index.d.ts.map +1 -1
  7. package/dist/lib/entities/index.js +2 -2
  8. package/dist/lib/entities/index.js.map +1 -1
  9. package/dist/lib/entities/shared.entity.d.ts +1 -5
  10. package/dist/lib/entities/shared.entity.d.ts.map +1 -1
  11. package/dist/lib/entities/shared.entity.js +1 -16
  12. package/dist/lib/entities/shared.entity.js.map +1 -1
  13. package/dist/lib/legacy-schema-cleanup.d.ts +9 -0
  14. package/dist/lib/legacy-schema-cleanup.d.ts.map +1 -0
  15. package/dist/lib/legacy-schema-cleanup.js +28 -0
  16. package/dist/lib/legacy-schema-cleanup.js.map +1 -0
  17. package/dist/lib/remote-components/trade-compliance-workbench/app.css +3268 -1
  18. package/dist/lib/remote-components/trade-compliance-workbench/app.js +5 -5
  19. package/dist/lib/remote-ui/app-source.d.ts.map +1 -1
  20. package/dist/lib/remote-ui/app-source.js +7 -6
  21. package/dist/lib/remote-ui/app-source.js.map +1 -1
  22. package/dist/lib/remote-ui/bridge.d.ts +6 -1
  23. package/dist/lib/remote-ui/bridge.d.ts.map +1 -1
  24. package/dist/lib/remote-ui/bridge.js +60 -10
  25. package/dist/lib/remote-ui/bridge.js.map +1 -1
  26. package/dist/lib/remote-ui/components/data-grid.js +1 -1
  27. package/dist/lib/remote-ui/components/data-grid.js.map +1 -1
  28. package/dist/lib/remote-ui/components/forms.js +2 -2
  29. package/dist/lib/remote-ui/components/forms.js.map +1 -1
  30. package/dist/lib/remote-ui/components/layout.d.ts +5 -1
  31. package/dist/lib/remote-ui/components/layout.d.ts.map +1 -1
  32. package/dist/lib/remote-ui/components/layout.js +23 -3
  33. package/dist/lib/remote-ui/components/layout.js.map +1 -1
  34. package/dist/lib/remote-ui/model.d.ts.map +1 -1
  35. package/dist/lib/remote-ui/model.js +11 -11
  36. package/dist/lib/remote-ui/model.js.map +1 -1
  37. package/dist/lib/remote-ui/pages/analytics.js +1 -1
  38. package/dist/lib/remote-ui/pages/analytics.js.map +1 -1
  39. package/dist/lib/remote-ui/pages/catalogs.js +14 -14
  40. package/dist/lib/remote-ui/pages/catalogs.js.map +1 -1
  41. package/dist/lib/remote-ui/pages/contracts.js +3 -3
  42. package/dist/lib/remote-ui/pages/contracts.js.map +1 -1
  43. package/dist/lib/remote-ui/pages/files.js +5 -5
  44. package/dist/lib/remote-ui/pages/files.js.map +1 -1
  45. package/dist/lib/remote-ui/pages/home.d.ts +18 -62
  46. package/dist/lib/remote-ui/pages/home.d.ts.map +1 -1
  47. package/dist/lib/remote-ui/pages/home.js +25 -131
  48. package/dist/lib/remote-ui/pages/home.js.map +1 -1
  49. package/dist/lib/remote-ui/pages/procurement.js +11 -11
  50. package/dist/lib/remote-ui/pages/procurement.js.map +1 -1
  51. package/dist/lib/remote-ui/pages/sales.js +8 -8
  52. package/dist/lib/remote-ui/pages/sales.js.map +1 -1
  53. package/dist/lib/remote-ui/pages/settings.d.ts +0 -3
  54. package/dist/lib/remote-ui/pages/settings.d.ts.map +1 -1
  55. package/dist/lib/remote-ui/pages/settings.js +7 -56
  56. package/dist/lib/remote-ui/pages/settings.js.map +1 -1
  57. package/dist/lib/remote-ui/settings-contracts.d.ts +2 -16
  58. package/dist/lib/remote-ui/settings-contracts.d.ts.map +1 -1
  59. package/dist/lib/remote-ui/settings-contracts.js +2 -2
  60. package/dist/lib/remote-ui/settings-contracts.js.map +1 -1
  61. package/dist/lib/remote-ui/sidebar-state.d.ts +5 -0
  62. package/dist/lib/remote-ui/sidebar-state.d.ts.map +1 -0
  63. package/dist/lib/remote-ui/sidebar-state.js +18 -0
  64. package/dist/lib/remote-ui/sidebar-state.js.map +1 -0
  65. package/dist/lib/runtime-validation.d.ts +0 -1
  66. package/dist/lib/runtime-validation.d.ts.map +1 -1
  67. package/dist/lib/runtime-validation.js +0 -17
  68. package/dist/lib/runtime-validation.js.map +1 -1
  69. package/dist/lib/types.d.ts +2 -10
  70. package/dist/lib/types.d.ts.map +1 -1
  71. package/dist/lib/types.js +2 -2
  72. package/dist/lib/types.js.map +1 -1
  73. package/dist/lib/view-parameters.d.ts +3 -0
  74. package/dist/lib/view-parameters.d.ts.map +1 -0
  75. package/dist/lib/view-parameters.js +23 -0
  76. package/dist/lib/view-parameters.js.map +1 -0
  77. package/dist/lib/workbench-view.provider.d.ts +0 -3
  78. package/dist/lib/workbench-view.provider.d.ts.map +1 -1
  79. package/dist/lib/workbench-view.provider.js +4 -2
  80. package/dist/lib/workbench-view.provider.js.map +1 -1
  81. package/dist/lib/workbench.plugin.d.ts +4 -1
  82. package/dist/lib/workbench.plugin.d.ts.map +1 -1
  83. package/dist/lib/workbench.plugin.js +12 -4
  84. package/dist/lib/workbench.plugin.js.map +1 -1
  85. package/dist/lib/workbench.service.d.ts +4 -8
  86. package/dist/lib/workbench.service.d.ts.map +1 -1
  87. package/dist/lib/workbench.service.js +8 -24
  88. package/dist/lib/workbench.service.js.map +1 -1
  89. package/package.json +3 -1
  90. package/dist/lib/domain/risk-notice.d.ts +0 -59
  91. package/dist/lib/domain/risk-notice.d.ts.map +0 -1
  92. package/dist/lib/domain/risk-notice.js +0 -30
  93. package/dist/lib/domain/risk-notice.js.map +0 -1
@@ -9,7 +9,7 @@ import { mkdtemp, readFile, rm } from 'node:fs/promises';
9
9
  import { tmpdir } from 'node:os';
10
10
  import { join } from 'node:path';
11
11
  import { finished } from 'node:stream/promises';
12
- import { BankAccountSettings, CompanySanctionMatch, CompanySettings, ControlledCatalogBatch, ControlledCatalogImportIssue, ControlledGoodsRecord, Customer, CustomerContract, CustomerContractAnalysisRun, CustomerContractClause, CustomerContractClauseAnalysis, DerivedSalesOrderManualData, GeneratedSalesFile, ImportTask, ManagedAsset, MonthlySafeExchangeRate, ProductComplianceMatch, ProfitRuleSettings, PurchaseOrder, PurchaseOrderLine, RiskNoticeSettings, SanctionCatalogBatch, SanctionCatalogImportIssue, SanctionedCompanyRecord, SettingsHistory, Supplier } from './entities/index.js';
12
+ import { BankAccountSettings, CompanySanctionMatch, CompanySettings, ControlledCatalogBatch, ControlledCatalogImportIssue, ControlledGoodsRecord, Customer, CustomerContract, CustomerContractAnalysisRun, CustomerContractClause, CustomerContractClauseAnalysis, DerivedSalesOrderManualData, GeneratedSalesFile, ImportTask, ManagedAsset, MonthlySafeExchangeRate, ProductComplianceMatch, ProfitRuleSettings, PurchaseOrder, PurchaseOrderLine, SanctionCatalogBatch, SanctionCatalogImportIssue, SanctionedCompanyRecord, SettingsHistory, Supplier } from './entities/index.js';
13
13
  import { CatalogTypes, ClauseTypes, CustomerProfitRateStatuses, DomainError, DomainErrorCodes, RefundValidationMethods, SalesPaymentStatuses, SanctionHitStatuses } from './types.js';
14
14
  import { deriveSalesLine, assertReceivedAmount } from './domain/finance.js';
15
15
  import { parseCustomerContractNo, parsePurchaseContractNo } from './domain/contract-number.js';
@@ -17,9 +17,8 @@ import { isProductNameMatch, normalizeExactName, normalizeForProductMatch, norma
17
17
  import { importTaskTimedOut, nextSettingsRevision, normalizeOptionalDecimalInput } from './domain/workflow.js';
18
18
  import { renderImportIssuesWorkbook } from './domain/import-issues.js';
19
19
  import { BUILTIN_COMPANY_LOGO_STORAGE_ID, DEFAULT_BANKS, DEFAULT_COMPANY, DEFAULT_PROFIT_RULE } from './domain/default-settings.js';
20
- import { DEFAULT_RISK_NOTICE } from './domain/risk-notice.js';
21
20
  import { TradeComplianceFileStorage } from './adapters/file-storage.js';
22
- import { parseBankAccountType, parseExchangeRateInput, parseExpectedRevision, sanitizeRiskNoticeContent, validateBankSettingsInput, validateProfitSettingsInput, validatePurchaseLineDiscriminators, validateTaxRates } from './runtime-validation.js';
21
+ import { parseBankAccountType, parseExchangeRateInput, parseExpectedRevision, validateBankSettingsInput, validateProfitSettingsInput, validatePurchaseLineDiscriminators, validateTaxRates } from './runtime-validation.js';
23
22
  const DEFAULT_IMPORT_ISSUE_EXPORT_MAX_ROWS = 50_000;
24
23
  const HARD_IMPORT_ISSUE_EXPORT_MAX_ROWS = 100_000;
25
24
  const CUSTOMER_REANALYSIS_TIMEOUT_MS = 20 * 60 * 1000;
@@ -28,7 +27,6 @@ const CATALOG_RISK_RECOMMENDATIONS = {
28
27
  DUAL_USE: '建议核验军民两用物项许可要求,并在出口前完成合规审批',
29
28
  OVERSEAS_SANCTION: '建议核验海外制裁限制及交易对手风险,并在交易前完成合规审批'
30
29
  };
31
- export { DEFAULT_RISK_NOTICE };
32
30
  export async function writeWorkbookFile(filePath, populate, openOutput = createWriteStream) {
33
31
  const output = openOutput(filePath);
34
32
  const closed = finished(output, { cleanup: true });
@@ -52,18 +50,16 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
52
50
  this.storage = storage;
53
51
  }
54
52
  async bootstrapSettings(scope) {
55
- const riskRepo = this.dataSource.getRepository(RiskNoticeSettings);
56
53
  const profitRepo = this.dataSource.getRepository(ProfitRuleSettings);
57
54
  const companyRepo = this.dataSource.getRepository(CompanySettings);
58
55
  const bankRepo = this.dataSource.getRepository(BankAccountSettings);
59
56
  const builtinLogo = await this.ensureBuiltinCompanyLogo(scope);
60
- const [risk, profit, company, ...banks] = await Promise.all([
61
- this.ensureSettingsDefault(riskRepo, activeScope(scope), { ...auditScope(scope), content: DEFAULT_RISK_NOTICE, revision: 1 }),
57
+ const [profit, company, ...banks] = await Promise.all([
62
58
  this.ensureSettingsDefault(profitRepo, activeScope(scope), { ...auditScope(scope), ...DEFAULT_PROFIT_RULE, revision: 1 }),
63
59
  this.ensureSettingsDefault(companyRepo, activeScope(scope), { ...auditScope(scope), ...DEFAULT_COMPANY, logoFileId: builtinLogo.id, revision: 1 }),
64
60
  ...DEFAULT_BANKS.map(defaults => this.ensureSettingsDefault(bankRepo, { ...activeScope(scope), bankType: defaults.bankType }, { ...auditScope(scope), ...defaults, revision: 1 }))
65
61
  ]);
66
- return { risk, profit, company, banks };
62
+ return { profit, company, banks };
67
63
  }
68
64
  async ensureBuiltinCompanyLogo(scope) {
69
65
  const repo = this.dataSource.getRepository(ManagedAsset);
@@ -88,14 +84,13 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
88
84
  return row;
89
85
  }
90
86
  async dashboard(scope) {
91
- const [{ risk }, controlledRiskCount, sanctionRiskCount, unlinkedPurchaseCount, unlinkedCustomerCount] = await Promise.all([
92
- this.bootstrapSettings(scope),
87
+ const [controlledRiskCount, sanctionRiskCount, unlinkedPurchaseCount, unlinkedCustomerCount] = await Promise.all([
93
88
  this.dataSource.getRepository(ProductComplianceMatch).count({ where: { ...activeScope(scope), deletedAt: IsNull() } }),
94
89
  this.dataSource.getRepository(CompanySanctionMatch).count({ where: { ...activeScope(scope), deletedAt: IsNull() } }),
95
90
  this.countUnlinkedPurchases(scope),
96
91
  this.countUnlinkedCustomers(scope)
97
92
  ]);
98
- return { riskNotice: risk, controlledRiskCount, sanctionRiskCount, unlinkedPurchaseCount, unlinkedCustomerCount };
93
+ return { controlledRiskCount, sanctionRiskCount, unlinkedPurchaseCount, unlinkedCustomerCount };
99
94
  }
100
95
  async listControlledGoods(scope, query = {}) {
101
96
  return this.pagedCatalogQuery(ControlledGoodsRecord, ControlledCatalogBatch, scope, query, {
@@ -1209,22 +1204,15 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
1209
1204
  async listGeneratedFiles(scope, query = {}) { return this.pagedQuery(GeneratedSalesFile, scope, query, ['salesOrderNoSnapshot', 'documentNo', 'fileName'], { customerContractId: query.parameters?.customerContractId, purchaseOrderId: query.parameters?.purchaseOrderId, fileType: query.parameters?.fileType }); }
1210
1205
  async settings(scope) {
1211
1206
  await this.bootstrapSettings(scope);
1212
- const [risk, profit, company, banks, rates] = await Promise.all([
1213
- this.dataSource.getRepository(RiskNoticeSettings).findOne({ where: activeScope(scope) }),
1207
+ const [profit, company, banks, rates] = await Promise.all([
1214
1208
  this.dataSource.getRepository(ProfitRuleSettings).findOne({ where: activeScope(scope) }),
1215
1209
  this.dataSource.getRepository(CompanySettings).findOne({ where: activeScope(scope) }),
1216
1210
  this.dataSource.getRepository(BankAccountSettings).find({ where: activeScope(scope), order: { bankType: 'ASC' } }),
1217
1211
  this.dataSource.getRepository(MonthlySafeExchangeRate).find({ where: { ...activeScope(scope), deletedAt: IsNull() }, order: { year: 'DESC', month: 'DESC' } })
1218
1212
  ]);
1219
- return { risk, company, banks, profit, rates };
1213
+ return { company, banks, profit, rates };
1220
1214
  }
1221
1215
  async saveSettings(scope, type, input, expectedRevision) {
1222
- if (type === 'risk') {
1223
- const changes = {};
1224
- if ('content' in input)
1225
- changes.content = sanitizeRiskNoticeContent(input.content);
1226
- return this.persistSettings(scope, 'RISK', RiskNoticeSettings, activeScope(scope), settingsCreateScope(scope), changes, expectedRevision);
1227
- }
1228
1216
  if (type === 'company') {
1229
1217
  const changes = {};
1230
1218
  for (const field of ['logoFileId', 'companyNameZh', 'companyNameEn', 'unifiedSocialCreditCode', 'addressZh', 'addressEn', 'phone', 'email'])
@@ -1247,8 +1235,6 @@ let TradeComplianceWorkbenchService = class TradeComplianceWorkbenchService {
1247
1235
  return this.persistMonthlyRate(scope, input, { ...parsed, sourceReference }, expectedRevision);
1248
1236
  }
1249
1237
  async restoreSettingsDefault(scope, input) {
1250
- if (input.settingsType === 'risk')
1251
- return this.persistSettings(scope, 'RISK', RiskNoticeSettings, activeScope(scope), settingsCreateScope(scope), { content: DEFAULT_RISK_NOTICE }, input.expectedRevision, 'RESTORE_DEFAULT');
1252
1238
  if (input.settingsType === 'company') {
1253
1239
  const builtinLogo = await this.ensureBuiltinCompanyLogo(scope);
1254
1240
  return this.persistCompanySettings(scope, { ...DEFAULT_COMPANY, logoFileId: builtinLogo.id }, input.expectedRevision, 'RESTORE_DEFAULT');
@@ -2005,8 +1991,6 @@ function settingsSnapshot(settingsType, row) {
2005
1991
  const revision = Number(value.revision);
2006
1992
  if (!Number.isInteger(revision) || revision < 1)
2007
1993
  throw new DomainError(DomainErrorCodes.INVALID_INPUT, '设置修订号无效', { settingsType, revision: value.revision });
2008
- if (settingsType === 'RISK')
2009
- return { settingsType, snapshotVersion: 'v1', revision, content: String(value.content ?? '') };
2010
1994
  if (settingsType === 'COMPANY')
2011
1995
  return { settingsType, snapshotVersion: 'v1', revision, logoFileId: nullableSnapshotText(value.logoFileId), companyNameZh: nullableSnapshotText(value.companyNameZh), companyNameEn: nullableSnapshotText(value.companyNameEn), unifiedSocialCreditCode: nullableSnapshotText(value.unifiedSocialCreditCode), addressZh: nullableSnapshotText(value.addressZh), addressEn: nullableSnapshotText(value.addressEn), phone: nullableSnapshotText(value.phone), email: nullableSnapshotText(value.email) };
2012
1996
  if (settingsType === 'BANK')