@oml/cli 0.12.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.
- package/README.md +29 -21
- package/out/{auth.d.ts → auth/auth.d.ts} +7 -0
- package/out/{auth.js → auth/auth.js} +42 -3
- package/out/auth/auth.js.map +1 -0
- package/out/{platform-constants.js → auth/constants.js} +1 -1
- package/out/auth/constants.js.map +1 -0
- package/out/{platform.d.ts → auth/platform.d.ts} +5 -7
- package/out/{platform.js → auth/platform.js} +39 -17
- package/out/auth/platform.js.map +1 -0
- package/out/cli.d.ts +6 -0
- package/out/cli.js +214 -59
- package/out/cli.js.map +1 -1
- package/out/commands/export.d.ts +8 -0
- package/out/commands/export.js +27 -0
- package/out/commands/export.js.map +1 -0
- package/out/commands/lint.d.ts +22 -2
- package/out/commands/lint.js +64 -18
- package/out/commands/lint.js.map +1 -1
- package/out/commands/reason.d.ts +2 -9
- package/out/commands/reason.js +52 -48
- package/out/commands/reason.js.map +1 -1
- package/out/commands/render.d.ts +1 -9
- package/out/commands/render.js +15 -726
- package/out/commands/render.js.map +1 -1
- package/out/commands/server/actions.d.ts +22 -0
- package/out/commands/server/actions.js +394 -0
- package/out/commands/server/actions.js.map +1 -0
- package/out/commands/server/require.d.ts +1 -0
- package/out/commands/server/require.js +89 -0
- package/out/commands/server/require.js.map +1 -0
- package/out/commands/server/rest.d.ts +2 -0
- package/out/commands/server/rest.js +117 -0
- package/out/commands/server/rest.js.map +1 -0
- package/out/commands/validate.d.ts +3 -3
- package/out/commands/validate.js +35 -171
- package/out/commands/validate.js.map +1 -1
- package/package.json +5 -7
- package/src/{auth.ts → auth/auth.ts} +54 -3
- package/src/{platform.ts → auth/platform.ts} +41 -17
- package/src/cli.ts +249 -59
- package/src/commands/export.ts +54 -0
- package/src/commands/lint.ts +88 -18
- package/src/commands/reason.ts +69 -56
- package/src/commands/render.ts +23 -995
- package/src/commands/server/actions.ts +480 -0
- package/src/commands/server/require.ts +99 -0
- package/src/commands/server/rest.ts +135 -0
- package/src/commands/validate.ts +46 -207
- package/out/auth.js.map +0 -1
- package/out/backend/backend-types.d.ts +0 -21
- package/out/backend/backend-types.js +0 -3
- package/out/backend/backend-types.js.map +0 -1
- package/out/backend/create-backend.d.ts +0 -2
- package/out/backend/create-backend.js +0 -6
- package/out/backend/create-backend.js.map +0 -1
- package/out/backend/direct-backend.d.ts +0 -20
- package/out/backend/direct-backend.js +0 -150
- package/out/backend/direct-backend.js.map +0 -1
- package/out/backend/reasoned-output.d.ts +0 -38
- package/out/backend/reasoned-output.js +0 -568
- package/out/backend/reasoned-output.js.map +0 -1
- package/out/commands/closure.d.ts +0 -33
- package/out/commands/closure.js +0 -537
- package/out/commands/closure.js.map +0 -1
- package/out/commands/compile.d.ts +0 -11
- package/out/commands/compile.js +0 -63
- package/out/commands/compile.js.map +0 -1
- package/out/platform-constants.js.map +0 -1
- package/out/platform.js.map +0 -1
- package/src/backend/backend-types.ts +0 -27
- package/src/backend/create-backend.ts +0 -8
- package/src/backend/direct-backend.ts +0 -169
- package/src/backend/reasoned-output.ts +0 -697
- package/src/commands/closure.ts +0 -624
- package/src/commands/compile.ts +0 -88
- /package/out/{platform-constants.d.ts → auth/constants.d.ts} +0 -0
- /package/src/{platform-constants.ts → auth/constants.ts} +0 -0
package/src/commands/reason.ts
CHANGED
|
@@ -1,77 +1,90 @@
|
|
|
1
1
|
// Copyright (c) 2026 Modelware. All rights reserved.
|
|
2
2
|
|
|
3
|
-
import { createOmlServices } from '@oml/language';
|
|
4
3
|
import chalk from 'chalk';
|
|
5
|
-
import { NodeFileSystem } from 'langium/node';
|
|
6
|
-
import { URI } from 'langium';
|
|
7
|
-
import * as fs from 'node:fs/promises';
|
|
8
4
|
import * as path from 'node:path';
|
|
9
|
-
import { buildWorkspaceDocuments, collectWorkspaceOntologyEntries, normalizeFormatExtension, OntologyInconsistencyError, reasonWorkspaceOntologies } from '../backend/reasoned-output.js';
|
|
10
5
|
import { failCli } from '../cli-error.js';
|
|
11
6
|
import { formatDuration } from '../util.js';
|
|
12
|
-
import {
|
|
7
|
+
import { restPost } from './server/rest.js';
|
|
8
|
+
import { formatLintSummary, printLintDiagnostics, type LintPayload } from './lint.js';
|
|
13
9
|
|
|
14
10
|
export type ReasonOptions = {
|
|
15
|
-
workspace?: string,
|
|
16
|
-
owl?: string,
|
|
17
|
-
format?: string,
|
|
18
|
-
clean?: boolean,
|
|
19
|
-
pretty?: boolean,
|
|
20
11
|
only?: boolean,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
explanations?: boolean,
|
|
24
|
-
profile?: boolean
|
|
12
|
+
explanation?: boolean,
|
|
13
|
+
authToken?: string
|
|
25
14
|
};
|
|
26
15
|
|
|
27
16
|
export const reasonAction = async (opts: ReasonOptions): Promise<void> => {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
const startedAt = Date.now();
|
|
18
|
+
const result = await restPost<{
|
|
19
|
+
success: boolean;
|
|
20
|
+
ontologiesReasoned: number;
|
|
21
|
+
elapsedMs?: number;
|
|
22
|
+
totalElapsedMs?: number;
|
|
23
|
+
inconsistent: Array<{ modelUri: string; validationWarnings: string[] }>;
|
|
24
|
+
failed: Array<{ modelUri: string; error: string }>;
|
|
25
|
+
validate?: {
|
|
26
|
+
success: boolean;
|
|
27
|
+
filesChecked: number;
|
|
28
|
+
errors: number;
|
|
29
|
+
warnings: number;
|
|
30
|
+
elapsedMs?: number;
|
|
31
|
+
lint?: LintPayload;
|
|
32
|
+
error?: string;
|
|
33
|
+
};
|
|
34
|
+
}>('/v0/reason', opts as unknown as Record<string, unknown>, opts.authToken);
|
|
34
35
|
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
if (result.validate?.lint) {
|
|
37
|
+
const lint = result.validate.lint;
|
|
38
|
+
if (lint.filesChecked <= 0) {
|
|
39
|
+
console.log(chalk.yellow('No .oml files found in server workspace.'));
|
|
40
|
+
} else {
|
|
41
|
+
printLintDiagnostics(lint);
|
|
42
|
+
const lintElapsedMs = typeof lint.elapsedMs === 'number' && Number.isFinite(lint.elapsedMs) && lint.elapsedMs >= 0
|
|
43
|
+
? lint.elapsedMs
|
|
44
|
+
: Date.now() - startedAt;
|
|
45
|
+
const lintSummary = formatLintSummary(lint, lintElapsedMs);
|
|
46
|
+
if (lint.errors > 0) {
|
|
47
|
+
failCli(chalk.red(lintSummary));
|
|
48
|
+
}
|
|
49
|
+
if (lint.warnings > 0) {
|
|
50
|
+
failCli(chalk.yellow(lintSummary));
|
|
51
|
+
}
|
|
52
|
+
console.log(chalk.green(lintSummary));
|
|
53
|
+
}
|
|
43
54
|
}
|
|
44
55
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
if (result.validate && result.validate.success) {
|
|
57
|
+
if (result.validate.filesChecked === 0) {
|
|
58
|
+
console.log(chalk.yellow('No markdown/table-editor targets found in server workspace.'));
|
|
59
|
+
} else {
|
|
60
|
+
const validateElapsedMs = typeof result.validate.elapsedMs === 'number'
|
|
61
|
+
&& Number.isFinite(result.validate.elapsedMs)
|
|
62
|
+
&& result.validate.elapsedMs >= 0
|
|
63
|
+
? result.validate.elapsedMs
|
|
64
|
+
: Date.now() - startedAt;
|
|
65
|
+
console.log(chalk.green(`validate: ${result.validate.filesChecked} item(s) checked. [${formatDuration(validateElapsedMs)}]`));
|
|
66
|
+
}
|
|
48
67
|
}
|
|
49
68
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
result = await reasonWorkspaceOntologies(entries, {
|
|
60
|
-
outputRoot,
|
|
61
|
-
format,
|
|
62
|
-
pretty: opts.pretty ?? false,
|
|
63
|
-
explanations: opts.explanations ?? true,
|
|
64
|
-
uniqueNamesAssumption: opts.uniqueNamesAssumption ?? true,
|
|
65
|
-
checkOnly: opts.checkOnly ?? false,
|
|
66
|
-
profile: opts.profile ?? false,
|
|
67
|
-
});
|
|
68
|
-
} catch (error) {
|
|
69
|
-
if (error instanceof OntologyInconsistencyError) {
|
|
70
|
-
failCli(chalk.red(error.message));
|
|
69
|
+
if (!result.success) {
|
|
70
|
+
for (const item of result.failed) {
|
|
71
|
+
const modelUri = String(item.modelUri ?? '').trim();
|
|
72
|
+
console.log(chalk.red(`reason failed: ${modelUri || '<workspace>'}: ${item.error}`));
|
|
73
|
+
}
|
|
74
|
+
for (const item of result.inconsistent) {
|
|
75
|
+
const warnings = item.validationWarnings.length > 0 ? ` warnings=${item.validationWarnings.join('; ')}` : '';
|
|
76
|
+
console.log(chalk.red(`reason inconsistency detected: ${item.modelUri}.${warnings}`));
|
|
71
77
|
}
|
|
72
|
-
|
|
78
|
+
failCli(chalk.red(result.validate?.error?.trim() || 'reason failed.'));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (result.ontologiesReasoned === 0) {
|
|
82
|
+
console.log(chalk.yellow(`No .oml files found under ${path.resolve('.')}.`));
|
|
83
|
+
return;
|
|
73
84
|
}
|
|
74
85
|
|
|
75
|
-
const
|
|
76
|
-
|
|
86
|
+
const reasonElapsedMs = typeof result.elapsedMs === 'number' && Number.isFinite(result.elapsedMs) && result.elapsedMs >= 0
|
|
87
|
+
? result.elapsedMs
|
|
88
|
+
: Date.now() - startedAt;
|
|
89
|
+
console.log(chalk.green(`reason: ${result.ontologiesReasoned} ontology file(s) checked [${formatDuration(reasonElapsedMs)}]`));
|
|
77
90
|
};
|