@oml/cli 0.13.0 → 0.14.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 (77) hide show
  1. package/README.md +28 -21
  2. package/out/{auth.d.ts → auth/auth.d.ts} +7 -0
  3. package/out/{auth.js → auth/auth.js} +42 -3
  4. package/out/auth/auth.js.map +1 -0
  5. package/out/{platform-constants.js → auth/constants.js} +1 -1
  6. package/out/auth/constants.js.map +1 -0
  7. package/out/{platform.d.ts → auth/platform.d.ts} +5 -7
  8. package/out/{platform.js → auth/platform.js} +13 -19
  9. package/out/auth/platform.js.map +1 -0
  10. package/out/cli.d.ts +6 -0
  11. package/out/cli.js +175 -62
  12. package/out/cli.js.map +1 -1
  13. package/out/commands/export.d.ts +8 -0
  14. package/out/commands/export.js +27 -0
  15. package/out/commands/export.js.map +1 -0
  16. package/out/commands/lint.d.ts +22 -2
  17. package/out/commands/lint.js +64 -18
  18. package/out/commands/lint.js.map +1 -1
  19. package/out/commands/reason.d.ts +2 -9
  20. package/out/commands/reason.js +52 -48
  21. package/out/commands/reason.js.map +1 -1
  22. package/out/commands/render.d.ts +1 -9
  23. package/out/commands/render.js +15 -726
  24. package/out/commands/render.js.map +1 -1
  25. package/out/commands/server/actions.d.ts +22 -0
  26. package/out/commands/server/actions.js +394 -0
  27. package/out/commands/server/actions.js.map +1 -0
  28. package/out/commands/server/require.d.ts +1 -0
  29. package/out/commands/server/require.js +89 -0
  30. package/out/commands/server/require.js.map +1 -0
  31. package/out/commands/server/rest.d.ts +2 -0
  32. package/out/commands/server/rest.js +117 -0
  33. package/out/commands/server/rest.js.map +1 -0
  34. package/out/commands/validate.d.ts +3 -3
  35. package/out/commands/validate.js +35 -171
  36. package/out/commands/validate.js.map +1 -1
  37. package/package.json +5 -7
  38. package/src/{auth.ts → auth/auth.ts} +54 -3
  39. package/src/{platform.ts → auth/platform.ts} +13 -19
  40. package/src/cli.ts +207 -63
  41. package/src/commands/export.ts +54 -0
  42. package/src/commands/lint.ts +88 -18
  43. package/src/commands/reason.ts +69 -56
  44. package/src/commands/render.ts +23 -995
  45. package/src/commands/server/actions.ts +480 -0
  46. package/src/commands/server/require.ts +99 -0
  47. package/src/commands/server/rest.ts +135 -0
  48. package/src/commands/validate.ts +46 -207
  49. package/out/auth.js.map +0 -1
  50. package/out/backend/backend-types.d.ts +0 -21
  51. package/out/backend/backend-types.js +0 -3
  52. package/out/backend/backend-types.js.map +0 -1
  53. package/out/backend/create-backend.d.ts +0 -2
  54. package/out/backend/create-backend.js +0 -6
  55. package/out/backend/create-backend.js.map +0 -1
  56. package/out/backend/direct-backend.d.ts +0 -20
  57. package/out/backend/direct-backend.js +0 -150
  58. package/out/backend/direct-backend.js.map +0 -1
  59. package/out/backend/reasoned-output.d.ts +0 -38
  60. package/out/backend/reasoned-output.js +0 -568
  61. package/out/backend/reasoned-output.js.map +0 -1
  62. package/out/commands/closure.d.ts +0 -33
  63. package/out/commands/closure.js +0 -537
  64. package/out/commands/closure.js.map +0 -1
  65. package/out/commands/compile.d.ts +0 -11
  66. package/out/commands/compile.js +0 -63
  67. package/out/commands/compile.js.map +0 -1
  68. package/out/platform-constants.js.map +0 -1
  69. package/out/platform.js.map +0 -1
  70. package/src/backend/backend-types.ts +0 -27
  71. package/src/backend/create-backend.ts +0 -8
  72. package/src/backend/direct-backend.ts +0 -169
  73. package/src/backend/reasoned-output.ts +0 -697
  74. package/src/commands/closure.ts +0 -624
  75. package/src/commands/compile.ts +0 -88
  76. /package/out/{platform-constants.d.ts → auth/constants.d.ts} +0 -0
  77. /package/src/{platform-constants.ts → auth/constants.ts} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAG3F,OAAO,KAAK,MAAM,OAA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AC"}
