@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,186 @@
1
+ ---
2
+ name: LaTeX Academic Paper
3
+ description: IEEE/ACM style academic paper with proper formatting and bibliography
4
+ version: 1.0.0
5
+ type: document
6
+ category: latex
7
+ variables:
8
+ title: Paper title
9
+ authors: Array of author objects with name, affiliation, email
10
+ abstract: Paper abstract text
11
+ keywords: Array of paper keywords
12
+ sections: Paper sections with title and content
13
+ references: Bibliography references
14
+ documentClass: LaTeX document class (default: article)
15
+ usePackages: Additional LaTeX packages to include
16
+ twoColumn: Use two-column format (default: false)
17
+ ---
18
+ \documentclass[{% if twoColumn %}twocolumn,{% endif %}10pt,conference]{{{ documentClass | default('IEEEtran') }}}
19
+
20
+ % Standard packages
21
+ \usepackage[utf8]{inputenc}
22
+ \usepackage[T1]{fontenc}
23
+ \usepackage{amsmath,amsfonts,amssymb}
24
+ \usepackage{graphicx}
25
+ \usepackage{url}
26
+ \usepackage{cite}
27
+ \usepackage{balance}
28
+ {% if usePackages -%}
29
+ {% for package in usePackages %}
30
+ \usepackage{{{ package }}}
31
+ {% endfor %}
32
+ {% endif %}
33
+
34
+ % Document information
35
+ \title{{{ title }}}
36
+
37
+ {% if authors -%}
38
+ \author{%
39
+ {% for author in authors -%}
40
+ \IEEEauthorblockN{{{ author.name }}}
41
+ \IEEEauthorblockA{{{ author.affiliation }}{% if author.email %}\\
42
+ Email: {{ author.email }}{% endif %}}{% if not loop.last %}
43
+ \and
44
+ {% endif %}
45
+ {% endfor %}
46
+ }
47
+ {% endif %}
48
+
49
+ \begin{document}
50
+
51
+ \maketitle
52
+
53
+ {% if abstract -%}
54
+ \begin{abstract}
55
+ {{ abstract }}
56
+ \end{abstract}
57
+ {% endif %}
58
+
59
+ {% if keywords -%}
60
+ \begin{IEEEkeywords}
61
+ {{ keywords | join(', ') }}
62
+ \end{IEEEkeywords}
63
+ {% endif %}
64
+
65
+ {% for section in sections %}
66
+ \section{{{ section.title }}}
67
+ {% if section.label -%}
68
+ \label{sec:{{ section.label }}}
69
+ {% endif %}
70
+
71
+ {% if section.content -%}
72
+ {{ section.content }}
73
+ {% endif %}
74
+
75
+ {% if section.subsections -%}
76
+ {% for subsection in section.subsections %}
77
+ \subsection{{{ subsection.title }}}
78
+ {% if subsection.label -%}
79
+ \label{subsec:{{ subsection.label }}}
80
+ {% endif %}
81
+
82
+ {{ subsection.content }}
83
+
84
+ {% endfor %}
85
+ {% endif %}
86
+
87
+ {% if section.figure -%}
88
+ \begin{figure}[{{ section.figure.placement | default('htbp') }}]
89
+ \centering
90
+ \includegraphics[width={{ section.figure.width | default('0.8\\columnwidth') }}]{{{ section.figure.file }}}
91
+ \caption{{{ section.figure.caption }}}
92
+ {% if section.figure.label -%}
93
+ \label{fig:{{ section.figure.label }}}
94
+ {% endif %}
95
+ \end{figure}
96
+ {% endif %}
97
+
98
+ {% if section.table -%}
99
+ \begin{table}[{{ section.table.placement | default('htbp') }}]
100
+ \centering
101
+ \caption{{{ section.table.caption }}}
102
+ {% if section.table.label -%}
103
+ \label{tab:{{ section.table.label }}}
104
+ {% endif %}
105
+ \begin{tabular}{{{ section.table.columns }}}
106
+ \hline
107
+ {% for header in section.table.headers -%}
108
+ {{ header }}{% if not loop.last %} & {% endif %}
109
+ {% endfor %} \\
110
+ \hline
111
+ {% for row in section.table.rows %}
112
+ {% for cell in row -%}
113
+ {{ cell }}{% if not loop.last %} & {% endif %}
114
+ {% endfor %} \\
115
+ {% endfor %}
116
+ \hline
117
+ \end{tabular}
118
+ \end{table}
119
+ {% endif %}
120
+
121
+ {% if section.algorithm -%}
122
+ \begin{algorithm}[{{ section.algorithm.placement | default('htbp') }}]
123
+ \caption{{{ section.algorithm.caption }}}
124
+ {% if section.algorithm.label -%}
125
+ \label{alg:{{ section.algorithm.label }}}
126
+ {% endif %}
127
+ \begin{algorithmic}[1]
128
+ {% for step in section.algorithm.steps %}
129
+ \{{ step.command | default('STATE') }} {{ step.text }}
130
+ {% endfor %}
131
+ \end{algorithmic}
132
+ \end{algorithm}
133
+ {% endif %}
134
+
135
+ {% endfor %}
136
+
137
+ {% if acknowledgments -%}
138
+ \section*{Acknowledgments}
139
+ {{ acknowledgments }}
140
+ {% endif %}
141
+
142
+ {% if references -%}
143
+ \begin{thebibliography}{99}
144
+ {% for ref in references %}
145
+ \bibitem{{{ ref.key }}}
146
+ {% if ref.authors -%}
147
+ {{ ref.authors | join(', ') }}.
148
+ {% endif %}
149
+ ``{{ ref.title }}.''
150
+ {% if ref.journal -%}
151
+ \emph{{{ ref.journal }}}{% if ref.volume %}, vol.~{{ ref.volume }}{% endif %}{% if ref.number %}, no.~{{ ref.number }}{% endif %}{% if ref.pages %}, pp.~{{ ref.pages }}{% endif %}, {{ ref.year }}.
152
+ {% elif ref.booktitle -%}
153
+ In \emph{{{ ref.booktitle }}}{% if ref.pages %}, pp.~{{ ref.pages }}{% endif %}, {{ ref.year }}.
154
+ {% elif ref.publisher -%}
155
+ {{ ref.publisher }}, {{ ref.year }}.
156
+ {% else %}
157
+ {{ ref.year }}.
158
+ {% endif %}
159
+ {% if ref.doi -%}
160
+ DOI: {{ ref.doi }}
161
+ {% endif %}
162
+ {% if ref.url -%}
163
+ Available: {{ ref.url }}
164
+ {% endif %}
165
+
166
+ {% endfor %}
167
+ \end{thebibliography}
168
+ {% endif %}
169
+
170
+ {% if appendices -%}
171
+ \appendices
172
+ {% for appendix in appendices %}
173
+ \section{{{ appendix.title }}}
174
+ {% if appendix.label -%}
175
+ \label{app:{{ appendix.label }}}
176
+ {% endif %}
177
+
178
+ {{ appendix.content }}
179
+
180
+ {% endfor %}
181
+ {% endif %}
182
+
183
+ {% if twoColumn -%}
184
+ \balance
185
+ {% endif %}
186
+ \end{document}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * LaTeX Template Pack
3
+ * Professional LaTeX document templates for academic and technical writing
4
+ */
5
+
6
+ export const templates = {
7
+ 'academic-paper': {
8
+ name: 'Academic Paper',
9
+ description: 'IEEE/ACM style academic paper template',
10
+ path: 'latex/academic-paper.njk',
11
+ variables: {
12
+ title: 'Paper title',
13
+ authors: 'Array of author objects with name, affiliation',
14
+ abstract: 'Paper abstract',
15
+ keywords: 'Array of keywords',
16
+ sections: 'Paper sections with content',
17
+ references: 'Bibliography references',
18
+ documentClass: 'LaTeX document class (default: article)'
19
+ }
20
+ },
21
+
22
+ 'technical-report': {
23
+ name: 'Technical Report',
24
+ description: 'Professional technical report template',
25
+ path: 'latex/technical-report.njk',
26
+ variables: {
27
+ title: 'Report title',
28
+ author: 'Report author',
29
+ organization: 'Organization name',
30
+ date: 'Report date',
31
+ reportNumber: 'Report number/identifier',
32
+ executiveSummary: 'Executive summary',
33
+ sections: 'Report sections',
34
+ appendices: 'Report appendices'
35
+ }
36
+ },
37
+
38
+ 'thesis': {
39
+ name: 'Thesis/Dissertation',
40
+ description: 'University thesis/dissertation template',
41
+ path: 'latex/thesis.njk',
42
+ variables: {
43
+ title: 'Thesis title',
44
+ author: 'Author name',
45
+ degree: 'Degree type (PhD, Masters)',
46
+ department: 'Department name',
47
+ university: 'University name',
48
+ year: 'Graduation year',
49
+ advisor: 'Thesis advisor',
50
+ committee: 'Committee members',
51
+ chapters: 'Thesis chapters'
52
+ }
53
+ },
54
+
55
+ 'presentation': {
56
+ name: 'Beamer Presentation',
57
+ description: 'LaTeX Beamer presentation template',
58
+ path: 'latex/presentation.njk',
59
+ variables: {
60
+ title: 'Presentation title',
61
+ author: 'Presenter name',
62
+ institute: 'Institution',
63
+ date: 'Presentation date',
64
+ theme: 'Beamer theme (default: default)',
65
+ slides: 'Array of slide configurations'
66
+ }
67
+ },
68
+
69
+ 'letter': {
70
+ name: 'Formal Letter',
71
+ description: 'Professional letter template',
72
+ path: 'latex/letter.njk',
73
+ variables: {
74
+ senderName: 'Sender name',
75
+ senderAddress: 'Sender address',
76
+ recipientName: 'Recipient name',
77
+ recipientAddress: 'Recipient address',
78
+ date: 'Letter date',
79
+ subject: 'Letter subject',
80
+ content: 'Letter content',
81
+ closing: 'Letter closing (default: Sincerely)'
82
+ }
83
+ }
84
+ };
85
+
86
+ export const categories = {
87
+ academic: ['academic-paper', 'thesis'],
88
+ professional: ['technical-report', 'letter'],
89
+ presentation: ['presentation']
90
+ };
91
+
92
+ export const documentClasses = {
93
+ article: 'Standard article format',
94
+ report: 'Report with chapters',
95
+ book: 'Book format with parts and chapters',
96
+ beamer: 'Presentation slides',
97
+ letter: 'Letter format'
98
+ };
99
+
100
+ export const getTemplate = (name) => templates[name];
101
+ export const getTemplatesByCategory = (category) =>
102
+ categories[category]?.map(name => templates[name]) || [];
103
+
104
+ export default templates;
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: Next.js App Router Page
3
+ description: Page component for Next.js App Router with metadata and error handling
4
+ version: 1.0.0
5
+ type: component
6
+ category: nextjs
7
+ variables:
8
+ pageName: Page component name (e.g., "Home", "About")
9
+ routePath: Route path (e.g., "/", "/about")
10
+ withMetadata: Include metadata export (default: true)
11
+ withLoading: Include loading component (default: false)
12
+ withError: Include error component (default: false)
13
+ title: Page title for metadata
14
+ description: Page description for metadata
15
+ ---
16
+ {% if withMetadata !== false -%}
17
+ import type { Metadata } from 'next'
18
+
19
+ export const metadata: Metadata = {
20
+ title: '{{ title | default(pageName) }}',
21
+ description: '{{ description | default("") }}',
22
+ }
23
+
24
+ {% endif -%}
25
+ {% if withLoading -%}
26
+ export default function Loading() {
27
+ return (
28
+ <div className="flex items-center justify-center min-h-screen">
29
+ <div className="animate-spin rounded-full h-32 w-32 border-b-2 border-gray-900"></div>
30
+ </div>
31
+ )
32
+ }
33
+
34
+ {% endif -%}
35
+ {% if withError -%}
36
+ export default function Error({
37
+ error,
38
+ reset,
39
+ }: {
40
+ error: Error & { digest?: string }
41
+ reset: () => void
42
+ }) {
43
+ return (
44
+ <div className="flex flex-col items-center justify-center min-h-screen">
45
+ <h2 className="text-2xl font-bold mb-4">Something went wrong!</h2>
46
+ <button
47
+ onClick={() => reset()}
48
+ className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"
49
+ >
50
+ Try again
51
+ </button>
52
+ </div>
53
+ )
54
+ }
55
+
56
+ {% endif -%}
57
+ export default function {{ pageName | pascalCase }}() {
58
+ return (
59
+ <div className="container mx-auto px-4 py-8">
60
+ <h1 className="text-3xl font-bold mb-6">{{ pageName }}</h1>
61
+ <p className="text-gray-600">
62
+ Welcome to the {{ pageName | lower }} page.
63
+ </p>
64
+ </div>
65
+ )
66
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Next.js Template Pack
3
+ * Comprehensive starter templates for Next.js projects
4
+ */
5
+
6
+ export const templates = {
7
+ 'app-page': {
8
+ name: 'Next.js App Router Page',
9
+ description: 'Page component for Next.js App Router',
10
+ path: 'nextjs/app-page.njk',
11
+ variables: {
12
+ pageName: 'Name of the page (e.g., "Home", "About")',
13
+ routePath: 'Route path (e.g., "/", "/about")',
14
+ withMetadata: 'Include metadata export (boolean)',
15
+ withLoading: 'Include loading component (boolean)',
16
+ withError: 'Include error component (boolean)'
17
+ }
18
+ },
19
+
20
+ 'api-route': {
21
+ name: 'Next.js API Route',
22
+ description: 'API route handler for Next.js',
23
+ path: 'nextjs/api-route.njk',
24
+ variables: {
25
+ routeName: 'Name of the API route',
26
+ methods: 'HTTP methods to handle (array)',
27
+ withAuth: 'Include authentication check (boolean)',
28
+ withValidation: 'Include request validation (boolean)'
29
+ }
30
+ },
31
+
32
+ 'component': {
33
+ name: 'Next.js React Component',
34
+ description: 'Reusable React component with TypeScript',
35
+ path: 'nextjs/component.njk',
36
+ variables: {
37
+ componentName: 'Name of the component',
38
+ withProps: 'Include props interface (boolean)',
39
+ withState: 'Include useState hook (boolean)',
40
+ withStyles: 'Include CSS modules (boolean)'
41
+ }
42
+ },
43
+
44
+ 'layout': {
45
+ name: 'Next.js Layout Component',
46
+ description: 'Layout component for consistent page structure',
47
+ path: 'nextjs/layout.njk',
48
+ variables: {
49
+ layoutName: 'Name of the layout',
50
+ withNavigation: 'Include navigation component (boolean)',
51
+ withFooter: 'Include footer component (boolean)',
52
+ withMetadata: 'Include metadata configuration (boolean)'
53
+ }
54
+ },
55
+
56
+ 'middleware': {
57
+ name: 'Next.js Middleware',
58
+ description: 'Middleware for request processing',
59
+ path: 'nextjs/middleware.njk',
60
+ variables: {
61
+ middlewareName: 'Name of the middleware',
62
+ routes: 'Routes to apply middleware (array)',
63
+ withAuth: 'Include authentication logic (boolean)',
64
+ withCORS: 'Include CORS handling (boolean)'
65
+ }
66
+ }
67
+ };
68
+
69
+ export const categories = {
70
+ pages: ['app-page'],
71
+ api: ['api-route'],
72
+ components: ['component', 'layout'],
73
+ middleware: ['middleware']
74
+ };
75
+
76
+ export const getTemplate = (name) => templates[name];
77
+ export const getTemplatesByCategory = (category) =>
78
+ categories[category]?.map(name => templates[name]) || [];
79
+
80
+ export default templates;