@openmbee/opensysml 0.9.2 → 0.10.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 +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 +94 -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 +536 -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 +105 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Instance } from "./model.js";
|
|
2
|
+
import { type ComplexValue, type EnumValue, type QuantityValue, type RationalValue, type SysMLValue } from "./values.js";
|
|
3
|
+
/** A quantity feature value: a magnitude and the unit it is expressed in. */
|
|
4
|
+
export type Quantity = {
|
|
5
|
+
kind: "quantity";
|
|
6
|
+
} & QuantityValue;
|
|
7
|
+
/** Resolves a nested feature value's instance id to its Instance, when known. */
|
|
8
|
+
export type InstanceResolver = (id: bigint) => Instance | undefined;
|
|
9
|
+
/** One decoder: a raw feature value to the typed value a getter returns. */
|
|
10
|
+
export type FeatureDecoder<T> = (featureName: string, value: SysMLValue, resolve: InstanceResolver | undefined) => T;
|
|
11
|
+
/** Register a generated class so {@link TypedObject.fromInstance} can tell a wrong type from an unknown one. */
|
|
12
|
+
export declare function registerTyped(ctor: TypedObjectClass): void;
|
|
13
|
+
/** Base class of generated typed views over an {@link Instance}. */
|
|
14
|
+
export declare class TypedObject {
|
|
15
|
+
#private;
|
|
16
|
+
/** FQN of the SysML definition this class was generated from. */
|
|
17
|
+
static readonly sysmlId: string;
|
|
18
|
+
constructor(instance: Instance, resolve?: InstanceResolver);
|
|
19
|
+
/** Return a typed view over `instance`, rejecting one of another type.
|
|
20
|
+
*
|
|
21
|
+
* Accepted: an instance of exactly this class's definition; an instance of a
|
|
22
|
+
* definition that specializes it and has a generated class of its own; and an
|
|
23
|
+
* instance whose type no generated class in this process describes — the
|
|
24
|
+
* service reports the type of an instantiated *usage* as the usage's own
|
|
25
|
+
* FQN, which no generated class carries, so it cannot be related to a
|
|
26
|
+
* definition at all.
|
|
27
|
+
*
|
|
28
|
+
* Use {@link TypedObject.unchecked} to bypass this deliberately.
|
|
29
|
+
*/
|
|
30
|
+
static fromInstance<C extends TypedObjectClass>(this: C, instance: Instance, resolve?: InstanceResolver): InstanceType<C>;
|
|
31
|
+
/** Return a typed view over `instance` without checking its type. */
|
|
32
|
+
static unchecked<C extends TypedObjectClass>(this: C, instance: Instance, resolve?: InstanceResolver): InstanceType<C>;
|
|
33
|
+
/** The underlying Tier 1 instance. */
|
|
34
|
+
get instance(): Instance;
|
|
35
|
+
/** The resolver nested feature values resolve instance ids through, if any. */
|
|
36
|
+
get resolver(): InstanceResolver | undefined;
|
|
37
|
+
/** Two views are equal over the same instance of the same generated class. */
|
|
38
|
+
equals(other: unknown): boolean;
|
|
39
|
+
toString(): string;
|
|
40
|
+
}
|
|
41
|
+
/** Decode a Boolean feature value. */
|
|
42
|
+
export declare function asBoolean(featureName: string, value: SysMLValue): boolean;
|
|
43
|
+
/** Decode an Integer/Natural feature value. */
|
|
44
|
+
export declare function asInt(featureName: string, value: SysMLValue): bigint;
|
|
45
|
+
/** Decode a Real feature value; an Integer or exact Rational widens to the nearest double. */
|
|
46
|
+
export declare function asReal(featureName: string, value: SysMLValue): number;
|
|
47
|
+
/** Decode a Rational feature value exactly, whichever wire arm carried it. */
|
|
48
|
+
export declare function asRational(featureName: string, value: SysMLValue): RationalValue;
|
|
49
|
+
/** Decode a Complex feature value; a real value widens to complex. */
|
|
50
|
+
export declare function asComplex(featureName: string, value: SysMLValue): ComplexValue;
|
|
51
|
+
/** Decode a String feature value. */
|
|
52
|
+
export declare function asString(featureName: string, value: SysMLValue): string;
|
|
53
|
+
/** Decode a quantity feature value: a magnitude and the unit it is expressed in. */
|
|
54
|
+
export declare function asQuantity(featureName: string, value: SysMLValue): Quantity;
|
|
55
|
+
/** Decode an enumeration-typed feature, which holds a literal rather than an instance. */
|
|
56
|
+
export declare function asEnum(featureName: string, value: SysMLValue): EnumValue;
|
|
57
|
+
/** Decode a feature value whose SysML type has no sound TypeScript type. */
|
|
58
|
+
export declare function asObject(_featureName: string, value: SysMLValue): SysMLValue;
|
|
59
|
+
/** A generated typed class: the constructor plus the sysmlId it was generated for. */
|
|
60
|
+
export interface TypedObjectClass<T extends TypedObject = TypedObject> {
|
|
61
|
+
new (instance: Instance, resolve?: InstanceResolver): T;
|
|
62
|
+
readonly sysmlId: string;
|
|
63
|
+
}
|
|
64
|
+
/** Return a decoder wrapping a nested instance in the generated class `cls`. */
|
|
65
|
+
export declare function asTyped<T extends TypedObject>(cls: TypedObjectClass<T>): FeatureDecoder<T>;
|
|
66
|
+
/** The decoded value of a required single-valued feature. */
|
|
67
|
+
export declare function featureValue<T>(obj: TypedObject, featureName: string, decode: FeatureDecoder<T>): T;
|
|
68
|
+
/** The decoded value of a `0..1` feature, or undefined when it holds no value. */
|
|
69
|
+
export declare function optionalFeatureValue<T>(obj: TypedObject, featureName: string, decode: FeatureDecoder<T>): T | undefined;
|
|
70
|
+
/** The decoded values of a multi-valued feature; one holding no value is empty. */
|
|
71
|
+
export declare function listFeatureValue<T>(obj: TypedObject, featureName: string, decode: FeatureDecoder<T>): T[];
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
// Runtime support for generated, statically typed views over instances.
|
|
2
|
+
//
|
|
3
|
+
// A generated class derives from TypedObject and exposes one getter per SysML
|
|
4
|
+
// feature, each delegating to the underlying Tier 1 Instance through
|
|
5
|
+
// featureValue, optionalFeatureValue or listFeatureValue. Decoding is
|
|
6
|
+
// unchanged: this layer only states what type a decoded value is expected to
|
|
7
|
+
// have, and reports a mismatch rather than returning a wrongly typed value.
|
|
8
|
+
import { FeatureValueError, InstanceTypeError, TypeMismatchError, } from "./errors.js";
|
|
9
|
+
import { rationalOfDouble, rationalToNumber, } from "./values.js";
|
|
10
|
+
const ABSENT = Symbol("absent");
|
|
11
|
+
function readRaw(instance, featureName) {
|
|
12
|
+
const feature = instance.get(featureName);
|
|
13
|
+
if (feature === undefined) {
|
|
14
|
+
return ABSENT;
|
|
15
|
+
}
|
|
16
|
+
if (feature.kind === "error") {
|
|
17
|
+
throw new FeatureValueError(featureName, feature.error);
|
|
18
|
+
}
|
|
19
|
+
if (feature.kind === "many") {
|
|
20
|
+
return feature.values;
|
|
21
|
+
}
|
|
22
|
+
if (feature.value.kind === "absent") {
|
|
23
|
+
if (feature.materialized) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
throw new FeatureValueError(featureName, "feature value is not materialized");
|
|
27
|
+
}
|
|
28
|
+
return feature.value;
|
|
29
|
+
}
|
|
30
|
+
function isMany(raw) {
|
|
31
|
+
return Array.isArray(raw);
|
|
32
|
+
}
|
|
33
|
+
function isUnset(value) {
|
|
34
|
+
return value.kind === "unset";
|
|
35
|
+
}
|
|
36
|
+
function isNull(value) {
|
|
37
|
+
return value.kind === "null";
|
|
38
|
+
}
|
|
39
|
+
function mismatch(featureName, expected, value) {
|
|
40
|
+
return new TypeMismatchError(featureName, expected, value);
|
|
41
|
+
}
|
|
42
|
+
// Every sysmlId a generated class in this process answers for, so a wrong type
|
|
43
|
+
// is distinguishable from one this client has never heard of.
|
|
44
|
+
const GENERATED = new Map();
|
|
45
|
+
/** Register a generated class so {@link TypedObject.fromInstance} can tell a wrong type from an unknown one. */
|
|
46
|
+
export function registerTyped(ctor) {
|
|
47
|
+
if (ctor.sysmlId !== "") {
|
|
48
|
+
GENERATED.set(ctor.sysmlId, ctor);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Base class of generated typed views over an {@link Instance}. */
|
|
52
|
+
export class TypedObject {
|
|
53
|
+
/** FQN of the SysML definition this class was generated from. */
|
|
54
|
+
static sysmlId = "";
|
|
55
|
+
#instance;
|
|
56
|
+
#resolve;
|
|
57
|
+
constructor(instance, resolve) {
|
|
58
|
+
this.#instance = instance;
|
|
59
|
+
this.#resolve = resolve;
|
|
60
|
+
}
|
|
61
|
+
/** Return a typed view over `instance`, rejecting one of another type.
|
|
62
|
+
*
|
|
63
|
+
* Accepted: an instance of exactly this class's definition; an instance of a
|
|
64
|
+
* definition that specializes it and has a generated class of its own; and an
|
|
65
|
+
* instance whose type no generated class in this process describes — the
|
|
66
|
+
* service reports the type of an instantiated *usage* as the usage's own
|
|
67
|
+
* FQN, which no generated class carries, so it cannot be related to a
|
|
68
|
+
* definition at all.
|
|
69
|
+
*
|
|
70
|
+
* Use {@link TypedObject.unchecked} to bypass this deliberately.
|
|
71
|
+
*/
|
|
72
|
+
static fromInstance(instance, resolve) {
|
|
73
|
+
const actual = instance.typeId;
|
|
74
|
+
const generated = actual === "" ? undefined : GENERATED.get(actual);
|
|
75
|
+
if (actual !== "" && actual !== this.sysmlId && generated !== undefined) {
|
|
76
|
+
if (!(generated.prototype instanceof this)) {
|
|
77
|
+
throw new InstanceTypeError(this.sysmlId || this.name, actual);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return new this(instance, resolve);
|
|
81
|
+
}
|
|
82
|
+
/** Return a typed view over `instance` without checking its type. */
|
|
83
|
+
static unchecked(instance, resolve) {
|
|
84
|
+
return new this(instance, resolve);
|
|
85
|
+
}
|
|
86
|
+
/** The underlying Tier 1 instance. */
|
|
87
|
+
get instance() {
|
|
88
|
+
return this.#instance;
|
|
89
|
+
}
|
|
90
|
+
/** The resolver nested feature values resolve instance ids through, if any. */
|
|
91
|
+
get resolver() {
|
|
92
|
+
return this.#resolve;
|
|
93
|
+
}
|
|
94
|
+
/** Two views are equal over the same instance of the same generated class. */
|
|
95
|
+
equals(other) {
|
|
96
|
+
return (other instanceof TypedObject &&
|
|
97
|
+
other.constructor === this.constructor &&
|
|
98
|
+
other.instance.id === this.instance.id);
|
|
99
|
+
}
|
|
100
|
+
toString() {
|
|
101
|
+
return `${this.constructor.name}(instance=${this.#instance.id.toString()})`;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** Decode a Boolean feature value. */
|
|
105
|
+
export function asBoolean(featureName, value) {
|
|
106
|
+
if (value.kind === "boolean") {
|
|
107
|
+
return value.value;
|
|
108
|
+
}
|
|
109
|
+
throw mismatch(featureName, "bool", value);
|
|
110
|
+
}
|
|
111
|
+
/** Decode an Integer/Natural feature value. */
|
|
112
|
+
export function asInt(featureName, value) {
|
|
113
|
+
if (value.kind === "int") {
|
|
114
|
+
return value.value;
|
|
115
|
+
}
|
|
116
|
+
throw mismatch(featureName, "int", value);
|
|
117
|
+
}
|
|
118
|
+
/** Decode a Real feature value; an Integer or exact Rational widens to the nearest double. */
|
|
119
|
+
export function asReal(featureName, value) {
|
|
120
|
+
if (value.kind === "real") {
|
|
121
|
+
return value.value;
|
|
122
|
+
}
|
|
123
|
+
if (value.kind === "int") {
|
|
124
|
+
return Number(value.value);
|
|
125
|
+
}
|
|
126
|
+
if (value.kind === "rational") {
|
|
127
|
+
return rationalToNumber(value);
|
|
128
|
+
}
|
|
129
|
+
throw mismatch(featureName, "float", value);
|
|
130
|
+
}
|
|
131
|
+
/** Decode a Rational feature value exactly, whichever wire arm carried it. */
|
|
132
|
+
export function asRational(featureName, value) {
|
|
133
|
+
if (value.kind === "rational") {
|
|
134
|
+
return { numerator: value.numerator, denominator: value.denominator };
|
|
135
|
+
}
|
|
136
|
+
if (value.kind === "int") {
|
|
137
|
+
return { numerator: value.value, denominator: 1n };
|
|
138
|
+
}
|
|
139
|
+
if (value.kind === "real" && Number.isFinite(value.value)) {
|
|
140
|
+
const { numerator, denominator } = rationalOfDouble(value.value);
|
|
141
|
+
return { numerator, denominator };
|
|
142
|
+
}
|
|
143
|
+
throw mismatch(featureName, "Rational", value);
|
|
144
|
+
}
|
|
145
|
+
/** Decode a Complex feature value; a real value widens to complex. */
|
|
146
|
+
export function asComplex(featureName, value) {
|
|
147
|
+
if (value.kind === "complex") {
|
|
148
|
+
return value.value;
|
|
149
|
+
}
|
|
150
|
+
if (value.kind === "real") {
|
|
151
|
+
return { real: value.value, imaginary: 0 };
|
|
152
|
+
}
|
|
153
|
+
if (value.kind === "int") {
|
|
154
|
+
return { real: Number(value.value), imaginary: 0 };
|
|
155
|
+
}
|
|
156
|
+
throw mismatch(featureName, "complex", value);
|
|
157
|
+
}
|
|
158
|
+
/** Decode a String feature value. */
|
|
159
|
+
export function asString(featureName, value) {
|
|
160
|
+
if (value.kind === "string") {
|
|
161
|
+
return value.value;
|
|
162
|
+
}
|
|
163
|
+
throw mismatch(featureName, "str", value);
|
|
164
|
+
}
|
|
165
|
+
/** Decode a quantity feature value: a magnitude and the unit it is expressed in. */
|
|
166
|
+
export function asQuantity(featureName, value) {
|
|
167
|
+
if (value.kind === "quantity") {
|
|
168
|
+
return value;
|
|
169
|
+
}
|
|
170
|
+
throw mismatch(featureName, "Quantity", value);
|
|
171
|
+
}
|
|
172
|
+
/** Decode an enumeration-typed feature, which holds a literal rather than an instance. */
|
|
173
|
+
export function asEnum(featureName, value) {
|
|
174
|
+
if (value.kind === "enum") {
|
|
175
|
+
return value.value;
|
|
176
|
+
}
|
|
177
|
+
throw mismatch(featureName, "EnumLiteral", value);
|
|
178
|
+
}
|
|
179
|
+
/** Decode a feature value whose SysML type has no sound TypeScript type. */
|
|
180
|
+
export function asObject(_featureName, value) {
|
|
181
|
+
return value;
|
|
182
|
+
}
|
|
183
|
+
/** Return a decoder wrapping a nested instance in the generated class `cls`. */
|
|
184
|
+
export function asTyped(cls) {
|
|
185
|
+
return (featureName, value, resolve) => {
|
|
186
|
+
if (value.kind === "instance") {
|
|
187
|
+
const nested = resolve?.(value.id);
|
|
188
|
+
if (nested !== undefined) {
|
|
189
|
+
return TypedObject.fromInstance.call(cls, nested, resolve);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
throw mismatch(featureName, cls.name, value);
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/** The decoded value of a required single-valued feature. */
|
|
196
|
+
export function featureValue(obj, featureName, decode) {
|
|
197
|
+
const raw = readRaw(obj.instance, featureName);
|
|
198
|
+
if (raw === ABSENT) {
|
|
199
|
+
throw mismatch(featureName, "a value", undefined);
|
|
200
|
+
}
|
|
201
|
+
if (isMany(raw)) {
|
|
202
|
+
throw mismatch(featureName, "a single value", raw);
|
|
203
|
+
}
|
|
204
|
+
if (isNull(raw)) {
|
|
205
|
+
throw mismatch(featureName, "a value", null);
|
|
206
|
+
}
|
|
207
|
+
return decode(featureName, raw, obj.resolver);
|
|
208
|
+
}
|
|
209
|
+
/** The decoded value of a `0..1` feature, or undefined when it holds no value. */
|
|
210
|
+
export function optionalFeatureValue(obj, featureName, decode) {
|
|
211
|
+
const raw = readRaw(obj.instance, featureName);
|
|
212
|
+
if (raw === ABSENT) {
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
if (isMany(raw)) {
|
|
216
|
+
if (raw.length === 0) {
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
219
|
+
if (raw.length > 1) {
|
|
220
|
+
throw mismatch(featureName, "at most one value", raw);
|
|
221
|
+
}
|
|
222
|
+
const element = raw[0];
|
|
223
|
+
return isNull(element) || isUnset(element)
|
|
224
|
+
? undefined
|
|
225
|
+
: decode(featureName, element, obj.resolver);
|
|
226
|
+
}
|
|
227
|
+
if (isNull(raw) || isUnset(raw)) {
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
return decode(featureName, raw, obj.resolver);
|
|
231
|
+
}
|
|
232
|
+
/** The decoded values of a multi-valued feature; one holding no value is empty. */
|
|
233
|
+
export function listFeatureValue(obj, featureName, decode) {
|
|
234
|
+
const raw = readRaw(obj.instance, featureName);
|
|
235
|
+
if (raw === ABSENT) {
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
238
|
+
if (isMany(raw)) {
|
|
239
|
+
return raw.map((element) => decode(featureName, element, obj.resolver));
|
|
240
|
+
}
|
|
241
|
+
if (isNull(raw) || isUnset(raw)) {
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
return [decode(featureName, raw, obj.resolver)];
|
|
245
|
+
}
|
package/dist/core/values.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import type { Bound, Value, Verdict } from "../generated/sysml_pb.js";
|
|
1
|
+
import type { Bound, Quantity, Rational, Value, Verdict } from "../generated/sysml_pb.js";
|
|
2
2
|
import { FailureReason } from "../generated/sysml_pb.js";
|
|
3
|
+
import { type ServerInfo } from "./capabilities.js";
|
|
3
4
|
import { type FailureCause } from "./errors.js";
|
|
4
|
-
/**
|
|
5
|
+
/** An exact Rational in lowest terms over a positive denominator. */
|
|
6
|
+
export interface RationalValue {
|
|
7
|
+
numerator: bigint;
|
|
8
|
+
denominator: bigint;
|
|
9
|
+
}
|
|
10
|
+
/** A quantity's magnitude: an Integer, an exact Rational or a Real, kept apart. */
|
|
5
11
|
export type Magnitude = {
|
|
6
12
|
kind: "int";
|
|
7
13
|
value: bigint;
|
|
8
|
-
} | {
|
|
14
|
+
} | ({
|
|
15
|
+
kind: "rational";
|
|
16
|
+
} & RationalValue) | {
|
|
9
17
|
kind: "real";
|
|
10
18
|
value: number;
|
|
11
19
|
};
|
|
@@ -116,7 +124,9 @@ export interface UndeterminedValue {
|
|
|
116
124
|
export type SysMLValue = {
|
|
117
125
|
kind: "int";
|
|
118
126
|
value: bigint;
|
|
119
|
-
} | {
|
|
127
|
+
} | ({
|
|
128
|
+
kind: "rational";
|
|
129
|
+
} & RationalValue) | {
|
|
120
130
|
kind: "real";
|
|
121
131
|
value: number;
|
|
122
132
|
} | {
|
|
@@ -170,9 +180,9 @@ export type SysMLValue = {
|
|
|
170
180
|
} | {
|
|
171
181
|
kind: "absent";
|
|
172
182
|
};
|
|
173
|
-
/** What a verification answered about.
|
|
183
|
+
/** What a verification answered about. */
|
|
174
184
|
export interface VerdictSubject {
|
|
175
|
-
/** "constraint", "requirement" or "
|
|
185
|
+
/** "constraint", "requirement", "satisfy", "objective", "assertion" or "object". */
|
|
176
186
|
kind: string;
|
|
177
187
|
/** FQN of the verified element; empty for an anonymous satisfy assertion. */
|
|
178
188
|
elementId: string;
|
|
@@ -181,6 +191,34 @@ export interface VerdictSubject {
|
|
|
181
191
|
/** The instance verified against, when there was one. */
|
|
182
192
|
instanceId?: bigint;
|
|
183
193
|
instanceTypeId?: string;
|
|
194
|
+
/** FQN of the requirement a "satisfy" verdict asserts satisfied; empty for every other kind. */
|
|
195
|
+
requirementId?: string;
|
|
196
|
+
/** Where the object this verdict is about sits in a validated one (`engine.injector`, `wheels[2]`). */
|
|
197
|
+
instancePath?: string;
|
|
198
|
+
}
|
|
199
|
+
/** One feature's value in the assignment witnessing a verdict. */
|
|
200
|
+
export interface WitnessAssignment {
|
|
201
|
+
/** The qualified feature name, chain steps appended with '.'. */
|
|
202
|
+
feature: string;
|
|
203
|
+
/** The value the evaluator replayed for the feature. */
|
|
204
|
+
value: SysMLValue;
|
|
205
|
+
/** The base units the magnitude is expressed in; empty for a value that has none. */
|
|
206
|
+
unit: string;
|
|
207
|
+
/** The solver's exact value as text. */
|
|
208
|
+
exact: string;
|
|
209
|
+
}
|
|
210
|
+
/** What the body of a verification case answered when it ran. */
|
|
211
|
+
export interface VerificationVerdict {
|
|
212
|
+
/** FQN of the verification case that ran. */
|
|
213
|
+
caseId: string;
|
|
214
|
+
/** The VerdictKind the body produced: "pass", "fail", "inconclusive" or "error". */
|
|
215
|
+
kind: string;
|
|
216
|
+
/** Why an inconclusive body decided nothing, or the error that stopped the run. */
|
|
217
|
+
detail: string;
|
|
218
|
+
/** Whether this is the verdict of a case performed by another. */
|
|
219
|
+
subcase: boolean;
|
|
220
|
+
/** FQN of the requirement this verdict was reported for; empty for a case run for itself. */
|
|
221
|
+
requirementId: string;
|
|
184
222
|
}
|
|
185
223
|
/** One limit an engine ran under, and whether the run stopped at it. */
|
|
186
224
|
export interface VerdictBound {
|
|
@@ -201,27 +239,45 @@ export interface VerdictStanding {
|
|
|
201
239
|
/** "not covered", "observed", "witnessed", "bounded" or "proved". */
|
|
202
240
|
strength: string;
|
|
203
241
|
bounds: VerdictBound[];
|
|
242
|
+
/** Whether the service reported a standing at all. */
|
|
243
|
+
reported: boolean;
|
|
244
|
+
/** The bounds the engine stopped at. */
|
|
245
|
+
reached: VerdictBound[];
|
|
204
246
|
}
|
|
205
247
|
/**
|
|
206
248
|
* One verification's answer. `undecided` is the service reporting it could not
|
|
207
249
|
* answer, which a `holds: false` alone does not distinguish. Every arm carries
|
|
208
|
-
* the `standing` its evidence rests on
|
|
250
|
+
* the `standing` its evidence rests on, the `question` asked and the `status`
|
|
251
|
+
* the service answered with, the `witness` assignment when the answer carries
|
|
252
|
+
* one, and the `verifications` the requirement's verification cases produced.
|
|
209
253
|
*/
|
|
210
254
|
export type SysMLVerdict = {
|
|
211
255
|
kind: "holds";
|
|
212
256
|
subject: VerdictSubject;
|
|
213
257
|
standing: VerdictStanding;
|
|
258
|
+
question: string;
|
|
259
|
+
status: string;
|
|
260
|
+
witness: WitnessAssignment[];
|
|
261
|
+
verifications: VerificationVerdict[];
|
|
214
262
|
} | {
|
|
215
263
|
kind: "fails";
|
|
216
264
|
subject: VerdictSubject;
|
|
217
265
|
condition: string;
|
|
218
266
|
standing: VerdictStanding;
|
|
267
|
+
question: string;
|
|
268
|
+
status: string;
|
|
269
|
+
witness: WitnessAssignment[];
|
|
270
|
+
verifications: VerificationVerdict[];
|
|
219
271
|
} | {
|
|
220
272
|
kind: "undecided";
|
|
221
273
|
subject: VerdictSubject;
|
|
222
274
|
error: string;
|
|
223
275
|
cause: FailureCause;
|
|
224
276
|
standing: VerdictStanding;
|
|
277
|
+
question: string;
|
|
278
|
+
status: string;
|
|
279
|
+
witness: WitnessAssignment[];
|
|
280
|
+
verifications: VerificationVerdict[];
|
|
225
281
|
};
|
|
226
282
|
/**
|
|
227
283
|
* Decodes a `sysml.Value` into the union.
|
|
@@ -244,7 +300,7 @@ export declare function decodeValue(value: Value | undefined): SysMLValue;
|
|
|
244
300
|
*/
|
|
245
301
|
export declare function encodeValue(value: SysMLValue): Value;
|
|
246
302
|
/** Decodes a `sysml.Verdict` into the union. */
|
|
247
|
-
export declare function decodeVerdict(verdict: Verdict): SysMLVerdict;
|
|
303
|
+
export declare function decodeVerdict(verdict: Verdict, verifications?: readonly VerificationVerdict[]): SysMLVerdict;
|
|
248
304
|
/** Reads the standing fields the `engines` capability adds to a verdict. */
|
|
249
305
|
export declare function decodeStanding(verdict: {
|
|
250
306
|
engine: string;
|
|
@@ -255,6 +311,43 @@ export declare function decodeStanding(verdict: {
|
|
|
255
311
|
export declare function failureCause(reason: FailureReason): FailureCause;
|
|
256
312
|
/** Renders a value the way the REPL prints one, for logs and error messages. */
|
|
257
313
|
export declare function formatValue(value: SysMLValue): string;
|
|
314
|
+
/** A terminating Rational as its decimal, `0.1`; any other as `numerator/denominator`, `1/3`. */
|
|
315
|
+
export declare function formatRational(value: RationalValue): string;
|
|
316
|
+
/** A quantity magnitude as the wire's `Quantity.magnitude` oneof writes it. */
|
|
317
|
+
export declare function encodeQuantityMagnitude(magnitude: Magnitude): Quantity["magnitude"];
|
|
318
|
+
/** Whether an Integer travels as `int_value`; one beyond int64 travels as `big_int_value`. */
|
|
319
|
+
export declare function fitsInt64(value: bigint): boolean;
|
|
320
|
+
/** Reads the decimal of a `big_int_value` or `big_int_magnitude`. */
|
|
321
|
+
export declare function decodeBigInteger(text: string): bigint;
|
|
322
|
+
/**
|
|
323
|
+
* Rewrites in place each Rational arm of a wire value a double holds exactly as
|
|
324
|
+
* that double: the form a service without `rational_values` reads. A Rational
|
|
325
|
+
* no double holds is left as it is; a collection's elements are values of their own.
|
|
326
|
+
*/
|
|
327
|
+
export declare function rationalsAsReals(value: Value): void;
|
|
328
|
+
/** Rewrites a quantity's Rational magnitude a double holds exactly as `real_magnitude`. */
|
|
329
|
+
export declare function quantityRationalAsReal(quantity: Quantity): void;
|
|
330
|
+
/** The `Rational` message of an exact Rational, numerator and denominator in full. */
|
|
331
|
+
export declare function encodeRational(value: RationalValue): Rational;
|
|
332
|
+
/**
|
|
333
|
+
* Reads a `rational_value` or `rational_magnitude`.
|
|
334
|
+
*
|
|
335
|
+
* @throws {MalformedValueError} for one not in lowest terms over a positive
|
|
336
|
+
* denominator, or one a double holds, which travels as `real_value`.
|
|
337
|
+
*/
|
|
338
|
+
export declare function decodeRational(rational: Rational): RationalValue;
|
|
339
|
+
/** The exact Rational `numerator/denominator`, reduced; throws a RangeError over a zero denominator. */
|
|
340
|
+
export declare function rational(numerator: bigint, denominator?: bigint): {
|
|
341
|
+
kind: "rational";
|
|
342
|
+
} & RationalValue;
|
|
343
|
+
/** The exact Rational a finite double holds. */
|
|
344
|
+
export declare function rationalOfDouble(x: number): {
|
|
345
|
+
kind: "rational";
|
|
346
|
+
} & RationalValue;
|
|
347
|
+
/** The double that holds a reduced Rational exactly, or undefined where none does. */
|
|
348
|
+
export declare function rationalAsDouble(value: RationalValue): number | undefined;
|
|
349
|
+
/** The double nearest the Rational: how a Real reads one. */
|
|
350
|
+
export declare function rationalToNumber(value: RationalValue): number;
|
|
258
351
|
/**
|
|
259
352
|
* Whether two values are the same value to the model, as the service judges a
|
|
260
353
|
* set's membership: numbers by value, so a whole `real` is the `int` of its
|
|
@@ -269,3 +362,29 @@ export declare function formatValue(value: SysMLValue): string;
|
|
|
269
362
|
* value however spelt.
|
|
270
363
|
*/
|
|
271
364
|
export declare function valuesEqual(a: SysMLValue, b: SysMLValue): boolean;
|
|
365
|
+
/** What a caller may pass as an argument or input to a run. A wire `Value`
|
|
366
|
+
* passes through untouched, which is how a caller sends a shape the typing
|
|
367
|
+
* layer would normalize away — including one the service is meant to refuse.
|
|
368
|
+
* A JavaScript array encodes as a sequence and a `Set` as a set, as Python's
|
|
369
|
+
* list and set do; collection elements accept every input form, not only
|
|
370
|
+
* `SysMLValue`s. */
|
|
371
|
+
export type ValueInput = SysMLValue | Value | boolean | string | bigint | number | readonly ValueInput[] | ReadonlySet<ValueInput> | {
|
|
372
|
+
kind: "sequence";
|
|
373
|
+
elements: readonly ValueInput[];
|
|
374
|
+
} | {
|
|
375
|
+
kind: "set";
|
|
376
|
+
elements: readonly ValueInput[];
|
|
377
|
+
} | ({
|
|
378
|
+
kind: "array";
|
|
379
|
+
elements: readonly ValueInput[];
|
|
380
|
+
} & Omit<ArrayValue, "elements">);
|
|
381
|
+
/**
|
|
382
|
+
* Encodes a caller-facing value for the wire, requiring of `info` each
|
|
383
|
+
* capability a value kind needs before the call is sent — exactly the checks
|
|
384
|
+
* Python's `Connection._python_to_value` makes. A `SysMLValue` encodes as
|
|
385
|
+
* itself; a boolean, string, bigint and number encode as the scalar arms; a
|
|
386
|
+
* JavaScript array and `Set` encode as a sequence and a set.
|
|
387
|
+
*/
|
|
388
|
+
export declare function toValue(input: ValueInput, info: ServerInfo): Value;
|
|
389
|
+
/** The capabilities one input value needs of the service that will decode it. */
|
|
390
|
+
export declare function requireInput(value: SysMLValue, info: ServerInfo): void;
|