@svadmin/ui 0.130.0 → 0.131.1

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 (81) hide show
  1. package/dist/app.css +318 -0
  2. package/dist/app.theme.css +318 -0
  3. package/dist/components/AboutSettings.svelte +1 -1
  4. package/dist/components/AccessRevocationMatrix.svelte +425 -0
  5. package/dist/components/AccessRevocationMatrix.svelte.d.ts +27 -0
  6. package/dist/components/AudioVisualInspector.svelte +458 -0
  7. package/dist/components/AudioVisualInspector.svelte.d.ts +53 -0
  8. package/dist/components/AuditSnapshotCapture.svelte +328 -0
  9. package/dist/components/AuditSnapshotCapture.svelte.d.ts +28 -0
  10. package/dist/components/CannedResponsePicker.svelte +257 -0
  11. package/dist/components/CannedResponsePicker.svelte.d.ts +22 -0
  12. package/dist/components/ContentModerationCenter.svelte +166 -0
  13. package/dist/components/ContentModerationCenter.svelte.d.ts +11 -0
  14. package/dist/components/ContractClauseDiffViewer.svelte +566 -0
  15. package/dist/components/ContractClauseDiffViewer.svelte.d.ts +53 -0
  16. package/dist/components/DataImportPipeline.svelte +577 -0
  17. package/dist/components/DataImportPipeline.svelte.d.ts +35 -0
  18. package/dist/components/DataRetentionPolicyEditor.svelte +455 -0
  19. package/dist/components/DataRetentionPolicyEditor.svelte.d.ts +10 -0
  20. package/dist/components/ElectronicSealInspector.svelte +450 -0
  21. package/dist/components/ElectronicSealInspector.svelte.d.ts +72 -0
  22. package/dist/components/EmployeeOffboardingAuditor.svelte +405 -0
  23. package/dist/components/EmployeeOffboardingAuditor.svelte.d.ts +39 -0
  24. package/dist/components/FieldMappingBuilder.svelte +393 -0
  25. package/dist/components/FieldMappingBuilder.svelte.d.ts +39 -0
  26. package/dist/components/FilterBuilder.svelte +50 -34
  27. package/dist/components/FilterBuilder.svelte.d.ts +2 -0
  28. package/dist/components/GatewayRouteEditor.svelte +493 -0
  29. package/dist/components/GatewayRouteEditor.svelte.d.ts +34 -0
  30. package/dist/components/I18nStudio.svelte +635 -0
  31. package/dist/components/I18nStudio.svelte.d.ts +23 -0
  32. package/dist/components/IpAccessRuleEditor.svelte +290 -0
  33. package/dist/components/IpAccessRuleEditor.svelte.d.ts +19 -0
  34. package/dist/components/IpWhitelistDrawer.svelte +94 -0
  35. package/dist/components/IpWhitelistDrawer.svelte.d.ts +10 -0
  36. package/dist/components/MediaAuthenticityAuditCard.svelte +357 -0
  37. package/dist/components/MediaAuthenticityAuditCard.svelte.d.ts +64 -0
  38. package/dist/components/PrintDocument.svelte +95 -0
  39. package/dist/components/PrintDocument.svelte.d.ts +10 -0
  40. package/dist/components/PrintPreviewModal.svelte +52 -0
  41. package/dist/components/PrintPreviewModal.svelte.d.ts +11 -0
  42. package/dist/components/PrintTemplateDesigner.svelte +280 -0
  43. package/dist/components/PrintTemplateDesigner.svelte.d.ts +11 -0
  44. package/dist/components/RateLimitPolicyPanel.svelte +369 -0
  45. package/dist/components/RateLimitPolicyPanel.svelte.d.ts +29 -0
  46. package/dist/components/SensitiveWordAuditor.svelte +368 -0
  47. package/dist/components/SensitiveWordAuditor.svelte.d.ts +9 -0
  48. package/dist/components/ServiceDeskTicketCard.svelte +297 -0
  49. package/dist/components/ServiceDeskTicketCard.svelte.d.ts +52 -0
  50. package/dist/components/ShiftScheduler.svelte +490 -0
  51. package/dist/components/ShiftScheduler.svelte.d.ts +50 -0
  52. package/dist/components/SslCertificateMonitorCard.svelte +309 -0
  53. package/dist/components/SslCertificateMonitorCard.svelte.d.ts +30 -0
  54. package/dist/components/SsoConnectionStudio.svelte +784 -0
  55. package/dist/components/SsoConnectionStudio.svelte.d.ts +44 -0
  56. package/dist/components/SsoSpMetadataPanel.svelte +44 -0
  57. package/dist/components/SsoSpMetadataPanel.svelte.d.ts +8 -0
  58. package/dist/components/StepUpAuthModal.svelte +448 -0
  59. package/dist/components/StepUpAuthModal.svelte.d.ts +26 -0
  60. package/dist/components/TrafficTopologyInspector.svelte +361 -0
  61. package/dist/components/TrafficTopologyInspector.svelte.d.ts +43 -0
  62. package/dist/components/enterprise/filter-tree.js +1 -1
  63. package/dist/components/filter-i18n.d.ts +61 -0
  64. package/dist/components/filter-i18n.js +114 -0
  65. package/dist/components/ip-access-rules.d.ts +24 -0
  66. package/dist/components/ip-access-rules.js +110 -0
  67. package/dist/components/moderation-utils.d.ts +45 -0
  68. package/dist/components/moderation-utils.js +74 -0
  69. package/dist/components/print-document.d.ts +3 -0
  70. package/dist/components/print-document.js +65 -0
  71. package/dist/components/print-utils.d.ts +44 -0
  72. package/dist/components/print-utils.js +68 -0
  73. package/dist/components/retention-utils.d.ts +31 -0
  74. package/dist/components/retention-utils.js +38 -0
  75. package/dist/components/sso-connection-presets.d.ts +2 -0
  76. package/dist/components/sso-connection-presets.js +59 -0
  77. package/dist/components/ui/sheet/sheet.svelte +3 -1
  78. package/dist/components/ui/sheet/sheet.svelte.d.ts +1 -0
  79. package/dist/index.d.ts +29 -0
  80. package/dist/index.js +44 -0
  81. package/package.json +5 -4
