@unrdf/kgn 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +210 -0
  3. package/package.json +90 -0
  4. package/src/MIGRATION_COMPLETE.md +186 -0
  5. package/src/PORT-MAP.md +302 -0
  6. package/src/base/filter-templates.js +479 -0
  7. package/src/base/index.js +92 -0
  8. package/src/base/injection-targets.js +583 -0
  9. package/src/base/macro-templates.js +298 -0
  10. package/src/base/macro-templates.js.bak +461 -0
  11. package/src/base/shacl-templates.js +617 -0
  12. package/src/base/template-base.js +388 -0
  13. package/src/core/attestor.js +381 -0
  14. package/src/core/filters.js +518 -0
  15. package/src/core/index.js +21 -0
  16. package/src/core/kgen-engine.js +372 -0
  17. package/src/core/parser.js +447 -0
  18. package/src/core/post-processor.js +313 -0
  19. package/src/core/renderer.js +469 -0
  20. package/src/doc-generator/cli.mjs +122 -0
  21. package/src/doc-generator/index.mjs +28 -0
  22. package/src/doc-generator/mdx-generator.mjs +71 -0
  23. package/src/doc-generator/nav-generator.mjs +136 -0
  24. package/src/doc-generator/parser.mjs +291 -0
  25. package/src/doc-generator/rdf-builder.mjs +306 -0
  26. package/src/doc-generator/scanner.mjs +189 -0
  27. package/src/engine/index.js +42 -0
  28. package/src/engine/pipeline.js +448 -0
  29. package/src/engine/renderer.js +604 -0
  30. package/src/engine/template-engine.js +566 -0
  31. package/src/filters/array.js +436 -0
  32. package/src/filters/data.js +479 -0
  33. package/src/filters/index.js +270 -0
  34. package/src/filters/rdf.js +264 -0
  35. package/src/filters/text.js +369 -0
  36. package/src/index.js +109 -0
  37. package/src/inheritance/index.js +40 -0
  38. package/src/injection/api.js +260 -0
  39. package/src/injection/atomic-writer.js +327 -0
  40. package/src/injection/constants.js +136 -0
  41. package/src/injection/idempotency-manager.js +295 -0
  42. package/src/injection/index.js +28 -0
  43. package/src/injection/injection-engine.js +378 -0
  44. package/src/injection/integration.js +339 -0
  45. package/src/injection/modes/index.js +341 -0
  46. package/src/injection/rollback-manager.js +373 -0
  47. package/src/injection/target-resolver.js +323 -0
  48. package/src/injection/tests/atomic-writer.test.js +382 -0
  49. package/src/injection/tests/injection-engine.test.js +611 -0
  50. package/src/injection/tests/integration.test.js +392 -0
  51. package/src/injection/tests/run-tests.js +283 -0
  52. package/src/injection/validation-engine.js +547 -0
  53. package/src/linter/determinism-linter.js +473 -0
  54. package/src/linter/determinism.js +410 -0
  55. package/src/linter/index.js +6 -0
  56. package/src/linter/test-doubles.js +475 -0
  57. package/src/parser/frontmatter.js +228 -0
  58. package/src/parser/variables.js +344 -0
  59. package/src/renderer/deterministic.js +245 -0
  60. package/src/renderer/index.js +6 -0
  61. package/src/templates/latex/academic-paper.njk +186 -0
  62. package/src/templates/latex/index.js +104 -0
  63. package/src/templates/nextjs/app-page.njk +66 -0
  64. package/src/templates/nextjs/index.js +80 -0
  65. package/src/templates/office/docx/document.njk +368 -0
  66. package/src/templates/office/index.js +79 -0
  67. package/src/templates/office/word-report.njk +129 -0
  68. package/src/utils/template-utils.js +426 -0
