documentation-hub 5.7.2

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 (271) hide show
  1. package/.eslintrc.json +43 -0
  2. package/.github/workflows/build.yml +64 -0
  3. package/.github/workflows/ci.yml +39 -0
  4. package/.vscode/extensions.json +3 -0
  5. package/Current.md +97 -0
  6. package/DocHub_Image.png +0 -0
  7. package/README.md +666 -0
  8. package/USER_GUIDE.md +1173 -0
  9. package/Updater.md +311 -0
  10. package/build/256x256.png +0 -0
  11. package/build/512x512.png +0 -0
  12. package/build/app-update.yml +4 -0
  13. package/build/create-icon.js +208 -0
  14. package/build/icon.ico +0 -0
  15. package/build/icon.png +0 -0
  16. package/build/icon_1024x1024.png +0 -0
  17. package/dist/assets/Analytics-BpsG9895.js +1 -0
  18. package/dist/assets/Card-IAZin8kp.js +1 -0
  19. package/dist/assets/CurrentSession-B-rFkHvf.js +12 -0
  20. package/dist/assets/Dashboard-C_5gMb0q.js +1 -0
  21. package/dist/assets/Documents-CqZ25axS.js +1 -0
  22. package/dist/assets/Input-l89xwXBi.js +1 -0
  23. package/dist/assets/Reporting-DqdHJY_a.js +1 -0
  24. package/dist/assets/Search-XNbu5z_3.js +1 -0
  25. package/dist/assets/SessionManager-lH9hZfzH.js +1 -0
  26. package/dist/assets/Sessions-ClZOPYNc.js +1 -0
  27. package/dist/assets/Settings-DUEHGURa.js +11 -0
  28. package/dist/assets/index-8xUe8ptc.js +24 -0
  29. package/dist/assets/index-RYyJqF7O.css +1 -0
  30. package/dist/assets/path-BkOl0AGO.js +1 -0
  31. package/dist/assets/promises-ID_B9S-h.js +1 -0
  32. package/dist/assets/urlHelpers-TvgahX0r.js +1 -0
  33. package/dist/assets/useToast-yRSO1dkm.js +1 -0
  34. package/dist/assets/vendor-charts-RkGK5ROP.js +36 -0
  35. package/dist/assets/vendor-db-l0sNRNKZ.js +1 -0
  36. package/dist/assets/vendor-react-BVZ_anCF.js +4 -0
  37. package/dist/assets/vendor-search-Dw8P0qyA.js +1 -0
  38. package/dist/assets/vendor-ui-BU7NfluV.js +53 -0
  39. package/dist/electron/PowerAutomateApiService-LfW09ZGr.js +147 -0
  40. package/dist/electron/main-CXkNtyv-.js +19789 -0
  41. package/dist/electron/main.js +5 -0
  42. package/dist/electron/preload.js +1 -0
  43. package/dist/icon.png +0 -0
  44. package/dist/index.html +27 -0
  45. package/docs/CODEBASE_ANALYSIS_REPORT.md +309 -0
  46. package/docs/DEBUG_LOGGING_GUIDE.md +244 -0
  47. package/docs/README.md +115 -0
  48. package/docs/TOC_WIRING_GUIDE.md +344 -0
  49. package/docs/analysis/Bullet_Symbol_Bug_Analysis.md +136 -0
  50. package/docs/analysis/DOCXMLATER_ANALYSIS_SUMMARY.txt +169 -0
  51. package/docs/analysis/Document_Processing_Issues_Analysis.md +704 -0
  52. package/docs/analysis/FIELD_PRESERVATION_ANALYSIS.md +1200 -0
  53. package/docs/analysis/INDENTATION_PRESERVE_ANALYSIS.md +181 -0
  54. package/docs/analysis/INDENTATION_PRESERVE_IMPLEMENTATION.md +207 -0
  55. package/docs/analysis/List_Implementation.md +206 -0
  56. package/docs/analysis/List_Implementation_Accuracy_Report.md +366 -0
  57. package/docs/analysis/PROCESSING_OPTIONS_UI_UPDATES.md +220 -0
  58. package/docs/analysis/RefactorStyles.md +852 -0
  59. package/docs/analysis/STYLE_PARAMETER_ENHANCEMENT.md +143 -0
  60. package/docs/analysis/docxmlater-comparison-todo-2025-11-13.md +636 -0
  61. package/docs/analysis/docxmlater-implementation-analysis-2025-11-13.md +340 -0
  62. package/docs/analysis/docxmlater-template_ui-integration-analysis.md +263 -0
  63. package/docs/analysis/github-issues-to-create.md +237 -0
  64. package/docs/api/API_README.md +538 -0
  65. package/docs/api/API_REFERENCE.md +751 -0
  66. package/docs/api/TYPE_DEFINITIONS.md +869 -0
  67. package/docs/architecture/FONT_EMBEDDING_GUIDE.md +318 -0
  68. package/docs/architecture/docxmlater-functions-and-structure.md +726 -0
  69. package/docs/docxmlater-readme.md +1341 -0
  70. package/docs/fixes/EXECUTION_LOG_TEST_BASE.md +573 -0
  71. package/docs/fixes/HYPERLINK_TEXT_SANITIZATION.md +253 -0
  72. package/docs/fixes/README.md +37 -0
  73. package/docs/github-issues/issue-1-body.md +125 -0
  74. package/docs/github-issues/issue-10-body.md +850 -0
  75. package/docs/github-issues/issue-2-body.md +200 -0
  76. package/docs/github-issues/issue-3-body.md +270 -0
  77. package/docs/github-issues/issue-4-body.md +169 -0
  78. package/docs/github-issues/issue-5-body.md +173 -0
  79. package/docs/github-issues/issue-6-body.md +158 -0
  80. package/docs/github-issues/issue-7-body.md +171 -0
  81. package/docs/github-issues/issue-8-body.md +407 -0
  82. package/docs/github-issues/issue-9-body.md +515 -0
  83. package/docs/github-issues/issue-tracker.md +274 -0
  84. package/docs/github-issues/predictive-analysis-2025-10-18.md +2131 -0
  85. package/docs/implementation/List_Framework_Refactor_Plan.md +336 -0
  86. package/docs/implementation/PRIMARY_TEXT_COLOR_FEATURE.md +217 -0
  87. package/docs/implementation/RELEASE_PLAN_v2.1.0.md +362 -0
  88. package/docs/implementation/RefactorStyles.md +588 -0
  89. package/docs/implementation/implement-plan.md +489 -0
  90. package/docs/implementation/missing-helpers-implementation.md +391 -0
  91. package/docs/implementation/refactor-plan.md +520 -0
  92. package/docs/implementation/session-implementation-complete.md +233 -0
  93. package/docs/implementation/session-management-plan.md +250 -0
  94. package/docs/setup-checklist.md +77 -0
  95. package/docs/versions/changelog.md +345 -0
  96. package/electron/customUpdater.ts +656 -0
  97. package/electron/main.ts +2441 -0
  98. package/electron/memoryConfig.ts +187 -0
  99. package/electron/preload.ts +394 -0
  100. package/electron/proxyConfig.ts +340 -0
  101. package/electron/services/BackupService.ts +452 -0
  102. package/electron/services/DictionaryService.ts +402 -0
  103. package/electron/services/LocalDictionaryLookupService.ts +147 -0
  104. package/electron/services/PowerAutomateApiService.ts +231 -0
  105. package/electron/services/SharePointSyncService.ts +474 -0
  106. package/electron/windowsCertStore.ts +427 -0
  107. package/electron/zscalerConfig.ts +381 -0
  108. package/eslint.config.js +92 -0
  109. package/jest.config.js +52 -0
  110. package/package.json +214 -0
  111. package/postcss.config.mjs +6 -0
  112. package/public/icon.png +0 -0
  113. package/publish-release.ps1 +5 -0
  114. package/renovate.json +30 -0
  115. package/src/App.tsx +216 -0
  116. package/src/__mocks__/p-limit.js +12 -0
  117. package/src/__mocks__/styleMock.js +1 -0
  118. package/src/components/common/BugReportButton.tsx +44 -0
  119. package/src/components/common/BugReportDialog.tsx +193 -0
  120. package/src/components/common/Button.tsx +153 -0
  121. package/src/components/common/Card.tsx +86 -0
  122. package/src/components/common/ColorPickerDialog.tsx +177 -0
  123. package/src/components/common/ConfirmDialog.tsx +96 -0
  124. package/src/components/common/DebugConsole.tsx +275 -0
  125. package/src/components/common/EmptyState.tsx +183 -0
  126. package/src/components/common/ErrorBoundary.tsx +98 -0
  127. package/src/components/common/ErrorDetailsDialog.tsx +153 -0
  128. package/src/components/common/ErrorFallback.tsx +218 -0
  129. package/src/components/common/Input.tsx +109 -0
  130. package/src/components/common/Skeleton.tsx +184 -0
  131. package/src/components/common/SplashScreen.tsx +81 -0
  132. package/src/components/common/Toast.tsx +155 -0
  133. package/src/components/common/Tooltip.tsx +79 -0
  134. package/src/components/common/UpdateNotification.tsx +320 -0
  135. package/src/components/comparison/ComparisonWindow.tsx +374 -0
  136. package/src/components/comparison/SideBySideDiff.tsx +486 -0
  137. package/src/components/comparison/index.ts +8 -0
  138. package/src/components/document/DocumentUploader.tsx +288 -0
  139. package/src/components/document/HyperlinkPreview.tsx +430 -0
  140. package/src/components/document/HyperlinkService.md +1484 -0
  141. package/src/components/document/Hyperlink_Technical_Documentation.md +496 -0
  142. package/src/components/document/InlineChangesView.tsx +707 -0
  143. package/src/components/document/ProcessingProgress.tsx +303 -0
  144. package/src/components/document/ProcessingResults.tsx +256 -0
  145. package/src/components/document/TrackedChangesDetail.tsx +530 -0
  146. package/src/components/document/TrackedChangesPanel.tsx +546 -0
  147. package/src/components/document/VirtualDocumentList.tsx +240 -0
  148. package/src/components/editor/DocumentEditor.tsx +723 -0
  149. package/src/components/editor/DocumentEditorModal.tsx +640 -0
  150. package/src/components/editor/EditorQuickActions.tsx +502 -0
  151. package/src/components/editor/EditorToolbar.tsx +312 -0
  152. package/src/components/editor/TableEditor.tsx +926 -0
  153. package/src/components/editor/index.ts +18 -0
  154. package/src/components/layout/Header.tsx +190 -0
  155. package/src/components/layout/Sidebar.tsx +313 -0
  156. package/src/components/layout/TitleBar.tsx +190 -0
  157. package/src/components/navigation/CommandPalette.tsx +233 -0
  158. package/src/components/navigation/KeyboardShortcutsModal.tsx +173 -0
  159. package/src/components/sessions/ChangeItem.tsx +408 -0
  160. package/src/components/sessions/ChangeViewer.tsx +1155 -0
  161. package/src/components/sessions/DocumentComparisonModal.tsx +314 -0
  162. package/src/components/sessions/ProcessingOptions.tsx +297 -0
  163. package/src/components/sessions/ReplacementsTab.tsx +438 -0
  164. package/src/components/sessions/RevisionHandlingOptions.tsx +87 -0
  165. package/src/components/sessions/SessionManager.tsx +188 -0
  166. package/src/components/sessions/StylesEditor.tsx +1335 -0
  167. package/src/components/sessions/TabContainer.tsx +151 -0
  168. package/src/components/sessions/VirtualSessionList.tsx +157 -0
  169. package/src/components/sessions/sessionToProcessorManager.tsx +420 -0
  170. package/src/components/settings/CertificateManager.tsx +410 -0
  171. package/src/components/settings/SegmentedControl.tsx +88 -0
  172. package/src/components/settings/SettingRow.tsx +52 -0
  173. package/src/contexts/GlobalStatsContext.tsx +396 -0
  174. package/src/contexts/SessionContext.tsx +2129 -0
  175. package/src/contexts/ThemeContext.tsx +428 -0
  176. package/src/contexts/UserSettingsContext.tsx +290 -0
  177. package/src/contexts/__tests__/GlobalStatsContext.test.tsx +390 -0
  178. package/src/global.d.ts +273 -0
  179. package/src/hooks/useDocumentQueue.tsx +210 -0
  180. package/src/hooks/useToast.tsx +55 -0
  181. package/src/main.tsx +10 -0
  182. package/src/pages/Analytics.tsx +386 -0
  183. package/src/pages/CurrentSession.tsx +1174 -0
  184. package/src/pages/Dashboard.tsx +319 -0
  185. package/src/pages/Documents.tsx +317 -0
  186. package/src/pages/Projects.tsx +250 -0
  187. package/src/pages/Reporting.tsx +386 -0
  188. package/src/pages/Search.tsx +349 -0
  189. package/src/pages/Sessions.tsx +285 -0
  190. package/src/pages/Settings.tsx +2662 -0
  191. package/src/services/HyperlinkService.ts +1085 -0
  192. package/src/services/document/DocXMLaterProcessor.ts +617 -0
  193. package/src/services/document/DocumentProcessingComparison.ts +856 -0
  194. package/src/services/document/DocumentSnapshotService.ts +575 -0
  195. package/src/services/document/WordDocumentProcessor.ts +10509 -0
  196. package/src/services/document/__tests__/DocXMLaterProcessor.hyperlinks.test.md +311 -0
  197. package/src/services/document/__tests__/WordDocumentProcessor.integration.test.ts +515 -0
  198. package/src/services/document/__tests__/WordDocumentProcessor.test.ts +812 -0
  199. package/src/services/document/blanklines/BlankLineManager.ts +658 -0
  200. package/src/services/document/blanklines/__tests__/paragraphChecks.test.ts +281 -0
  201. package/src/services/document/blanklines/helpers/blankLineInsertion.ts +87 -0
  202. package/src/services/document/blanklines/helpers/blankLineSnapshot.ts +251 -0
  203. package/src/services/document/blanklines/helpers/clearCustom.ts +121 -0
  204. package/src/services/document/blanklines/helpers/contextChecks.ts +117 -0
  205. package/src/services/document/blanklines/helpers/imageChecks.ts +51 -0
  206. package/src/services/document/blanklines/helpers/paragraphChecks.ts +236 -0
  207. package/src/services/document/blanklines/helpers/removeBlanksBetweenListItems.ts +91 -0
  208. package/src/services/document/blanklines/helpers/removeTrailingBlanks.ts +35 -0
  209. package/src/services/document/blanklines/helpers/tableGuards.ts +21 -0
  210. package/src/services/document/blanklines/index.ts +67 -0
  211. package/src/services/document/blanklines/rules/additionRules.ts +337 -0
  212. package/src/services/document/blanklines/rules/indentationRules.ts +317 -0
  213. package/src/services/document/blanklines/rules/removalRules.ts +362 -0
  214. package/src/services/document/blanklines/rules/ruleTypes.ts +92 -0
  215. package/src/services/document/blanklines/types.ts +29 -0
  216. package/src/services/document/helpers/ImageBorderCropper.ts +377 -0
  217. package/src/services/document/helpers/__tests__/whitespace.test.ts +272 -0
  218. package/src/services/document/helpers/whitespace.ts +117 -0
  219. package/src/services/document/list/ListNormalizer.ts +947 -0
  220. package/src/services/document/list/index.ts +45 -0
  221. package/src/services/document/list/list-detection.ts +275 -0
  222. package/src/services/document/list/list-types.ts +162 -0
  223. package/src/services/document/processors/HyperlinkProcessor.ts +370 -0
  224. package/src/services/document/processors/ListProcessor.ts +257 -0
  225. package/src/services/document/processors/StructureProcessor.ts +176 -0
  226. package/src/services/document/processors/StyleProcessor.ts +389 -0
  227. package/src/services/document/processors/TableProcessor.ts +2238 -0
  228. package/src/services/document/processors/__tests__/HyperlinkProcessor.test.ts +314 -0
  229. package/src/services/document/processors/__tests__/ListProcessor.test.ts +291 -0
  230. package/src/services/document/processors/__tests__/StructureProcessor.test.ts +257 -0
  231. package/src/services/document/processors/__tests__/TableProcessor.hlp-tips-bullets.test.ts +459 -0
  232. package/src/services/document/processors/__tests__/TableProcessor.test.ts +1604 -0
  233. package/src/services/document/processors/index.ts +28 -0
  234. package/src/services/document/types/docx-processing.ts +310 -0
  235. package/src/services/editor/EditorActionHandlers.ts +901 -0
  236. package/src/services/editor/index.ts +13 -0
  237. package/src/setupTests.ts +47 -0
  238. package/src/styles/global.css +782 -0
  239. package/src/types/backup.ts +132 -0
  240. package/src/types/dictionary.ts +125 -0
  241. package/src/types/document-processing.ts +331 -0
  242. package/src/types/docxmlater-augments.d.ts +142 -0
  243. package/src/types/editor.ts +280 -0
  244. package/src/types/electron.ts +340 -0
  245. package/src/types/globalStats.ts +155 -0
  246. package/src/types/hyperlink.ts +471 -0
  247. package/src/types/operations.ts +354 -0
  248. package/src/types/session.ts +427 -0
  249. package/src/types/settings.ts +112 -0
  250. package/src/utils/MemoryMonitor.ts +248 -0
  251. package/src/utils/cn.ts +6 -0
  252. package/src/utils/colorConvert.ts +306 -0
  253. package/src/utils/diffUtils.ts +347 -0
  254. package/src/utils/documentUtils.ts +202 -0
  255. package/src/utils/electronGuard.ts +62 -0
  256. package/src/utils/indexedDB.ts +915 -0
  257. package/src/utils/logger.ts +717 -0
  258. package/src/utils/pathSecurity.ts +232 -0
  259. package/src/utils/pathValidator.ts +236 -0
  260. package/src/utils/processingTimeEstimator.ts +153 -0
  261. package/src/utils/safeJsonParse.ts +62 -0
  262. package/src/utils/textSanitizer.ts +162 -0
  263. package/src/utils/urlHelpers.ts +304 -0
  264. package/src/utils/urlPatterns.ts +198 -0
  265. package/src/utils/urlSanitizer.ts +152 -0
  266. package/src/vite-env.d.ts +11 -0
  267. package/tsconfig.electron.json +19 -0
  268. package/tsconfig.json +36 -0
  269. package/tsconfig.node.json +12 -0
  270. package/typedoc.json +45 -0
  271. package/vite.config.ts +152 -0
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Backup Service Type Definitions
3
+ *
4
+ * These types are shared between main process (BackupService)
5
+ * and renderer process (via IPC) for type-safe backup operations.
6
+ */
7
+
8
+ /**
9
+ * Information about a single backup file
10
+ */
11
+ export interface BackupInfo {
12
+ /** Absolute path to the backup file */
13
+ path: string;
14
+
15
+ /** Filename of the backup (without directory) */
16
+ filename: string;
17
+
18
+ /** Size of backup file in bytes */
19
+ size: number;
20
+
21
+ /** Date when backup was created */
22
+ created: Date;
23
+
24
+ /** Date when backup was last modified */
25
+ modified: Date;
26
+
27
+ /** Path to the original document */
28
+ originalPath: string;
29
+
30
+ /** SHA-256 checksum of backup file (for integrity verification) */
31
+ checksum?: string;
32
+ }
33
+
34
+ /**
35
+ * Metadata stored alongside each backup
36
+ */
37
+ export interface BackupMetadata {
38
+ /** Path to the original document */
39
+ originalPath: string;
40
+
41
+ /** Path where backup is stored */
42
+ backupPath: string;
43
+
44
+ /** ISO timestamp of backup creation */
45
+ timestamp: string;
46
+
47
+ /** Size of backed up document in bytes */
48
+ size: number;
49
+
50
+ /** SHA-256 checksum for integrity verification */
51
+ checksum: string;
52
+ }
53
+
54
+ /**
55
+ * Storage statistics for all backups
56
+ */
57
+ export interface StorageInfo {
58
+ /** Total size of all backups in bytes */
59
+ totalSize: number;
60
+
61
+ /** Total number of backup files */
62
+ fileCount: number;
63
+
64
+ /** Average size per backup in bytes */
65
+ averageSize: number;
66
+
67
+ /** Path to backup directory */
68
+ path: string;
69
+ }
70
+
71
+ /**
72
+ * Configuration options for BackupService
73
+ */
74
+ export interface BackupConfig {
75
+ /** Custom backup directory (default: ~/.dochub/backups) */
76
+ backupDir?: string;
77
+
78
+ /** Maximum age of backups in days (default: 7) */
79
+ maxBackupAgeDays?: number;
80
+
81
+ /** Maximum number of backups to keep per document (default: 5) */
82
+ maxBackupsPerDocument?: number;
83
+ }
84
+
85
+ /**
86
+ * IPC Response types for backup operations
87
+ */
88
+
89
+ export interface BackupCreateResponse {
90
+ success: boolean;
91
+ backupPath?: string;
92
+ error?: string;
93
+ }
94
+
95
+ export interface BackupRestoreResponse {
96
+ success: boolean;
97
+ error?: string;
98
+ }
99
+
100
+ export interface BackupListResponse {
101
+ success: boolean;
102
+ backups: BackupInfo[];
103
+ error?: string;
104
+ }
105
+
106
+ export interface BackupDeleteResponse {
107
+ success: boolean;
108
+ error?: string;
109
+ }
110
+
111
+ export interface BackupCleanupResponse {
112
+ success: boolean;
113
+ deletedCount: number;
114
+ error?: string;
115
+ }
116
+
117
+ export interface BackupVerifyResponse {
118
+ success: boolean;
119
+ isValid: boolean;
120
+ error?: string;
121
+ }
122
+
123
+ export interface BackupStorageInfoResponse {
124
+ success: boolean;
125
+ storageInfo?: StorageInfo;
126
+ error?: string;
127
+ }
128
+
129
+ export interface BackupSetConfigResponse {
130
+ success: boolean;
131
+ error?: string;
132
+ }
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Dictionary Types for Local SharePoint Dictionary Integration
3
+ *
4
+ * These types define the structure for storing and querying the
5
+ * SharePoint Dictionary.xlsx file locally using SQLite.
6
+ */
7
+
8
+ /**
9
+ * Represents a single entry from the Dictionary.xlsx file
10
+ * Matches the structure of the "Dictionary_Table" in "Daily_Inventory" sheet
11
+ */
12
+ export interface DictionaryEntry {
13
+ Document_ID: string;
14
+ Content_ID: string;
15
+ Title: string;
16
+ Summary: string;
17
+ Type: string;
18
+ Release_Date: string;
19
+ Expiration_Date: string;
20
+ Status: string;
21
+ Owner: string;
22
+ BPO: string;
23
+ LOB: string;
24
+ Last_Published_By: string;
25
+ }
26
+
27
+ /**
28
+ * Result of a dictionary lookup operation
29
+ */
30
+ export interface DictionaryLookupResult {
31
+ found: boolean;
32
+ entry?: DictionaryEntry;
33
+ lookupId: string;
34
+ lookupType: 'Document_ID' | 'Content_ID';
35
+ }
36
+
37
+ /**
38
+ * Batch lookup result for multiple IDs
39
+ */
40
+ export interface DictionaryBatchLookupResult {
41
+ results: Map<string, DictionaryLookupResult>;
42
+ found: number;
43
+ notFound: number;
44
+ totalRequested: number;
45
+ }
46
+
47
+ /**
48
+ * Current status of the dictionary sync operation
49
+ */
50
+ export interface DictionarySyncStatus {
51
+ enabled: boolean;
52
+ lastSyncTime: string | null;
53
+ lastSyncSuccess: boolean;
54
+ totalEntries: number;
55
+ syncInProgress: boolean;
56
+ syncProgress: number;
57
+ syncError: string | null;
58
+ nextScheduledSync: string | null;
59
+ fileHash: string | null;
60
+ }
61
+
62
+ /**
63
+ * SharePoint configuration for dictionary download
64
+ */
65
+ export interface SharePointConfig {
66
+ siteUrl: string;
67
+ documentLibraryPath: string;
68
+ tenantId: string;
69
+ clientId: string;
70
+ }
71
+
72
+ /**
73
+ * Progress update during sync operation
74
+ */
75
+ export interface SyncProgressUpdate {
76
+ phase: 'authenticating' | 'downloading' | 'parsing' | 'importing' | 'complete' | 'error';
77
+ progress: number;
78
+ message: string;
79
+ entriesProcessed?: number;
80
+ totalEntries?: number;
81
+ }
82
+
83
+ /**
84
+ * Response from dictionary initialization
85
+ */
86
+ export interface DictionaryInitResponse {
87
+ success: boolean;
88
+ totalEntries: number;
89
+ error?: string;
90
+ }
91
+
92
+ /**
93
+ * Response from dictionary sync operation
94
+ */
95
+ export interface DictionarySyncResponse {
96
+ success: boolean;
97
+ entriesImported: number;
98
+ duration: number;
99
+ error?: string;
100
+ }
101
+
102
+ /**
103
+ * Response from setting credentials
104
+ */
105
+ export interface DictionaryCredentialsResponse {
106
+ success: boolean;
107
+ error?: string;
108
+ }
109
+
110
+ /**
111
+ * IPC channel names for dictionary operations
112
+ */
113
+ export const DICTIONARY_IPC_CHANNELS = {
114
+ INITIALIZE: 'dictionary:initialize',
115
+ CONFIGURE_SYNC: 'dictionary:configure-sync',
116
+ SYNC: 'dictionary:sync',
117
+ START_SCHEDULER: 'dictionary:start-scheduler',
118
+ STOP_SCHEDULER: 'dictionary:stop-scheduler',
119
+ LOOKUP: 'dictionary:lookup',
120
+ BATCH_LOOKUP: 'dictionary:batch-lookup',
121
+ GET_STATUS: 'dictionary:get-status',
122
+ SET_CREDENTIALS: 'dictionary:set-credentials',
123
+ SYNC_PROGRESS: 'dictionary:sync-progress',
124
+ SYNC_COMPLETE: 'dictionary:sync-complete',
125
+ } as const;
@@ -0,0 +1,331 @@
1
+ /**
2
+ * Core type definitions for document processing
3
+ * Following TypeScript 2025 best practices with strict type safety
4
+ */
5
+
6
+ import JSZip from 'jszip';
7
+
8
+ // Template literal types for document parts
9
+ export type DocumentPart = `word/${
10
+ | 'document.xml'
11
+ | 'styles.xml'
12
+ | 'numbering.xml'
13
+ | 'settings.xml'
14
+ | 'fontTable.xml'
15
+ | 'header1.xml'
16
+ | 'footer1.xml'}`;
17
+
18
+ // Relationship types in OpenXML
19
+ export type RelationshipType =
20
+ | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink'
21
+ | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles'
22
+ | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/header'
23
+ | 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer';
24
+
25
+ // Document structure with readonly properties for immutability
26
+ export interface DocumentStructure {
27
+ readonly parts: ReadonlyArray<string>;
28
+ readonly relationships: ReadonlyArray<RelationshipInfo>;
29
+ readonly hasStyles: boolean;
30
+ readonly hasNumbering: boolean;
31
+ readonly statistics: Readonly<DocumentStatistics>;
32
+ }
33
+
34
+ export interface DocumentStatistics {
35
+ paragraphCount: number;
36
+ tableCount: number;
37
+ imageCount: number;
38
+ hyperlinkCount: number;
39
+ wordCount?: number;
40
+ characterCount?: number;
41
+ }
42
+
43
+ export interface RelationshipInfo {
44
+ readonly id: string;
45
+ readonly type: RelationshipType;
46
+ readonly target: string;
47
+ readonly targetMode?: 'External' | 'Internal';
48
+ }
49
+
50
+ // Processing options with granular control
51
+ export interface DocumentProcessingOptions {
52
+ createBackup?: boolean;
53
+ validateBeforeProcessing?: boolean;
54
+ preserveOriginalFormatting?: boolean;
55
+ processInChunks?: boolean;
56
+ chunkSize?: number;
57
+ timeout?: number; // in milliseconds
58
+ maxRetries?: number;
59
+ retryDelay?: number; // in milliseconds
60
+ }
61
+
62
+ // Processing result with detailed feedback
63
+ export interface ProcessingResult {
64
+ success: boolean;
65
+ documentPath: string;
66
+ backupPath?: string;
67
+ startTime: Date;
68
+ endTime: Date;
69
+ duration: number; // in milliseconds
70
+ statistics: ProcessingStatistics;
71
+ errors: ProcessingError[];
72
+ warnings: ProcessingWarning[];
73
+ }
74
+
75
+ export interface ProcessingStatistics {
76
+ totalElements: number;
77
+ processedElements: number;
78
+ skippedElements: number;
79
+ modifiedElements: number;
80
+ hyperlinksProcessed?: number;
81
+ stylesApplied?: number;
82
+ replacementsMade?: number;
83
+ }
84
+
85
+ export interface ProcessingError {
86
+ code: string;
87
+ message: string;
88
+ element?: string;
89
+ location?: string;
90
+ stack?: string;
91
+ recoverable: boolean;
92
+ }
93
+
94
+ export interface ProcessingWarning {
95
+ code: string;
96
+ message: string;
97
+ element?: string;
98
+ location?: string;
99
+ suggestion?: string;
100
+ }
101
+
102
+ // Document operation types
103
+ export type DocumentOperation =
104
+ | HyperlinkOperation
105
+ | StyleOperation
106
+ | TextOperation
107
+ | StructureOperation;
108
+
109
+ export interface BaseOperation {
110
+ id: string;
111
+ type: 'hyperlink' | 'style' | 'text' | 'structure';
112
+ description: string;
113
+ critical?: boolean; // If true, failure stops all processing
114
+ priority?: number; // Higher priority operations execute first
115
+ }
116
+
117
+ export interface HyperlinkOperation extends BaseOperation {
118
+ type: 'hyperlink';
119
+ action: 'update' | 'validate' | 'remove' | 'append';
120
+ targetPattern?: RegExp;
121
+ replacement?: string;
122
+ contentId?: string;
123
+ }
124
+
125
+ export interface StyleOperation extends BaseOperation {
126
+ type: 'style';
127
+ action: 'apply' | 'remove' | 'modify';
128
+ styleName: string;
129
+ properties?: Record<string, unknown>;
130
+ }
131
+
132
+ export interface TextOperation extends BaseOperation {
133
+ type: 'text';
134
+ action: 'replace' | 'remove' | 'format';
135
+ pattern: string | RegExp;
136
+ replacement?: string;
137
+ caseSensitive?: boolean;
138
+ wholeWord?: boolean;
139
+ }
140
+
141
+ export interface StructureOperation extends BaseOperation {
142
+ type: 'structure';
143
+ action: 'reorder' | 'indent' | 'align';
144
+ target: 'lists' | 'tables' | 'paragraphs' | 'images';
145
+ options?: Record<string, unknown>;
146
+ }
147
+
148
+ // Batch processing types
149
+ export interface BatchProcessingOptions extends DocumentProcessingOptions {
150
+ concurrency?: number; // Number of documents to process in parallel
151
+ continueOnError?: boolean;
152
+ progressCallback?: (progress: BatchProgress) => void;
153
+ }
154
+
155
+ export interface BatchProgress {
156
+ totalFiles: number;
157
+ processedFiles: number;
158
+ currentFile?: string;
159
+ currentFileProgress?: number; // 0-100
160
+ overallProgress: number; // 0-100
161
+ errors: number;
162
+ warnings: number;
163
+ estimatedTimeRemaining?: number; // in milliseconds
164
+ }
165
+
166
+ export interface BatchResult {
167
+ totalFiles: number;
168
+ successfulFiles: number;
169
+ failedFiles: number;
170
+ results: ProcessingResult[];
171
+ duration: number;
172
+ errors: BatchError[];
173
+ }
174
+
175
+ export interface BatchError extends ProcessingError {
176
+ filePath: string;
177
+ fileIndex: number;
178
+ }
179
+
180
+ // Document metadata
181
+ export interface DocumentMetadata {
182
+ title?: string;
183
+ subject?: string;
184
+ creator?: string;
185
+ keywords?: string[];
186
+ description?: string;
187
+ lastModifiedBy?: string;
188
+ revision?: string;
189
+ created?: Date;
190
+ modified?: Date;
191
+ lastPrinted?: Date;
192
+ category?: string;
193
+ contentStatus?: string;
194
+ language?: string;
195
+ }
196
+
197
+ // XML parsing types
198
+ export interface ParsedXML {
199
+ root: XMLElement;
200
+ namespaces: Record<string, string>;
201
+ encoding?: string;
202
+ version?: string;
203
+ }
204
+
205
+ export interface XMLElement {
206
+ name: string;
207
+ attributes: Record<string, string>;
208
+ children: XMLElement[];
209
+ text?: string;
210
+ namespace?: string;
211
+ }
212
+
213
+ // Utility type for deep readonly
214
+ export type DeepReadonly<T> = {
215
+ readonly [P in keyof T]: T[P] extends object
216
+ ? T[P] extends (...args: any[]) => any
217
+ ? T[P]
218
+ : DeepReadonly<T[P]>
219
+ : T[P];
220
+ };
221
+
222
+ // Either pattern for error handling
223
+ export type Either<L, R> = { ok: false; error: L } | { ok: true; value: R };
224
+
225
+ // Result type for operations that can fail
226
+ export type Result<T, E = Error> = Either<E, T>;
227
+
228
+ // Conditional type for operation results
229
+ export type OperationResult<T> = T extends { critical: true }
230
+ ? { success: true; data: T } | { success: false; error: Error }
231
+ : { success: boolean; data?: T; warning?: string };
232
+
233
+ // Document processing context
234
+ export interface ProcessingContext {
235
+ document: JSZip;
236
+ documentPath: string;
237
+ backupPath?: string;
238
+ operations: DocumentOperation[];
239
+ options: DocumentProcessingOptions;
240
+ statistics: ProcessingStatistics;
241
+ errors: ProcessingError[];
242
+ warnings: ProcessingWarning[];
243
+ metadata?: DocumentMetadata;
244
+ cache: Map<string, unknown>;
245
+ startTime: Date;
246
+ }
247
+
248
+ // Stream processing types for large documents
249
+ export interface StreamOptions {
250
+ chunkSize: number;
251
+ encoding?: BufferEncoding;
252
+ highWaterMark?: number;
253
+ }
254
+
255
+ export interface ProcessedChunk {
256
+ index: number;
257
+ content: string | Buffer;
258
+ progress: number;
259
+ bytesProcessed: number;
260
+ totalBytes?: number;
261
+ }
262
+
263
+ // Change tracking types
264
+ export interface DocumentChange {
265
+ id: string;
266
+ timestamp: Date;
267
+ type: 'addition' | 'deletion' | 'modification' | 'move';
268
+ element: string;
269
+ originalContent?: string;
270
+ newContent?: string;
271
+ originalPosition?: number;
272
+ newPosition?: number;
273
+ author?: string;
274
+ description?: string;
275
+ }
276
+
277
+ export interface ChangeSet {
278
+ documentId: string;
279
+ documentPath: string;
280
+ changes: DocumentChange[];
281
+ summary: ChangeSummary;
282
+ }
283
+
284
+ export interface ChangeSummary {
285
+ totalChanges: number;
286
+ additions: number;
287
+ deletions: number;
288
+ modifications: number;
289
+ moves: number;
290
+ authors: string[];
291
+ startTime: Date;
292
+ endTime: Date;
293
+ }
294
+
295
+ // Validation types
296
+ export interface ValidationOptions {
297
+ checkStructure?: boolean;
298
+ checkRelationships?: boolean;
299
+ checkStyles?: boolean;
300
+ checkHyperlinks?: boolean;
301
+ checkImages?: boolean;
302
+ checkMetadata?: boolean;
303
+ strictMode?: boolean;
304
+ }
305
+
306
+ export interface ValidationResult {
307
+ valid: boolean;
308
+ issues: ValidationIssue[];
309
+ suggestions: ValidationSuggestion[];
310
+ score?: number; // 0-100 quality score
311
+ }
312
+
313
+ export interface ValidationIssue {
314
+ severity: 'error' | 'warning' | 'info';
315
+ code: string;
316
+ message: string;
317
+ location?: string;
318
+ element?: string;
319
+ fixable: boolean;
320
+ autoFix?: () => Promise<void>;
321
+ }
322
+
323
+ export interface ValidationSuggestion {
324
+ type: string;
325
+ message: string;
326
+ impact: 'high' | 'medium' | 'low';
327
+ implementation?: string;
328
+ }
329
+
330
+ // Export all types
331
+ export type { JSZip as DocumentArchive };