@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.
Files changed (67) hide show
  1. package/README.md +355 -33
  2. package/dist/browser/index.d.ts +9 -0
  3. package/dist/browser/index.js +16 -0
  4. package/dist/browser/wasm-worker.d.ts +1 -0
  5. package/dist/browser/wasm-worker.js +2 -0
  6. package/dist/browser/wasm.d.ts +17 -0
  7. package/dist/browser/wasm.js +94 -0
  8. package/dist/core/arguments.d.ts +4 -0
  9. package/dist/core/arguments.js +19 -0
  10. package/dist/core/capabilities.d.ts +90 -9
  11. package/dist/core/capabilities.js +111 -10
  12. package/dist/core/connection.d.ts +203 -2
  13. package/dist/core/connection.js +810 -17
  14. package/dist/core/conversion.d.ts +153 -0
  15. package/dist/core/conversion.js +191 -0
  16. package/dist/core/document.d.ts +188 -0
  17. package/dist/core/document.js +457 -0
  18. package/dist/core/edit.d.ts +446 -0
  19. package/dist/core/edit.js +1994 -0
  20. package/dist/core/engines.d.ts +64 -0
  21. package/dist/core/engines.js +74 -0
  22. package/dist/core/errors.d.ts +164 -2
  23. package/dist/core/errors.js +209 -3
  24. package/dist/core/exploration.d.ts +71 -0
  25. package/dist/core/exploration.js +116 -0
  26. package/dist/core/graphs.d.ts +15 -0
  27. package/dist/core/graphs.js +3 -0
  28. package/dist/core/index.d.ts +30 -9
  29. package/dist/core/index.js +14 -5
  30. package/dist/core/model.d.ts +168 -8
  31. package/dist/core/model.js +258 -31
  32. package/dist/core/package.d.ts +2 -0
  33. package/dist/core/package.js +2 -0
  34. package/dist/core/query.d.ts +50 -0
  35. package/dist/core/query.js +197 -0
  36. package/dist/core/render-view.d.ts +97 -0
  37. package/dist/core/render-view.js +120 -0
  38. package/dist/core/sources.d.ts +34 -0
  39. package/dist/core/sources.js +134 -0
  40. package/dist/core/status.d.ts +9 -2
  41. package/dist/core/status.js +24 -8
  42. package/dist/core/typed.d.ts +71 -0
  43. package/dist/core/typed.js +245 -0
  44. package/dist/core/values.d.ts +127 -8
  45. package/dist/core/values.js +536 -30
  46. package/dist/core/verdict.d.ts +271 -0
  47. package/dist/core/verdict.js +567 -0
  48. package/dist/core/wasm.d.ts +114 -0
  49. package/dist/core/wasm.js +514 -0
  50. package/dist/generated/sysml_pb.d.ts +1062 -15
  51. package/dist/generated/sysml_pb.js +200 -100
  52. package/dist/node/generate-cli.d.ts +2 -0
  53. package/dist/node/generate-cli.js +10 -0
  54. package/dist/node/generate.d.ts +99 -0
  55. package/dist/node/generate.js +757 -0
  56. package/dist/node/index.d.ts +29 -2
  57. package/dist/node/index.js +211 -10
  58. package/dist/node/service.d.ts +5 -3
  59. package/dist/node/service.js +32 -26
  60. package/dist/node/wasm-source.d.ts +18 -0
  61. package/dist/node/wasm-source.js +103 -0
  62. package/dist/node/wasm-worker.d.ts +1 -0
  63. package/dist/node/wasm-worker.js +10 -0
  64. package/dist/node/wasm.d.ts +17 -0
  65. package/dist/node/wasm.js +63 -0
  66. package/package.json +19 -7
  67. package/release-digests.json +105 -0