@@ -0,0 +1,368 @@
1
+ ---
2
+ name: Microsoft Word Document Template
3
+ description: Professional Word document with headers, footers, and structured content
4
+ version: 1.0.0
5
+ type: document
6
+ category: office
7
+ format: docx
8
+ variables:
9
+ title: Document title
10
+ author: Document author name
11
+ company: Company or organization name
12
+ date: Document date (optional, defaults to current date)
13
+ sections: Array of document sections with title and content
14
+ includeHeader: Include document header with title (default: true)
15
+ includeFooter: Include document footer with page numbers (default: true)
16
+ pageSize: Page size (default: A4)
17
+ margins: Page margins configuration
18
+ ---
19
+ {
20
+ "document": {
21
+ "creator": "{{ author | default('Unknown') }}",
22
+ "title": "{{ title }}",
23
+ "subject": "{{ title }}",
24
+ "keywords": "{{ keywords | join(', ') if keywords else '' }}",
25
+ "sections": [
26
+ {
27
+ "properties": {
28
+ "page": {
29
+ "size": {
30
+ "orientation": "portrait"{% if pageSize == 'letter' %},
31
+ "width": 612,
32
+ "height": 792{% else %},
33
+ "width": 595,
34
+ "height": 842{% endif %}
35
+ },
36
+ "margin": {
37
+ "top": {{ margins.top | default(1440) }},
38
+ "right": {{ margins.right | default(1440) }},
39
+ "bottom": {{ margins.bottom | default(1440) }},
40
+ "left": {{ margins.left | default(1440) }},
41
+ "header": {{ margins.header | default(720) }},
42
+ "footer": {{ margins.footer | default(720) }}
43
+ }
44
+ }
45
+ },
46
+ {% if includeHeader !== false -%}
47
+ "headers": {
48
+ "default": {
49
+ "options": {},
50
+ "children": [
51
+ {
52
+ "type": "paragraph",
53
+ "alignment": "center",
54
+ "children": [
55
+ {
56
+ "type": "textRun",
57
+ "text": "{{ title }}",
58
+ "font": {
59
+ "name": "Calibri",
60
+ "size": 24
61
+ },
62
+ "bold": true
63
+ }
64
+ ]
65
+ }
66
+ ]
67
+ }
68
+ },
69
+ {% endif -%}
70
+ {% if includeFooter !== false -%}
71
+ "footers": {
72
+ "default": {
73
+ "options": {},
74
+ "children": [
75
+ {
76
+ "type": "paragraph",
77
+ "alignment": "center",
78
+ "children": [
79
+ {
80
+ "type": "textRun",
81
+ "text": "Page ",
82
+ "font": {
83
+ "name": "Calibri",
84
+ "size": 20
85
+ }
86
+ },
87
+ {
88
+ "type": "pageNumber"
89
+ },
90
+ {
91
+ "type": "textRun",
92
+ "text": " of ",
93
+ "font": {
94
+ "name": "Calibri",
95
+ "size": 20
96
+ }
97
+ },
98
+ {
99
+ "type": "numberOfPages"
100
+ }
101
+ ]
102
+ }
103
+ ]
104
+ }
105
+ },
106
+ {% endif -%}
107
+ "children": [
108
+ {
109
+ "type": "paragraph",
110
+ "alignment": "center",
111
+ "spacing": {
112
+ "after": 400
113
+ },
114
+ "children": [
115
+ {
116
+ "type": "textRun",
117
+ "text": "{{ title }}",
118
+ "font": {
119
+ "name": "Calibri",
120
+ "size": 32
121
+ },
122
+ "bold": true
123
+ }
124
+ ]
125
+ },
126
+ {% if author or company or date -%}
127
+ {
128
+ "type": "paragraph",
129
+ "alignment": "center",
130
+ "spacing": {
131
+ "after": 600
132
+ },
133
+ "children": [
134
+ {% if author -%}
135
+ {
136
+ "type": "textRun",
137
+ "text": "{{ author }}",
138
+ "font": {
139
+ "name": "Calibri",
140
+ "size": 24
141
+ }
142
+ }{% if company %},
143
+ {
144
+ "type": "textRun",
145
+ "text": "\n{{ company }}",
146
+ "font": {
147
+ "name": "Calibri",
148
+ "size": 20
149
+ }
150
+ }{% endif %}{% if date %},
151
+ {
152
+ "type": "textRun",
153
+ "text": "\n{{ date | formatDate | default(timestamp | formatDate) }}",
154
+ "font": {
155
+ "name": "Calibri",
156
+ "size": 18
157
+ }
158
+ }{% endif %}
159
+ {% endif %}
160
+ ]
161
+ },
162
+ {% endif -%}
163
+ {% for section in sections %}
164
+ {
165
+ "type": "paragraph",
166
+ "spacing": {
167
+ "before": 400,
168
+ "after": 200
169
+ },
170
+ "children": [
171
+ {
172
+ "type": "textRun",
173
+ "text": "{{ section.title }}",
174
+ "font": {
175
+ "name": "Calibri",
176
+ "size": 28
177
+ },
178
+ "bold": true
179
+ }
180
+ ]
181
+ },
182
+ {% if section.content %}
183
+ {% if section.content is string %}
184
+ {
185
+ "type": "paragraph",
186
+ "alignment": "justify",
187
+ "spacing": {
188
+ "line": 360,
189
+ "after": 200
190
+ },
191
+ "children": [
192
+ {
193
+ "type": "textRun",
194
+ "text": "{{ section.content }}",
195
+ "font": {
196
+ "name": "Calibri",
197
+ "size": 22
198
+ }
199
+ }
200
+ ]
201
+ },
202
+ {% else %}
203
+ {% for paragraph in section.content %}
204
+ {
205
+ "type": "paragraph",
206
+ "alignment": "justify",
207
+ "spacing": {
208
+ "line": 360,
209
+ "after": 200
210
+ },
211
+ "children": [
212
+ {
213
+ "type": "textRun",
214
+ "text": "{{ paragraph.text if paragraph.text else paragraph }}",
215
+ "font": {
216
+ "name": "Calibri",
217
+ "size": 22
218
+ }{% if paragraph.bold %},
219
+ "bold": true{% endif %}{% if paragraph.italic %},
220
+ "italic": true{% endif %}
221
+ }
222
+ ]
223
+ },
224
+ {% endfor %}
225
+ {% endif %}
226
+ {% endif %}
227
+ {% if section.list %}
228
+ {
229
+ "type": "paragraph",
230
+ "children": []
231
+ },
232
+ {% for item in section.list %}
233
+ {
234
+ "type": "paragraph",
235
+ "numbering": {
236
+ "reference": "bullet-points",
237
+ "level": 0
238
+ },
239
+ "children": [
240
+ {
241
+ "type": "textRun",
242
+ "text": "{{ item.text if item.text else item }}",
243
+ "font": {
244
+ "name": "Calibri",
245
+ "size": 22
246
+ }
247
+ }
248
+ ]
249
+ },
250
+ {% endfor %}
251
+ {% endif %}
252
+ {% if section.table %}
253
+ {
254
+ "type": "table",
255
+ "rows": [
256
+ {
257
+ "children": [
258
+ {% for header in section.table.headers %}
259
+ {
260
+ "children": [
261
+ {
262
+ "type": "paragraph",
263
+ "children": [
264
+ {
265
+ "type": "textRun",
266
+ "text": "{{ header }}",
267
+ "font": {
268
+ "name": "Calibri",
269
+ "size": 22
270
+ },
271
+ "bold": true
272
+ }
273
+ ]
274
+ }
275
+ ],
276
+ "shading": {
277
+ "fill": "DDDDDD"
278
+ }
279
+ }{% if not loop.last %},{% endif %}
280
+ {% endfor %}
281
+ ]
282
+ },
283
+ {% for row in section.table.rows %}
284
+ {
285
+ "children": [
286
+ {% for cell in row %}
287
+ {
288
+ "children": [
289
+ {
290
+ "type": "paragraph",
291
+ "children": [
292
+ {
293
+ "type": "textRun",
294
+ "text": "{{ cell }}",
295
+ "font": {
296
+ "name": "Calibri",
297
+ "size": 22
298
+ }
299
+ }
300
+ ]
301
+ }
302
+ ]
303
+ }{% if not loop.last %},{% endif %}
304
+ {% endfor %}
305
+ ]
306
+ }{% if not loop.last %},{% endif %}
307
+ {% endfor %}
308
+ ]
309
+ },
310
+ {% endif %}
311
+ {% endfor %}
312
+ {% if conclusion %}
313
+ {
314
+ "type": "paragraph",
315
+ "spacing": {
316
+ "before": 600,
317
+ "after": 200
318
+ },
319
+ "children": [
320
+ {
321
+ "type": "textRun",
322
+ "text": "Conclusion",
323
+ "font": {
324
+ "name": "Calibri",
325
+ "size": 28
326
+ },
327
+ "bold": true
328
+ }
329
+ ]
330
+ },
331
+ {
332
+ "type": "paragraph",
333
+ "alignment": "justify",
334
+ "spacing": {
335
+ "line": 360
336
+ },
337
+ "children": [
338
+ {
339
+ "type": "textRun",
340
+ "text": "{{ conclusion }}",
341
+ "font": {
342
+ "name": "Calibri",
343
+ "size": 22
344
+ }
345
+ }
346
+ ]
347
+ }
348
+ {% endif %}
349
+ ]
350
+ }
351
+ ],
352
+ "numbering": {
353
+ "config": [
354
+ {
355
+ "reference": "bullet-points",
356
+ "levels": [
357
+ {
358
+ "level": 0,
359
+ "format": "bullet",
360
+ "text": "•",
361
+ "alignment": "left"
362
+ }
363
+ ]
364
+ }
365
+ ]
366
+ }
367
+ }
368
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Microsoft Office Template Pack
3
+ * Templates for generating Office documents (Word, Excel, PowerPoint)
4
+ */
5
+
6
+ export const templates = {
7
+ 'word-document': {
8
+ name: 'Word Document',
9
+ description: 'Microsoft Word document with structured content',
10
+ path: 'office/docx/document.njk',
11
+ variables: {
12
+ title: 'Document title',
13
+ author: 'Document author',
14
+ company: 'Company name',
15
+ sections: 'Document sections (array)',
16
+ includeHeader: 'Include document header (boolean)',
17
+ includeFooter: 'Include document footer (boolean)'
18
+ }
19
+ },
20
+
21
+ 'word-report': {
22
+ name: 'Word Report',
23
+ description: 'Professional report template for Word',
24
+ path: 'office/docx/report.njk',
25
+ variables: {
26
+ title: 'Report title',
27
+ author: 'Report author',
28
+ date: 'Report date',
29
+ executive_summary: 'Executive summary text',
30
+ sections: 'Report sections with content',
31
+ appendices: 'Report appendices (optional)'
32
+ }
33
+ },
34
+
35
+ 'excel-workbook': {
36
+ name: 'Excel Workbook',
37
+ description: 'Excel workbook with multiple worksheets',
38
+ path: 'office/xlsx/workbook.njk',
39
+ variables: {
40
+ workbookName: 'Name of the workbook',
41
+ worksheets: 'Array of worksheet configurations',
42
+ includeCharts: 'Include chart definitions (boolean)',
43
+ includePivot: 'Include pivot table definitions (boolean)'
44
+ }
45
+ },
46
+
47
+ 'powerpoint-presentation': {
48
+ name: 'PowerPoint Presentation',
49
+ description: 'PowerPoint presentation with slides',
50
+ path: 'office/pptx/presentation.njk',
51
+ variables: {
52
+ title: 'Presentation title',
53
+ author: 'Presentation author',
54
+ slides: 'Array of slide configurations',
55
+ theme: 'Presentation theme',
56
+ includeNotes: 'Include speaker notes (boolean)'
57
+ }
58
+ }
59
+ };
60
+
61
+ export const categories = {
62
+ word: ['word-document', 'word-report'],
63
+ excel: ['excel-workbook'],
64
+ powerpoint: ['powerpoint-presentation']
65
+ };
66
+
67
+ export const formats = {
68
+ docx: 'Microsoft Word Document',
69
+ xlsx: 'Microsoft Excel Workbook',
70
+ pptx: 'Microsoft PowerPoint Presentation'
71
+ };
72
+
73
+ export const getTemplate = (name) => templates[name];
74
+ export const getTemplatesByCategory = (category) =>
75
+ categories[category]?.map(name => templates[name]) || [];
76
+ export const getTemplatesByFormat = (format) =>
77
+ Object.values(templates).filter(t => t.path.includes(`/${format}/`));
78
+
79
+ export default templates;
@@ -0,0 +1,129 @@
1
+ ---
2
+ name: Word Report Template
3
+ description: Professional Word document report with sections and formatting
4
+ version: 1.0.0
5
+ type: document
6
+ category: office
7
+ outputFormat: docx
8
+ variables:
9
+ title: Document title
10
+ author: Document author
11
+ date: Document date (defaults to current)
12
+ abstract: Executive summary or abstract
13
+ sections: Array of section objects with title, content, subsections
14
+ appendices: Array of appendix sections
15
+ includeTableOfContents: Include TOC (default: true)
16
+ includePageNumbers: Include page numbers (default: true)
17
+ references: Bibliography references
18
+ ---
19
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
20
+ <w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
21
+ <w:body>
22
+ {# Title Page #}
23
+ <w:p>
24
+ <w:pPr><w:jc w:val="center"/><w:spacing w:before="240" w:after="240"/></w:pPr>
25
+ <w:r>
26
+ <w:rPr><w:b/><w:sz w:val="48"/></w:rPr>
27
+ <w:t>{{ title }}</w:t>
28
+ </w:r>
29
+ </w:p>
30
+
31
+ {% if author %}
32
+ <w:p>
33
+ <w:pPr><w:jc w:val="center"/></w:pPr>
34
+ <w:r>
35
+ <w:rPr><w:sz w:val="24"/></w:rPr>
36
+ <w:t>{{ author }}</w:t>
37
+ </w:r>
38
+ </w:p>
39
+ {% endif %}
40
+
41
+ <w:p>
42
+ <w:pPr><w:jc w:val="center"/></w:pPr>
43
+ <w:r>
44
+ <w:t>{{ date | default(now() | date('MMMM d, yyyy')) }}</w:t>
45
+ </w:r>
46
+ </w:p>
47
+
48
+ {# Page Break #}
49
+ <w:p><w:r><w:br w:type="page"/></w:r></w:p>
50
+
51
+ {# Table of Contents #}
52
+ {% if includeTableOfContents %}
53
+ <w:p>
54
+ <w:pPr><w:pStyle w:val="Heading1"/></w:pPr>
55
+ <w:r><w:t>Table of Contents</w:t></w:r>
56
+ </w:p>
57
+ <w:p>
58
+ <w:r><w:fldSimple w:instr="TOC \o &quot;1-3&quot; \h \z \u"/></w:r>
59
+ </w:p>
60
+ <w:p><w:r><w:br w:type="page"/></w:r></w:p>
61
+ {% endif %}
62
+
63
+ {# Abstract #}
64
+ {% if abstract %}
65
+ <w:p>
66
+ <w:pPr><w:pStyle w:val="Heading1"/></w:pPr>
67
+ <w:r><w:t>Abstract</w:t></w:r>
68
+ </w:p>
69
+ <w:p>
70
+ <w:r><w:t>{{ abstract }}</w:t></w:r>
71
+ </w:p>
72
+ <w:p><w:r><w:br w:type="page"/></w:r></w:p>
73
+ {% endif %}
74
+
75
+ {# Main Content Sections #}
76
+ {% for section in sections %}
77
+ <w:p>
78
+ <w:pPr><w:pStyle w:val="Heading1"/></w:pPr>
79
+ <w:r><w:t>{{ loop.index }}. {{ section.title }}</w:t></w:r>
80
+ </w:p>
81
+
82
+ {% if section.content %}
83
+ <w:p>
84
+ <w:r><w:t>{{ section.content }}</w:t></w:r>
85
+ </w:p>
86
+ {% endif %}
87
+
88
+ {% if section.subsections %}
89
+ {% for subsection in section.subsections %}
90
+ <w:p>
91
+ <w:pPr><w:pStyle w:val="Heading2"/></w:pPr>
92
+ <w:r><w:t>{{ loop.parent.loop.index }}.{{ loop.index }} {{ subsection.title }}</w:t></w:r>
93
+ </w:p>
94
+ <w:p>
95
+ <w:r><w:t>{{ subsection.content }}</w:t></w:r>
96
+ </w:p>
97
+ {% endfor %}
98
+ {% endif %}
99
+ {% endfor %}
100
+
101
+ {# References #}
102
+ {% if references %}
103
+ <w:p><w:r><w:br w:type="page"/></w:r></w:p>
104
+ <w:p>
105
+ <w:pPr><w:pStyle w:val="Heading1"/></w:pPr>
106
+ <w:r><w:t>References</w:t></w:r>
107
+ </w:p>
108
+ {% for ref in references %}
109
+ <w:p>
110
+ <w:r><w:t>[{{ loop.index }}] {{ ref }}</w:t></w:r>
111
+ </w:p>
112
+ {% endfor %}
113
+ {% endif %}
114
+
115
+ {# Appendices #}
116
+ {% if appendices %}
117
+ {% for appendix in appendices %}
118
+ <w:p><w:r><w:br w:type="page"/></w:r></w:p>
119
+ <w:p>
120
+ <w:pPr><w:pStyle w:val="Heading1"/></w:pPr>
121
+ <w:r><w:t>Appendix {{ loop.index | alpha | upper }}: {{ appendix.title }}</w:t></w:r>
122
+ </w:p>
123
+ <w:p>
124
+ <w:r><w:t>{{ appendix.content }}</w:t></w:r>
125
+ </w:p>
126
+ {% endfor %}
127
+ {% endif %}
128
+ </w:body>
129
+ </w:document>