@@ -1,27 +0,0 @@
1
- // Copyright (c) 2026 Modelware. All rights reserved.
2
-
3
- import type { MdExecuteBlocksParams, MdExecuteBlocksResult } from '@oml/markdown';
4
-
5
- export interface ValidateSummary {
6
- filesChecked: number;
7
- warnings: number;
8
- }
9
-
10
- export interface MarkdownRenderResult {
11
- renderedHtml: string;
12
- contextUri?: string;
13
- }
14
-
15
- export interface CliBackendOptions {
16
- owlOutputRoot?: string;
17
- rdfFormat?: string;
18
- }
19
-
20
- export interface CliBackend {
21
- validate(fileName: string | undefined, workspaceRoot: string): Promise<ValidateSummary>;
22
- renderMarkdown(markdown: string): Promise<MarkdownRenderResult>;
23
- executeMarkdownBlocks(params: MdExecuteBlocksParams, workspaceRoot: string): Promise<MdExecuteBlocksResult>;
24
- getContextMemberLabelSnapshot(modelUri: string, workspaceRoot: string): Promise<Record<string, string>>;
25
- getWorkspaceMemberLabelSnapshot(workspaceRoot: string): Promise<Record<string, string>>;
26
- dispose(): Promise<void>;
27
- }
@@ -1,8 +0,0 @@
1
- // Copyright (c) 2026 Modelware. All rights reserved.
2
-
3
- import { DirectBackend } from './direct-backend.js';
4
- import type { CliBackend, CliBackendOptions } from './backend-types.js';
5
-
6
- export function createBackend(options: CliBackendOptions = {}): CliBackend {
7
- return new DirectBackend(options);
8
- }
@@ -1,169 +0,0 @@
1
- // Copyright (c) 2026 Modelware. All rights reserved.
2
-
3
- import { createOwlServices } from '@oml/owl';
4
- import { MarkdownHandlerRegistry, MarkdownPreviewRuntime } from '@oml/markdown';
5
- import { MarkdownExecutor, type MdExecuteBlocksParams, type MdExecuteBlocksResult } from '@oml/markdown';
6
- import { getOntologyModelIndex } from '@oml/language';
7
- import { NodeFileSystem } from 'langium/node';
8
- import { URI } from 'langium';
9
- import * as fs from 'node:fs/promises';
10
- import * as path from 'node:path';
11
- import { extractDocument } from '../util.js';
12
- import type { CliBackend, CliBackendOptions, MarkdownRenderResult, ValidateSummary } from './backend-types.js';
13
- import { loadPreparedDatasetFromOutput, normalizeFormatExtension } from './reasoned-output.js';
14
-
15
- export class DirectBackend implements CliBackend {
16
- private readonly markdownRuntime = new MarkdownPreviewRuntime(new MarkdownHandlerRegistry());
17
- private readonly owlOutputRoot?: string;
18
- private readonly rdfFormat: string;
19
- private readonly contextLabelSnapshots = new Map<string, Record<string, string>>();
20
- private servicesBundle?: ReturnType<typeof createOwlServices>;
21
- private initializedWorkspaceRoot?: string;
22
- private loadedDatasetKey?: string;
23
-
24
- constructor(options: CliBackendOptions = {}) {
25
- this.owlOutputRoot = options.owlOutputRoot ? path.resolve(options.owlOutputRoot) : undefined;
26
- this.rdfFormat = normalizeFormatExtension(options.rdfFormat);
27
- }
28
-
29
- async validate(fileName: string | undefined, workspaceRoot: string): Promise<ValidateSummary> {
30
- const services = await this.ensureServices(workspaceRoot);
31
-
32
- if (fileName) {
33
- const document = await extractDocument(fileName, services, undefined);
34
- const warnings = (document.diagnostics ?? []).filter((d) => d.severity === 2).length;
35
- return { filesChecked: 1, warnings };
36
- }
37
-
38
- const files = await findOmlFiles(workspaceRoot);
39
- let warningCount = 0;
40
- for (const file of files) {
41
- const document = await extractDocument(file, services, undefined);
42
- warningCount += (document.diagnostics ?? []).filter((d) => d.severity === 2).length;
43
- }
44
- return { filesChecked: files.length, warnings: warningCount };
45
- }
46
-
47
- async renderMarkdown(markdown: string): Promise<MarkdownRenderResult> {
48
- const rendered = this.markdownRuntime.prepare(markdown);
49
- return {
50
- renderedHtml: rendered.renderedHtml,
51
- contextUri: rendered.contextUri
52
- };
53
- }
54
-
55
- async executeMarkdownBlocks(params: MdExecuteBlocksParams, workspaceRoot: string): Promise<MdExecuteBlocksResult> {
56
- const services = await this.ensureServices(workspaceRoot);
57
- await this.ensurePreparedDataset(workspaceRoot, services);
58
- const reasoningService = services.reasoning.ReasoningService as any;
59
- const ontologyIndex = getOntologyModelIndex(services.shared as any);
60
- const knownNamespaceCache = new Map<string, boolean>();
61
- const isKnownOntologyIriNamespace = (ontologyIri: string): boolean => {
62
- const normalized = ontologyIri.trim().replace(/[\/#]+$/, '');
63
- if (!normalized) {
64
- return false;
65
- }
66
- const cached = knownNamespaceCache.get(normalized);
67
- if (cached !== undefined) {
68
- return cached;
69
- }
70
- if (ontologyIndex.resolveModelUri(normalized)) {
71
- knownNamespaceCache.set(normalized, true);
72
- return true;
73
- }
74
- const exists = ontologyIndex.getDuplicateWorkspaceModelUris(normalized).length > 0;
75
- knownNamespaceCache.set(normalized, exists);
76
- return exists;
77
- };
78
- const executor = new MarkdownExecutor({
79
- ensureContext: (modelUri) => reasoningService.ensureQueryContext(modelUri),
80
- resolveContextIri: (modelUri) => reasoningService.getContextIri(modelUri),
81
- query: (modelUri, sparql) => reasoningService.getSparqlService().query(modelUri, sparql),
82
- construct: (modelUri, sparql) => reasoningService.getSparqlService().construct(modelUri, sparql),
83
- isKnownOntologyIriNamespace,
84
- });
85
- return executor.executeBlocks(params);
86
- }
87
-
88
- async getContextMemberLabelSnapshot(modelUri: string, workspaceRoot: string): Promise<Record<string, string>> {
89
- const resolvedModelUri = modelUri.trim();
90
- if (!resolvedModelUri) {
91
- return {};
92
- }
93
- const cached = this.contextLabelSnapshots.get(resolvedModelUri);
94
- if (cached) {
95
- return cached;
96
- }
97
- const services = await this.ensureServices(workspaceRoot);
98
- await this.ensurePreparedDataset(workspaceRoot, services);
99
- const reasoningService = services.reasoning.ReasoningService as any;
100
- const snapshot = await reasoningService.getContextMemberLabelSnapshot(resolvedModelUri);
101
- this.contextLabelSnapshots.set(resolvedModelUri, snapshot);
102
- return snapshot;
103
- }
104
-
105
- async getWorkspaceMemberLabelSnapshot(workspaceRoot: string): Promise<Record<string, string>> {
106
- const cacheKey = `workspace:${path.resolve(workspaceRoot)}`;
107
- const cached = this.contextLabelSnapshots.get(cacheKey);
108
- if (cached) {
109
- return cached;
110
- }
111
- const services = await this.ensureServices(workspaceRoot);
112
- await this.ensurePreparedDataset(workspaceRoot, services);
113
- const reasoningService = services.reasoning.ReasoningService as any;
114
- const snapshot = await reasoningService.getWorkspaceMemberLabelSnapshot();
115
- this.contextLabelSnapshots.set(cacheKey, snapshot);
116
- return snapshot;
117
- }
118
-
119
- async dispose(): Promise<void> {
120
- this.servicesBundle = undefined;
121
- this.initializedWorkspaceRoot = undefined;
122
- this.loadedDatasetKey = undefined;
123
- this.contextLabelSnapshots.clear();
124
- }
125
-
126
- private async ensureServices(workspaceRoot: string): Promise<ReturnType<typeof createOwlServices>['Oml']> {
127
- const resolvedRoot = path.resolve(workspaceRoot);
128
- if (!this.servicesBundle || this.initializedWorkspaceRoot !== resolvedRoot) {
129
- this.servicesBundle = createOwlServices(NodeFileSystem);
130
- this.initializedWorkspaceRoot = resolvedRoot;
131
- this.contextLabelSnapshots.clear();
132
- await this.servicesBundle.Oml.shared.workspace.WorkspaceManager.initializeWorkspace([
133
- { uri: URI.file(resolvedRoot).toString(), name: path.basename(resolvedRoot) }
134
- ]);
135
- }
136
- return this.servicesBundle.Oml;
137
- }
138
-
139
- private async ensurePreparedDataset(workspaceRoot: string, services: ReturnType<typeof createOwlServices>['Oml']): Promise<void> {
140
- if (!this.owlOutputRoot) {
141
- throw new Error('CLI markdown execution requires a prepared RDF output folder.');
142
- }
143
- const datasetKey = `${this.initializedWorkspaceRoot ?? ''}|${this.owlOutputRoot}|${this.rdfFormat}`;
144
- if (this.loadedDatasetKey === datasetKey) {
145
- return;
146
- }
147
- const prepared = await loadPreparedDatasetFromOutput(path.resolve(workspaceRoot), this.owlOutputRoot, this.rdfFormat);
148
- services.reasoning.ReasoningService.loadPreparedDataset(prepared);
149
- this.loadedDatasetKey = datasetKey;
150
- }
151
- }
152
-
153
- async function findOmlFiles(root: string): Promise<string[]> {
154
- const entries = await fs.readdir(root, { withFileTypes: true });
155
- const results: string[] = [];
156
-
157
- for (const entry of entries) {
158
- const fullPath = path.join(root, entry.name);
159
- if (entry.isDirectory()) {
160
- if (entry.name === 'node_modules' || entry.name.startsWith('.')) {
161
- continue;
162
- }
163
- results.push(...await findOmlFiles(fullPath));
164
- } else if (entry.isFile() && path.extname(entry.name) === '.oml') {
165
- results.push(fullPath);
166
- }
167
- }
168
- return results;
169
- }