@openmbee/opensysml 0.9.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 +462 -0
- package/dist/browser/index.d.ts +12 -0
- package/dist/browser/index.js +34 -0
- package/dist/core/capabilities.d.ts +94 -0
- package/dist/core/capabilities.js +130 -0
- package/dist/core/connection.d.ts +79 -0
- package/dist/core/connection.js +110 -0
- package/dist/core/errors.d.ts +98 -0
- package/dist/core/errors.js +100 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.js +10 -0
- package/dist/core/model.d.ts +139 -0
- package/dist/core/model.js +339 -0
- package/dist/core/package.d.ts +4 -0
- package/dist/core/package.js +4 -0
- package/dist/core/status.d.ts +15 -0
- package/dist/core/status.js +94 -0
- package/dist/core/transport.d.ts +10 -0
- package/dist/core/transport.js +69 -0
- package/dist/core/values.d.ts +271 -0
- package/dist/core/values.js +687 -0
- package/dist/generated/sysml_pb.d.ts +5668 -0
- package/dist/generated/sysml_pb.js +837 -0
- package/dist/node/binary.d.ts +127 -0
- package/dist/node/binary.js +564 -0
- package/dist/node/index.d.ts +31 -0
- package/dist/node/index.js +101 -0
- package/dist/node/service.d.ts +31 -0
- package/dist/node/service.js +238 -0
- package/dist/node/signing.d.ts +55 -0
- package/dist/node/signing.js +167 -0
- package/package.json +77 -0
- package/release-digests.json +60 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import type { Bound, Value, Verdict } from "../generated/sysml_pb.js";
|
|
2
|
+
import { FailureReason } from "../generated/sysml_pb.js";
|
|
3
|
+
import { type FailureCause } from "./errors.js";
|
|
4
|
+
/** A quantity's magnitude: an integer or a real, never both. */
|
|
5
|
+
export type Magnitude = {
|
|
6
|
+
kind: "int";
|
|
7
|
+
value: bigint;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "real";
|
|
10
|
+
value: number;
|
|
11
|
+
};
|
|
12
|
+
/** One unit raised to an exponent, as the service factorises a derived unit. */
|
|
13
|
+
export interface UnitFactor {
|
|
14
|
+
unitId: string;
|
|
15
|
+
exponent: number;
|
|
16
|
+
}
|
|
17
|
+
/** A unit as a scale factor over base-unit powers, when the service reports one. */
|
|
18
|
+
export interface UnitFactorization {
|
|
19
|
+
scaleNum: number;
|
|
20
|
+
scaleDen: number;
|
|
21
|
+
factors: UnitFactor[];
|
|
22
|
+
}
|
|
23
|
+
/** A complex number in rectangular form: one value, never a sequence of two reals. */
|
|
24
|
+
export interface ComplexValue {
|
|
25
|
+
real: number;
|
|
26
|
+
imaginary: number;
|
|
27
|
+
}
|
|
28
|
+
/** An enumeration literal, identified by the enumeration that declares it. */
|
|
29
|
+
export interface EnumValue {
|
|
30
|
+
name: string;
|
|
31
|
+
literalId: string;
|
|
32
|
+
enumerationId: string;
|
|
33
|
+
/** The scalar the literal equals when its enumeration specializes a scalar type (`high = 3`). */
|
|
34
|
+
value?: SysMLValue;
|
|
35
|
+
}
|
|
36
|
+
/** A magnitude in a unit as written, with the unit's reduction when the service reports one. */
|
|
37
|
+
export interface QuantityValue {
|
|
38
|
+
magnitude: Magnitude;
|
|
39
|
+
unit: string;
|
|
40
|
+
unitTerm?: UnitFactorization;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A measurement unit held as a value by itself, with no magnitude: `SI::m`, or
|
|
44
|
+
* `m / s` as an operation composed it. `unitTerm` is its reduction, which the
|
|
45
|
+
* service always sends and requires; `unitId` is the FQN of the one declaration
|
|
46
|
+
* it names (`SI::kilometre`), absent for a unit an operation composed.
|
|
47
|
+
*/
|
|
48
|
+
export interface MeasurementRefValue {
|
|
49
|
+
unit: string;
|
|
50
|
+
unitTerm: UnitFactorization;
|
|
51
|
+
unitId?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A calc held as a value — a calc definition, or a calc usage with an input no
|
|
55
|
+
* read could supply — named by the FQN of its declaration, which is its identity.
|
|
56
|
+
* `selfId` is the object its feature names resolve against, for a calc usage
|
|
57
|
+
* read off a part (`holder.scale`); absent for a function closing over no object.
|
|
58
|
+
*/
|
|
59
|
+
export interface FunctionValue {
|
|
60
|
+
calcId: string;
|
|
61
|
+
selfId?: bigint;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* An element of the model held as an instance of its reflective metaclass: what
|
|
65
|
+
* `x meta KerML::Feature`, or the last element of `x.metadata`, evaluates to.
|
|
66
|
+
* `elementId` is the FQN of the element reflected on, which is its identity;
|
|
67
|
+
* `metaclassId` is the FQN of the element's own metaclass
|
|
68
|
+
* (`SysML::Systems::PartUsage`), not the type it was cast to. The service always
|
|
69
|
+
* sends it; one sent to the service may leave it empty to have the model's used,
|
|
70
|
+
* but one naming a metaclass that is not the element's is refused. The
|
|
71
|
+
* metaobject's features (`declaredName`, `ownedFeature`, ...) are read in the
|
|
72
|
+
* model, not carried.
|
|
73
|
+
*/
|
|
74
|
+
export interface MetaobjectValue {
|
|
75
|
+
elementId: string;
|
|
76
|
+
metaclassId: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A multidimensional array: `dimensions` gives the extent of each dimension and
|
|
80
|
+
* `elements` the elements flattened row-major, the last dimension varying
|
|
81
|
+
* fastest. A rank-0 array holds one element; an element may itself be an array.
|
|
82
|
+
*/
|
|
83
|
+
export interface ArrayValue {
|
|
84
|
+
dimensions: bigint[];
|
|
85
|
+
elements: SysMLValue[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A tensor quantity of any rank: `dimensions` gives the extent of each dimension
|
|
89
|
+
* and `components` one quantity per component, flattened row-major as an
|
|
90
|
+
* array's elements are. A tensor of rank one is not a `vectorQuantity`.
|
|
91
|
+
*/
|
|
92
|
+
export interface TensorQuantityValue {
|
|
93
|
+
dimensions: bigint[];
|
|
94
|
+
components: QuantityValue[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A model-level result the model leaves open (an unbound feature, an unfixed count):
|
|
98
|
+
* `reason` says why, `countLower`/`countUpper` bound its count as `MultiplicityInfo` spells them.
|
|
99
|
+
*/
|
|
100
|
+
export interface UndeterminedValue {
|
|
101
|
+
reason: string;
|
|
102
|
+
countLower: string;
|
|
103
|
+
countUpper: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A value the service computed. `absent` is the case a service sent no value at
|
|
107
|
+
* all for, which is distinct from `unset` — a feature that exists and has none —
|
|
108
|
+
* and from `undetermined`, a model-level answer the model leaves open.
|
|
109
|
+
* A `vector` is one value of numeric components, never a sequence of numbers,
|
|
110
|
+
* and a `vectorQuantity` carries one quantity per component, each with its own unit.
|
|
111
|
+
* A `set` is a unique, unordered collection — a `Collections::Set`'s elements —
|
|
112
|
+
* distinct from a `sequence`, whose order is part of its value: the service
|
|
113
|
+
* sends its elements in canonical order, so equal sets arrive alike, and reads
|
|
114
|
+
* one sent in any order, refusing one that lists an element twice.
|
|
115
|
+
*/
|
|
116
|
+
export type SysMLValue = {
|
|
117
|
+
kind: "int";
|
|
118
|
+
value: bigint;
|
|
119
|
+
} | {
|
|
120
|
+
kind: "real";
|
|
121
|
+
value: number;
|
|
122
|
+
} | {
|
|
123
|
+
kind: "complex";
|
|
124
|
+
value: ComplexValue;
|
|
125
|
+
} | {
|
|
126
|
+
kind: "boolean";
|
|
127
|
+
value: boolean;
|
|
128
|
+
} | {
|
|
129
|
+
kind: "string";
|
|
130
|
+
value: string;
|
|
131
|
+
} | {
|
|
132
|
+
kind: "instance";
|
|
133
|
+
id: bigint;
|
|
134
|
+
} | {
|
|
135
|
+
kind: "sequence";
|
|
136
|
+
elements: SysMLValue[];
|
|
137
|
+
} | ({
|
|
138
|
+
kind: "quantity";
|
|
139
|
+
} & QuantityValue) | ({
|
|
140
|
+
kind: "measurementRef";
|
|
141
|
+
} & MeasurementRefValue) | ({
|
|
142
|
+
kind: "function";
|
|
143
|
+
} & FunctionValue) | {
|
|
144
|
+
kind: "enum";
|
|
145
|
+
value: EnumValue;
|
|
146
|
+
} | ({
|
|
147
|
+
kind: "array";
|
|
148
|
+
} & ArrayValue) | {
|
|
149
|
+
kind: "vector";
|
|
150
|
+
components: Magnitude[];
|
|
151
|
+
} | {
|
|
152
|
+
kind: "vectorQuantity";
|
|
153
|
+
components: QuantityValue[];
|
|
154
|
+
} | {
|
|
155
|
+
kind: "set";
|
|
156
|
+
elements: SysMLValue[];
|
|
157
|
+
} | ({
|
|
158
|
+
kind: "tensorQuantity";
|
|
159
|
+
} & TensorQuantityValue) | ({
|
|
160
|
+
kind: "metaobject";
|
|
161
|
+
} & MetaobjectValue) | {
|
|
162
|
+
kind: "null";
|
|
163
|
+
reason: string;
|
|
164
|
+
} | {
|
|
165
|
+
kind: "unset";
|
|
166
|
+
} | ({
|
|
167
|
+
kind: "undetermined";
|
|
168
|
+
} & UndeterminedValue) | {
|
|
169
|
+
kind: "infinity";
|
|
170
|
+
} | {
|
|
171
|
+
kind: "absent";
|
|
172
|
+
};
|
|
173
|
+
/** What a verification answered about. Kept for the verification RPCs of a later version. */
|
|
174
|
+
export interface VerdictSubject {
|
|
175
|
+
/** "constraint", "requirement" or "satisfy". */
|
|
176
|
+
kind: string;
|
|
177
|
+
/** FQN of the verified element; empty for an anonymous satisfy assertion. */
|
|
178
|
+
elementId: string;
|
|
179
|
+
/** The element as a reader names it. */
|
|
180
|
+
element: string;
|
|
181
|
+
/** The instance verified against, when there was one. */
|
|
182
|
+
instanceId?: bigint;
|
|
183
|
+
instanceTypeId?: string;
|
|
184
|
+
}
|
|
185
|
+
/** One limit an engine ran under, and whether the run stopped at it. */
|
|
186
|
+
export interface VerdictBound {
|
|
187
|
+
/** The bound's name as the budget spells it: "runs", "depth", "steps", "solver". */
|
|
188
|
+
name: string;
|
|
189
|
+
limit: bigint;
|
|
190
|
+
/** True when the run stopped at the limit, which lowers the verdict's strength. */
|
|
191
|
+
reached: boolean;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* What a verdict rests on: the engine that answered, the strength of its
|
|
195
|
+
* evidence and the bounds it ran under. Empty from a service without the
|
|
196
|
+
* `engines` capability, or for a verdict decided before any engine was asked.
|
|
197
|
+
*/
|
|
198
|
+
export interface VerdictStanding {
|
|
199
|
+
/** The engine as `ListEngines` names it. */
|
|
200
|
+
engine: string;
|
|
201
|
+
/** "not covered", "observed", "witnessed", "bounded" or "proved". */
|
|
202
|
+
strength: string;
|
|
203
|
+
bounds: VerdictBound[];
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* One verification's answer. `undecided` is the service reporting it could not
|
|
207
|
+
* answer, which a `holds: false` alone does not distinguish. Every arm carries
|
|
208
|
+
* the `standing` its evidence rests on.
|
|
209
|
+
*/
|
|
210
|
+
export type SysMLVerdict = {
|
|
211
|
+
kind: "holds";
|
|
212
|
+
subject: VerdictSubject;
|
|
213
|
+
standing: VerdictStanding;
|
|
214
|
+
} | {
|
|
215
|
+
kind: "fails";
|
|
216
|
+
subject: VerdictSubject;
|
|
217
|
+
condition: string;
|
|
218
|
+
standing: VerdictStanding;
|
|
219
|
+
} | {
|
|
220
|
+
kind: "undecided";
|
|
221
|
+
subject: VerdictSubject;
|
|
222
|
+
error: string;
|
|
223
|
+
cause: FailureCause;
|
|
224
|
+
standing: VerdictStanding;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Decodes a `sysml.Value` into the union.
|
|
228
|
+
*
|
|
229
|
+
* @throws {MalformedValueError} for a value that contradicts itself: an array
|
|
230
|
+
* whose elements do not fill its dimensions, a vector with a component that
|
|
231
|
+
* is not a number, a vector quantity with no components, a set listing a
|
|
232
|
+
* member twice, a tensor quantity whose components do not fill its
|
|
233
|
+
* dimensions, a quantity (alone or as a component) with no magnitude, a
|
|
234
|
+
* measurement reference naming no unit or a unit without its reduction, or a
|
|
235
|
+
* metaobject naming no element.
|
|
236
|
+
*/
|
|
237
|
+
export declare function decodeValue(value: Value | undefined): SysMLValue;
|
|
238
|
+
/**
|
|
239
|
+
* Encodes the union as the `sysml.Value` the service decodes: the inverse of
|
|
240
|
+
* {@link decodeValue} for every kind but `absent`, which is no value at all.
|
|
241
|
+
*
|
|
242
|
+
* @throws {MalformedValueError} for an `absent` value, or a structured value
|
|
243
|
+
* the service would refuse (see {@link decodeValue}).
|
|
244
|
+
*/
|
|
245
|
+
export declare function encodeValue(value: SysMLValue): Value;
|
|
246
|
+
/** Decodes a `sysml.Verdict` into the union. */
|
|
247
|
+
export declare function decodeVerdict(verdict: Verdict): SysMLVerdict;
|
|
248
|
+
/** Reads the standing fields the `engines` capability adds to a verdict. */
|
|
249
|
+
export declare function decodeStanding(verdict: {
|
|
250
|
+
engine: string;
|
|
251
|
+
strength: string;
|
|
252
|
+
bounds: Bound[];
|
|
253
|
+
}): VerdictStanding;
|
|
254
|
+
/** Names the enum the service reports for a failure it could not answer through. */
|
|
255
|
+
export declare function failureCause(reason: FailureReason): FailureCause;
|
|
256
|
+
/** Renders a value the way the REPL prints one, for logs and error messages. */
|
|
257
|
+
export declare function formatValue(value: SysMLValue): string;
|
|
258
|
+
/**
|
|
259
|
+
* Whether two values are the same value to the model, as the service judges a
|
|
260
|
+
* set's membership: numbers by value, so a whole `real` is the `int` of its
|
|
261
|
+
* value and a `complex` on the real axis is its real part, exactly across the
|
|
262
|
+
* whole `int` range; a `sequence`'s order counts and a `set`'s does not, nor
|
|
263
|
+
* does a member it lists twice; a quantity is the same over its base units; a
|
|
264
|
+
* `measurementRef` is one reduction at one scale however spelt, except that a
|
|
265
|
+
* named unit of dimension one is only its own declaration (`rad` is not `sr`);
|
|
266
|
+
* an `enum` is its `literalId`, whatever else describes it; a `function` is
|
|
267
|
+
* its `calcId` read against its `selfId`; a `null` is the same whatever its
|
|
268
|
+
* reason, and the same as an empty `sequence` or `set` — the model's absent
|
|
269
|
+
* value however spelt.
|
|
270
|
+
*/
|
|
271
|
+
export declare function valuesEqual(a: SysMLValue, b: SysMLValue): boolean;
|