@openmbee/opensysml 0.9.2 → 0.10.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.
- package/README.md +355 -33
- package/dist/browser/index.d.ts +9 -0
- package/dist/browser/index.js +16 -0
- package/dist/browser/wasm-worker.d.ts +1 -0
- package/dist/browser/wasm-worker.js +2 -0
- package/dist/browser/wasm.d.ts +17 -0
- package/dist/browser/wasm.js +97 -0
- package/dist/core/arguments.d.ts +4 -0
- package/dist/core/arguments.js +19 -0
- package/dist/core/capabilities.d.ts +90 -9
- package/dist/core/capabilities.js +111 -10
- package/dist/core/connection.d.ts +203 -2
- package/dist/core/connection.js +810 -17
- package/dist/core/conversion.d.ts +153 -0
- package/dist/core/conversion.js +191 -0
- package/dist/core/document.d.ts +188 -0
- package/dist/core/document.js +457 -0
- package/dist/core/edit.d.ts +446 -0
- package/dist/core/edit.js +1994 -0
- package/dist/core/engines.d.ts +64 -0
- package/dist/core/engines.js +74 -0
- package/dist/core/errors.d.ts +164 -2
- package/dist/core/errors.js +209 -3
- package/dist/core/exploration.d.ts +71 -0
- package/dist/core/exploration.js +116 -0
- package/dist/core/graphs.d.ts +15 -0
- package/dist/core/graphs.js +3 -0
- package/dist/core/index.d.ts +30 -9
- package/dist/core/index.js +14 -5
- package/dist/core/model.d.ts +168 -8
- package/dist/core/model.js +258 -31
- package/dist/core/package.d.ts +2 -0
- package/dist/core/package.js +2 -0
- package/dist/core/query.d.ts +50 -0
- package/dist/core/query.js +197 -0
- package/dist/core/render-view.d.ts +97 -0
- package/dist/core/render-view.js +120 -0
- package/dist/core/sources.d.ts +34 -0
- package/dist/core/sources.js +134 -0
- package/dist/core/status.d.ts +9 -2
- package/dist/core/status.js +24 -8
- package/dist/core/typed.d.ts +71 -0
- package/dist/core/typed.js +245 -0
- package/dist/core/values.d.ts +127 -8
- package/dist/core/values.js +538 -30
- package/dist/core/verdict.d.ts +271 -0
- package/dist/core/verdict.js +567 -0
- package/dist/core/wasm.d.ts +114 -0
- package/dist/core/wasm.js +514 -0
- package/dist/generated/sysml_pb.d.ts +1062 -15
- package/dist/generated/sysml_pb.js +200 -100
- package/dist/node/generate-cli.d.ts +2 -0
- package/dist/node/generate-cli.js +10 -0
- package/dist/node/generate.d.ts +99 -0
- package/dist/node/generate.js +757 -0
- package/dist/node/index.d.ts +29 -2
- package/dist/node/index.js +211 -10
- package/dist/node/service.d.ts +5 -3
- package/dist/node/service.js +32 -26
- package/dist/node/wasm-source.d.ts +18 -0
- package/dist/node/wasm-source.js +103 -0
- package/dist/node/wasm-worker.d.ts +1 -0
- package/dist/node/wasm-worker.js +10 -0
- package/dist/node/wasm.d.ts +17 -0
- package/dist/node/wasm.js +63 -0
- package/package.json +19 -7
- package/release-digests.json +117 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The opensysml-generate bin: generate typed TypeScript classes from a model.
|
|
3
|
+
import { main } from "./generate.js";
|
|
4
|
+
try {
|
|
5
|
+
process.exitCode = await main(process.argv.slice(2));
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
console.error(`error: ${error.message}`);
|
|
9
|
+
process.exitCode = 2;
|
|
10
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Connection } from "../core/connection.js";
|
|
2
|
+
import type { Model, SpecializationFacts, TypeFacts } from "../core/model.js";
|
|
3
|
+
export declare const GENERATED_HEADER = "// Generated by opensysml-generate. Do not edit.";
|
|
4
|
+
export declare const GENERATOR_VERSION = "5";
|
|
5
|
+
export declare const MODEL_HASH_ALGORITHM = "sha256";
|
|
6
|
+
export declare const UNSTAMPED = "unstamped";
|
|
7
|
+
/** Whether a symbol kind declares a type, e.g. `partDef` or `metaclass`. */
|
|
8
|
+
export declare function isDefinitionKind(kind: string): boolean;
|
|
9
|
+
/** Whether a symbol kind is a usage exposed as an instance feature. */
|
|
10
|
+
export declare function isFeatureKind(kind: string): boolean;
|
|
11
|
+
/** One SysML feature to emit as a getter. */
|
|
12
|
+
export interface Feature {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly kind: string;
|
|
16
|
+
readonly type?: TypeFacts | undefined;
|
|
17
|
+
readonly multiplicity?: {
|
|
18
|
+
lower: string;
|
|
19
|
+
upper: string;
|
|
20
|
+
} | undefined;
|
|
21
|
+
}
|
|
22
|
+
/** One SysML definition to emit as a class. */
|
|
23
|
+
export declare class Definition {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly kind: string;
|
|
27
|
+
readonly specializations: readonly SpecializationFacts[];
|
|
28
|
+
readonly features: readonly Feature[];
|
|
29
|
+
constructor(init: {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
kind: string;
|
|
33
|
+
specializations?: readonly SpecializationFacts[] | undefined;
|
|
34
|
+
features?: readonly Feature[] | undefined;
|
|
35
|
+
});
|
|
36
|
+
/** FQNs of what this definition specializes, subsets or redefines, in
|
|
37
|
+
* declaration order, without repetition. */
|
|
38
|
+
get baseIds(): readonly string[];
|
|
39
|
+
}
|
|
40
|
+
/** A rendered TypeScript annotation plus the decoder and note behind it. */
|
|
41
|
+
export interface TypeScriptType {
|
|
42
|
+
readonly annotation: string;
|
|
43
|
+
readonly decoder: string;
|
|
44
|
+
readonly comment: string;
|
|
45
|
+
}
|
|
46
|
+
/** A symbol in a symbol tree; {@link ModelSymbol} satisfies this structurally. */
|
|
47
|
+
export interface SymbolTree {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly kind: string;
|
|
51
|
+
readonly type?: TypeFacts | undefined;
|
|
52
|
+
readonly multiplicity?: {
|
|
53
|
+
lower: string;
|
|
54
|
+
upper: string;
|
|
55
|
+
} | undefined;
|
|
56
|
+
readonly specializations?: readonly SpecializationFacts[] | undefined;
|
|
57
|
+
children(): Promise<readonly SymbolTree[]>;
|
|
58
|
+
}
|
|
59
|
+
/** Collect the definitions in one or more symbol trees, sorted by FQN, each
|
|
60
|
+
* feature taking the type and multiplicity it inherits. */
|
|
61
|
+
export declare function collectDefinitions(...roots: readonly SymbolTree[]): Promise<Definition[]>;
|
|
62
|
+
/** Map definition FQN → TypeScript class name.
|
|
63
|
+
*
|
|
64
|
+
* A simple name declared by more than one definition is qualified with its
|
|
65
|
+
* owning path so that every generated class name is unique and stable. */
|
|
66
|
+
export declare function classNames(definitions: readonly Definition[]): Map<string, string>;
|
|
67
|
+
/** TypeScript name of the getter for a feature; the SysML feature name is unchanged. */
|
|
68
|
+
export declare function propertyName(name: string): string;
|
|
69
|
+
/** Map the type of a single value to a TypeScript annotation and decoder. */
|
|
70
|
+
export declare function elementType(typeFacts: TypeFacts | undefined, names: Map<string, string>): TypeScriptType;
|
|
71
|
+
/** Map a feature to its TypeScript annotation, decoder and accessor, honoring multiplicity. */
|
|
72
|
+
export declare function featureType(feature: Feature, names: Map<string, string>): TypeScriptType;
|
|
73
|
+
/** Hash of the model source a generated module was produced from.
|
|
74
|
+
*
|
|
75
|
+
* Newlines are normalized so the same model checked out with CRLF endings
|
|
76
|
+
* stamps identically; nothing else about the text is interpreted. */
|
|
77
|
+
export declare function modelStamp(sourceText: string): string;
|
|
78
|
+
/** Render a complete, importable TypeScript module for `definitions`.
|
|
79
|
+
*
|
|
80
|
+
* `stamp` is the {@link modelStamp} of the model source, recorded in the
|
|
81
|
+
* module so a reader — and the `--check` gate — can tell what it was generated
|
|
82
|
+
* from. Without one the module says `unstamped` rather than claim a hash it
|
|
83
|
+
* does not have. */
|
|
84
|
+
export declare function renderModule(definitions: readonly Definition[], stamp?: string): string;
|
|
85
|
+
/** Render the typed module for a loaded model.
|
|
86
|
+
*
|
|
87
|
+
* `sourceText` is the model source the module is stamped with; it is required
|
|
88
|
+
* so a module cannot silently claim the hash of nothing. A model of several
|
|
89
|
+
* documents (`Connection.parseSources`) is generated whole, from every
|
|
90
|
+
* document's root. */
|
|
91
|
+
export declare function generateSource(model: Model, sourceText: string): Promise<string>;
|
|
92
|
+
/** Fail unless `connection`'s service can supply static type facts. */
|
|
93
|
+
export declare function requireTypeFacts(connection: Connection): void;
|
|
94
|
+
/** The externally managed service `--host`/`--port` names, or undefined when
|
|
95
|
+
* neither names one and the connection starts a private child — or honors
|
|
96
|
+
* $OPENSYSML_SERVICE — the way `connect()` does with no address. */
|
|
97
|
+
export declare function serviceAddress(host: string, port?: number): string | undefined;
|
|
98
|
+
/** Entry point for the `opensysml-generate` bin. */
|
|
99
|
+
export declare function main(argv?: readonly string[]): Promise<number>;
|