@@ -0,0 +1,64 @@
1
+ import type { Bound as PbBound, EngineInfo as PbEngineInfo } from "../generated/sysml_pb.js";
2
+ import { type VerdictBound, type VerdictStanding } from "./values.js";
3
+ /** Strengths, weakest first, as the service spells them. */
4
+ export declare const STRENGTH_NOT_COVERED = "not covered";
5
+ export declare const STRENGTH_OBSERVED = "observed";
6
+ export declare const STRENGTH_WITNESSED = "witnessed";
7
+ export declare const STRENGTH_BOUNDED = "bounded";
8
+ export declare const STRENGTH_PROVED = "proved";
9
+ /** Engine selections that name no single engine. */
10
+ export declare const ENGINE_AUTO = "auto";
11
+ export declare const ENGINE_ALL = "all";
12
+ /** How far an answer can be trusted: who answered, how strongly, within what. */
13
+ export type Standing = VerdictStanding;
14
+ /** The standing a service that reported none carries. */
15
+ export declare function emptyStanding(): Standing;
16
+ /** One limit an engine ran under, and whether the run stopped at it. */
17
+ export type EngineBound = VerdictBound;
18
+ /** Reads the standing fields a response or verdict carries. */
19
+ export declare function standingOf(pb: {
20
+ engine: string;
21
+ strength: string;
22
+ bounds: PbBound[];
23
+ }): Standing;
24
+ /** Whether the service reported a standing at all. */
25
+ export declare function standingReported(standing: Standing): boolean;
26
+ /** The bounds the engine stopped at. */
27
+ export declare function standingReached(standing: Standing): EngineBound[];
28
+ /** One phrase: `observed by run`, `bounded by explore (runs 64 reached)`. */
29
+ export declare function explainStanding(standing: Standing): string;
30
+ /** One engine the service registers, as `listEngines` reports it. */
31
+ export interface EngineInfo {
32
+ /** The engine's name, the spelling `engine` selects it by. */
33
+ name: string;
34
+ /** The strongest evidence it may claim, one of `STRENGTH_*`. */
35
+ authority: string;
36
+ /** The question kinds it answers. */
37
+ answers: readonly string[];
38
+ /** The bounds it runs under. */
39
+ bounds: readonly string[];
40
+ /** The external process it needs; empty for an in-process engine. */
41
+ process: string;
42
+ /** Where that process was found; empty when it was not. */
43
+ processFound: string;
44
+ /** Whether it can run here. */
45
+ ready: boolean;
46
+ /** Why it cannot, when it cannot. */
47
+ unavailable: string;
48
+ /** `built-in`, `tool` or `engine` (one registered from a manifest). */
49
+ kind: string;
50
+ /** How it is spoken to. */
51
+ protocol: string;
52
+ /** The manifest file an external engine was read from; empty for a built-in one. */
53
+ source: string;
54
+ /** The resolved command of an external engine; empty for a built-in one. */
55
+ command: string;
56
+ /** The version its manifest declares; empty for a built-in one. */
57
+ version: string;
58
+ /** Whether this service runs it; an external engine is listed unserved until `-serve-external-engines`. */
59
+ served: boolean;
60
+ }
61
+ /** An engine as the wire describes it. */
62
+ export declare function engineInfoOf(pb: PbEngineInfo): EngineInfo;
63
+ /** One line naming the engine, its kind, its authority, its questions and its status. */
64
+ export declare function explainEngine(engine: EngineInfo): string;
@@ -0,0 +1,74 @@
1
+ // The analysis engines the service answers with, and the standing of an answer.
2
+ // The standing a verdict or response carries is the `VerdictStanding` of
3
+ // values.ts; the helpers here read it.
4
+ import { decodeStanding } from "./values.js";
5
+ /** Strengths, weakest first, as the service spells them. */
6
+ export const STRENGTH_NOT_COVERED = "not covered";
7
+ export const STRENGTH_OBSERVED = "observed";
8
+ export const STRENGTH_WITNESSED = "witnessed";
9
+ export const STRENGTH_BOUNDED = "bounded";
10
+ export const STRENGTH_PROVED = "proved";
11
+ /** Engine selections that name no single engine. */
12
+ export const ENGINE_AUTO = "auto";
13
+ export const ENGINE_ALL = "all";
14
+ /** The standing a service that reported none carries. */
15
+ export function emptyStanding() {
16
+ return { engine: "", strength: "", bounds: [], reported: false, reached: [] };
17
+ }
18
+ /** Reads the standing fields a response or verdict carries. */
19
+ export function standingOf(pb) {
20
+ return decodeStanding(pb);
21
+ }
22
+ /** Whether the service reported a standing at all. */
23
+ export function standingReported(standing) {
24
+ return standing.strength !== "";
25
+ }
26
+ /** The bounds the engine stopped at. */
27
+ export function standingReached(standing) {
28
+ return standing.bounds.filter((bound) => bound.reached);
29
+ }
30
+ /** One phrase: `observed by run`, `bounded by explore (runs 64 reached)`. */
31
+ export function explainStanding(standing) {
32
+ if (!standingReported(standing)) {
33
+ return "";
34
+ }
35
+ let line = standing.strength;
36
+ if (standing.engine !== "") {
37
+ line += ` by ${standing.engine}`;
38
+ }
39
+ const reached = standingReached(standing).map((b) => `${b.name} ${b.limit.toString()} reached`);
40
+ if (reached.length > 0) {
41
+ line += ` (${reached.join(", ")})`;
42
+ }
43
+ return line;
44
+ }
45
+ /** An engine as the wire describes it. */
46
+ export function engineInfoOf(pb) {
47
+ return {
48
+ name: pb.name,
49
+ authority: pb.authority,
50
+ answers: [...pb.answers],
51
+ bounds: [...pb.bounds],
52
+ process: pb.process,
53
+ processFound: pb.processFound,
54
+ ready: pb.ready,
55
+ unavailable: pb.unavailable,
56
+ kind: pb.kind,
57
+ protocol: pb.protocol,
58
+ source: pb.source,
59
+ command: pb.command,
60
+ version: pb.version,
61
+ served: pb.served,
62
+ };
63
+ }
64
+ /** One line naming the engine, its kind, its authority, its questions and its status. */
65
+ export function explainEngine(engine) {
66
+ let status = engine.ready ? "ready" : `unavailable: ${engine.unavailable}`;
67
+ if (engine.kind === "engine" && !engine.served) {
68
+ status += "; not served by this service";
69
+ }
70
+ const kind = engine.kind === "engine" || engine.kind === "tool"
71
+ ? ` (${engine.kind}, ${engine.protocol})`
72
+ : "";
73
+ return `${engine.name}${kind}: ${engine.authority}, answers ${engine.answers.join(", ")}; ${status}`;
74
+ }
@@ -1,3 +1,6 @@
1
+ import type { ServerInfo } from "./capabilities.js";
2
+ import type { DocumentEvent } from "./document.js";
3
+ import type { AnalysisResult } from "./verdict.js";
1
4
  /** Base class of every error this client raises. */
