@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.
@@ -0,0 +1,130 @@
1
+ // What a connected service can do. A client asks by capability name, never by
2
+ // version: the service does not answer UNIMPLEMENTED for a capability it lacks,
3
+ // so the advertised list is the only reliable answer.
4
+ import { OpenSysMLError } from "./errors.js";
5
+ import { PLATFORM_PACKAGE_PREFIX } from "./package.js";
6
+ /** Static type facts on a symbol: `typeInfo`, `multiplicity`, `specializations`. */
7
+ export const CAPABILITY_TYPE_FACTS = "type_facts";
8
+ /** Populated `SymbolInfo.attributes`. */
9
+ export const CAPABILITY_SYMBOL_ATTRIBUTES = "symbol_attributes";
10
+ /** Evaluating an expression against an instantiated subject. */
11
+ export const CAPABILITY_EVALUATE_SUBJECT = "evaluate_subject";
12
+ /** An object's values as `Instance.feature_values`. */
13
+ export const CAPABILITY_FEATURE_VALUES = "feature_values";
14
+ /** An enumeration literal as `Value.enum_literal`. */
15
+ export const CAPABILITY_ENUM_VALUES = "enum_values";
16
+ /** A valueless feature of a value type as `Value.unset`. */
17
+ export const CAPABILITY_UNSET_VALUE = "unset_value";
18
+ /** A complex number as `Value.complex`, rather than an unsupported null. */
19
+ export const CAPABILITY_COMPLEX_VALUES = "complex_values";
20
+ /** An array, a vector and a vector quantity as their own arms, rather than unsupported nulls. */
21
+ export const CAPABILITY_STRUCTURED_VALUES = "structured_values";
22
+ /** A bare measurement unit (`SI::m`, `m / s`) as `Value.measurement_ref`, rather than an unsupported null. */
23
+ export const CAPABILITY_MEASUREMENT_REFS = "measurement_refs";
24
+ /** A calc held as a value as `Value.function`, named by its declaration, rather than an unsupported null. */
25
+ export const CAPABILITY_FUNCTION_VALUES = "function_values";
26
+ /** The unbounded value `*` as `Value.infinity`, rather than an unsupported null. */
27
+ export const CAPABILITY_INFINITY_VALUE = "infinity_value";
28
+ /** `Diagnostic.code` is populated, so an empty code is a finding none was assigned. */
29
+ export const CAPABILITY_DIAGNOSTIC_CODES = "diagnostic_codes";
30
+ /** A unique, unordered collection (a `Collections::Set`'s elements) as `Value.set`, rather than an unsupported null. */
31
+ export const CAPABILITY_SET_VALUES = "set_values";
32
+ /** A tensor quantity of any rank as `Value.tensor_quantity`, rather than an unsupported null. */
33
+ export const CAPABILITY_TENSOR_VALUES = "tensor_values";
34
+ /** An element reflected on (`x meta T`, the last of `x.metadata`) as `Value.metaobject`, rather than an unsupported null. */
35
+ export const CAPABILITY_METAOBJECT_VALUES = "metaobject_values";
36
+ /** `finalTime` on an execution response: the run's simulation clock when it ended, in seconds. */
37
+ export const CAPABILITY_FINAL_TIME = "final_time";
38
+ /** `ParseFileRequest.language`, which declares the language of inline content. */
39
+ export const CAPABILITY_INLINE_LANGUAGE = "inline_language";
40
+ /** `ParseFileRequest.strict_conformance`. */
41
+ export const CAPABILITY_STRICT_CONFORMANCE = "strict_conformance";
42
+ /** The `Convert` RPC. Not used by this version; see the README. */
43
+ export const CAPABILITY_CONVERT = "convert";
44
+ /** The verification RPCs. Not used by this version; see the README. */
45
+ export const CAPABILITY_VERIFICATION = "verification";
46
+ /** What the body of a verification case answered, as `verification_verdicts`. */
47
+ export const CAPABILITY_VERIFICATION_VERDICTS = "verification_verdicts";
48
+ /** `RunAnalysisResponse.evaluations`: each call the run made to a calc held as a value, such as a trade study's evaluation of every alternative. */
49
+ export const CAPABILITY_CASE_EVALUATIONS = "case_evaluations";
50
+ /** The `Query` RPC. Not used by this version; see the README. */
51
+ export const CAPABILITY_QUERY = "query";
52
+ /** The `ApplyEdits` RPC. Not used by this version; see the README. */
53
+ export const CAPABILITY_APPLY_EDITS = "apply_edits";
54
+ /** `ApplyEdits` can add `first`/`then` action sequencing members. */
55
+ export const CAPABILITY_SEQUENCE_AUTHORING = "sequence_authoring";
56
+ /** `ApplyEdits` can add action-body statements and succession source multiplicities. */
57
+ export const CAPABILITY_ACTION_BODY_STATEMENT_AUTHORING = "action_body_statement_authoring";
58
+ /** `ApplyEdits` edits a model of several documents as one batch and answers each edited document by name in `documents`. Not used by this version; see the README. */
59
+ export const CAPABILITY_EDIT_DOCUMENTS = "edit_documents";
60
+ /** The `schedule` field of the execution requests, naming the scheduling policy. Not used by this version; see the README. */
61
+ export const CAPABILITY_SCHEDULE = "schedule";
62
+ /** The `explore` scheduling policy, answering with every `outcomes` entry and an `exploration` status. Not used by this version; see the README. */
63
+ export const CAPABILITY_SCHEDULE_EXPLORE = "schedule_explore";
64
+ /** `performerSymbolId` on the action and state requests: the object the behavior runs on, a declaration or a path from one into its parts. Not used by this version; see the README. */
65
+ export const CAPABILITY_PERFORMER = "performer";
66
+ /** The `ListEngines` RPC, the `engine` field selecting an analysis engine, and `engine`, `strength` and `bounds` on the answers. Not used by this version; see the README. */
67
+ export const CAPABILITY_ENGINES = "engines";
68
+ /** A model-level result the model leaves open as `Value.undetermined`, read as an `undetermined` value. */
69
+ export const CAPABILITY_UNDETERMINED_VALUE = "undetermined_value";
70
+ /**
71
+ * Orders capability names by code unit, the order the service reports them in.
72
+ * Locale-aware collation ignores the underscores that separate their words.
73
+ */
74
+ function byCodeUnit(a, b) {
75
+ if (a < b) {
76
+ return -1;
77
+ }
78
+ return a > b ? 1 : 0;
79
+ }
80
+ /** Self-description of the service a connection talks to. */
81
+ export class ServerInfo {
82
+ /** Version the service reports. Informational only; empty when unanswered. */
83
+ version;
84
+ capabilities;
85
+ /** Whether the service answered the handshake; false means it predates `GetServerInfo`. */
86
+ answered;
87
+ /** Where the service came from: the binary this client started, or the address it dialled. */
88
+ origin;
89
+ constructor(init) {
90
+ this.version = init.version;
91
+ this.capabilities = new Set(init.capabilities);
92
+ this.answered = init.answered;
93
+ this.origin = init.origin;
94
+ }
95
+ has(capability) {
96
+ return this.capabilities.has(capability);
97
+ }
98
+ /** One-line description of the service, for an error message. */
99
+ describe() {
100
+ if (!this.answered) {
101
+ return `${this.origin} (version unknown: too old to answer GetServerInfo, so it predates every capability)`;
102
+ }
103
+ const reported = [...this.capabilities].sort(byCodeUnit).join(", ") || "none";
104
+ const version = this.version === "" ? "unknown" : this.version;
105
+ return `${this.origin} (version ${version}, capabilities: ${reported})`;
106
+ }
107
+ }
108
+ /** The connected service does not report a capability the operation requires. */
109
+ export class MissingCapabilityError extends OpenSysMLError {
110
+ capability;
111
+ info;
112
+ constructor(capability, info, remedy) {
113
+ super(`the sysml-grpc service does not support the ${JSON.stringify(capability)} capability, ` +
114
+ `which this operation requires.\n service: ${info.describe()}\n fix: ${remedy}`);
115
+ this.capability = capability;
116
+ this.info = info;
117
+ }
118
+ }
119
+ /** Throws unless the service reports `capability`. */
120
+ export function requireCapability(info, capability, remedy) {
121
+ if (!info.has(capability)) {
122
+ throw new MissingCapabilityError(capability, info, remedy);
123
+ }
124
+ }
125
+ /** Remedy text for a service that lacks `capability`, naming both routes to one that has it. */
126
+ export function upgradeRemedy(capability) {
127
+ return (`run a sysml-grpc whose GetServerInfo reports ${JSON.stringify(capability)}: install a ` +
128
+ `newer ${PLATFORM_PACKAGE_PREFIX}<platform> package, point $OPENSYSML_BINARY at a build that ` +
129
+ `has it, or start one yourself and connect to its address`);
130
+ }
@@ -0,0 +1,79 @@
1
+ import { type Client, type Transport } from "@connectrpc/connect";
2
+ import { ServerInfo } from "./capabilities.js";
3
+ import { SysMLService } from "../generated/sysml_pb.js";
4
+ import { Model } from "./model.js";
5
+ import type { ParseOptions } from "./model.js";
6
+ /** Wire encoding of the request and response bodies. Protobuf is the default. */
7
+ export type Encoding = "protobuf" | "json";
8
+ /** Observability hook: called with every response the service returns. */
9
+ export type ResponseTap = (event: {
10
+ method: string;
11
+ response: unknown;
12
+ }) => void;
13
+ /** Options shared by every way of opening a connection. */
14
+ export interface TransportOptions {
15
+ /** `host:port`, `http://host:port` or `https://host:port` of a running service. */
16
+ address?: string;
17
+ /** Body encoding. Protobuf by default; JSON costs ~6x the server CPU on large answers. */
18
+ encoding?: Encoding;
19
+ /** Deadline applied to every call this connection makes. */
20
+ timeoutMs?: number;
21
+ /** Extra headers sent with every call. */
22
+ headers?: Record<string, string>;
23
+ /** Called with each response, for logging, metrics or a conformance runner. */
24
+ onResponse?: ResponseTap;
25
+ }
26
+ /**
27
+ * What a connection talks to, and how it lets go. A private child releases its
28
+ * reference on close; an external service is only disconnected from.
29
+ */
30
+ export interface ConnectionBackend {
31
+ /** Human-readable provenance, used to name the service in an error message. */
32
+ readonly origin: string;
33
+ /** Releases this connection's hold. Never stops a service the client did not start. */
34
+ release(): Promise<void>;
35
+ }
36
+ /** A connection to a sysml-grpc service. Close it, or use `await using`. */
37
+ export declare class Connection {
38
+ /**
39
+ * The generated Connect client. The ergonomic API covers what this version
40
+ * supports; this is the escape hatch to the RPCs it does not.
41
+ */
42
+ readonly rpc: Client<typeof SysMLService>;
43
+ readonly info: ServerInfo;
44
+ readonly encoding: Encoding;
45
+ private readonly backend;
46
+ private readonly timeoutMs;
47
+ private closed;
48
+ private constructor();
49
+ /** Opens a connection over `transport` and performs the capability handshake. */
50
+ static open(init: {
51
+ transport: Transport;
52
+ backend: ConnectionBackend;
53
+ encoding: Encoding;
54
+ timeoutMs?: number | undefined;
55
+ }): Promise<Connection>;
56
+ /** Whether this connection has been closed. */
57
+ get isClosed(): boolean;
58
+ /** Call options every request of this connection carries. */
59
+ callOptions(): {
60
+ timeoutMs?: number;
61
+ };
62
+ /** Parses a file the service can read, and returns the model it loaded. */
63
+ load(path: string, options?: ParseOptions): Promise<Model>;
64
+ /** Parses inline source text, and returns the model it loaded. */
65
+ loads(source: string, options?: ParseOptions): Promise<Model>;
66
+ /**
67
+ * Adopts a model the service already holds, by hash. Lets a hash pass between
68
+ * processes, and answers NOT_FOUND once the service has evicted the model.
69
+ */
70
+ model(hash: string): Model;
71
+ /** Asks the service what it is and what it can do, again. */
72
+ serverInfo(): Promise<ServerInfo>;
73
+ /**
74
+ * Releases this connection. A private child loses a reference and stops when
75
+ * the last one goes; a service this client did not start keeps running.
76
+ */
77
+ close(): Promise<void>;
78
+ [Symbol.asyncDispose](): Promise<void>;
79
+ }
@@ -0,0 +1,110 @@
1
+ // A connection: one Connect client against one service, plus the handshake that
2
+ // tells the client what that service can do.
3
+ import { Code, ConnectError, createClient } from "@connectrpc/connect";
4
+ import { ServerInfo } from "./capabilities.js";
5
+ import { ClosedConnectionError } from "./errors.js";
6
+ import { SysMLService } from "../generated/sysml_pb.js";
7
+ import { callRpc, fromHandshakeError } from "./status.js";
8
+ import { Model } from "./model.js";
9
+ /** A connection to a sysml-grpc service. Close it, or use `await using`. */
10
+ export class Connection {
11
+ /**
12
+ * The generated Connect client. The ergonomic API covers what this version
13
+ * supports; this is the escape hatch to the RPCs it does not.
14
+ */
15
+ rpc;
16
+ info;
17
+ encoding;
18
+ backend;
19
+ timeoutMs;
20
+ closed = false;
21
+ constructor(init) {
22
+ this.rpc = init.rpc;
23
+ this.info = init.info;
24
+ this.encoding = init.encoding;
25
+ this.backend = init.backend;
26
+ this.timeoutMs = init.timeoutMs;
27
+ }
28
+ /** Opens a connection over `transport` and performs the capability handshake. */
29
+ static async open(init) {
30
+ const rpc = createClient(SysMLService, init.transport);
31
+ const info = await handshake(rpc, init.backend.origin, init.timeoutMs);
32
+ return new Connection({
33
+ rpc,
34
+ info,
35
+ encoding: init.encoding,
36
+ backend: init.backend,
37
+ ...(init.timeoutMs === undefined ? {} : { timeoutMs: init.timeoutMs }),
38
+ });
39
+ }
40
+ /** Whether this connection has been closed. */
41
+ get isClosed() {
42
+ return this.closed;
43
+ }
44
+ /** Call options every request of this connection carries. */
45
+ callOptions() {
46
+ if (this.closed) {
47
+ throw new ClosedConnectionError();
48
+ }
49
+ return this.timeoutMs === undefined ? {} : { timeoutMs: this.timeoutMs };
50
+ }
51
+ /** Parses a file the service can read, and returns the model it loaded. */
52
+ load(path, options = {}) {
53
+ return Model.parse(this, { source: { case: "filePath", value: path } }, options);
54
+ }
55
+ /** Parses inline source text, and returns the model it loaded. */
56
+ loads(source, options = {}) {
57
+ return Model.parse(this, { source: { case: "content", value: source } }, options);
58
+ }
59
+ /**
60
+ * Adopts a model the service already holds, by hash. Lets a hash pass between
61
+ * processes, and answers NOT_FOUND once the service has evicted the model.
62
+ */
63
+ model(hash) {
64
+ return Model.adopt(this, hash);
65
+ }
66
+ /** Asks the service what it is and what it can do, again. */
67
+ async serverInfo() {
68
+ const response = await callRpc(this.rpc.getServerInfo({}, this.callOptions()));
69
+ return new ServerInfo({
70
+ version: response.version,
71
+ capabilities: response.capabilities,
72
+ answered: true,
73
+ origin: this.backend.origin,
74
+ });
75
+ }
76
+ /**
77
+ * Releases this connection. A private child loses a reference and stops when
78
+ * the last one goes; a service this client did not start keeps running.
79
+ */
80
+ async close() {
81
+ if (this.closed) {
82
+ return;
83
+ }
84
+ this.closed = true;
85
+ await this.backend.release();
86
+ }
87
+ async [Symbol.asyncDispose]() {
88
+ await this.close();
89
+ }
90
+ }
91
+ async function handshake(rpc, origin, timeoutMs) {
92
+ const options = timeoutMs === undefined ? {} : { timeoutMs };
93
+ try {
94
+ const info = await rpc.getServerInfo({}, options);
95
+ return new ServerInfo({
96
+ version: info.version,
97
+ capabilities: info.capabilities,
98
+ answered: true,
99
+ origin,
100
+ });
101
+ }
102
+ catch (error) {
103
+ const connectError = ConnectError.from(error);
104
+ // A service too old to answer the handshake is still usable; anything else is not.
105
+ if (connectError.code === Code.Unimplemented) {
106
+ return new ServerInfo({ version: "", capabilities: [], answered: false, origin });
107
+ }
108
+ throw fromHandshakeError(connectError, origin);
109
+ }
110
+ }
@@ -0,0 +1,98 @@
1
+ /** Base class of every error this client raises. */
2
+ export declare class OpenSysMLError extends Error {
3
+ constructor(message: string, options?: {
4
+ cause?: unknown;
5
+ });
6
+ }
7
+ /**
8
+ * The service could not be reached, started, or answered nothing usable. Also
9
+ * what a failed call becomes: the subclasses name the statuses a caller acts on
10
+ * differently, and the ConnectError behind one is always its `cause`.
11
+ */
12
+ export declare class ServiceError extends OpenSysMLError {
13
+ /** Status the call failed with, when the failure came from a call. */
14
+ readonly code: string | undefined;
15
+ constructor(message: string, options?: {
16
+ cause?: unknown;
17
+ code?: string;
18
+ });
19
+ }
20
+ /** A private child service failed to start, or died while it was needed. */
21
+ export declare class ServiceStartError extends ServiceError {
22
+ }
23
+ /** The connection was closed and cannot be used again. */
24
+ export declare class ClosedConnectionError extends OpenSysMLError {
25
+ constructor();
26
+ }
27
+ /** The service no longer holds the model a call named; load it again. */
28
+ export declare class ModelNotFoundError extends ServiceError {
29
+ }
30
+ /** The service could not read the source file a call named. */
31
+ export declare class ModelFileNotFoundError extends ServiceError {
32
+ }
33
+ /** The service rejected the request as malformed or unsupported. */
34
+ export declare class InvalidRequestError extends ServiceError {
35
+ }
36
+ /** A call exceeded its deadline, or was cancelled. */
37
+ export declare class ServiceTimeoutError extends ServiceError {
38
+ }
39
+ /** The connected service does not implement the call at all. */
40
+ export declare class UnsupportedOperationError extends ServiceError {
41
+ }
42
+ /** A value contradicts itself on the wire, such as an array whose elements do not fill its dimensions. */
43
+ export declare class MalformedValueError extends OpenSysMLError {
44
+ }
45
+ /** A release binary could not be downloaded, or could not be installed once it was. */
46
+ export declare class DownloadError extends ServiceError {
47
+ }
48
+ /** A download's digest contradicts the one expected of it, so it is never used. */
49
+ export declare class ChecksumMismatchError extends DownloadError {
50
+ }
51
+ /** Nothing pins or signs a digest for the release, leaving only its origin's word. */
52
+ export declare class UnpinnedReleaseError extends ChecksumMismatchError {
53
+ }
54
+ /**
55
+ * No signature on the checksum manifest could be checked at all: none published,
56
+ * unreadable, or no verifier installed. Refused exactly as an unpinned release is.
57
+ */
58
+ export declare class UnsignedReleaseError extends UnpinnedReleaseError {
59
+ }
60
+ /** A signature was checked and does not verify: another signer, or a changed manifest. */
61
+ export declare class ManifestSignatureError extends ChecksumMismatchError {
62
+ }
63
+ /** A model file could not be read, or its content did not parse. */
64
+ export declare class ParseError extends OpenSysMLError {
65
+ /** Diagnostics the service reported, in the order it reported them. */
66
+ readonly diagnostics: readonly ModelDiagnostic[];
67
+ constructor(message: string, diagnostics?: readonly ModelDiagnostic[]);
68
+ }
69
+ /** One diagnostic about a model, at a source position when the service gave one. */
70
+ export interface ModelDiagnostic {
71
+ severity: string;
72
+ message: string;
73
+ /** What was found, stable across message wording (`"syntax"`, a validation code,
74
+ * `"choice-point"`, `"guard-unevaluable"`); `""` when the service assigned none. */
75
+ code: string;
76
+ file?: string;
77
+ startLine?: number;
78
+ startColumn?: number;
79
+ endLine?: number;
80
+ endColumn?: number;
81
+ }
82
+ /** No symbol of that name is declared in the model. */
83
+ export declare class SymbolNotFoundError extends OpenSysMLError {
84
+ /** Name that was looked up. `name` is the error's class, as on every Error. */
85
+ readonly symbolName: string;
86
+ /** Names the model declares that are close enough to be typos of it. */
87
+ readonly suggestions: readonly string[];
88
+ constructor(name: string, near?: readonly string[]);
89
+ }
90
+ /** An expression could not be evaluated, or a symbol could not be instantiated. */
91
+ export declare class EvaluationError extends OpenSysMLError {
92
+ /** Why the service could not answer, when it classified the failure. */
93
+ readonly reason: FailureCause;
94
+ readonly diagnostics: readonly ModelDiagnostic[];
95
+ constructor(message: string, reason?: FailureCause, diagnostics?: readonly ModelDiagnostic[]);
96
+ }
97
+ /** The service's classification of a failure it reported in a successful answer. */
98
+ export type FailureCause = "unspecified" | "evaluation" | "wrong_kind" | "ambiguous_subject" | "undecided";
@@ -0,0 +1,100 @@
1
+ // Errors this client raises. Everything derives from OpenSysMLError, so a caller
2
+ // can catch the family without knowing the members.
3
+ /** Base class of every error this client raises. */
4
+ export class OpenSysMLError extends Error {
5
+ constructor(message, options) {
6
+ super(message, options);
7
+ this.name = new.target.name;
8
+ }
9
+ }
10
+ /**
11
+ * The service could not be reached, started, or answered nothing usable. Also
12
+ * what a failed call becomes: the subclasses name the statuses a caller acts on
13
+ * differently, and the ConnectError behind one is always its `cause`.
14
+ */
15
+ export class ServiceError extends OpenSysMLError {
16
+ /** Status the call failed with, when the failure came from a call. */
17
+ code;
18
+ constructor(message, options = {}) {
19
+ super(message, options.cause === undefined ? {} : { cause: options.cause });
20
+ this.code = options.code;
21
+ }
22
+ }
23
+ /** A private child service failed to start, or died while it was needed. */
24
+ export class ServiceStartError extends ServiceError {
25
+ }
26
+ /** The connection was closed and cannot be used again. */
27
+ export class ClosedConnectionError extends OpenSysMLError {
28
+ constructor() {
29
+ super("this connection is closed; open another with connect()");
30
+ }
31
+ }
32
+ /** The service no longer holds the model a call named; load it again. */
33
+ export class ModelNotFoundError extends ServiceError {
34
+ }
35
+ /** The service could not read the source file a call named. */
36
+ export class ModelFileNotFoundError extends ServiceError {
37
+ }
38
+ /** The service rejected the request as malformed or unsupported. */
39
+ export class InvalidRequestError extends ServiceError {
40
+ }
41
+ /** A call exceeded its deadline, or was cancelled. */
42
+ export class ServiceTimeoutError extends ServiceError {
43
+ }
44
+ /** The connected service does not implement the call at all. */
45
+ export class UnsupportedOperationError extends ServiceError {
46
+ }
47
+ /** A value contradicts itself on the wire, such as an array whose elements do not fill its dimensions. */
48
+ export class MalformedValueError extends OpenSysMLError {
49
+ }
50
+ /** A release binary could not be downloaded, or could not be installed once it was. */
51
+ export class DownloadError extends ServiceError {
52
+ }
53
+ /** A download's digest contradicts the one expected of it, so it is never used. */
54
+ export class ChecksumMismatchError extends DownloadError {
55
+ }
56
+ /** Nothing pins or signs a digest for the release, leaving only its origin's word. */
57
+ export class UnpinnedReleaseError extends ChecksumMismatchError {
58
+ }
59
+ /**
60
+ * No signature on the checksum manifest could be checked at all: none published,
61
+ * unreadable, or no verifier installed. Refused exactly as an unpinned release is.
62
+ */
63
+ export class UnsignedReleaseError extends UnpinnedReleaseError {
64
+ }
65
+ /** A signature was checked and does not verify: another signer, or a changed manifest. */
66
+ export class ManifestSignatureError extends ChecksumMismatchError {
67
+ }
68
+ /** A model file could not be read, or its content did not parse. */
69
+ export class ParseError extends OpenSysMLError {
70
+ /** Diagnostics the service reported, in the order it reported them. */
71
+ diagnostics;
72
+ constructor(message, diagnostics = []) {
73
+ super(message);
74
+ this.diagnostics = diagnostics;
75
+ }
76
+ }
77
+ /** No symbol of that name is declared in the model. */
78
+ export class SymbolNotFoundError extends OpenSysMLError {
79
+ /** Name that was looked up. `name` is the error's class, as on every Error. */
80
+ symbolName;
81
+ /** Names the model declares that are close enough to be typos of it. */
82
+ suggestions;
83
+ constructor(name, near = []) {
84
+ const hint = near.length > 0 ? `; did you mean ${near.join(", ")}?` : "";
85
+ super(`the model declares no symbol named ${JSON.stringify(name)}${hint}`);
86
+ this.symbolName = name;
87
+ this.suggestions = [...near];
88
+ }
89
+ }
90
+ /** An expression could not be evaluated, or a symbol could not be instantiated. */
91
+ export class EvaluationError extends OpenSysMLError {
92
+ /** Why the service could not answer, when it classified the failure. */
93
+ reason;
94
+ diagnostics;
95
+ constructor(message, reason = "unspecified", diagnostics = []) {
96
+ super(message);
97
+ this.reason = reason;
98
+ this.diagnostics = diagnostics;
99
+ }
100
+ }
@@ -0,0 +1,14 @@
1
+ export { Connection } from "./connection.js";
2
+ export type { ConnectionBackend, Encoding, ResponseTap, TransportOptions, } from "./connection.js";
3
+ export { Instance, InstanceTree, Model, ModelSymbol } from "./model.js";
4
+ export type { AttributeFacts, EvalOptions, FeatureValue, ParseOptions, SpecializationFacts, TypeFacts, } from "./model.js";
5
+ export { CAPABILITY_APPLY_EDITS, CAPABILITY_ACTION_BODY_STATEMENT_AUTHORING, CAPABILITY_CASE_EVALUATIONS, CAPABILITY_COMPLEX_VALUES, CAPABILITY_CONVERT, CAPABILITY_DIAGNOSTIC_CODES, CAPABILITY_EDIT_DOCUMENTS, CAPABILITY_ENGINES, CAPABILITY_ENUM_VALUES, CAPABILITY_EVALUATE_SUBJECT, CAPABILITY_FEATURE_VALUES, CAPABILITY_FINAL_TIME, CAPABILITY_FUNCTION_VALUES, CAPABILITY_INFINITY_VALUE, CAPABILITY_INLINE_LANGUAGE, CAPABILITY_MEASUREMENT_REFS, CAPABILITY_METAOBJECT_VALUES, CAPABILITY_PERFORMER, CAPABILITY_QUERY, CAPABILITY_SCHEDULE, CAPABILITY_SCHEDULE_EXPLORE, CAPABILITY_SEQUENCE_AUTHORING, CAPABILITY_SET_VALUES, CAPABILITY_STRICT_CONFORMANCE, CAPABILITY_STRUCTURED_VALUES, CAPABILITY_UNDETERMINED_VALUE, CAPABILITY_VERIFICATION_VERDICTS, CAPABILITY_SYMBOL_ATTRIBUTES, CAPABILITY_TENSOR_VALUES, CAPABILITY_TYPE_FACTS, CAPABILITY_UNSET_VALUE, CAPABILITY_VERIFICATION, MissingCapabilityError, ServerInfo, requireCapability, upgradeRemedy, } from "./capabilities.js";
6
+ export { ChecksumMismatchError, ClosedConnectionError, DownloadError, EvaluationError, InvalidRequestError, MalformedValueError, ManifestSignatureError, ModelFileNotFoundError, ModelNotFoundError, OpenSysMLError, ParseError, ServiceError, ServiceStartError, ServiceTimeoutError, SymbolNotFoundError, UnpinnedReleaseError, UnsignedReleaseError, UnsupportedOperationError, } from "./errors.js";
7
+ export type { FailureCause, ModelDiagnostic } from "./errors.js";
8
+ export { fromHandshakeError, fromRpcError, statusName } from "./status.js";
9
+ export type { NotFoundSubject } from "./status.js";
10
+ export { decodeValue, decodeVerdict, decodeStanding, encodeValue, formatValue, valuesEqual, } from "./values.js";
11
+ export type { ArrayValue, ComplexValue, EnumValue, FunctionValue, Magnitude, MeasurementRefValue, MetaobjectValue, QuantityValue, SysMLValue, SysMLVerdict, VerdictBound, VerdictStanding, TensorQuantityValue, UndeterminedValue, UnitFactor, UnitFactorization, VerdictSubject, } from "./values.js";
12
+ export { baseUrl } from "./transport.js";
13
+ export { PACKAGE_NAME, PLATFORM_PACKAGE_PREFIX } from "./package.js";
14
+ export { SysMLService } from "../generated/sysml_pb.js";
@@ -0,0 +1,10 @@
1
+ // The isomorphic core: everything that does not need a process to spawn.
2
+ export { Connection } from "./connection.js";
3
+ export { Instance, InstanceTree, Model, ModelSymbol } from "./model.js";
4
+ export { CAPABILITY_APPLY_EDITS, CAPABILITY_ACTION_BODY_STATEMENT_AUTHORING, CAPABILITY_CASE_EVALUATIONS, CAPABILITY_COMPLEX_VALUES, CAPABILITY_CONVERT, CAPABILITY_DIAGNOSTIC_CODES, CAPABILITY_EDIT_DOCUMENTS, CAPABILITY_ENGINES, CAPABILITY_ENUM_VALUES, CAPABILITY_EVALUATE_SUBJECT, CAPABILITY_FEATURE_VALUES, CAPABILITY_FINAL_TIME, CAPABILITY_FUNCTION_VALUES, CAPABILITY_INFINITY_VALUE, CAPABILITY_INLINE_LANGUAGE, CAPABILITY_MEASUREMENT_REFS, CAPABILITY_METAOBJECT_VALUES, CAPABILITY_PERFORMER, CAPABILITY_QUERY, CAPABILITY_SCHEDULE, CAPABILITY_SCHEDULE_EXPLORE, CAPABILITY_SEQUENCE_AUTHORING, CAPABILITY_SET_VALUES, CAPABILITY_STRICT_CONFORMANCE, CAPABILITY_STRUCTURED_VALUES, CAPABILITY_UNDETERMINED_VALUE, CAPABILITY_VERIFICATION_VERDICTS, CAPABILITY_SYMBOL_ATTRIBUTES, CAPABILITY_TENSOR_VALUES, CAPABILITY_TYPE_FACTS, CAPABILITY_UNSET_VALUE, CAPABILITY_VERIFICATION, MissingCapabilityError, ServerInfo, requireCapability, upgradeRemedy, } from "./capabilities.js";
5
+ export { ChecksumMismatchError, ClosedConnectionError, DownloadError, EvaluationError, InvalidRequestError, MalformedValueError, ManifestSignatureError, ModelFileNotFoundError, ModelNotFoundError, OpenSysMLError, ParseError, ServiceError, ServiceStartError, ServiceTimeoutError, SymbolNotFoundError, UnpinnedReleaseError, UnsignedReleaseError, UnsupportedOperationError, } from "./errors.js";
6
+ export { fromHandshakeError, fromRpcError, statusName } from "./status.js";
7
+ export { decodeValue, decodeVerdict, decodeStanding, encodeValue, formatValue, valuesEqual, } from "./values.js";
8
+ export { baseUrl } from "./transport.js";
9
+ export { PACKAGE_NAME, PLATFORM_PACKAGE_PREFIX } from "./package.js";
10
+ export { SysMLService } from "../generated/sysml_pb.js";