@@ -0,0 +1,110 @@
1
+ import { Address4, Address6 } from 'ip-address';
2
+ const ipv4 = /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;
3
+ function parseAddress(address) {
4
+ if (ipv4.test(address))
5
+ return new Address4(address);
6
+ if (!address.includes(':') || /[/\s%[\]]/.test(address) || !Address6.isValid(address))
7
+ return null;
8
+ return new Address6(address);
9
+ }
10
+ function singleBounds(address) {
11
+ const parsed = parseAddress(address);
12
+ if (!parsed)
13
+ return null;
14
+ // 映射 IPv6 与普通 IPv4 必须使用同一比较域,防止同一连接绕过冲突检查。
15
+ const normalized = parsed instanceof Address6 && parsed.isMapped4() ? parsed.to4() : parsed;
16
+ return { family: normalized instanceof Address4 ? 4 : 6, first: normalized.bigInt(), last: normalized.bigInt() };
17
+ }
18
+ function cidrBounds(pattern) {
19
+ const parts = pattern.split('/');
20
+ const address = parts[0] ? parseAddress(parts[0]) : null;
21
+ if (parts.length !== 2 || !address || !/^(0|[1-9]\d*)$/.test(parts[1] ?? ''))
22
+ return null;
23
+ const prefix = Number(parts[1]);
24
+ const maximum = address instanceof Address4 ? 32 : 128;
25
+ if (prefix > maximum)
26
+ return null;
27
+ const subnet = address instanceof Address4 ? new Address4(pattern) : new Address6(pattern);
28
+ if (subnet instanceof Address6 && subnet.isMapped4() && prefix >= 96) {
29
+ const mapped = subnet.to4();
30
+ return { family: 4, first: mapped.startAddress().bigInt(), last: mapped.endAddress().bigInt() };
31
+ }
32
+ return { family: maximum === 32 ? 4 : 6, first: subnet.startAddress().bigInt(), last: subnet.endAddress().bigInt() };
33
+ }
34
+ function patternBounds(type, pattern) {
35
+ if (type === 'SINGLE')
36
+ return singleBounds(pattern);
37
+ if (type === 'CIDR')
38
+ return cidrBounds(pattern);
39
+ if (type !== 'RANGE')
40
+ return null;
41
+ const endpoints = pattern.split('-').map(endpoint => singleBounds(endpoint.trim()));
42
+ const [start, end] = endpoints;
43
+ if (endpoints.length !== 2 || !start || !end || start.family !== end.family || start.first > end.first)
44
+ return null;
45
+ return { family: start.family, first: start.first, last: end.first };
46
+ }
47
+ export function validateIpRuleValue(type, value) {
48
+ if (patternBounds(type, value.trim()))
49
+ return { valid: true };
50
+ return { valid: false, error: 'Enter a valid IP, decimal CIDR prefix, or ascending same-family IP range.' };
51
+ }
52
+ export function ruleTimingError(rule) {
53
+ const start = rule.startsAt == null ? null : Date.parse(rule.startsAt);
54
+ const end = rule.expiresAt == null ? null : Date.parse(rule.expiresAt);
55
+ if ((start !== null && !Number.isFinite(start)) || (end !== null && !Number.isFinite(end)))
56
+ return 'Invalid rule date.';
57
+ if (start !== null && end !== null && end <= start)
58
+ return 'Expiration must be after activation.';
59
+ return null;
60
+ }
61
+ export function ipRuleState(rule, now) {
62
+ if (!rule.enabled)
63
+ return 'Disabled';
64
+ if (ruleTimingError(rule) || !validateIpRuleValue(rule.type, rule.value).valid)
65
+ return 'Invalid';
66
+ if (rule.expiresAt != null && Date.parse(rule.expiresAt) <= now)
67
+ return 'Expired';
68
+ if (rule.startsAt != null && Date.parse(rule.startsAt) > now)
69
+ return 'Scheduled';
70
+ return 'Active';
71
+ }
72
+ function matchesAddress(bounds, address) {
73
+ if (bounds.family === address.family)
74
+ return bounds.first <= address.first && address.first <= bounds.last;
75
+ // IPv6 的 /0 等广域规则也必须覆盖 IPv4-mapped 连接。
76
+ if (bounds.family === 6 && address.family === 4) {
77
+ const mapped = new Address6(`::ffff:${Address4.fromBigInt(address.first).correctForm()}`).bigInt();
78
+ return bounds.first <= mapped && mapped <= bounds.last;
79
+ }
80
+ return false;
81
+ }
82
+ export function clientIpAllowed(rules, mode, ip, now) {
83
+ const address = singleBounds(ip.trim());
84
+ if (!address)
85
+ return false;
86
+ const matches = rules.filter(rule => {
87
+ const bounds = patternBounds(rule.type, rule.value.trim());
88
+ return bounds && ipRuleState(rule, now) === 'Active' && matchesAddress(bounds, address);
89
+ });
90
+ if (matches.some(rule => rule.action === 'DENY'))
91
+ return false;
92
+ return mode === 'BLACKLIST' || matches.some(rule => rule.action === 'ALLOW');
93
+ }
94
+ export function lockoutError(rules, mode, ip, now) {
95
+ if (!validateIpRuleValue('SINGLE', ip).valid)
96
+ return 'Resolve a valid server-observed client IP before changing this policy.';
97
+ if (rules.some(rule => !validateIpRuleValue(rule.type, rule.value).valid || ruleTimingError(rule)
98
+ || !['ALLOW', 'DENY'].includes(rule.action)))
99
+ return 'Fix invalid rule patterns, actions or dates before saving the policy.';
100
+ if (new Set(rules.map(rule => rule.id)).size !== rules.length)
101
+ return 'Rule IDs must be unique.';
102
+ if (!clientIpAllowed(rules, mode, ip, now))
103
+ return 'This change would block your current IP. Keep an active ALLOW rule and remove conflicting DENY rules.';
104
+ // 只检查会改变策略的时刻,防止临时放行到期或未来 DENY 生效后误锁。
105
+ const boundaries = rules.flatMap(rule => [rule.startsAt, rule.expiresAt])
106
+ .filter((date) => date != null).map(date => Date.parse(date)).filter(time => Number.isFinite(time) && time > now);
107
+ return boundaries.some(time => !clientIpAllowed(rules, mode, ip, time))
108
+ ? 'A scheduled rule or expiration would later block your current IP. Keep permanent access before saving.'
109
+ : null;
110
+ }
@@ -0,0 +1,45 @@
1
+ export type ModerationCategory = 'politics' | 'violence' | 'pornography' | 'spam' | 'custom';
2
+ export type ModerationAction = 'block' | 'mask' | 'review';
3
+ export type ModerationSeverity = 'critical' | 'high' | 'medium' | 'low';
4
+ export interface SensitiveWordItem {
5
+ id: string;
6
+ word: string;
7
+ category: ModerationCategory;
8
+ action: ModerationAction;
9
+ severity: ModerationSeverity;
10
+ replacement?: string;
11
+ enabled: boolean;
12
+ }
13
+ export interface ModerationMatch {
14
+ word: string;
15
+ category: ModerationCategory;
16
+ action: ModerationAction;
17
+ severity: ModerationSeverity;
18
+ index: number;
19
+ length: number;
20
+ replacement?: string;
21
+ }
22
+ export interface ModerationScanResult {
23
+ hasViolation: boolean;
24
+ blockRequired: boolean;
25
+ reviewRequired: boolean;
26
+ totalHits: number;
27
+ matches: ModerationMatch[];
28
+ maskedText: string;
29
+ }
30
+ export interface ModerationTicket {
31
+ id: string;
32
+ title: string;
33
+ sourceModule: string;
34
+ author: string;
35
+ submittedAt: string;
36
+ rawContent: string;
37
+ status: 'pending' | 'approved' | 'rejected' | 'masked';
38
+ riskScore: number;
39
+ matches: ModerationMatch[];
40
+ }
41
+ export declare function maskModerationMatches(text: string, matches: ModerationMatch[]): string;
42
+ /**
43
+ * 扫描文本并根据敏感词库进行分词匹配与脱敏处理
44
+ */
45
+ export declare function scanContent(text: string, dictionary: SensitiveWordItem[]): ModerationScanResult;
@@ -0,0 +1,74 @@
1
+ export function maskModerationMatches(text, matches) {
2
+ const regions = [];
3
+ for (const match of [...matches].sort((a, b) => a.index - b.index)) {
4
+ if (!Number.isInteger(match.index) || !Number.isInteger(match.length)
5
+ || match.index < 0 || match.length < 1 || match.index + match.length > text.length) {
6
+ throw new RangeError('敏感词匹配位置无效');
7
+ }
8
+ const end = match.index + match.length;
9
+ const previous = regions.at(-1);
10
+ // 重叠命中覆盖原文区间的并集;相邻命中独立替换,不处理替换产物。
11
+ if (previous && match.index < previous.end) {
12
+ previous.end = Math.max(previous.end, end);
13
+ previous.replacement = '*'.repeat(previous.end - previous.start);
14
+ }
15
+ else {
16
+ regions.push({ start: match.index, end, replacement: match.replacement ?? '*'.repeat(match.length) });
17
+ }
18
+ }
19
+ let cursor = 0;
20
+ let masked = '';
21
+ for (const region of regions) {
22
+ masked += text.slice(cursor, region.start) + region.replacement;
23
+ cursor = region.end;
24
+ }
25
+ return masked + text.slice(cursor);
26
+ }
27
+ /**
28
+ * 扫描文本并根据敏感词库进行分词匹配与脱敏处理
29
+ */
30
+ export function scanContent(text, dictionary) {
31
+ if (!text) {
32
+ return {
33
+ hasViolation: false,
34
+ blockRequired: false,
35
+ reviewRequired: false,
36
+ totalHits: 0,
37
+ matches: [],
38
+ maskedText: '',
39
+ };
40
+ }
41
+ const activeWords = dictionary.filter(w => w.enabled);
42
+ const matches = [];
43
+ for (const item of activeWords) {
44
+ if (!item.word.trim())
45
+ continue;
46
+ const pattern = new RegExp(item.word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gi');
47
+ let occurrence;
48
+ while ((occurrence = pattern.exec(text)) !== null) {
49
+ matches.push({
50
+ word: item.word,
51
+ category: item.category,
52
+ action: item.action,
53
+ severity: item.severity,
54
+ index: occurrence.index,
55
+ length: occurrence[0].length,
56
+ ...(item.replacement ? { replacement: item.replacement } : {}),
57
+ });
58
+ pattern.lastIndex = occurrence.index + 1;
59
+ }
60
+ }
61
+ // Sort matches by offset index
62
+ matches.sort((a, b) => a.index - b.index);
63
+ const maskedText = maskModerationMatches(text, matches);
64
+ const blockRequired = matches.some(m => m.action === 'block' || m.severity === 'critical');
65
+ const reviewRequired = matches.some(m => m.action === 'review' || m.severity === 'high');
66
+ return {
67
+ hasViolation: matches.length > 0,
68
+ blockRequired,
69
+ reviewRequired,
70
+ totalHits: matches.length,
71
+ matches,
72
+ maskedText,
73
+ };
74
+ }
@@ -0,0 +1,3 @@
1
+ import { type PaperSize } from './print-utils.js';
2
+ /** 只复制单据;80mm 小票至少 160mm,超出时按内容高度打印。 */
3
+ export declare function printDocument(element: HTMLElement, paperSize: PaperSize): Promise<void>;
@@ -0,0 +1,65 @@
1
+ import { PRINT_PAPER_DIMENSIONS } from './print-utils.js';
2
+ async function copyPrintStyles(source, target) {
3
+ await Promise.all(Array.from(source.querySelectorAll('style, link[rel="stylesheet"]'), node => {
4
+ const clone = node.cloneNode(true);
5
+ const loaded = clone instanceof HTMLLinkElement
6
+ ? new Promise((resolve, reject) => {
7
+ clone.onload = () => resolve();
8
+ clone.onerror = () => reject(new Error('打印样式加载失败'));
9
+ }) : Promise.resolve();
10
+ target.head.append(clone);
11
+ return loaded;
12
+ }));
13
+ }
14
+ /** 只复制单据;80mm 小票至少 160mm,超出时按内容高度打印。 */
15
+ export async function printDocument(element, paperSize) {
16
+ const frame = document.createElement('iframe');
17
+ frame.title = '单据打印';
18
+ frame.style.cssText = 'position:fixed;left:-10000px;top:0;width:1px;height:1px;border:0';
19
+ document.body.append(frame);
20
+ let timeout;
21
+ try {
22
+ const target = frame.contentDocument;
23
+ const printWindow = frame.contentWindow;
24
+ if (!target || !printWindow)
25
+ throw new Error('无法创建打印窗口');
26
+ target.documentElement.lang = document.documentElement.lang;
27
+ const base = target.createElement('base');
28
+ base.href = document.baseURI;
29
+ target.head.append(base);
30
+ const stylesheetReady = copyPrintStyles(document, target);
31
+ const paper = PRINT_PAPER_DIMENSIONS[paperSize];
32
+ const pageStyle = target.createElement('style');
33
+ pageStyle.textContent = `@page { size: ${paper.width}mm ${paper.height}mm; margin: 0; }
34
+ html, body { margin: 0; padding: 0; background: white; color: black; }
35
+ .print-pages { display: block !important; }
36
+ .print-page { box-shadow: none !important; border: 0 !important; }`;
37
+ target.head.append(pageStyle);
38
+ const copied = element.cloneNode(true);
39
+ copied.hidden = false;
40
+ copied.style.display = 'block';
41
+ target.body.append(copied);
42
+ const deadline = new Promise((_, reject) => {
43
+ timeout = setTimeout(() => reject(new Error('打印资源加载超时')), 15000);
44
+ });
45
+ await Promise.race([stylesheetReady.then(() => target.fonts?.ready), deadline]);
46
+ clearTimeout(timeout);
47
+ if (paperSize === 'RECEIPT_80MM') {
48
+ const height = Math.max(paper.height, ...Array.from(copied.querySelectorAll('.print-page'), page => Math.ceil(page.getBoundingClientRect().height * 25.4 / 96 - 0.01)));
49
+ pageStyle.textContent += `@page { size: ${paper.width}mm ${height}mm; }`;
50
+ }
51
+ // Safari 的打印对话框可能非阻塞,不能在 print() 返回时立即移除文档。
52
+ const cleanupTimer = setTimeout(() => frame.remove(), 60000);
53
+ printWindow.addEventListener('afterprint', () => {
54
+ clearTimeout(cleanupTimer);
55
+ frame.remove();
56
+ }, { once: true });
57
+ printWindow.focus();
58
+ printWindow.print();
59
+ }
60
+ catch (error) {
61
+ clearTimeout(timeout);
62
+ frame.remove();
63
+ throw error;
64
+ }
65
+ }
@@ -0,0 +1,44 @@
1
+ export type PaperSize = 'A4' | 'A4_LANDSCAPE' | 'RECEIPT_80MM' | 'SHIPPING_100X180' | 'TRIPLICATE_241X140';
2
+ export interface PrintColumn {
3
+ id: string;
4
+ label: string;
5
+ field: string;
6
+ width?: string;
7
+ align?: 'left' | 'center' | 'right';
8
+ visible: boolean;
9
+ }
10
+ export interface PrintTemplateConfig {
11
+ id: string;
12
+ name: string;
13
+ title: string;
14
+ subTitle?: string;
15
+ companyName: string;
16
+ paperSize: PaperSize;
17
+ showBarcode: boolean;
18
+ showQrCode: boolean;
19
+ showWatermark: boolean;
20
+ watermarkText?: string;
21
+ showAmountInWords: boolean;
22
+ currencySymbol: string;
23
+ metaFields: Array<{
24
+ id: string;
25
+ label: string;
26
+ field: string;
27
+ value?: string;
28
+ }>;
29
+ columns: PrintColumn[];
30
+ signers: string[];
31
+ copies: string[];
32
+ footerNotes?: string;
33
+ }
34
+ /**
35
+ * 将数字金额转换为符合中国财务规范的人民币汉字大写字符串
36
+ * 例如:1234.56 -> 壹仟贰佰叁拾肆元伍角陆分
37
+ */
38
+ export declare function currencyMinorUnits(amount: number): number;
39
+ export declare function numberToChineseCurrency(num: number): string;
40
+ export declare const PRINT_PAPER_DIMENSIONS: Record<PaperSize, {
41
+ width: number;
42
+ height: number;
43
+ }>;
44
+ export declare function printSampleItems(sample: Record<string, unknown>): Record<string, unknown>[];
@@ -0,0 +1,68 @@
1
+ /**
2
+ * 将数字金额转换为符合中国财务规范的人民币汉字大写字符串
3
+ * 例如:1234.56 -> 壹仟贰佰叁拾肆元伍角陆分
4
+ */
5
+ export function currencyMinorUnits(amount) {
6
+ if (!Number.isFinite(amount) || Math.abs(amount) >= 1e12) {
7
+ throw new RangeError('金额必须是绝对值小于一万亿元的有限数值');
8
+ }
9
+ // 用十进制原值舍入,避免 1.15 丢分、1.005 不进位及科学计数法误差。
10
+ const [coefficient = '0', exponent = '0'] = Math.abs(amount).toString().split('e');
11
+ const decimals = coefficient.split('.')[1]?.length ?? 0;
12
+ const digits = BigInt(coefficient.replace('.', ''));
13
+ const shift = Number(exponent) - decimals + 2;
14
+ const divisor = 10n ** BigInt(Math.max(0, -shift));
15
+ const cents = shift >= 0 ? digits * 10n ** BigInt(shift)
16
+ : (digits + divisor / 2n) / divisor;
17
+ if (cents >= 100000000000000n)
18
+ throw new RangeError('金额舍入后超出支持范围');
19
+ return Number(cents) * (amount < 0 ? -1 : 1);
20
+ }
21
+ export function numberToChineseCurrency(num) {
22
+ if (!Number.isFinite(num) || Math.abs(num) >= 1e12)
23
+ return '金额无效';
24
+ let minorUnits;
25
+ try {
26
+ minorUnits = Math.abs(currencyMinorUnits(num));
27
+ }
28
+ catch (error) {
29
+ if (error instanceof RangeError)
30
+ return '金额无效';
31
+ throw error;
32
+ }
33
+ const fraction = ['角', '分'];
34
+ const digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
35
+ const unit = [
36
+ ['元', '万', '亿'],
37
+ ['', '拾', '佰', '仟'],
38
+ ];
39
+ let s = '';
40
+ const fractionPart = minorUnits % 100;
41
+ for (let i = 0; i < fraction.length; i++) {
42
+ s += `${digit[Math.floor(fractionPart / (i === 0 ? 10 : 1)) % 10] ?? ''}${fraction[i] ?? ''}`.replace(/零./, '');
43
+ }
44
+ s = s || '整';
45
+ let integerPart = Math.floor(minorUnits / 100);
46
+ for (let i = 0; i < (unit[0]?.length ?? 0) && integerPart > 0; i++) {
47
+ let p = '';
48
+ for (let j = 0; j < (unit[1]?.length ?? 0) && integerPart > 0; j++) {
49
+ p = `${digit[integerPart % 10] ?? ''}${unit[1]?.[j] ?? ''}${p}`;
50
+ integerPart = Math.floor(integerPart / 10);
51
+ }
52
+ s = `${p.replace(/(零.)*零$/, '').replace(/^$/, '零')}${unit[0]?.[i] ?? ''}${s}`;
53
+ }
54
+ const words = s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整');
55
+ return num < 0 && minorUnits > 0 ? `负${words}` : words;
56
+ }
57
+ export const PRINT_PAPER_DIMENSIONS = {
58
+ A4: { width: 210, height: 297 },
59
+ A4_LANDSCAPE: { width: 297, height: 210 },
60
+ RECEIPT_80MM: { width: 80, height: 160 },
61
+ SHIPPING_100X180: { width: 100, height: 180 },
62
+ TRIPLICATE_241X140: { width: 241, height: 140 },
63
+ };
64
+ export function printSampleItems(sample) {
65
+ if (Array.isArray(sample['items']))
66
+ return sample['items'];
67
+ return Object.values(sample).filter((row) => typeof row === 'object' && row !== null && !Array.isArray(row));
68
+ }
@@ -0,0 +1,31 @@
1
+ export type RetentionAction = 'hard_delete' | 'soft_delete' | 'archive_cold_storage' | 'mask_and_archive';
2
+ export type RetentionStatus = 'active' | 'paused' | 'draft';
3
+ export interface RetentionPolicy {
4
+ id: string;
5
+ name: string;
6
+ resource: string;
7
+ retentionDays: number;
8
+ action: RetentionAction;
9
+ status: RetentionStatus;
10
+ targetStorage?: string;
11
+ filterCondition?: string;
12
+ estimatedRows: number;
13
+ estimatedStorageMb: number;
14
+ lastExecutedAt?: string;
15
+ scheduleCron?: string;
16
+ }
17
+ export interface RetentionSummaryMetrics {
18
+ totalPolicies: number;
19
+ activePolicies: number;
20
+ totalEstimatedRows: number;
21
+ totalEstimatedStorageGb: number;
22
+ archivedToColdStorageGb: number;
23
+ }
24
+ /**
25
+ * 汇总统计所有生命周期策略的预估受影响量与节省存储指标
26
+ */
27
+ export declare function calculateRetentionMetrics(policies: RetentionPolicy[]): RetentionSummaryMetrics;
28
+ /**
29
+ * 检测同一资源是否存在潜在冲突的留存策略(同资源同状态同动作)
30
+ */
31
+ export declare function detectPolicyConflicts(policies: RetentionPolicy[]): string[];
@@ -0,0 +1,38 @@
1
+ /**
2
+ * 汇总统计所有生命周期策略的预估受影响量与节省存储指标
3
+ */
4
+ export function calculateRetentionMetrics(policies) {
5
+ const activeList = policies.filter(p => p.status === 'active');
6
+ const totalRows = activeList.reduce((acc, curr) => acc + curr.estimatedRows, 0);
7
+ const totalStorageMb = activeList.reduce((acc, curr) => acc + curr.estimatedStorageMb, 0);
8
+ const coldStorageMb = activeList
9
+ .filter(p => p.action === 'archive_cold_storage' || p.action === 'mask_and_archive')
10
+ .reduce((acc, curr) => acc + curr.estimatedStorageMb, 0);
11
+ return {
12
+ totalPolicies: policies.length,
13
+ activePolicies: activeList.length,
14
+ totalEstimatedRows: totalRows,
15
+ totalEstimatedStorageGb: Number((totalStorageMb / 1024).toFixed(2)),
16
+ archivedToColdStorageGb: Number((coldStorageMb / 1024).toFixed(2)),
17
+ };
18
+ }
19
+ /**
20
+ * 检测同一资源是否存在潜在冲突的留存策略(同资源同状态同动作)
21
+ */
22
+ export function detectPolicyConflicts(policies) {
23
+ const warnings = [];
24
+ const map = new Map();
25
+ for (const p of policies) {
26
+ if (p.status !== 'active')
27
+ continue;
28
+ const list = map.get(p.resource) || [];
29
+ list.push(p);
30
+ map.set(p.resource, list);
31
+ }
32
+ for (const [resource, list] of map.entries()) {
33
+ if (list.length > 1) {
34
+ warnings.push(`资源 "${resource}" 存在 ${list.length} 条并发执行的活跃留存策略,请确保过滤条件互斥。`);
35
+ }
36
+ }
37
+ return warnings;
38
+ }
@@ -0,0 +1,2 @@
1
+ import type { SsoConnection } from './SsoConnectionStudio.svelte';
2
+ export declare const defaultSsoConnections: SsoConnection[];
@@ -0,0 +1,59 @@
1
+ // 默认 SSO 连接示例,集中存放保持组件精简。
2
+ export const defaultSsoConnections = [
3
+ {
4
+ id: 'conn-okta-saml',
5
+ name: 'Corporate Okta SSO',
6
+ protocol: 'saml',
7
+ status: 'active',
8
+ domains: ['corp.example.com', 'partner.example.com'],
9
+ isDefault: true,
10
+ entityId: 'http://www.okta.com/exk1234567890abcdef',
11
+ ssoUrl: 'https://corp.okta.com/app/svadmin/exk1234567890abcdef/sso/saml',
12
+ certificate: 'MIIDpDCCAoygAwIBAgIGAV...[X.509 Certificate]...EXAMPLEDATA',
13
+ claimMappings: [
14
+ { remoteClaim: 'email', localField: 'email' },
15
+ { remoteClaim: 'firstName', localField: 'first_name' },
16
+ { remoteClaim: 'lastName', localField: 'last_name' },
17
+ { remoteClaim: 'department', localField: 'department' },
18
+ ],
19
+ lastTestedAt: '2026-11-14 18:30',
20
+ testStatus: 'success',
21
+ testMessage: 'Handshake 200 OK. Signature verified.',
22
+ },
23
+ {
24
+ id: 'conn-azure-oidc',
25
+ name: 'Microsoft Entra ID (Azure AD)',
26
+ protocol: 'oidc',
27
+ status: 'active',
28
+ domains: ['cloud.example.org'],
29
+ isDefault: false,
30
+ clientId: '9f8b4a2c-1d3e-4f5a-8b9c-0d1e2f3a4b5c',
31
+ clientSecret: 'ms_sec_••••••••••••••••',
32
+ discoveryUrl: 'https://login.microsoftonline.com/tenant-id/v2.0/.well-known/openid-configuration',
33
+ scopes: ['openid', 'profile', 'email'],
34
+ claimMappings: [
35
+ { remoteClaim: 'preferred_username', localField: 'email' },
36
+ { remoteClaim: 'name', localField: 'display_name' },
37
+ ],
38
+ lastTestedAt: '2026-11-14 17:15',
39
+ testStatus: 'success',
40
+ testMessage: 'Discovery endpoint parsed. OIDC JWKS valid.',
41
+ },
42
+ {
43
+ id: 'conn-feishu-suite',
44
+ name: '飞书自建应用企业登录',
45
+ protocol: 'feishu',
46
+ status: 'inactive',
47
+ domains: ['feishu.internal'],
48
+ isDefault: false,
49
+ appId: 'cli_a1b2c3d4e5f6g7h8',
50
+ appSecret: 'secret_••••••••••••',
51
+ claimMappings: [
52
+ { remoteClaim: 'open_id', localField: 'sso_uid' },
53
+ { remoteClaim: 'name', localField: 'display_name' },
54
+ { remoteClaim: 'mobile', localField: 'phone' },
55
+ ],
56
+ lastTestedAt: '2026-11-10 09:00',
57
+ testStatus: 'untested',
58
+ },
59
+ ];
@@ -56,6 +56,7 @@
56
56
  onClose?: () => void;
57
57
  onCloseRequest?: (close: () => void) => void;
58
58
  closeLabel?: string;
59
+ closeOnOverlayClick?: boolean;
59
60
  };
