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,229 @@
1
+ /**
2
+ * @fileoverview Constants and Configuration for Legal Markdown Processing
3
+ *
4
+ * This module contains all the constants, regular expressions, and configuration
5
+ * values used throughout the Legal Markdown processing system. It provides
6
+ * centralized definitions for patterns, options, and supported formats.
7
+ *
8
+ * Features:
9
+ * - Default processing options and configurations
10
+ * - Regular expression patterns for parsing different markup elements
11
+ * - Supported file formats and extensions
12
+ * - Error codes for consistent error handling
13
+ * - Constants for import, clause, and reference processing
14
+ * - Type-safe constant definitions with 'as const' assertions
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { DEFAULT_OPTIONS, HEADER_PATTERNS, ERROR_CODES } from './constants';
19
+ *
20
+ * // Use default options
21
+ * const options = { ...DEFAULT_OPTIONS, debug: true };
22
+ *
23
+ * // Use header patterns
24
+ * const headerMatch = content.match(HEADER_PATTERNS.TRADITIONAL);
25
+ *
26
+ * // Use error codes
27
+ * throw new Error(ERROR_CODES.YAML_PARSING_ERROR);
28
+ * ```
29
+ */
30
+ /**
31
+ * Default options for Legal Markdown processing
32
+ *
33
+ * @constant {Object} DEFAULT_OPTIONS
34
+ * @example
35
+ * ```typescript
36
+ * import { DEFAULT_OPTIONS } from './constants';
37
+ *
38
+ * // Use default options
39
+ * const options = { ...DEFAULT_OPTIONS, debug: true };
40
+ *
41
+ * // Override specific options
42
+ * const customOptions = {
43
+ * ...DEFAULT_OPTIONS,
44
+ * yamlOnly: true,
45
+ * exportMetadata: true,
46
+ * exportFormat: 'json' as const
47
+ * };
48
+ * ```
49
+ */
50
+ export declare const DEFAULT_OPTIONS: {
51
+ /** Process only YAML frontmatter, skip content processing */
52
+ yamlOnly: boolean;
53
+ /** Skip processing of header structures */
54
+ noHeaders: boolean;
55
+ /** Skip processing of optional clauses */
56
+ noClauses: boolean;
57
+ /** Skip processing of cross-references */
58
+ noReferences: boolean;
59
+ /** Skip processing of import statements */
60
+ noImports: boolean;
61
+ /** Export metadata to external files */
62
+ exportMetadata: boolean;
63
+ /** Format for metadata export */
64
+ exportFormat: "yaml";
65
+ /** Enable debug logging */
66
+ debug: boolean;
67
+ /** Throw errors on YAML parsing failures */
68
+ throwOnYamlError: boolean;
69
+ };
70
+ /**
71
+ * Regular expression patterns for parsing header structures
72
+ *
73
+ * @constant {Object} HEADER_PATTERNS
74
+ * @example
75
+ * ```typescript
76
+ * import { HEADER_PATTERNS } from './constants';
77
+ *
78
+ * // Match traditional headers: l. Section, ll. Subsection
79
+ * const traditionalHeaders = content.match(HEADER_PATTERNS.TRADITIONAL);
80
+ *
81
+ * // Match alternative headers: l1. Section, l2. Subsection
82
+ * const alternativeHeaders = content.match(HEADER_PATTERNS.ALTERNATIVE);
83
+ * ```
84
+ */
85
+ export declare const HEADER_PATTERNS: {
86
+ /** Traditional header pattern: l. Section, ll. Subsection, etc. */
87
+ readonly TRADITIONAL: RegExp;
88
+ /** Alternative header pattern: l1. Section, l2. Subsection, etc. */
89
+ readonly ALTERNATIVE: RegExp;
90
+ };
91
+ /**
92
+ * Regular expression patterns for parsing import statements
93
+ *
94
+ * @constant {Object} IMPORT_PATTERNS
95
+ * @example
96
+ * ```typescript
97
+ * import { IMPORT_PATTERNS } from './constants';
98
+ *
99
+ * // Match partial imports: [[filename]]
100
+ * const partialImports = content.match(IMPORT_PATTERNS.PARTIAL);
101
+ *
102
+ * // Match full file imports: @import filename
103
+ * const fullImports = content.match(IMPORT_PATTERNS.FULL_FILE);
104
+ * ```
105
+ */
106
+ export declare const IMPORT_PATTERNS: {
107
+ /** Partial import pattern: [[filename]] */
108
+ readonly PARTIAL: RegExp;
109
+ /** Full file import pattern: @import filename */
110
+ readonly FULL_FILE: RegExp;
111
+ };
112
+ /**
113
+ * Regular expression patterns for parsing optional and conditional clauses
114
+ *
115
+ * @constant {Object} CLAUSE_PATTERNS
116
+ * @example
117
+ * ```typescript
118
+ * import { CLAUSE_PATTERNS } from './constants';
119
+ *
120
+ * // Match optional clauses: {{field.name}}
121
+ * const optionalClauses = content.match(CLAUSE_PATTERNS.OPTIONAL);
122
+ *
123
+ * // Match conditional clauses: {{#if condition}}content{{/if}}
124
+ * const conditionalClauses = content.match(CLAUSE_PATTERNS.CONDITIONAL);
125
+ * ```
126
+ */
127
+ export declare const CLAUSE_PATTERNS: {
128
+ /** Optional clause pattern: {{field.name}} */
129
+ readonly OPTIONAL: RegExp;
130
+ /** Conditional clause pattern: {{#if condition}}content{{/if}} */
131
+ readonly CONDITIONAL: RegExp;
132
+ };
133
+ /**
134
+ * Regular expression patterns for parsing cross-references
135
+ *
136
+ * @constant {Object} REFERENCE_PATTERNS
137
+ * @example
138
+ * ```typescript
139
+ * import { REFERENCE_PATTERNS } from './constants';
140
+ *
141
+ * // Match cross-references: [[reference]]
142
+ * const crossRefs = content.match(REFERENCE_PATTERNS.CROSS_REF);
143
+ *
144
+ * // Match numbered references: [1], [2], etc.
145
+ * const numberedRefs = content.match(REFERENCE_PATTERNS.NUMBERED_REF);
146
+ * ```
147
+ */
148
+ export declare const REFERENCE_PATTERNS: {
149
+ /** Cross-reference pattern: [[reference]] */
150
+ readonly CROSS_REF: RegExp;
151
+ /** Numbered reference pattern: [1], [2], etc. */
152
+ readonly NUMBERED_REF: RegExp;
153
+ };
154
+ /**
155
+ * Supported file formats for input and export operations
156
+ *
157
+ * @constant {Object} SUPPORTED_FORMATS
158
+ * @example
159
+ * ```typescript
160
+ * import { SUPPORTED_FORMATS } from './constants';
161
+ *
162
+ * // Check if format is supported for export
163
+ * const isExportSupported = SUPPORTED_FORMATS.EXPORT.includes('yaml');
164
+ *
165
+ * // Check if input format is supported
166
+ * const isInputSupported = SUPPORTED_FORMATS.INPUT.includes('md');
167
+ * ```
168
+ */
169
+ export declare const SUPPORTED_FORMATS: {
170
+ /** Supported export formats */
171
+ readonly EXPORT: readonly ["yaml", "json"];
172
+ /** Supported input formats */
173
+ readonly INPUT: readonly ["md", "markdown"];
174
+ };
175
+ /**
176
+ * File extensions for different document types
177
+ *
178
+ * @constant {Object} FILE_EXTENSIONS
179
+ * @example
180
+ * ```typescript
181
+ * import { FILE_EXTENSIONS } from './constants';
182
+ *
183
+ * // Check if file is markdown
184
+ * const isMarkdown = FILE_EXTENSIONS.MARKDOWN.includes(path.extname(filename));
185
+ *
186
+ * // Check if file is YAML
187
+ * const isYaml = FILE_EXTENSIONS.YAML.includes(path.extname(filename));
188
+ * ```
189
+ */
190
+ export declare const FILE_EXTENSIONS: {
191
+ /** Markdown file extensions */
192
+ readonly MARKDOWN: readonly [".md", ".markdown"];
193
+ /** YAML file extensions */
194
+ readonly YAML: readonly [".yml", ".yaml"];
195
+ /** JSON file extensions */
196
+ readonly JSON: readonly [".json"];
197
+ };
198
+ /**
199
+ * Error codes for consistent error handling throughout the system
200
+ *
201
+ * @constant {Object} ERROR_CODES
202
+ * @example
203
+ * ```typescript
204
+ * import { ERROR_CODES } from './constants';
205
+ *
206
+ * // Use error codes in custom errors
207
+ * throw new Error(ERROR_CODES.YAML_PARSING_ERROR);
208
+ *
209
+ * // Check error codes in error handling
210
+ * if (error.code === ERROR_CODES.FILE_NOT_FOUND) {
211
+ * // Handle file not found error
212
+ * }
213
+ * ```
214
+ */
215
+ export declare const ERROR_CODES: {
216
+ /** YAML parsing error code */
217
+ readonly YAML_PARSING_ERROR: "YAML_PARSING_ERROR";
218
+ /** File not found error code */
219
+ readonly FILE_NOT_FOUND: "FILE_NOT_FOUND";
220
+ /** Import processing error code */
221
+ readonly IMPORT_PROCESSING_ERROR: "IMPORT_PROCESSING_ERROR";
222
+ /** Metadata export error code */
223
+ readonly METADATA_EXPORT_ERROR: "METADATA_EXPORT_ERROR";
224
+ /** Validation error code */
225
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
226
+ /** General processing error code */
227
+ readonly PROCESSING_ERROR: "PROCESSING_ERROR";
228
+ };
229
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,eAAe;IAC1B,6DAA6D;;IAE7D,2CAA2C;;IAE3C,0CAA0C;;IAE1C,0CAA0C;;IAE1C,2CAA2C;;IAE3C,wCAAwC;;IAExC,iCAAiC;;IAEjC,2BAA2B;;IAE3B,4CAA4C;;CAE7C,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe;IAC1B,mEAAmE;;IAEnE,oEAAoE;;CAE5D,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe;IAC1B,2CAA2C;;IAE3C,iDAAiD;;CAEzC,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe;IAC1B,8CAA8C;;IAE9C,kEAAkE;;CAE1D,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB;IAC7B,6CAA6C;;IAE7C,iDAAiD;;CAEzC,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB;IAC5B,+BAA+B;;IAE/B,8BAA8B;;CAEtB,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe;IAC1B,+BAA+B;;IAE/B,2BAA2B;;IAE3B,2BAA2B;;CAEnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW;IACtB,8BAA8B;;IAE9B,gCAAgC;;IAEhC,mCAAmC;;IAEnC,iCAAiC;;IAEjC,4BAA4B;;IAE5B,oCAAoC;;CAE5B,CAAC"}
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Constants and Configuration for Legal Markdown Processing
4
+ *
5
+ * This module contains all the constants, regular expressions, and configuration
6
+ * values used throughout the Legal Markdown processing system. It provides
7
+ * centralized definitions for patterns, options, and supported formats.
8
+ *
9
+ * Features:
10
+ * - Default processing options and configurations
11
+ * - Regular expression patterns for parsing different markup elements
12
+ * - Supported file formats and extensions
13
+ * - Error codes for consistent error handling
14
+ * - Constants for import, clause, and reference processing
15
+ * - Type-safe constant definitions with 'as const' assertions
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { DEFAULT_OPTIONS, HEADER_PATTERNS, ERROR_CODES } from './constants';
20
+ *
21
+ * // Use default options
22
+ * const options = { ...DEFAULT_OPTIONS, debug: true };
23
+ *
24
+ * // Use header patterns
25
+ * const headerMatch = content.match(HEADER_PATTERNS.TRADITIONAL);
26
+ *
27
+ * // Use error codes
28
+ * throw new Error(ERROR_CODES.YAML_PARSING_ERROR);
29
+ * ```
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.ERROR_CODES = exports.FILE_EXTENSIONS = exports.SUPPORTED_FORMATS = exports.REFERENCE_PATTERNS = exports.CLAUSE_PATTERNS = exports.IMPORT_PATTERNS = exports.HEADER_PATTERNS = exports.DEFAULT_OPTIONS = void 0;
33
+ /**
34
+ * Default options for Legal Markdown processing
35
+ *
36
+ * @constant {Object} DEFAULT_OPTIONS
37
+ * @example
38
+ * ```typescript
39
+ * import { DEFAULT_OPTIONS } from './constants';
40
+ *
41
+ * // Use default options
42
+ * const options = { ...DEFAULT_OPTIONS, debug: true };
43
+ *
44
+ * // Override specific options
45
+ * const customOptions = {
46
+ * ...DEFAULT_OPTIONS,
47
+ * yamlOnly: true,
48
+ * exportMetadata: true,
49
+ * exportFormat: 'json' as const
50
+ * };
51
+ * ```
52
+ */
53
+ exports.DEFAULT_OPTIONS = {
54
+ /** Process only YAML frontmatter, skip content processing */
55
+ yamlOnly: false,
56
+ /** Skip processing of header structures */
57
+ noHeaders: false,
58
+ /** Skip processing of optional clauses */
59
+ noClauses: false,
60
+ /** Skip processing of cross-references */
61
+ noReferences: false,
62
+ /** Skip processing of import statements */
63
+ noImports: false,
64
+ /** Export metadata to external files */
65
+ exportMetadata: false,
66
+ /** Format for metadata export */
67
+ exportFormat: 'yaml',
68
+ /** Enable debug logging */
69
+ debug: false,
70
+ /** Throw errors on YAML parsing failures */
71
+ throwOnYamlError: false,
72
+ };
73
+ /**
74
+ * Regular expression patterns for parsing header structures
75
+ *
76
+ * @constant {Object} HEADER_PATTERNS
77
+ * @example
78
+ * ```typescript
79
+ * import { HEADER_PATTERNS } from './constants';
80
+ *
81
+ * // Match traditional headers: l. Section, ll. Subsection
82
+ * const traditionalHeaders = content.match(HEADER_PATTERNS.TRADITIONAL);
83
+ *
84
+ * // Match alternative headers: l1. Section, l2. Subsection
85
+ * const alternativeHeaders = content.match(HEADER_PATTERNS.ALTERNATIVE);
86
+ * ```
87
+ */
88
+ exports.HEADER_PATTERNS = {
89
+ /** Traditional header pattern: l. Section, ll. Subsection, etc. */
90
+ TRADITIONAL: /^(l+)\.\s+(.*?)$/gm,
91
+ /** Alternative header pattern: l1. Section, l2. Subsection, etc. */
92
+ ALTERNATIVE: /^l(\d+)\.\s+(.*?)$/gm,
93
+ };
94
+ /**
95
+ * Regular expression patterns for parsing import statements
96
+ *
97
+ * @constant {Object} IMPORT_PATTERNS
98
+ * @example
99
+ * ```typescript
100
+ * import { IMPORT_PATTERNS } from './constants';
101
+ *
102
+ * // Match partial imports: [[filename]]
103
+ * const partialImports = content.match(IMPORT_PATTERNS.PARTIAL);
104
+ *
105
+ * // Match full file imports: @import filename
106
+ * const fullImports = content.match(IMPORT_PATTERNS.FULL_FILE);
107
+ * ```
108
+ */
109
+ exports.IMPORT_PATTERNS = {
110
+ /** Partial import pattern: [[filename]] */
111
+ PARTIAL: /\[\[(.*?)\]\]/g,
112
+ /** Full file import pattern: @import filename */
113
+ FULL_FILE: /^@import\s+(.+)$/gm,
114
+ };
115
+ /**
116
+ * Regular expression patterns for parsing optional and conditional clauses
117
+ *
118
+ * @constant {Object} CLAUSE_PATTERNS
119
+ * @example
120
+ * ```typescript
121
+ * import { CLAUSE_PATTERNS } from './constants';
122
+ *
123
+ * // Match optional clauses: {{field.name}}
124
+ * const optionalClauses = content.match(CLAUSE_PATTERNS.OPTIONAL);
125
+ *
126
+ * // Match conditional clauses: {{#if condition}}content{{/if}}
127
+ * const conditionalClauses = content.match(CLAUSE_PATTERNS.CONDITIONAL);
128
+ * ```
129
+ */
130
+ exports.CLAUSE_PATTERNS = {
131
+ /** Optional clause pattern: {{field.name}} */
132
+ OPTIONAL: /\{\{\s*([^}]+)\s*\}\}/g,
133
+ /** Conditional clause pattern: {{#if condition}}content{{/if}} */
134
+ CONDITIONAL: /\{\{\s*#if\s+([^}]+)\s*\}\}([\s\S]*?)\{\{\s*\/if\s*\}\}/g,
135
+ };
136
+ /**
137
+ * Regular expression patterns for parsing cross-references
138
+ *
139
+ * @constant {Object} REFERENCE_PATTERNS
140
+ * @example
141
+ * ```typescript
142
+ * import { REFERENCE_PATTERNS } from './constants';
143
+ *
144
+ * // Match cross-references: [[reference]]
145
+ * const crossRefs = content.match(REFERENCE_PATTERNS.CROSS_REF);
146
+ *
147
+ * // Match numbered references: [1], [2], etc.
148
+ * const numberedRefs = content.match(REFERENCE_PATTERNS.NUMBERED_REF);
149
+ * ```
150
+ */
151
+ exports.REFERENCE_PATTERNS = {
152
+ /** Cross-reference pattern: [[reference]] */
153
+ CROSS_REF: /\[\[([^\]]+)\]\]/g,
154
+ /** Numbered reference pattern: [1], [2], etc. */
155
+ NUMBERED_REF: /\[(\d+)\]/g,
156
+ };
157
+ /**
158
+ * Supported file formats for input and export operations
159
+ *
160
+ * @constant {Object} SUPPORTED_FORMATS
161
+ * @example
162
+ * ```typescript
163
+ * import { SUPPORTED_FORMATS } from './constants';
164
+ *
165
+ * // Check if format is supported for export
166
+ * const isExportSupported = SUPPORTED_FORMATS.EXPORT.includes('yaml');
167
+ *
168
+ * // Check if input format is supported
169
+ * const isInputSupported = SUPPORTED_FORMATS.INPUT.includes('md');
170
+ * ```
171
+ */
172
+ exports.SUPPORTED_FORMATS = {
173
+ /** Supported export formats */
174
+ EXPORT: ['yaml', 'json'],
175
+ /** Supported input formats */
176
+ INPUT: ['md', 'markdown'],
177
+ };
178
+ /**
179
+ * File extensions for different document types
180
+ *
181
+ * @constant {Object} FILE_EXTENSIONS
182
+ * @example
183
+ * ```typescript
184
+ * import { FILE_EXTENSIONS } from './constants';
185
+ *
186
+ * // Check if file is markdown
187
+ * const isMarkdown = FILE_EXTENSIONS.MARKDOWN.includes(path.extname(filename));
188
+ *
189
+ * // Check if file is YAML
190
+ * const isYaml = FILE_EXTENSIONS.YAML.includes(path.extname(filename));
191
+ * ```
192
+ */
193
+ exports.FILE_EXTENSIONS = {
194
+ /** Markdown file extensions */
195
+ MARKDOWN: ['.md', '.markdown'],
196
+ /** YAML file extensions */
197
+ YAML: ['.yml', '.yaml'],
198
+ /** JSON file extensions */
199
+ JSON: ['.json'],
200
+ };
201
+ /**
202
+ * Error codes for consistent error handling throughout the system
203
+ *
204
+ * @constant {Object} ERROR_CODES
205
+ * @example
206
+ * ```typescript
207
+ * import { ERROR_CODES } from './constants';
208
+ *
209
+ * // Use error codes in custom errors
210
+ * throw new Error(ERROR_CODES.YAML_PARSING_ERROR);
211
+ *
212
+ * // Check error codes in error handling
213
+ * if (error.code === ERROR_CODES.FILE_NOT_FOUND) {
214
+ * // Handle file not found error
215
+ * }
216
+ * ```
217
+ */
218
+ exports.ERROR_CODES = {
219
+ /** YAML parsing error code */
220
+ YAML_PARSING_ERROR: 'YAML_PARSING_ERROR',
221
+ /** File not found error code */
222
+ FILE_NOT_FOUND: 'FILE_NOT_FOUND',
223
+ /** Import processing error code */
224
+ IMPORT_PROCESSING_ERROR: 'IMPORT_PROCESSING_ERROR',
225
+ /** Metadata export error code */
226
+ METADATA_EXPORT_ERROR: 'METADATA_EXPORT_ERROR',
227
+ /** Validation error code */
228
+ VALIDATION_ERROR: 'VALIDATION_ERROR',
229
+ /** General processing error code */
230
+ PROCESSING_ERROR: 'PROCESSING_ERROR',
231
+ };
232
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACU,QAAA,eAAe,GAAG;IAC7B,6DAA6D;IAC7D,QAAQ,EAAE,KAAK;IACf,2CAA2C;IAC3C,SAAS,EAAE,KAAK;IAChB,0CAA0C;IAC1C,SAAS,EAAE,KAAK;IAChB,0CAA0C;IAC1C,YAAY,EAAE,KAAK;IACnB,2CAA2C;IAC3C,SAAS,EAAE,KAAK;IAChB,wCAAwC;IACxC,cAAc,EAAE,KAAK;IACrB,iCAAiC;IACjC,YAAY,EAAE,MAAe;IAC7B,2BAA2B;IAC3B,KAAK,EAAE,KAAK;IACZ,4CAA4C;IAC5C,gBAAgB,EAAE,KAAK;CACxB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACU,QAAA,eAAe,GAAG;IAC7B,mEAAmE;IACnE,WAAW,EAAE,oBAAoB;IACjC,oEAAoE;IACpE,WAAW,EAAE,sBAAsB;CAC3B,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACU,QAAA,eAAe,GAAG;IAC7B,2CAA2C;IAC3C,OAAO,EAAE,gBAAgB;IACzB,iDAAiD;IACjD,SAAS,EAAE,oBAAoB;CACvB,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACU,QAAA,eAAe,GAAG;IAC7B,8CAA8C;IAC9C,QAAQ,EAAE,wBAAwB;IAClC,kEAAkE;IAClE,WAAW,EAAE,0DAA0D;CAC/D,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACU,QAAA,kBAAkB,GAAG;IAChC,6CAA6C;IAC7C,SAAS,EAAE,mBAAmB;IAC9B,iDAAiD;IACjD,YAAY,EAAE,YAAY;CAClB,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACU,QAAA,iBAAiB,GAAG;IAC/B,+BAA+B;IAC/B,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAU;IACjC,8BAA8B;IAC9B,KAAK,EAAE,CAAC,IAAI,EAAE,UAAU,CAAU;CAC1B,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACU,QAAA,eAAe,GAAG;IAC7B,+BAA+B;IAC/B,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC;IAC9B,2BAA2B;IAC3B,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;IACvB,2BAA2B;IAC3B,IAAI,EAAE,CAAC,OAAO,CAAC;CACP,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,WAAW,GAAG;IACzB,8BAA8B;IAC9B,kBAAkB,EAAE,oBAAoB;IACxC,gCAAgC;IAChC,cAAc,EAAE,gBAAgB;IAChC,mCAAmC;IACnC,uBAAuB,EAAE,yBAAyB;IAClD,iCAAiC;IACjC,qBAAqB,EAAE,uBAAuB;IAC9C,4BAA4B;IAC5B,gBAAgB,EAAE,kBAAkB;IACpC,oCAAoC;IACpC,gBAAgB,EAAE,kBAAkB;CAC5B,CAAC"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * @fileoverview Metadata Export System for Legal Markdown Documents
3
+ *
4
+ * This module provides functionality for exporting document metadata to external
5
+ * files in various formats. It supports YAML and JSON export formats with
6
+ * configurable output paths and metadata filtering.
7
+ *
8
+ * Features:
9
+ * - Metadata export to YAML and JSON formats
10
+ * - Configurable output paths and filenames
11
+ * - Metadata filtering and processing
12
+ * - Internal metadata key removal
13
+ * - Directory creation for output files
14
+ * - Error handling and logging
15
+ * - Support for custom export configurations
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { exportMetadata } from './metadata-exporter';
20
+ *
21
+ * // Export metadata to YAML
22
+ * const result = exportMetadata(metadata, 'yaml', './output');
23
+ * console.log('Exported files:', result.exportedFiles);
24
+ *
25
+ * // Export with custom configuration
26
+ * const metadata = {
27
+ * title: 'Legal Agreement',
28
+ * 'meta-yaml-output': 'custom-metadata.yaml',
29
+ * 'meta-json-output': 'custom-metadata.json'
30
+ * };
31
+ * const result = exportMetadata(metadata);
32
+ * ```
33
+ */
34
+ import { MetadataExportResult } from '@types';
35
+ /**
36
+ * Exports document metadata to external files
37
+ *
38
+ * Processes document metadata and exports it to specified formats (YAML/JSON)
39
+ * with support for custom output paths and metadata filtering. Handles directory
40
+ * creation and provides comprehensive error handling.
41
+ *
42
+ * @async
43
+ * @function exportMetadata
44
+ * @param {Record<string, any>} metadata - Document metadata to export
45
+ * @param {'yaml' | 'json'} [format] - Export format (yaml or json)
46
+ * @param {string} [outputPath] - Optional path for export files
47
+ * @returns {MetadataExportResult} Result object with list of exported files
48
+ * @example
49
+ * ```typescript
50
+ * import { exportMetadata } from './metadata-exporter';
51
+ *
52
+ * // Basic metadata export
53
+ * const metadata = {
54
+ * title: 'Service Agreement',
55
+ * author: 'Legal Team',
56
+ * version: '1.0',
57
+ * date: '2023-01-01'
58
+ * };
59
+ *
60
+ * const result = exportMetadata(metadata, 'yaml', './output');
61
+ * console.log('Exported to:', result.exportedFiles);
62
+ *
63
+ * // Export with custom filenames
64
+ * const customMetadata = {
65
+ * title: 'Contract',
66
+ * 'meta-yaml-output': 'contract-metadata.yaml',
67
+ * 'meta-json-output': 'contract-metadata.json',
68
+ * 'meta-output-path': './custom-output'
69
+ * };
70
+ *
71
+ * const customResult = exportMetadata(customMetadata);
72
+ * ```
73
+ */
74
+ export declare function exportMetadata(metadata: Record<string, any>, format?: 'yaml' | 'json', outputPath?: string): MetadataExportResult;
75
+ /**
76
+ * Filters metadata based on export configuration
77
+ *
78
+ * Processes metadata to remove internal configuration keys and applies filtering
79
+ * rules based on export settings. This ensures that only relevant metadata is
80
+ * included in the exported files.
81
+ *
82
+ * @function filterMetadataForExport
83
+ * @param {Record<string, any>} metadata - Complete metadata object to filter
84
+ * @returns {Record<string, any>} Filtered metadata object suitable for export
85
+ * @example
86
+ * ```typescript
87
+ * import { filterMetadataForExport } from './metadata-exporter';
88
+ *
89
+ * const metadata = {
90
+ * title: 'Legal Agreement',
91
+ * author: 'Legal Team',
92
+ * 'meta-yaml-output': 'output.yaml',
93
+ * 'meta-json-output': 'output.json',
94
+ * 'meta-output-path': './exports',
95
+ * 'meta-include-original': false
96
+ * };
97
+ *
98
+ * const filtered = filterMetadataForExport(metadata);
99
+ * // Result: { title: 'Legal Agreement', author: 'Legal Team' }
100
+ * // Internal meta-* keys are removed
101
+ * ```
102
+ */
103
+ export declare function filterMetadataForExport(metadata: Record<string, any>): Record<string, any>;
104
+ //# sourceMappingURL=metadata-exporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata-exporter.d.ts","sourceRoot":"","sources":["../../../src/core/exporters/metadata-exporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAKH,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,UAAU,CAAC,EAAE,MAAM,GAClB,oBAAoB,CAoDtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAgB1F"}