2
5
  export declare class OpenSysMLError extends Error {
3
6
  constructor(message: string, options?: {
@@ -20,6 +23,21 @@ export declare class ServiceError extends OpenSysMLError {
20
23
  /** A private child service failed to start, or died while it was needed. */
21
24
  export declare class ServiceStartError extends ServiceError {
22
25
  }
26
+ /** The service already listening is not the one asked for, reported rather than stopped. */
27
+ export declare class StaleServiceError extends ServiceError {
28
+ /** Address the mismatched service is listening on. */
29
+ readonly address: string;
30
+ /** How it differs from the service that was asked for. */
31
+ readonly reason: string;
32
+ /** What to do about it. */
33
+ readonly remedy: string;
34
+ /** What it reported about itself, when it could be asked. */
35
+ readonly info: ServerInfo | undefined;
36
+ constructor(address: string, reason: string, remedy: string, options?: {
37
+ info?: ServerInfo;
38
+ cause?: unknown;
39
+ });
40
+ }
23
41
  /** The connection was closed and cannot be used again. */
24
42
  export declare class ClosedConnectionError extends OpenSysMLError {
25
43
  constructor();
@@ -36,6 +54,9 @@ export declare class InvalidRequestError extends ServiceError {
36
54
  /** A call exceeded its deadline, or was cancelled. */
37
55
  export declare class ServiceTimeoutError extends ServiceError {
38
56
  }
57
+ /** The service was unreachable, refused the stream, or died before answering. */
58
+ export declare class ServiceUnavailableError extends ServiceError {
59
+ }
39
60
  /** The connected service does not implement the call at all. */
40
61
  export declare class UnsupportedOperationError extends ServiceError {
41
62
  }
@@ -64,7 +85,16 @@ export declare class ManifestSignatureError extends ChecksumMismatchError {
64
85
  export declare class ParseError extends OpenSysMLError {
65
86
  /** Diagnostics the service reported, in the order it reported them. */
66
87
  readonly diagnostics: readonly ModelDiagnostic[];
67
- constructor(message: string, diagnostics?: readonly ModelDiagnostic[]);
88
+ /** The model the errors belong to, when one was loaded, so it stays inspectable. */
89
+ readonly model: ModelLike | undefined;
90
+ constructor(message: string, diagnostics?: readonly ModelDiagnostic[], options?: {
91
+ model?: ModelLike;
92
+ });
93
+ }
94
+ /** The surface of a model a ParseError carries, kept structural so model.ts stays a client of this file. */
95
+ export interface ModelLike {
96
+ readonly hash: string;
97
+ readonly diagnostics: readonly ModelDiagnostic[];
68
98
  }
69
99
  /** One diagnostic about a model, at a source position when the service gave one. */
70
100
  export interface ModelDiagnostic {
@@ -85,7 +115,9 @@ export declare class SymbolNotFoundError extends OpenSysMLError {
85
115
  readonly symbolName: string;
86
116
  /** Names the model declares that are close enough to be typos of it. */
87
117
  readonly suggestions: readonly string[];
88
- constructor(name: string, near?: readonly string[]);
118
+ constructor(name: string, near?: readonly string[], options?: {
119
+ cause?: unknown;
120
+ });
89
121
  }
90
122
  /** An expression could not be evaluated, or a symbol could not be instantiated. */
91
123
  export declare class EvaluationError extends OpenSysMLError {
@@ -94,5 +126,135 @@ export declare class EvaluationError extends OpenSysMLError {
94
126
  readonly diagnostics: readonly ModelDiagnostic[];
95
127
  constructor(message: string, reason?: FailureCause, diagnostics?: readonly ModelDiagnostic[]);
96
128
  }
129
+ /** A run — an execution, verification, calculation, analysis or sweep — failed. */
130
+ export declare class ExecutionError extends EvaluationError {
131
+ /** Partial ExecuteState trace, when a traced run failed. */
132
+ readonly trace: readonly DocumentEvent[];
133
+ /** Oldest ExecuteState trace records the service discarded. */
134
+ readonly traceDropped: number;
135
+ constructor(message: string, reason?: FailureCause, diagnostics?: readonly ModelDiagnostic[], trace?: readonly DocumentEvent[], traceDropped?: number);
136
+ }
137
+ /** The element a verification named is of another kind, a wrong request rather than a verdict. */
138
+ export declare class WrongKindError extends ExecutionError {
139
+ }
140
+ /** An analysis case could not run to its end but left something to inspect, carried as `result`. */
141
+ export declare class AnalysisRunError extends ExecutionError {
142
+ /** The partial result the failed run left: the evaluations made, the verdicts left undecided. */
143
+ readonly result: AnalysisResult;
144
+ constructor(message: string, result: AnalysisResult, options?: {
145
+ diagnostics?: readonly ModelDiagnostic[];
146
+ reason?: FailureCause;
147
+ });
148
+ }
149
+ /** A model could not be written in the format asked for. */
150
+ export declare class ConversionError extends OpenSysMLError {
151
+ readonly diagnostics: readonly ModelDiagnostic[];
152
+ constructor(message: string, diagnostics?: readonly ModelDiagnostic[]);
153
+ }
154
+ /** A SysML v1 model could not be read, so nothing of it was migrated. */
155
+ export declare class MigrationError extends OpenSysMLError {
156
+ }
157
+ /** The service sent a value the wire format cannot represent, or a caller sent one it cannot carry. */
158
+ export declare class UnsupportedValueError extends OpenSysMLError {
159
+ }
160
+ /** A feature value could not be evaluated or was never materialized. */
161
+ export declare class FeatureValueError extends OpenSysMLError {
162
+ /** Name of the feature. */
163
+ readonly featureName: string;
164
+ /** Error description the service reported. */
165
+ readonly message: string;
166
+ constructor(featureName: string, message: string);
167
+ }
168
+ /** A feature holds a value of another type than its generated view declares. */
169
+ export declare class TypeMismatchError extends OpenSysMLError {
170
+ /** Name of the feature. */
171
+ readonly featureName: string;
172
+ /** Type the generated class declares. */
173
+ readonly expected: string;
174
+ /** The value actually decoded. */
175
+ readonly value: unknown;
176
+ constructor(featureName: string, expected: string, value: unknown);
177
+ }
178
+ /** A generated typed view was asked to wrap an instance of another type. */
179
+ export declare class InstanceTypeError extends OpenSysMLError {
180
+ /** FQN of the definition the generated class views. */
181
+ readonly expected: string;
182
+ /** FQN the instance reports as its type. */
183
+ readonly actual: string;
184
+ constructor(expected: string, actual: string);
185
+ }
186
+ /** A query payload is not one the SysML v2 API & Services query model describes. */
187
+ export declare class QueryError extends OpenSysMLError {
188
+ }
189
+ /** A document query binding cannot be written before anything is sent. */
190
+ export declare class DocumentQueryError extends OpenSysMLError {
191
+ }
192
+ /** One declaration referring to the target of a refused rename, delete or move. */
193
+ export declare class Referrer {
194
+ /** The referring declaration, as the notation names it. */
195
+ readonly name: string;
196
+ /** The document declaring it, as the parse named it. */
197
+ readonly document: string;
198
+ constructor(name: string, document: string);
199
+ }
200
+ /** An edit to a model was refused, and nothing was changed. */
201
+ export declare class EditError extends OpenSysMLError {
202
+ /** Refusal kind, as the wire enum names it, e.g. `EDIT_FAILURE_UNKNOWN_TARGET`. */
203
+ readonly failure: string;
204
+ /** Diagnostics behind the refusal. */
205
+ readonly diagnostics: readonly ModelDiagnostic[];
206
+ /** Where references a refused rename, delete or move would have broken are made. */
207
+ readonly referringElements: readonly string[];
208
+ /** The same referrers, each with the document declaring it. */
209
+ readonly referrers: readonly Referrer[];
210
+ constructor(message: string, options?: {
211
+ failure?: string;
212
+ diagnostics?: readonly ModelDiagnostic[];
213
+ referringElements?: readonly string[];
214
+ referrers?: readonly Referrer[];
215
+ });
216
+ }
217
+ /** An editor with no operations was applied. */
218
+ export declare class NoEditsError extends EditError {
219
+ }
220
+ /** The element an edit names cannot carry that edit. */
221
+ export declare class EditTargetError extends EditError {
222
+ }
223
+ /** The new value or name itself cannot be read. */
224
+ export declare class InvalidEditError extends EditError {
225
+ }
226
+ /** A rename would break references to the renamed element. */
227
+ export declare class RenameReferencedError extends EditError {
228
+ }
229
+ /** Two operations would edit the same bytes of the source. */
230
+ export declare class OverlappingEditsError extends EditError {
231
+ }
232
+ /** The edited notation could not be read back. */
233
+ export declare class EditResultError extends EditError {
234
+ }
235
+ /** An add-member owner is not declared in the model. */
236
+ export declare class OwnerNotFoundError extends EditError {
237
+ }
238
+ /** An add-member owner cannot contain members. */
239
+ export declare class OwnerNotNamespaceError extends EditError {
240
+ }
241
+ /** A declaration kind is invalid for the source language. */
242
+ export declare class IllegalMemberKindError extends InvalidEditError {
243
+ }
244
+ /** An owner already declares the requested member name. */
245
+ export declare class MemberNameTakenError extends EditError {
246
+ }
247
+ /** A referenced declaration is deleted without cascade. */
248
+ export declare class DeleteReferencedError extends EditError {
249
+ }
250
+ /** A move's new owner is the moved declaration or inside it. */
251
+ export declare class OwnerInsideTargetError extends EditError {
252
+ }
253
+ /** A move would leave a reference no spelling can restore. */
254
+ export declare class MoveReferencedError extends EditError {
255
+ }
256
+ /** A rename, delete or move is referred to from a document the edit cannot rewrite. */
257
+ export declare class ReferencedElsewhereError extends EditError {
258
+ }
97
259
  /** The service's classification of a failure it reported in a successful answer. */
98
260
  export type FailureCause = "unspecified" | "evaluation" | "wrong_kind" | "ambiguous_subject" | "undecided";
@@ -23,6 +23,25 @@ export class ServiceError extends OpenSysMLError {
23
23
  /** A private child service failed to start, or died while it was needed. */
24
24
  export class ServiceStartError extends ServiceError {
25
25
  }
26
+ /** The service already listening is not the one asked for, reported rather than stopped. */
27
+ export class StaleServiceError extends ServiceError {
28
+ /** Address the mismatched service is listening on. */
29
+ address;
30
+ /** How it differs from the service that was asked for. */
31
+ reason;
32
+ /** What to do about it. */
33
+ remedy;
34
+ /** What it reported about itself, when it could be asked. */
35
+ info;
36
+ constructor(address, reason, remedy, options = {}) {
37
+ super(`the sysml-grpc service already listening on ${address} is not the one this client ` +
38
+ `asked for: ${reason}.\n service: ${options.info?.describe() ?? address}\n fix: ${remedy}`, options.cause === undefined ? {} : { cause: options.cause });
39
+ this.address = address;
40
+ this.reason = reason;
41
+ this.remedy = remedy;
42
+ this.info = options.info;
43
+ }
44
+ }
26
45
  /** The connection was closed and cannot be used again. */
27
46
  export class ClosedConnectionError extends OpenSysMLError {
28
47
  constructor() {
@@ -41,6 +60,9 @@ export class InvalidRequestError extends ServiceError {
41
60
  /** A call exceeded its deadline, or was cancelled. */
42
61
  export class ServiceTimeoutError extends ServiceError {
43
62
  }
63
+ /** The service was unreachable, refused the stream, or died before answering. */
64
+ export class ServiceUnavailableError extends ServiceError {
65
+ }
44
66
  /** The connected service does not implement the call at all. */
45
67
  export class UnsupportedOperationError extends ServiceError {
46
68
  }
@@ -69,9 +91,12 @@ export class ManifestSignatureError extends ChecksumMismatchError {
69
91
  export class ParseError extends OpenSysMLError {
70
92
  /** Diagnostics the service reported, in the order it reported them. */
71
93
  diagnostics;
72
- constructor(message, diagnostics = []) {
94
+ /** The model the errors belong to, when one was loaded, so it stays inspectable. */
95
+ model;
96
+ constructor(message, diagnostics = [], options = {}) {
73
97
  super(message);
74
98
  this.diagnostics = diagnostics;
99
+ this.model = options.model;
75
100
  }
76
101
  }
77
102
  /** No symbol of that name is declared in the model. */
@@ -80,9 +105,9 @@ export class SymbolNotFoundError extends OpenSysMLError {
80
105
  symbolName;
81
106
  /** Names the model declares that are close enough to be typos of it. */
82
107
  suggestions;
83
- constructor(name, near = []) {
108
+ constructor(name, near = [], options = {}) {
84
109
  const hint = near.length > 0 ? `; did you mean ${near.join(", ")}?` : "";
85
- super(`the model declares no symbol named ${JSON.stringify(name)}${hint}`);
110
+ super(`the model declares no symbol named ${JSON.stringify(name)}${hint}`, options.cause === undefined ? {} : { cause: options.cause });
86
111
  this.symbolName = name;
87
112
  this.suggestions = [...near];
88
113
  }
@@ -98,3 +123,184 @@ export class EvaluationError extends OpenSysMLError {
98
123
  this.diagnostics = diagnostics;
99
124
  }
100
125
  }
126
+ /** A run — an execution, verification, calculation, analysis or sweep — failed. */
127
+ export class ExecutionError extends EvaluationError {
128
+ /** Partial ExecuteState trace, when a traced run failed. */
129
+ trace;
130
+ /** Oldest ExecuteState trace records the service discarded. */
131
+ traceDropped;
132
+ constructor(message, reason = "unspecified", diagnostics = [], trace = [], traceDropped = 0) {
133
+ super(message, reason, diagnostics);
134
+ this.trace = trace;
135
+ this.traceDropped = traceDropped;
136
+ }
137
+ }
138
+ /** The element a verification named is of another kind, a wrong request rather than a verdict. */
139
+ export class WrongKindError extends ExecutionError {
140
+ }
141
+ /** An analysis case could not run to its end but left something to inspect, carried as `result`. */
142
+ export class AnalysisRunError extends ExecutionError {
143
+ /** The partial result the failed run left: the evaluations made, the verdicts left undecided. */
144
+ result;
145
+ constructor(message, result, options = {}) {
146
+ super(message, options.reason ?? "unspecified", options.diagnostics ?? []);
147
+ this.result = result;
148
+ }
149
+ }
150
+ /** A model could not be written in the format asked for. */
151
+ export class ConversionError extends OpenSysMLError {
152
+ diagnostics;
153
+ constructor(message, diagnostics = []) {
154
+ super(message);
155
+ this.diagnostics = diagnostics;
156
+ }
157
+ }
158
+ /** A SysML v1 model could not be read, so nothing of it was migrated. */
159
+ export class MigrationError extends OpenSysMLError {
160
+ }
161
+ /** The service sent a value the wire format cannot represent, or a caller sent one it cannot carry. */
162
+ export class UnsupportedValueError extends OpenSysMLError {
163
+ }
164
+ /** A feature value could not be evaluated or was never materialized. */
165
+ export class FeatureValueError extends OpenSysMLError {
166
+ /** Name of the feature. */
167
+ featureName;
168
+ /** Error description the service reported. */
169
+ message;
170
+ constructor(featureName, message) {
171
+ super(`feature value ${JSON.stringify(featureName)}: ${message}`);
172
+ this.featureName = featureName;
173
+ this.message = message;
174
+ }
175
+ }
176
+ /** A feature holds a value of another type than its generated view declares. */
177
+ export class TypeMismatchError extends OpenSysMLError {
178
+ /** Name of the feature. */
179
+ featureName;
180
+ /** Type the generated class declares. */
181
+ expected;
182
+ /** The value actually decoded. */
183
+ value;
184
+ constructor(featureName, expected, value) {
185
+ super(`feature value ${JSON.stringify(featureName)}: expected ${expected}, got ${describeValue(value)}`);
186
+ this.featureName = featureName;
187
+ this.expected = expected;
188
+ this.value = value;
189
+ }
190
+ }
191
+ /** A generated typed view was asked to wrap an instance of another type. */
192
+ export class InstanceTypeError extends OpenSysMLError {
193
+ /** FQN of the definition the generated class views. */
194
+ expected;
195
+ /** FQN the instance reports as its type. */
196
+ actual;
197
+ constructor(expected, actual) {
198
+ super(`instance of ${JSON.stringify(actual)} is not a ${JSON.stringify(expected)}; ` +
199
+ "call the generated class's unchecked(instance) to view it without this check");
200
+ this.expected = expected;
201
+ this.actual = actual;
202
+ }
203
+ }
204
+ function describeValue(value) {
205
+ if (value === null) {
206
+ return "null";
207
+ }
208
+ if (typeof value === "object") {
209
+ try {
210
+ return JSON.stringify(value);
211
+ }
212
+ catch {
213
+ return "[unprintable]";
214
+ }
215
+ }
216
+ switch (typeof value) {
217
+ case "string":
218
+ return JSON.stringify(value);
219
+ case "number":
220
+ return String(value);
221
+ case "bigint":
222
+ return `${value.toString()}n`;
223
+ case "boolean":
224
+ case "undefined":
225
+ return String(value);
226
+ default:
227
+ return "[unprintable]";
228
+ }
229
+ }
230
+ /** A query payload is not one the SysML v2 API & Services query model describes. */
231
+ export class QueryError extends OpenSysMLError {
232
+ }
233
+ /** A document query binding cannot be written before anything is sent. */
234
+ export class DocumentQueryError extends OpenSysMLError {
235
+ }
236
+ /** One declaration referring to the target of a refused rename, delete or move. */
237
+ export class Referrer {
238
+ /** The referring declaration, as the notation names it. */
239
+ name;
240
+ /** The document declaring it, as the parse named it. */
241
+ document;
242
+ constructor(name, document) {
243
+ this.name = name;
244
+ this.document = document;
245
+ }
246
+ }
247
+ /** An edit to a model was refused, and nothing was changed. */
248
+ export class EditError extends OpenSysMLError {
249
+ /** Refusal kind, as the wire enum names it, e.g. `EDIT_FAILURE_UNKNOWN_TARGET`. */
250
+ failure;
251
+ /** Diagnostics behind the refusal. */
252
+ diagnostics;
253
+ /** Where references a refused rename, delete or move would have broken are made. */
254
+ referringElements;
255
+ /** The same referrers, each with the document declaring it. */
256
+ referrers;
257
+ constructor(message, options = {}) {
258
+ super(message);
259
+ this.failure = options.failure ?? "";
260
+ this.diagnostics = options.diagnostics ?? [];
261
+ this.referringElements = [...(options.referringElements ?? [])];
262
+ this.referrers = [...(options.referrers ?? [])];
263
+ }
264
+ }
265
+ /** An editor with no operations was applied. */
266
+ export class NoEditsError extends EditError {
267
+ }
268
+ /** The element an edit names cannot carry that edit. */
269
+ export class EditTargetError extends EditError {
270
+ }
271
+ /** The new value or name itself cannot be read. */
272
+ export class InvalidEditError extends EditError {
273
+ }
274
+ /** A rename would break references to the renamed element. */
275
+ export class RenameReferencedError extends EditError {
276
+ }
277
+ /** Two operations would edit the same bytes of the source. */
278
+ export class OverlappingEditsError extends EditError {
279
+ }
280
+ /** The edited notation could not be read back. */
281
+ export class EditResultError extends EditError {
282
+ }
283
+ /** An add-member owner is not declared in the model. */
284
+ export class OwnerNotFoundError extends EditError {
285
+ }
286
+ /** An add-member owner cannot contain members. */
287
+ export class OwnerNotNamespaceError extends EditError {
288
+ }
289
+ /** A declaration kind is invalid for the source language. */
290
+ export class IllegalMemberKindError extends InvalidEditError {
291
+ }
292
+ /** An owner already declares the requested member name. */
293
+ export class MemberNameTakenError extends EditError {
294
+ }
295
+ /** A referenced declaration is deleted without cascade. */
296
+ export class DeleteReferencedError extends EditError {
297
+ }
298
+ /** A move's new owner is the moved declaration or inside it. */
299
+ export class OwnerInsideTargetError extends EditError {
300
+ }
301
+ /** A move would leave a reference no spelling can restore. */
302
+ export class MoveReferencedError extends EditError {
303
+ }
304
+ /** A rename, delete or move is referred to from a document the edit cannot rewrite. */
305
+ export class ReferencedElsewhereError extends EditError {
306
+ }
@@ -0,0 +1,71 @@
1
+ import { type ModelDiagnostic, type UnsupportedValueError } from "./errors.js";
2
+ import type { SysMLValue } from "./values.js";
3
+ /** A value map an outcome reports: an action's outputs, a machine's final context. */
4
+ export type OutcomeValues = ReadonlyMap<string, SysMLValue | UnsupportedValueError>;
5
+ /** One distinct outcome an exploration reached. */
6
+ export declare class Outcome {
7
+ /** The values the behavior holds at the end, by name; empty for a failed run. */
8
+ readonly outputs: OutcomeValues;
9
+ /** The state a state machine rests in; empty for an action. */
10
+ readonly finalState: string;
11
+ /** The states a state machine entered, in order. */
12
+ readonly statesVisited: readonly string[];
13
+ /** Why the run failed; empty for a run that completed. */
14
+ readonly error: string;
15
+ /** How many of the explored orders reached this outcome. */
16
+ readonly linearizations: number;
17
+ /** Share of the explored orders' likelihood reaching this outcome; a lower bound while incomplete. */
18
+ readonly probability: number;
19
+ /** The choices one run reaching it made, in run order; empty with no choice point. */
20
+ readonly witness: readonly string[];
21
+ /** What the witness run reported, its choice points among them. */
22
+ readonly diagnostics: readonly ModelDiagnostic[];
23
+ constructor(init: {
24
+ outputs: OutcomeValues;
25
+ finalState: string;
26
+ statesVisited: readonly string[];
27
+ error: string;
28
+ linearizations: number;
29
+ probability: number;
30
+ witness: readonly string[];
31
+ diagnostics: readonly ModelDiagnostic[];
32
+ });
33
+ /** Whether the runs reaching this outcome failed rather than completed. */
34
+ get failed(): boolean;
35
+ /** Raise the run's failure as an {@link ExecutionError}, if it failed. */
36
+ raiseForError(): this;
37
+ toString(): string;
38
+ }
39
+ /** Every distinct outcome a behavior reached under `explore`, and how the exploration ended. */
40
+ export declare class Exploration {
41
+ /** The distinct outcomes reached, in the service's canonical order. */
42
+ readonly outcomes: readonly Outcome[];
43
+ /** Whether every linearization within the budget was run. */
44
+ readonly complete: boolean;
45
+ /** How many runs were made. */
46
+ readonly runs: number;
47
+ /** The budgets the exploration ran into; empty when complete. */
48
+ readonly budgetsHit: readonly string[];
49
+ /** The most runs the exploration would make. */
50
+ readonly runsBudget: number;
51
+ /** The most choice points one run would resolve. */
52
+ readonly depthBudget: number;
53
+ /** Whether the outcomes' probabilities are lower bounds. */
54
+ readonly probabilitiesLowerBound: boolean;
55
+ constructor(init: {
56
+ outcomes: readonly Outcome[];
57
+ complete: boolean;
58
+ runs: number;
59
+ budgetsHit: readonly string[];
60
+ runsBudget: number;
61
+ depthBudget: number;
62
+ probabilitiesLowerBound?: boolean;
63
+ });
64
+ get length(): number;
65
+ [Symbol.iterator](): Iterator<Outcome>;
66
+ /** How the exploration ended, as `sysml -schedule explore` prints it. */
67
+ get status(): string;
68
+ /** Raise an {@link ExecutionError} unless every linearization was run. */
69
+ raiseForIncomplete(): this;
70
+ toString(): string;
71
+ }