60
61
 
61
62
  let {
@@ -65,6 +66,7 @@
65
66
  onClose,
66
67
  onCloseRequest,
67
68
  closeLabel = i18n.t("common.close"),
69
+ closeOnOverlayClick = true,
68
70
  class: className,
69
71
  tabindex = -1,
70
72
  children,
@@ -169,7 +171,7 @@
169
171
  <div
170
172
  role="presentation"
171
173
  class="svadmin-sheet-overlay"
172
- onclick={close}
174
+ onclick={() => { if (closeOnOverlayClick) close(); }}
173
175
  ></div>
174
176
 
175
177
  <!-- Sheet panel -->
@@ -6,6 +6,7 @@ type Props = WithElementRef<HTMLAttributes<HTMLDivElement>> & {
6
6
  onClose?: () => void;
7
7
  onCloseRequest?: (close: () => void) => void;
8
8
  closeLabel?: string;
9
+ closeOnOverlayClick?: boolean;
9
10
  };
10
11
  declare const Sheet: import("svelte").Component<Props, {}, "open" | "ref">;
11
12
  type Sheet = ReturnType<typeof Sheet>;
package/dist/index.d.ts CHANGED
@@ -635,7 +635,9 @@ export { default as TableAggregationFooter, default as TableColumnSumSummary, ty
635
635
  export { default as IncidentWarRoomDrawer, default as AlertIncidentTimeline, type IncidentWarRoomDrawerProps, type IncidentTimelineEvent, type IncidentSeverity } from './components/IncidentWarRoomDrawer.svelte';
636
636
  export { default as DataImportDropzone, default as BatchImportDropzone, type DataImportDropzoneProps } from './components/DataImportDropzone.svelte';
637
637
  export { default as ColumnMappingTable, default as FieldMappingTable, type ColumnMappingTableProps, type TargetFieldConfig } from './components/ColumnMappingTable.svelte';
638
+ export { default as FieldMappingBuilder, default as ColumnMappingBuilder, type FieldMappingBuilderProps, type SourceField, type TargetField, type FieldMappingRule, type TransformType } from './components/FieldMappingBuilder.svelte';
638
639
  export { default as ImportPreviewValidator, default as ImportDataValidator, type ImportPreviewValidatorProps, type RowValidationError } from './components/ImportPreviewValidator.svelte';
640
+ export { default as DataImportPipeline, default as BatchImportPipeline, type DataImportPipelineProps, type ValidationRule, type PipelineValidationError } from './components/DataImportPipeline.svelte';
639
641
  export { default as PivotMatrix, default as CrossTableSummary, type PivotMatrixProps, type PivotDimension, type PivotMeasure } from './components/PivotMatrix.svelte';
640
642
  export { default as GeoScatterMap, default as RegionDistributionMap, type GeoScatterMapProps, type GeoRegionData } from './components/GeoScatterMap.svelte';
641
643
  export { default as DataMaskPolicyEngine, default as DataMaskCenter, type DataMaskPolicyEngineProps, type MaskingPolicyItem, type MaskingRuleType, type MaskingLevel } from './components/DataMaskPolicyEngine.svelte';
@@ -669,4 +671,31 @@ export { default as MicroAppSandbox, default as SubAppRuntimeSandbox, type Micro
669
671
  export { useMicroAppState, type UseMicroAppStateOptions, type MicroAppStateMessage } from './components/useMicroAppState.svelte.js';
670
672
  export { default as MicroAppStateBusIndicator, default as CrossAppStateBus, type MicroAppStateBusIndicatorProps } from './components/MicroAppStateBusIndicator.svelte';
671
673
  export { default as MicroAppRouteSync, default as SubAppUrlSynchronizer, type MicroAppRouteSyncProps } from './components/MicroAppRouteSync.svelte';
674
+ export { default as IpAccessRuleEditor, validateIpRuleValue, type IpAccessRuleEditorProps, type IpAccessRule, type IpRuleType, type IpRuleAction, } from './components/IpAccessRuleEditor.svelte';
675
+ export { default as IpWhitelistDrawer, default as IpAccessControlDrawer, type IpWhitelistDrawerProps, } from './components/IpWhitelistDrawer.svelte';
676
+ export { default as ShiftScheduler, default as WorkShiftCalendar, type ShiftSchedulerProps, type ShiftType, type StaffMember, type ShiftAssignment, type ShiftConflictAlert } from './components/ShiftScheduler.svelte';
672
677
  export { default as NotificationDrawer, default as GlobalNoticeDrawer, type NotificationDrawerProps, type NotificationItem as NotificationDrawerItem, type NotificationAction, type NotificationCategory, } from './components/NotificationDrawer.svelte';
678
+ export { default as I18nStudio, default as TranslationManager, type I18nStudioProps, } from './components/I18nStudio.svelte';
679
+ export { default as ContractClauseDiffViewer, default as LegalClauseComparator, type ContractClauseDiffViewerProps, type ContractClause, type ClauseChangeType, type ClauseRiskLevel, type ClauseDecisionStatus, type ClauseAnnotation, } from './components/ContractClauseDiffViewer.svelte';
680
+ export { default as ElectronicSealInspector, default as StampAuthenticityCard, type ElectronicSealInspectorProps, type ElectronicSealInfo, type SealValidationStatus, type SealType as ElectronicSealValidationType, type SealCertificateInfo, type SealTimestampInfo, type SealVerificationLog, } from './components/ElectronicSealInspector.svelte';
681
+ export { default as GatewayRouteEditor, default as ApiRouteRuleCard, type HttpMethod as GatewayHttpMethod, type HeaderMatchRule, type GatewayRouteConfig, } from './components/GatewayRouteEditor.svelte';
682
+ export { default as RateLimitPolicyPanel, default as CircuitBreakerCard, type CircuitBreakerState, type RateLimitDimension, type FallbackStrategy, type RateLimitPolicyConfig, } from './components/RateLimitPolicyPanel.svelte';
683
+ export { default as StepUpAuthModal, default as PrivilegeElevationModal, type StepUpAuthMethod, type StepUpRiskLevel, } from './components/StepUpAuthModal.svelte';
684
+ export { default as AuditSnapshotCapture, default as ComplianceEvidenceCard, type AuditSnapshotDiffItem, } from './components/AuditSnapshotCapture.svelte';
685
+ export { default as ServiceDeskTicketCard, default as SupportTicketCard, type ServiceDeskTicketCardProps, type TicketPriority, type TicketStatus, type TicketActor, type SlaInfo } from './components/ServiceDeskTicketCard.svelte';
686
+ export { default as CannedResponsePicker, default as QuickReplyDrawer, type CannedResponsePickerProps, type CannedTemplate } from './components/CannedResponsePicker.svelte';
687
+ export { default as EmployeeOffboardingAuditor, default as HandoverChecklistDrawer, type OffboardingEmployee, type OffboardingItem, type OffboardingCategory, type OffboardingItemStatus, type SignoffStatus, } from './components/EmployeeOffboardingAuditor.svelte';
688
+ export { default as AccessRevocationMatrix, default as PrivilegeDeprovisionCard, type TargetSystemAccess, type SystemType, type PrivilegeLevel, type RevocationStatus, } from './components/AccessRevocationMatrix.svelte';
689
+ export { default as DataRetentionPolicyEditor, default as DataArchiveStudio, type DataRetentionPolicyEditorProps, } from './components/DataRetentionPolicyEditor.svelte';
690
+ export { calculateRetentionMetrics, detectPolicyConflicts, type RetentionAction, type RetentionStatus, type RetentionPolicy, type RetentionSummaryMetrics, } from './components/retention-utils.js';
691
+ export { default as TrafficTopologyInspector, default as ClusterTrafficVisualizer, type TrafficTopologyInspectorProps, type TopologyNode, type TopologyEdge, type TopologyNodeStatus, type TopologyNodeType, } from './components/TrafficTopologyInspector.svelte';
692
+ export { default as SslCertificateMonitorCard, default as TlsCertExpiryRadar, type SslCertificateMonitorCardProps, type SslCertificateData, type CertSecurityLevel, } from './components/SslCertificateMonitorCard.svelte';
693
+ export { default as SensitiveWordAuditor, default as ComplianceWordFilter, type SensitiveWordAuditorProps, } from './components/SensitiveWordAuditor.svelte';
694
+ export { default as ContentModerationCenter, default as ContentReviewWorkbench, type ContentModerationCenterProps, } from './components/ContentModerationCenter.svelte';
695
+ export { scanContent, type ModerationCategory, type ModerationAction, type ModerationSeverity, type SensitiveWordItem, type ModerationMatch, type ModerationScanResult, type ModerationTicket, } from './components/moderation-utils.js';
696
+ export { default as AudioVisualInspector, default as MediaInspectionCard, type AudioVisualInspectorProps, type AudioVisualMediaMeta, type ViolationMarker, type InspectionViolationLevel, type InspectionOverallResult, } from './components/AudioVisualInspector.svelte';
697
+ export { default as MediaAuthenticityAuditCard, default as ExifMetadataAuditor, type MediaAuthenticityAuditCardProps, type MediaAuthenticityData, type MediaExifMeta, type MediaGpsLocation, type BlindWatermarkPayload, type MediaTamperRiskLevel, } from './components/MediaAuthenticityAuditCard.svelte';
698
+ export { default as PrintTemplateDesigner, default as DocumentPrintStudio, type PrintTemplateDesignerProps, } from './components/PrintTemplateDesigner.svelte';
699
+ export { default as PrintPreviewModal, default as DocumentPrintPreview, type PrintPreviewModalProps, } from './components/PrintPreviewModal.svelte';
700
+ export { numberToChineseCurrency, type PaperSize, type PrintColumn, type PrintTemplateConfig, } from './components/print-utils.js';
701
+ export { default as SsoConnectionStudio, default as IdentityProviderManager, type SsoConnectionStudioProps, type SsoConnection, type SsoProtocol, type SsoStatus, type SsoClaimMapping, } from './components/SsoConnectionStudio.svelte';