legal-markdown-js 0.1.0

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 (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +168 -0
  3. package/dist/browser.d.ts +87 -0
  4. package/dist/browser.d.ts.map +1 -0
  5. package/dist/browser.js +157 -0
  6. package/dist/browser.js.map +1 -0
  7. package/dist/cli/index.d.ts +34 -0
  8. package/dist/cli/index.d.ts.map +1 -0
  9. package/dist/cli/index.js +221 -0
  10. package/dist/cli/index.js.map +1 -0
  11. package/dist/cli/service.d.ts +128 -0
  12. package/dist/cli/service.d.ts.map +1 -0
  13. package/dist/cli/service.js +284 -0
  14. package/dist/cli/service.js.map +1 -0
  15. package/dist/constants/index.d.ts +229 -0
  16. package/dist/constants/index.d.ts.map +1 -0
  17. package/dist/constants/index.js +232 -0
  18. package/dist/constants/index.js.map +1 -0
  19. package/dist/core/exporters/metadata-exporter.d.ts +104 -0
  20. package/dist/core/exporters/metadata-exporter.d.ts.map +1 -0
  21. package/dist/core/exporters/metadata-exporter.js +201 -0
  22. package/dist/core/exporters/metadata-exporter.js.map +1 -0
  23. package/dist/core/index.d.ts +40 -0
  24. package/dist/core/index.d.ts.map +1 -0
  25. package/dist/core/index.js +56 -0
  26. package/dist/core/index.js.map +1 -0
  27. package/dist/core/parsers/yaml-parser.d.ts +149 -0
  28. package/dist/core/parsers/yaml-parser.d.ts.map +1 -0
  29. package/dist/core/parsers/yaml-parser.js +321 -0
  30. package/dist/core/parsers/yaml-parser.js.map +1 -0
  31. package/dist/core/processors/clause-processor.d.ts +74 -0
  32. package/dist/core/processors/clause-processor.d.ts.map +1 -0
  33. package/dist/core/processors/clause-processor.js +213 -0
  34. package/dist/core/processors/clause-processor.js.map +1 -0
  35. package/dist/core/processors/date-processor.d.ts +90 -0
  36. package/dist/core/processors/date-processor.d.ts.map +1 -0
  37. package/dist/core/processors/date-processor.js +336 -0
  38. package/dist/core/processors/date-processor.js.map +1 -0
  39. package/dist/core/processors/header-processor.d.ts +104 -0
  40. package/dist/core/processors/header-processor.d.ts.map +1 -0
  41. package/dist/core/processors/header-processor.js +585 -0
  42. package/dist/core/processors/header-processor.js.map +1 -0
  43. package/dist/core/processors/import-processor.d.ts +116 -0
  44. package/dist/core/processors/import-processor.d.ts.map +1 -0
  45. package/dist/core/processors/import-processor.js +236 -0
  46. package/dist/core/processors/import-processor.js.map +1 -0
  47. package/dist/core/processors/mixin-processor.d.ts +93 -0
  48. package/dist/core/processors/mixin-processor.d.ts.map +1 -0
  49. package/dist/core/processors/mixin-processor.js +378 -0
  50. package/dist/core/processors/mixin-processor.js.map +1 -0
  51. package/dist/core/processors/reference-processor.d.ts +115 -0
  52. package/dist/core/processors/reference-processor.d.ts.map +1 -0
  53. package/dist/core/processors/reference-processor.js +273 -0
  54. package/dist/core/processors/reference-processor.js.map +1 -0
  55. package/dist/errors/index.d.ts +234 -0
  56. package/dist/errors/index.d.ts.map +1 -0
  57. package/dist/errors/index.js +267 -0
  58. package/dist/errors/index.js.map +1 -0
  59. package/dist/extensions/batch-processor.d.ts +197 -0
  60. package/dist/extensions/batch-processor.d.ts.map +1 -0
  61. package/dist/extensions/batch-processor.js +392 -0
  62. package/dist/extensions/batch-processor.js.map +1 -0
  63. package/dist/extensions/formatters/index.d.ts +99 -0
  64. package/dist/extensions/formatters/index.d.ts.map +1 -0
  65. package/dist/extensions/formatters/index.js +128 -0
  66. package/dist/extensions/formatters/index.js.map +1 -0
  67. package/dist/extensions/index.d.ts +53 -0
  68. package/dist/extensions/index.d.ts.map +1 -0
  69. package/dist/extensions/index.js +71 -0
  70. package/dist/extensions/index.js.map +1 -0
  71. package/dist/extensions/latex-parser.d.ts +111 -0
  72. package/dist/extensions/latex-parser.d.ts.map +1 -0
  73. package/dist/extensions/latex-parser.js +563 -0
  74. package/dist/extensions/latex-parser.js.map +1 -0
  75. package/dist/extensions/rst-parser.d.ts +112 -0
  76. package/dist/extensions/rst-parser.d.ts.map +1 -0
  77. package/dist/extensions/rst-parser.js +268 -0
  78. package/dist/extensions/rst-parser.js.map +1 -0
  79. package/dist/extensions/template-loops.d.ts +61 -0
  80. package/dist/extensions/template-loops.d.ts.map +1 -0
  81. package/dist/extensions/template-loops.js +418 -0
  82. package/dist/extensions/template-loops.js.map +1 -0
  83. package/dist/extensions/utilities/index.d.ts +114 -0
  84. package/dist/extensions/utilities/index.d.ts.map +1 -0
  85. package/dist/extensions/utilities/index.js +137 -0
  86. package/dist/extensions/utilities/index.js.map +1 -0
  87. package/dist/extensions/validators/index.d.ts +65 -0
  88. package/dist/extensions/validators/index.d.ts.map +1 -0
  89. package/dist/extensions/validators/index.js +88 -0
  90. package/dist/extensions/validators/index.js.map +1 -0
  91. package/dist/generators/html-generator.d.ts +184 -0
  92. package/dist/generators/html-generator.d.ts.map +1 -0
  93. package/dist/generators/html-generator.js +361 -0
  94. package/dist/generators/html-generator.js.map +1 -0
  95. package/dist/generators/pdf-generator.d.ts +165 -0
  96. package/dist/generators/pdf-generator.d.ts.map +1 -0
  97. package/dist/generators/pdf-generator.js +275 -0
  98. package/dist/generators/pdf-generator.js.map +1 -0
  99. package/dist/helpers/date-helpers.d.ts +216 -0
  100. package/dist/helpers/date-helpers.d.ts.map +1 -0
  101. package/dist/helpers/date-helpers.js +402 -0
  102. package/dist/helpers/date-helpers.js.map +1 -0
  103. package/dist/helpers/index.d.ts +87 -0
  104. package/dist/helpers/index.d.ts.map +1 -0
  105. package/dist/helpers/index.js +149 -0
  106. package/dist/helpers/index.js.map +1 -0
  107. package/dist/helpers/number-helpers.d.ts +269 -0
  108. package/dist/helpers/number-helpers.d.ts.map +1 -0
  109. package/dist/helpers/number-helpers.js +406 -0
  110. package/dist/helpers/number-helpers.js.map +1 -0
  111. package/dist/helpers/string-helpers.d.ts +391 -0
  112. package/dist/helpers/string-helpers.d.ts.map +1 -0
  113. package/dist/helpers/string-helpers.js +549 -0
  114. package/dist/helpers/string-helpers.js.map +1 -0
  115. package/dist/index.d.ts +229 -0
  116. package/dist/index.d.ts.map +1 -0
  117. package/dist/index.js +384 -0
  118. package/dist/index.js.map +1 -0
  119. package/dist/legal-markdown.umd.min.js +2 -0
  120. package/dist/legal-markdown.umd.min.js.LICENSE.txt +14 -0
  121. package/dist/legal-markdown.umd.min.js.map +1 -0
  122. package/dist/lib/index.d.ts +150 -0
  123. package/dist/lib/index.d.ts.map +1 -0
  124. package/dist/lib/index.js +265 -0
  125. package/dist/lib/index.js.map +1 -0
  126. package/dist/parsers/content-detector.d.ts +131 -0
  127. package/dist/parsers/content-detector.d.ts.map +1 -0
  128. package/dist/parsers/content-detector.js +220 -0
  129. package/dist/parsers/content-detector.js.map +1 -0
  130. package/dist/parsers/fallback-parsers.d.ts +14 -0
  131. package/dist/parsers/fallback-parsers.d.ts.map +1 -0
  132. package/dist/parsers/fallback-parsers.js +188 -0
  133. package/dist/parsers/fallback-parsers.js.map +1 -0
  134. package/dist/parsers/implementations/pandoc-native.d.ts +13 -0
  135. package/dist/parsers/implementations/pandoc-native.d.ts.map +1 -0
  136. package/dist/parsers/implementations/pandoc-native.js +63 -0
  137. package/dist/parsers/implementations/pandoc-native.js.map +1 -0
  138. package/dist/parsers/implementations/pandoc-wasm.d.ts +14 -0
  139. package/dist/parsers/implementations/pandoc-wasm.d.ts.map +1 -0
  140. package/dist/parsers/implementations/pandoc-wasm.js +64 -0
  141. package/dist/parsers/implementations/pandoc-wasm.js.map +1 -0
  142. package/dist/parsers/pandoc-factory.d.ts +97 -0
  143. package/dist/parsers/pandoc-factory.d.ts.map +1 -0
  144. package/dist/parsers/pandoc-factory.js +146 -0
  145. package/dist/parsers/pandoc-factory.js.map +1 -0
  146. package/dist/parsers/pandoc-loader.d.ts +24 -0
  147. package/dist/parsers/pandoc-loader.d.ts.map +1 -0
  148. package/dist/parsers/pandoc-loader.js +124 -0
  149. package/dist/parsers/pandoc-loader.js.map +1 -0
  150. package/dist/parsers/pandoc-parser.d.ts +27 -0
  151. package/dist/parsers/pandoc-parser.d.ts.map +1 -0
  152. package/dist/parsers/pandoc-parser.js +3 -0
  153. package/dist/parsers/pandoc-parser.js.map +1 -0
  154. package/dist/styles/default.css +125 -0
  155. package/dist/styles/headers.css +146 -0
  156. package/dist/styles/highlight.css +171 -0
  157. package/dist/tracking/field-tracker.d.ts +206 -0
  158. package/dist/tracking/field-tracker.d.ts.map +1 -0
  159. package/dist/tracking/field-tracker.js +247 -0
  160. package/dist/tracking/field-tracker.js.map +1 -0
  161. package/dist/types.d.ts +186 -0
  162. package/dist/types.d.ts.map +1 -0
  163. package/dist/types.js +33 -0
  164. package/dist/types.js.map +1 -0
  165. package/dist/utils/logger.d.ts +107 -0
  166. package/dist/utils/logger.d.ts.map +1 -0
  167. package/dist/utils/logger.js +122 -0
  168. package/dist/utils/logger.js.map +1 -0
  169. package/dist/web/bundle-standalone.js +28 -0
  170. package/dist/web/bundle.js +17 -0
  171. package/dist/web/index.html +1465 -0
  172. package/dist/web/legal-markdown.umd.min.js +2 -0
  173. package/dist/web/standalone.html +390 -0
  174. package/dist/web/styles.css +874 -0
  175. package/package.json +118 -0
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Custom Error Classes for Legal Markdown Processing
4
+ *
5
+ * This module provides a comprehensive set of custom error classes for the Legal Markdown
6
+ * processing system. All errors inherit from a base LegalMarkdownError class that provides
7
+ * structured error handling with error codes and contextual information.
8
+ *
9
+ * Features:
10
+ * - Base LegalMarkdownError class with error codes and context
11
+ * - Specialized error classes for different failure scenarios
12
+ * - Structured error information for debugging and user feedback
13
+ * - Proper stack trace preservation
14
+ * - Contextual data attachment for detailed error reporting
15
+ * - Type-safe error handling throughout the system
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { YamlParsingError, FileNotFoundError, ValidationError } from './errors';
20
+ *
21
+ * // YAML parsing error
22
+ * throw new YamlParsingError('Invalid YAML syntax', { line: 5, column: 12 });
23
+ *
24
+ * // File not found error
25
+ * throw new FileNotFoundError('./missing-file.md', { operation: 'import' });
26
+ *
27
+ * // Validation error
28
+ * throw new ValidationError('Field is required', 'client.name', { value: '' });
29
+ * ```
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.ProcessingError = exports.ValidationError = exports.MetadataExportError = exports.ImportProcessingError = exports.FileNotFoundError = exports.YamlParsingError = exports.LegalMarkdownError = void 0;
33
+ /**
34
+ * Base error class for all Legal Markdown processing errors
35
+ *
36
+ * Provides structured error handling with error codes and contextual information.
37
+ * All other error types in the system inherit from this base class.
38
+ *
39
+ * @class LegalMarkdownError
40
+ * @extends {Error}
41
+ * @example
42
+ * ```typescript
43
+ * import { LegalMarkdownError } from './errors';
44
+ *
45
+ * // Create a custom error with context
46
+ * const error = new LegalMarkdownError(
47
+ * 'Processing failed',
48
+ * 'PROCESSING_ERROR',
49
+ * { file: 'contract.md', step: 'field-resolution' }
50
+ * );
51
+ *
52
+ * console.log(error.code); // 'PROCESSING_ERROR'
53
+ * console.log(error.context); // { file: 'contract.md', step: 'field-resolution' }
54
+ * ```
55
+ */
56
+ class LegalMarkdownError extends Error {
57
+ /**
58
+ * Creates a new LegalMarkdownError instance
59
+ *
60
+ * @param {string} message - Human-readable error message
61
+ * @param {string} code - Error code for programmatic handling
62
+ * @param {Record<string, unknown>} [context] - Optional contextual data
63
+ * @example
64
+ * ```typescript
65
+ * const error = new LegalMarkdownError(
66
+ * 'Field resolution failed',
67
+ * 'FIELD_RESOLUTION_ERROR',
68
+ * { fieldName: 'client.name', value: undefined }
69
+ * );
70
+ * ```
71
+ */
72
+ constructor(message, code, context) {
73
+ super(message);
74
+ this.name = 'LegalMarkdownError';
75
+ this.code = code;
76
+ this.context = context;
77
+ // Maintains proper stack trace for where our error was thrown (only available on V8)
78
+ if (Error.captureStackTrace) {
79
+ Error.captureStackTrace(this, LegalMarkdownError);
80
+ }
81
+ }
82
+ }
83
+ exports.LegalMarkdownError = LegalMarkdownError;
84
+ /**
85
+ * Error thrown when YAML frontmatter parsing fails
86
+ *
87
+ * @class YamlParsingError
88
+ * @extends {LegalMarkdownError}
89
+ * @example
90
+ * ```typescript
91
+ * import { YamlParsingError } from './errors';
92
+ *
93
+ * // YAML parsing error with context
94
+ * throw new YamlParsingError('Invalid YAML syntax at line 5', {
95
+ * line: 5,
96
+ * column: 12,
97
+ * yamlContent: 'title: "Unterminated string...'
98
+ * });
99
+ * ```
100
+ */
101
+ class YamlParsingError extends LegalMarkdownError {
102
+ /**
103
+ * Creates a new YamlParsingError instance
104
+ *
105
+ * @param {string} message - Human-readable error message describing the YAML parsing issue
106
+ * @param {Record<string, unknown>} [context] - Optional contextual data like line number, column, etc.
107
+ */
108
+ constructor(message, context) {
109
+ super(message, 'YAML_PARSING_ERROR', context);
110
+ this.name = 'YamlParsingError';
111
+ }
112
+ }
113
+ exports.YamlParsingError = YamlParsingError;
114
+ /**
115
+ * Error thrown when a required file cannot be found
116
+ *
117
+ * @class FileNotFoundError
118
+ * @extends {LegalMarkdownError}
119
+ * @example
120
+ * ```typescript
121
+ * import { FileNotFoundError } from './errors';
122
+ *
123
+ * // File not found during import
124
+ * throw new FileNotFoundError('./imports/header.md', {
125
+ * operation: 'import',
126
+ * basePath: './documents'
127
+ * });
128
+ * ```
129
+ */
130
+ class FileNotFoundError extends LegalMarkdownError {
131
+ /**
132
+ * Creates a new FileNotFoundError instance
133
+ *
134
+ * @param {string} filePath - The path of the file that could not be found
135
+ * @param {Record<string, unknown>} [context] - Optional contextual data like operation type, base path, etc.
136
+ */
137
+ constructor(filePath, context) {
138
+ super(`File not found: ${filePath}`, 'FILE_NOT_FOUND', { filePath, ...context });
139
+ this.name = 'FileNotFoundError';
140
+ }
141
+ }
142
+ exports.FileNotFoundError = FileNotFoundError;
143
+ /**
144
+ * Error thrown when import processing fails
145
+ *
146
+ * @class ImportProcessingError
147
+ * @extends {LegalMarkdownError}
148
+ * @example
149
+ * ```typescript
150
+ * import { ImportProcessingError } from './errors';
151
+ *
152
+ * // Import processing error
153
+ * throw new ImportProcessingError(
154
+ * 'Circular import detected',
155
+ * './imports/header.md',
156
+ * { importChain: ['main.md', 'header.md', 'header.md'] }
157
+ * );
158
+ * ```
159
+ */
160
+ class ImportProcessingError extends LegalMarkdownError {
161
+ /**
162
+ * Creates a new ImportProcessingError instance
163
+ *
164
+ * @param {string} message - Human-readable error message describing the import processing issue
165
+ * @param {string} [filePath] - Optional file path where the import error occurred
166
+ * @param {Record<string, unknown>} [context] - Optional contextual data like import chain, operation details, etc.
167
+ */
168
+ constructor(message, filePath, context) {
169
+ super(message, 'IMPORT_PROCESSING_ERROR', { filePath, ...context });
170
+ this.name = 'ImportProcessingError';
171
+ }
172
+ }
173
+ exports.ImportProcessingError = ImportProcessingError;
174
+ /**
175
+ * Error thrown when metadata export operations fail
176
+ *
177
+ * @class MetadataExportError
178
+ * @extends {LegalMarkdownError}
179
+ * @example
180
+ * ```typescript
181
+ * import { MetadataExportError } from './errors';
182
+ *
183
+ * // Metadata export error
184
+ * throw new MetadataExportError(
185
+ * 'Failed to write metadata file',
186
+ * './output/metadata.yaml',
187
+ * { format: 'yaml', permissions: 'denied' }
188
+ * );
189
+ * ```
190
+ */
191
+ class MetadataExportError extends LegalMarkdownError {
192
+ /**
193
+ * Creates a new MetadataExportError instance
194
+ *
195
+ * @param {string} message - Human-readable error message describing the metadata export issue
196
+ * @param {string} [exportPath] - Optional path where the export was attempted
197
+ * @param {Record<string, unknown>} [context] - Optional contextual data like export format, permissions, etc.
198
+ */
199
+ constructor(message, exportPath, context) {
200
+ super(message, 'METADATA_EXPORT_ERROR', { exportPath, ...context });
201
+ this.name = 'MetadataExportError';
202
+ }
203
+ }
204
+ exports.MetadataExportError = MetadataExportError;
205
+ /**
206
+ * Error thrown when document validation fails
207
+ *
208
+ * @class ValidationError
209
+ * @extends {LegalMarkdownError}
210
+ * @example
211
+ * ```typescript
212
+ * import { ValidationError } from './errors';
213
+ *
214
+ * // Validation error for a specific field
215
+ * throw new ValidationError(
216
+ * 'Field value is required',
217
+ * 'client.name',
218
+ * { value: '', required: true, type: 'string' }
219
+ * );
220
+ * ```
221
+ */
222
+ class ValidationError extends LegalMarkdownError {
223
+ /**
224
+ * Creates a new ValidationError instance
225
+ *
226
+ * @param {string} message - Human-readable error message describing the validation issue
227
+ * @param {string} [field] - Optional field name that failed validation
228
+ * @param {Record<string, unknown>} [context] - Optional contextual data like expected value, validation rules, etc.
229
+ */
230
+ constructor(message, field, context) {
231
+ super(message, 'VALIDATION_ERROR', { field, ...context });
232
+ this.name = 'ValidationError';
233
+ }
234
+ }
235
+ exports.ValidationError = ValidationError;
236
+ /**
237
+ * Error thrown when general processing operations fail
238
+ *
239
+ * @class ProcessingError
240
+ * @extends {LegalMarkdownError}
241
+ * @example
242
+ * ```typescript
243
+ * import { ProcessingError } from './errors';
244
+ *
245
+ * // Processing error with processor information
246
+ * throw new ProcessingError(
247
+ * 'Field resolution failed',
248
+ * 'field-processor',
249
+ * { fieldCount: 25, failedFields: ['client.name', 'date'] }
250
+ * );
251
+ * ```
252
+ */
253
+ class ProcessingError extends LegalMarkdownError {
254
+ /**
255
+ * Creates a new ProcessingError instance
256
+ *
257
+ * @param {string} message - Human-readable error message describing the processing issue
258
+ * @param {string} [processor] - Optional name of the processor that failed
259
+ * @param {Record<string, unknown>} [context] - Optional contextual data like processing stage, affected items, etc.
260
+ */
261
+ constructor(message, processor, context) {
262
+ super(message, 'PROCESSING_ERROR', { processor, ...context });
263
+ this.name = 'ProcessingError';
264
+ }
265
+ }
266
+ exports.ProcessingError = ProcessingError;
267
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,kBAAmB,SAAQ,KAAK;IAM3C;;;;;;;;;;;;;;OAcG;IACH,YAAY,OAAe,EAAE,IAAY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a,mBAAoB,SAAQ,kBAAkB;IACzD;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,UAAmB,EAAE,OAAiC;QACjF,KAAK,CAAC,OAAO,EAAE,uBAAuB,EAAE,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAZD,kDAYC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,eAAgB,SAAQ,kBAAkB;IACrD;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,KAAc,EAAE,OAAiC;QAC5E,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAZD,0CAYC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,eAAgB,SAAQ,kBAAkB;IACrD;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,SAAkB,EAAE,OAAiC;QAChF,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAZD,0CAYC"}
@@ -0,0 +1,197 @@
1
+ /**
2
+ * @fileoverview Batch Processing Module for Legal Markdown Documents
3
+ *
4
+ * This module provides functionality for processing multiple Legal Markdown files
5
+ * in batch operations. It supports recursive directory processing, concurrent
6
+ * file operations, progress tracking, and error handling.
7
+ *
8
+ * Features:
9
+ * - Batch processing of multiple Legal Markdown files
10
+ * - Recursive directory traversal with pattern matching
11
+ * - Concurrent processing with configurable concurrency limits
12
+ * - Progress tracking and error reporting callbacks
13
+ * - Directory structure preservation in output
14
+ * - File extension filtering and exclusion patterns
15
+ * - Metadata export support for batch operations
16
+ * - Statistics and performance tracking
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { processBatch } from './batch-processor';
21
+ *
22
+ * // Basic batch processing
23
+ * const result = await processBatch({
24
+ * inputDir: './legal-docs',
25
+ * outputDir: './output',
26
+ * extensions: ['.md'],
27
+ * recursive: true
28
+ * });
29
+ *
30
+ * // Advanced batch processing with callbacks
31
+ * const result = await processBatch({
32
+ * inputDir: './contracts',
33
+ * outputDir: './processed-contracts',
34
+ * extensions: ['.md', '.txt'],
35
+ * recursive: true,
36
+ * concurrency: 3,
37
+ * exclude: ['temp', 'backup'],
38
+ * onProgress: (processed, total, currentFile) => {
39
+ * console.log(`Progress: ${processed}/${total} - ${currentFile}`);
40
+ * },
41
+ * onError: (file, error) => {
42
+ * console.error(`Error processing ${file}:`, error.message);
43
+ * }
44
+ * });
45
+ * ```
46
+ */
47
+ import { LegalMarkdownOptions } from '@types';
48
+ /**
49
+ * Configuration options for batch processing operations
50
+ *
51
+ * Extends LegalMarkdownOptions to include batch-specific settings like
52
+ * directory paths, concurrency control, and progress callbacks.
53
+ *
54
+ * @interface BatchProcessingOptions
55
+ * @extends {LegalMarkdownOptions}
56
+ * @example
57
+ * ```typescript
58
+ * const options: BatchProcessingOptions = {
59
+ * inputDir: './legal-documents',
60
+ * outputDir: './processed-documents',
61
+ * extensions: ['.md', '.txt'],
62
+ * recursive: true,
63
+ * preserveStructure: true,
64
+ * exclude: ['temp', 'backup'],
65
+ * concurrency: 5,
66
+ * onProgress: (processed, total, currentFile) => {
67
+ * console.log(`Processing: ${currentFile} (${processed}/${total})`);
68
+ * }
69
+ * };
70
+ * ```
71
+ */
72
+ export interface BatchProcessingOptions extends LegalMarkdownOptions {
73
+ /** Input directory containing files to process */
74
+ inputDir: string;
75
+ /** Output directory for processed files */
76
+ outputDir: string;
77
+ /** File extensions to process (defaults to ['.md', '.txt']) */
78
+ extensions?: string[];
79
+ /** Whether to process subdirectories recursively */
80
+ recursive?: boolean;
81
+ /** Whether to preserve directory structure in output */
82
+ preserveStructure?: boolean;
83
+ /** Pattern to exclude files/directories */
84
+ exclude?: string[];
85
+ /** Maximum number of concurrent file processing operations */
86
+ concurrency?: number;
87
+ /** Callback for progress updates during batch processing */
88
+ onProgress?: (processed: number, total: number, currentFile: string) => void;
89
+ /** Callback for handling errors during file processing */
90
+ onError?: (file: string, error: Error) => void;
91
+ }
92
+ /**
93
+ * Result of batch processing operation
94
+ *
95
+ * Contains statistics and details about the batch processing operation,
96
+ * including success/failure counts, file lists, and timing information.
97
+ *
98
+ * @interface BatchProcessingResult
99
+ * @example
100
+ * ```typescript
101
+ * const result = await processBatch(options);
102
+ *
103
+ * console.log(`Successfully processed: ${result.totalProcessed} files`);
104
+ * console.log(`Failed: ${result.totalErrors} files`);
105
+ * console.log(`Processing time: ${result.processingTime}ms`);
106
+ *
107
+ * // List failed files
108
+ * result.failedFiles.forEach(({ file, error }) => {
109
+ * console.error(`Failed to process ${file}: ${error}`);
110
+ * });
111
+ * ```
112
+ */
113
+ export interface BatchProcessingResult {
114
+ /** Total number of files successfully processed */
115
+ totalProcessed: number;
116
+ /** Number of files that failed processing */
117
+ totalErrors: number;
118
+ /** List of successfully processed file paths */
119
+ successfulFiles: string[];
120
+ /** List of failed files with error messages */
121
+ failedFiles: Array<{
122
+ file: string;
123
+ error: string;
124
+ }>;
125
+ /** Total processing time in milliseconds */
126
+ processingTime: number;
127
+ }
128
+ /**
129
+ * Processes multiple legal markdown files in batch
130
+ *
131
+ * This function performs batch processing of Legal Markdown files with support
132
+ * for recursive directory traversal, concurrent processing, and progress tracking.
133
+ * It automatically handles file discovery, directory creation, and error management.
134
+ *
135
+ * @async
136
+ * @function processBatch
137
+ * @param {BatchProcessingOptions} options - Configuration options for batch processing
138
+ * @returns {Promise<BatchProcessingResult>} A promise that resolves to the processing result
139
+ * @throws {Error} When input directory doesn't exist or other setup errors occur
140
+ * @example
141
+ * ```typescript
142
+ * import { processBatch } from './batch-processor';
143
+ *
144
+ * // Process all .md files in a directory
145
+ * const result = await processBatch({
146
+ * inputDir: './legal-documents',
147
+ * outputDir: './processed-documents',
148
+ * extensions: ['.md'],
149
+ * recursive: true,
150
+ * preserveStructure: true,
151
+ * concurrency: 3,
152
+ * onProgress: (processed, total, currentFile) => {
153
+ * console.log(`Progress: ${processed}/${total} - ${path.basename(currentFile)}`);
154
+ * },
155
+ * onError: (file, error) => {
156
+ * console.error(`Error processing ${file}:`, error.message);
157
+ * }
158
+ * });
159
+ *
160
+ * console.log(`Processed ${result.totalProcessed} files successfully`);
161
+ * console.log(`${result.totalErrors} files failed processing`);
162
+ * ```
163
+ */
164
+ export declare function processBatch(options: BatchProcessingOptions): Promise<BatchProcessingResult>;
165
+ /**
166
+ * Utility function to get processing statistics from batch processing results
167
+ *
168
+ * Calculates useful statistics about the batch processing operation including
169
+ * success rate, average processing time per file, and throughput metrics.
170
+ *
171
+ * @function getProcessingStats
172
+ * @param {BatchProcessingResult} result - The batch processing result to analyze
173
+ * @returns {Object} Object containing processing statistics
174
+ * @returns {number} returns.successRate - Success rate as a percentage (0-100)
175
+ * @returns {number} returns.averageTimePerFile - Average processing time per file in milliseconds
176
+ * @returns {number} returns.filesPerSecond - Processing throughput in files per second
177
+ * @example
178
+ * ```typescript
179
+ * import { processBatch, getProcessingStats } from './batch-processor';
180
+ *
181
+ * const result = await processBatch({
182
+ * inputDir: './documents',
183
+ * outputDir: './output'
184
+ * });
185
+ *
186
+ * const stats = getProcessingStats(result);
187
+ * console.log(`Success rate: ${stats.successRate.toFixed(2)}%`);
188
+ * console.log(`Average time per file: ${stats.averageTimePerFile.toFixed(2)}ms`);
189
+ * console.log(`Throughput: ${stats.filesPerSecond.toFixed(2)} files/second`);
190
+ * ```
191
+ */
192
+ export declare function getProcessingStats(result: BatchProcessingResult): {
193
+ successRate: number;
194
+ averageTimePerFile: number;
195
+ filesPerSecond: number;
196
+ };
197
+ //# sourceMappingURL=batch-processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch-processor.d.ts","sourceRoot":"","sources":["../../src/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