@istar-ts/core 0.14.2 → 0.15.0-beta.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 +22 -0
- package/dist/index.cjs +372 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +244 -133
- package/dist/index.d.ts +244 -133
- package/dist/index.js +367 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -76,6 +76,7 @@ export type LinkCheck = {
|
|
|
76
76
|
ok: false;
|
|
77
77
|
reason: string;
|
|
78
78
|
code: ConstraintCode;
|
|
79
|
+
end?: "source" | "target";
|
|
79
80
|
};
|
|
80
81
|
/**
|
|
81
82
|
* True for a link, as opposed to an element: the target of a link kind whose rules target links
|
|
@@ -607,6 +608,51 @@ export declare function elementCenter<EK extends string, LK extends string>(mode
|
|
|
607
608
|
* Returns its top-left corner for a hub of `size`.
|
|
608
609
|
*/
|
|
609
610
|
export declare function defaultHubPosition<EK extends string, LK extends string>(model: IstarModel<EK, LK>, source: IstarElement<EK>, target: IstarElement<EK>, size: Size): Point;
|
|
611
|
+
export interface Box extends Point, Size {}
|
|
612
|
+
/** Space kept between inner elements and an actor's boundary (piStar's `updateBoundary` adds 10px). */
|
|
613
|
+
export declare const ACTOR_PADDING = 10;
|
|
614
|
+
/**
|
|
615
|
+
* An actor's boundary: the kind's default-size rectangle at the actor's position, grown to
|
|
616
|
+
* include every inner element (each padded by `ACTOR_PADDING`), like piStar's `updateBoundary`
|
|
617
|
+
* (which floors on the kind's default size, not the actor's last expanded `display` size; an
|
|
618
|
+
* inner element's own `display` size does override, same as its rendered size elsewhere).
|
|
619
|
+
* Shared by `@istar-ts/react`'s node layout and `@istar-ts/glsp`'s GModel, so an actor draws the
|
|
620
|
+
* same box in both: children are looked up by category (`metamodelOf`), not `istar.*` names.
|
|
621
|
+
*
|
|
622
|
+
* `defaultSizeOf` resolves a kind's default size; it defaults to the metamodel's, but a host
|
|
623
|
+
* whose registry overrides a kind's size independently of the metamodel (`@istar-ts/react`'s
|
|
624
|
+
* `IstarRegistry`) must pass one that reads its own sizes, or its boundary would stop matching
|
|
625
|
+
* what it actually draws.
|
|
626
|
+
*/
|
|
627
|
+
export declare function actorBounds<EK extends string, LK extends string>(model: IstarModel<EK, LK>, actorId: string, metamodel?: Metamodel<EK, LK>, defaultSizeOf?: (kind: EK) => Size): Box;
|
|
628
|
+
/** Space kept between a suggested box and any existing element (`suggestPosition`). */
|
|
629
|
+
export declare const SUGGEST_MARGIN = 20;
|
|
630
|
+
export interface SuggestPositionOptions<EK extends string> {
|
|
631
|
+
/** The kind of element being placed; its metamodel size is what must not overlap. */
|
|
632
|
+
readonly kind: EK;
|
|
633
|
+
/** Place inside this actor's boundary (`actorBounds`), growing it if full. */
|
|
634
|
+
readonly containerId?: string;
|
|
635
|
+
/** Prefer a spot adjacent to this element's id, or to this point. */
|
|
636
|
+
readonly near?: string | Point;
|
|
637
|
+
readonly metamodel?: Metamodel<EK, string>;
|
|
638
|
+
/** See `actorBounds`' `defaultSizeOf`. */
|
|
639
|
+
readonly defaultSizeOf?: (kind: EK) => Size;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* A free spot for a new element of `kind`, overlapping no existing element (sizes from the
|
|
643
|
+
* metamodel, or `defaultSizeOf` for a host with its own size overrides, as in `actorBounds`).
|
|
644
|
+
*
|
|
645
|
+
* Scans a deterministic, fixed-order set of candidates — rings around `near` when given, else
|
|
646
|
+
* the container's interior, else rings around the origin — and returns the first whose padded
|
|
647
|
+
* box (`SUGGEST_MARGIN`) overlaps nothing; same input always yields the same output. However
|
|
648
|
+
* dense the model, the result never overlaps: once every ring candidate is taken, it falls back
|
|
649
|
+
* to a point past the right edge of every obstacle (`guaranteedFreePoint`).
|
|
650
|
+
*
|
|
651
|
+
* Inside `containerId`, the candidate stays within the actor's current boundary (`actorBounds`)
|
|
652
|
+
* when there is room, or goes just past its last child when the boundary is full — the boundary
|
|
653
|
+
* grows from there, same as any other inner element (`actorBounds`).
|
|
654
|
+
*/
|
|
655
|
+
export declare function suggestPosition<EK extends string, LK extends string>(model: IstarModel<EK, LK>, options: SuggestPositionOptions<EK>): Point;
|
|
610
656
|
//#endregion
|
|
611
657
|
//#region src/file-metamodel.d.ts
|
|
612
658
|
/** The top-level key of the block in piStar JSON. */
|
|
@@ -811,11 +857,149 @@ export declare function fileMetamodelOf<EK extends string, LK extends string>(mo
|
|
|
811
857
|
* host's kinds, or leaves out a kind the model still uses.
|
|
812
858
|
*/
|
|
813
859
|
export declare function withFileMetamodel<EK extends string, LK extends string>(model: IstarModel<EK, LK>, block: FileMetamodel | null): IstarModel<string, string>;
|
|
860
|
+
//#endregion
|
|
861
|
+
//#region src/diagnostics.d.ts
|
|
862
|
+
/**
|
|
863
|
+
* The Goal Model Diagnostics Protocol: findings about a model's elements and links, published by
|
|
864
|
+
* any analyser (a language server, a validator, a simulation…) and anchored by element id rather
|
|
865
|
+
* than by text position. Data only: diagnostics are never part of the model and are never
|
|
866
|
+
* written to disk.
|
|
867
|
+
*
|
|
868
|
+
* See goal-controller issue #24 (option D). Producers publish per source; consumers see the
|
|
869
|
+
* union of every source, deduplicated by `(elementId, key, message)`.
|
|
870
|
+
*/
|
|
871
|
+
export type DiagnosticSeverity = "error" | "warning" | "info" | "hint";
|
|
872
|
+
/** Most severe first. */
|
|
873
|
+
export declare const DIAGNOSTIC_SEVERITIES: readonly DiagnosticSeverity[];
|
|
874
|
+
/** A zero-based position in the producer's document (as in LSP). */
|
|
875
|
+
export interface DiagnosticPosition {
|
|
876
|
+
readonly line: number;
|
|
877
|
+
readonly character: number;
|
|
878
|
+
}
|
|
879
|
+
export interface DiagnosticRange {
|
|
880
|
+
readonly start: DiagnosticPosition;
|
|
881
|
+
readonly end: DiagnosticPosition;
|
|
882
|
+
}
|
|
883
|
+
export interface GoalDiagnostic {
|
|
884
|
+
/** Id of the element or link the diagnostic is about. */
|
|
885
|
+
readonly elementId: string;
|
|
886
|
+
/** The custom property it is about; absent for the element as a whole. */
|
|
887
|
+
readonly key?: string;
|
|
888
|
+
readonly severity: DiagnosticSeverity;
|
|
889
|
+
readonly message: string;
|
|
890
|
+
/** Who published it (e.g. `mutrose`, `goal-language`). */
|
|
891
|
+
readonly source?: string;
|
|
892
|
+
/** Where it was found in the producer's document, if it has one. */
|
|
893
|
+
readonly range?: DiagnosticRange;
|
|
894
|
+
readonly code?: string;
|
|
895
|
+
/** Producer data, passed through untouched. */
|
|
896
|
+
readonly data?: unknown;
|
|
897
|
+
}
|
|
898
|
+
/** Negative when `a` is more severe than `b`. */
|
|
899
|
+
export declare function compareSeverity(a: DiagnosticSeverity, b: DiagnosticSeverity): number;
|
|
900
|
+
/** The most severe severity in a list (what a badge shows), or `undefined` if it is empty. */
|
|
901
|
+
export declare function worstDiagnosticSeverity(diagnostics: readonly {
|
|
902
|
+
readonly severity: DiagnosticSeverity;
|
|
903
|
+
}[] | undefined): DiagnosticSeverity | undefined;
|
|
904
|
+
/**
|
|
905
|
+
* The union of several lists, in order, without duplicates: diagnostics with the same
|
|
906
|
+
* `(elementId, key, message)` count once, keeping the first one's position and the most severe
|
|
907
|
+
* severity among them.
|
|
908
|
+
*/
|
|
909
|
+
export declare function mergeDiagnostics(lists: Iterable<readonly GoalDiagnostic[] | undefined>): GoalDiagnostic[];
|
|
910
|
+
/** Diagnostics by element (or link) id, each list in the input order. */
|
|
911
|
+
export declare function groupDiagnostics(diagnostics: readonly GoalDiagnostic[] | undefined): ReadonlyMap<string, readonly GoalDiagnostic[]>;
|
|
912
|
+
/**
|
|
913
|
+
* Holds the diagnostics of several sources. Each `publish` replaces that source's set, so a
|
|
914
|
+
* producer re-publishes everything it currently reports, as an LSP server does.
|
|
915
|
+
*/
|
|
916
|
+
export interface DiagnosticsStore {
|
|
917
|
+
/**
|
|
918
|
+
* Replaces `source`'s diagnostics (an empty list clears them). Entries without a `source` get
|
|
919
|
+
* this one.
|
|
920
|
+
*/
|
|
921
|
+
publish(source: string, diagnostics: readonly GoalDiagnostic[]): void;
|
|
922
|
+
/** Removes one source's diagnostics, or every source's. */
|
|
923
|
+
clear(source?: string): void;
|
|
924
|
+
/** Sources with diagnostics, in the order they first published. */
|
|
925
|
+
sources(): readonly string[];
|
|
926
|
+
/** One source's diagnostics. */
|
|
927
|
+
get(source: string): readonly GoalDiagnostic[];
|
|
928
|
+
/**
|
|
929
|
+
* Every source's diagnostics, merged (see `mergeDiagnostics`). The same array until the next
|
|
930
|
+
* change, so it can back `useSyncExternalStore`.
|
|
931
|
+
*/
|
|
932
|
+
getAll(): readonly GoalDiagnostic[];
|
|
933
|
+
subscribe(listener: () => void): () => void;
|
|
934
|
+
}
|
|
935
|
+
export declare function createDiagnosticsStore(): DiagnosticsStore;
|
|
936
|
+
/**
|
|
937
|
+
* The parts of an LSP `Diagnostic` the adapter reads (structurally typed, so no LSP library is
|
|
938
|
+
* needed). The element is taken from `data.elementId`, or MutRoSe's `data.nodeId`; the property
|
|
939
|
+
* from `data.key`.
|
|
940
|
+
*/
|
|
941
|
+
export interface LspDiagnosticLike {
|
|
942
|
+
readonly range?: DiagnosticRange;
|
|
943
|
+
/** LSP numbering: 1 error, 2 warning, 3 information, 4 hint. */
|
|
944
|
+
readonly severity?: number;
|
|
945
|
+
readonly message: string | {
|
|
946
|
+
readonly value: string;
|
|
947
|
+
};
|
|
948
|
+
readonly source?: string;
|
|
949
|
+
readonly code?: string | number | {
|
|
950
|
+
readonly value: string | number;
|
|
951
|
+
};
|
|
952
|
+
readonly data?: unknown;
|
|
953
|
+
}
|
|
954
|
+
export interface FromLspOptions<D extends LspDiagnosticLike = LspDiagnosticLike> {
|
|
955
|
+
/**
|
|
956
|
+
* The element of a diagnostic whose `data` names none, e.g. by looking its range up in the
|
|
957
|
+
* document. Return `undefined` to drop it.
|
|
958
|
+
*/
|
|
959
|
+
readonly elementIdFor?: (diagnostic: D) => string | undefined;
|
|
960
|
+
/**
|
|
961
|
+
* `'vscode'` for `vscode.Diagnostic` objects, whose severity counts from 0 (error) to 3
|
|
962
|
+
* (hint). Default `'lsp'`, the protocol's 1 to 4.
|
|
963
|
+
*/
|
|
964
|
+
readonly severityNumbering?: "lsp" | "vscode";
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* One LSP diagnostic anchored by `data.elementId` (or `data.nodeId`), or `undefined` when it
|
|
968
|
+
* names no element. For range-anchored diagnostics use `fromLspDiagnostics` with `elementIdFor`.
|
|
969
|
+
*/
|
|
970
|
+
export declare function fromLspDiagnostic(diagnostic: LspDiagnosticLike): GoalDiagnostic | undefined;
|
|
971
|
+
/** LSP diagnostics as goal diagnostics; those that can't be anchored to an element are dropped. */
|
|
972
|
+
export declare function fromLspDiagnostics<D extends LspDiagnosticLike>(diagnostics: readonly D[], options?: FromLspOptions<D>): GoalDiagnostic[];
|
|
973
|
+
/**
|
|
974
|
+
* The shape MutRoSe's VS Code extension posts to its webview: `{ nodeId, severity, message }`
|
|
975
|
+
* (plus `range` and `source`). `nodeId` is missing when no node could be found.
|
|
976
|
+
*/
|
|
977
|
+
export interface NodeIdDiagnostic {
|
|
978
|
+
readonly nodeId?: string;
|
|
979
|
+
readonly key?: string;
|
|
980
|
+
readonly severity: DiagnosticSeverity | string;
|
|
981
|
+
readonly message: string;
|
|
982
|
+
readonly source?: string;
|
|
983
|
+
readonly range?: DiagnosticRange;
|
|
984
|
+
readonly code?: string;
|
|
985
|
+
}
|
|
986
|
+
/** One `{ nodeId, severity, message }` diagnostic, or `undefined` without a `nodeId`. */
|
|
987
|
+
export declare function fromNodeIdDiagnostic(diagnostic: NodeIdDiagnostic): GoalDiagnostic | undefined;
|
|
988
|
+
/**
|
|
989
|
+
* `{ nodeId, severity, message }` diagnostics (MutRoSe) as goal diagnostics, dropping those
|
|
990
|
+
* without a node: `store.publish('mutrose', fromNodeIdDiagnostics(message.diagnostics))`.
|
|
991
|
+
*/
|
|
992
|
+
export declare function fromNodeIdDiagnostics(diagnostics: readonly NodeIdDiagnostic[]): GoalDiagnostic[];
|
|
814
993
|
declare namespace operations_d_exports {
|
|
815
|
-
export { AddDependencyResult, ConnectOptions, ConnectResult, ElementPatch, IdGenerator, LinkPatch, ModelOperationError, NewDependency, NewElement, NewLink, OperationContext, addDependency, addElement, addLeg, connect, defaultIdGenerator, dependencyEnds, disconnect, moveElement, nestElement, removeElement, removeElements, removeLeg, updateDiagram, updateElement, updateLink };
|
|
994
|
+
export { AddDependencyResult, ConnectOptions, ConnectResult, ElementPatch, IdGenerator, LinkPatch, ModelOperationError, NewDependency, NewElement, NewLink, OperationContext, addDependency, addElement, addLeg, connect, connectResultToDiagnostic, defaultIdGenerator, dependencyEnds, disconnect, moveElement, nestElement, removeElement, removeElements, removeLeg, updateDiagram, updateElement, updateLink };
|
|
816
995
|
}
|
|
817
996
|
export declare class ModelOperationError extends Error {
|
|
818
997
|
override name: string;
|
|
998
|
+
/** The element or link the error is about, when the operation named one. */
|
|
999
|
+
readonly elementId?: string;
|
|
1000
|
+
constructor(message: string, elementId?: string);
|
|
1001
|
+
/** As a `GoalDiagnostic`, anchored on `elementId` (empty string if the error names none). */
|
|
1002
|
+
toDiagnostic(): GoalDiagnostic;
|
|
819
1003
|
}
|
|
820
1004
|
/** Generates ids for new elements and links. piStar uses UUID v4. */
|
|
821
1005
|
export type IdGenerator = () => string;
|
|
@@ -873,11 +1057,22 @@ export interface NewLink<K extends string = LinkKind> {
|
|
|
873
1057
|
readonly source: string;
|
|
874
1058
|
/** An element id, or a link id for kinds whose rules target links. */
|
|
875
1059
|
readonly target: string;
|
|
1060
|
+
/**
|
|
1061
|
+
* The new link's id: for an n-ary kind whose target is not yet a hub, the new hub's; for an
|
|
1062
|
+
* n-ary kind whose target already is a hub, the new leg's (same as `legId` there).
|
|
1063
|
+
*/
|
|
876
1064
|
readonly id?: string;
|
|
877
1065
|
/** Contribution value: make, help, hurt or break. */
|
|
878
1066
|
readonly label?: string;
|
|
879
1067
|
readonly name?: string;
|
|
880
1068
|
readonly customProperties?: CustomProperties;
|
|
1069
|
+
/**
|
|
1070
|
+
* The id of the leg it creates: for a target that is not yet a hub, the new leg from `source`;
|
|
1071
|
+
* for a target that already is a hub, the new leg instead of `id`.
|
|
1072
|
+
*/
|
|
1073
|
+
readonly legId?: string;
|
|
1074
|
+
/** For an n-ary kind whose target is not yet a hub: the id of the end it creates. */
|
|
1075
|
+
readonly endId?: string;
|
|
881
1076
|
}
|
|
882
1077
|
export interface ConnectOptions extends OperationContext {
|
|
883
1078
|
/** Skip constraint checking (used when loading or scripting known-good data). */
|
|
@@ -899,13 +1094,23 @@ export type ConnectResult<EK extends string = ElementKind, LK extends string = L
|
|
|
899
1094
|
} | Extract<LinkCheck, {
|
|
900
1095
|
ok: false;
|
|
901
1096
|
}>;
|
|
1097
|
+
/**
|
|
1098
|
+
* Maps a failing `connect` result to a `GoalDiagnostic`, anchored on the end named by the
|
|
1099
|
+
* `LinkCheck`'s `end` field (`target` when a check doesn't single out one end, such as
|
|
1100
|
+
* `self-link` or `actor-types-differ`). `undefined` for a successful result.
|
|
1101
|
+
*/
|
|
1102
|
+
export declare function connectResultToDiagnostic<EK extends string = ElementKind, LK extends string = LinkKind>(result: ConnectResult<EK, LK>, endpoints: {
|
|
1103
|
+
readonly source: string;
|
|
1104
|
+
readonly target: string;
|
|
1105
|
+
}): GoalDiagnostic | undefined;
|
|
902
1106
|
/**
|
|
903
1107
|
* Adds a link between two elements if the iStar constraints allow it.
|
|
904
1108
|
*
|
|
905
1109
|
* With an n-ary kind (`arity: 'n'`), a `target` that is one of the kind's hubs gets a new leg
|
|
906
|
-
* from `source` (see `addLeg`).
|
|
907
|
-
* target
|
|
908
|
-
*
|
|
1110
|
+
* from `source` (see `addLeg`), taking `input.id` or `input.legId` (default a fresh id) as the
|
|
1111
|
+
* leg's id. Any other target gets a new hub, centred between source and target, with a leg from
|
|
1112
|
+
* `source` and an end to `target`. `input.id` and `customProperties` then go to the hub, `label`
|
|
1113
|
+
* and `name` to the end, and `legId`/`endId` (default fresh ids) to the leg and end.
|
|
909
1114
|
*/
|
|
910
1115
|
export declare function connect<EK extends string = ElementKind, LK extends string = LinkKind>(model: IstarModel<EK, LK>, input: NewLink<LK>, options?: ConnectOptions): ConnectResult<EK, LK>;
|
|
911
1116
|
/**
|
|
@@ -1170,137 +1375,43 @@ export declare function defineProperties<const S extends PropertyShape, const Ki
|
|
|
1170
1375
|
}): PropertySchema<S, Kind>;
|
|
1171
1376
|
export declare function validateModelProperties<EK extends string, LK extends string>(model: IstarModel<EK, LK>, schemas: readonly PropertySchema<PropertyShape, string>[]): ModelPropertyIssue[];
|
|
1172
1377
|
//#endregion
|
|
1173
|
-
//#region src/
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
export
|
|
1184
|
-
/**
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
export interface
|
|
1188
|
-
|
|
1189
|
-
readonly
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
export interface GoalDiagnostic {
|
|
1196
|
-
/** Id of the element or link the diagnostic is about. */
|
|
1197
|
-
readonly elementId: string;
|
|
1198
|
-
/** The custom property it is about; absent for the element as a whole. */
|
|
1199
|
-
readonly key?: string;
|
|
1200
|
-
readonly severity: DiagnosticSeverity;
|
|
1201
|
-
readonly message: string;
|
|
1202
|
-
/** Who published it (e.g. `mutrose`, `goal-language`). */
|
|
1203
|
-
readonly source?: string;
|
|
1204
|
-
/** Where it was found in the producer's document, if it has one. */
|
|
1205
|
-
readonly range?: DiagnosticRange;
|
|
1206
|
-
readonly code?: string;
|
|
1207
|
-
/** Producer data, passed through untouched. */
|
|
1208
|
-
readonly data?: unknown;
|
|
1209
|
-
}
|
|
1210
|
-
/** Negative when `a` is more severe than `b`. */
|
|
1211
|
-
export declare function compareSeverity(a: DiagnosticSeverity, b: DiagnosticSeverity): number;
|
|
1212
|
-
/** The most severe severity in a list (what a badge shows), or `undefined` if it is empty. */
|
|
1213
|
-
export declare function worstDiagnosticSeverity(diagnostics: readonly {
|
|
1214
|
-
readonly severity: DiagnosticSeverity;
|
|
1215
|
-
}[] | undefined): DiagnosticSeverity | undefined;
|
|
1216
|
-
/**
|
|
1217
|
-
* The union of several lists, in order, without duplicates: diagnostics with the same
|
|
1218
|
-
* `(elementId, key, message)` count once, keeping the first one's position and the most severe
|
|
1219
|
-
* severity among them.
|
|
1220
|
-
*/
|
|
1221
|
-
export declare function mergeDiagnostics(lists: Iterable<readonly GoalDiagnostic[] | undefined>): GoalDiagnostic[];
|
|
1222
|
-
/** Diagnostics by element (or link) id, each list in the input order. */
|
|
1223
|
-
export declare function groupDiagnostics(diagnostics: readonly GoalDiagnostic[] | undefined): ReadonlyMap<string, readonly GoalDiagnostic[]>;
|
|
1224
|
-
/**
|
|
1225
|
-
* Holds the diagnostics of several sources. Each `publish` replaces that source's set, so a
|
|
1226
|
-
* producer re-publishes everything it currently reports, as an LSP server does.
|
|
1227
|
-
*/
|
|
1228
|
-
export interface DiagnosticsStore {
|
|
1229
|
-
/**
|
|
1230
|
-
* Replaces `source`'s diagnostics (an empty list clears them). Entries without a `source` get
|
|
1231
|
-
* this one.
|
|
1232
|
-
*/
|
|
1233
|
-
publish(source: string, diagnostics: readonly GoalDiagnostic[]): void;
|
|
1234
|
-
/** Removes one source's diagnostics, or every source's. */
|
|
1235
|
-
clear(source?: string): void;
|
|
1236
|
-
/** Sources with diagnostics, in the order they first published. */
|
|
1237
|
-
sources(): readonly string[];
|
|
1238
|
-
/** One source's diagnostics. */
|
|
1239
|
-
get(source: string): readonly GoalDiagnostic[];
|
|
1240
|
-
/**
|
|
1241
|
-
* Every source's diagnostics, merged (see `mergeDiagnostics`). The same array until the next
|
|
1242
|
-
* change, so it can back `useSyncExternalStore`.
|
|
1243
|
-
*/
|
|
1244
|
-
getAll(): readonly GoalDiagnostic[];
|
|
1245
|
-
subscribe(listener: () => void): () => void;
|
|
1246
|
-
}
|
|
1247
|
-
export declare function createDiagnosticsStore(): DiagnosticsStore;
|
|
1248
|
-
/**
|
|
1249
|
-
* The parts of an LSP `Diagnostic` the adapter reads (structurally typed, so no LSP library is
|
|
1250
|
-
* needed). The element is taken from `data.elementId`, or MutRoSe's `data.nodeId`; the property
|
|
1251
|
-
* from `data.key`.
|
|
1252
|
-
*/
|
|
1253
|
-
export interface LspDiagnosticLike {
|
|
1254
|
-
readonly range?: DiagnosticRange;
|
|
1255
|
-
/** LSP numbering: 1 error, 2 warning, 3 information, 4 hint. */
|
|
1256
|
-
readonly severity?: number;
|
|
1257
|
-
readonly message: string | {
|
|
1258
|
-
readonly value: string;
|
|
1259
|
-
};
|
|
1260
|
-
readonly source?: string;
|
|
1261
|
-
readonly code?: string | number | {
|
|
1262
|
-
readonly value: string | number;
|
|
1263
|
-
};
|
|
1264
|
-
readonly data?: unknown;
|
|
1265
|
-
}
|
|
1266
|
-
export interface FromLspOptions<D extends LspDiagnosticLike = LspDiagnosticLike> {
|
|
1267
|
-
/**
|
|
1268
|
-
* The element of a diagnostic whose `data` names none, e.g. by looking its range up in the
|
|
1269
|
-
* document. Return `undefined` to drop it.
|
|
1270
|
-
*/
|
|
1271
|
-
readonly elementIdFor?: (diagnostic: D) => string | undefined;
|
|
1272
|
-
/**
|
|
1273
|
-
* `'vscode'` for `vscode.Diagnostic` objects, whose severity counts from 0 (error) to 3
|
|
1274
|
-
* (hint). Default `'lsp'`, the protocol's 1 to 4.
|
|
1275
|
-
*/
|
|
1276
|
-
readonly severityNumbering?: "lsp" | "vscode";
|
|
1277
|
-
}
|
|
1278
|
-
/**
|
|
1279
|
-
* One LSP diagnostic anchored by `data.elementId` (or `data.nodeId`), or `undefined` when it
|
|
1280
|
-
* names no element. For range-anchored diagnostics use `fromLspDiagnostics` with `elementIdFor`.
|
|
1281
|
-
*/
|
|
1282
|
-
export declare function fromLspDiagnostic(diagnostic: LspDiagnosticLike): GoalDiagnostic | undefined;
|
|
1283
|
-
/** LSP diagnostics as goal diagnostics; those that can't be anchored to an element are dropped. */
|
|
1284
|
-
export declare function fromLspDiagnostics<D extends LspDiagnosticLike>(diagnostics: readonly D[], options?: FromLspOptions<D>): GoalDiagnostic[];
|
|
1285
|
-
/**
|
|
1286
|
-
* The shape MutRoSe's VS Code extension posts to its webview: `{ nodeId, severity, message }`
|
|
1287
|
-
* (plus `range` and `source`). `nodeId` is missing when no node could be found.
|
|
1288
|
-
*/
|
|
1289
|
-
export interface NodeIdDiagnostic {
|
|
1290
|
-
readonly nodeId?: string;
|
|
1291
|
-
readonly key?: string;
|
|
1292
|
-
readonly severity: DiagnosticSeverity | string;
|
|
1293
|
-
readonly message: string;
|
|
1294
|
-
readonly source?: string;
|
|
1295
|
-
readonly range?: DiagnosticRange;
|
|
1296
|
-
readonly code?: string;
|
|
1378
|
+
//#region src/palette.d.ts
|
|
1379
|
+
export interface PaletteEntryDescription {
|
|
1380
|
+
readonly label: string;
|
|
1381
|
+
/** Lower comes first. */
|
|
1382
|
+
readonly order?: number;
|
|
1383
|
+
/** Entries sharing a group collapse into one dropdown button (e.g. Actor / Agent / Role). */
|
|
1384
|
+
readonly group?: string;
|
|
1385
|
+
/** Sections are separated by a divider. Default palette: "actors" and "elements". */
|
|
1386
|
+
readonly section?: string;
|
|
1387
|
+
}
|
|
1388
|
+
export interface ElementToolEntryDescription extends PaletteEntryDescription {
|
|
1389
|
+
/** customProperties preset on the element this entry creates, over `defaultProperties`. */
|
|
1390
|
+
readonly properties?: CustomProperties;
|
|
1391
|
+
}
|
|
1392
|
+
export interface LinkToolEntryDescription<DK extends string = NodeKind> extends PaletteEntryDescription {
|
|
1393
|
+
/** Contribution value to set on the new link. */
|
|
1394
|
+
readonly value?: string;
|
|
1395
|
+
/** For dependencies: the kind of dependum to create. */
|
|
1396
|
+
readonly dependum?: DK;
|
|
1397
|
+
}
|
|
1398
|
+
export interface PaletteGroupDescription {
|
|
1399
|
+
readonly label: string;
|
|
1297
1400
|
}
|
|
1298
|
-
/** One `{ nodeId, severity, message }` diagnostic, or `undefined` without a `nodeId`. */
|
|
1299
|
-
export declare function fromNodeIdDiagnostic(diagnostic: NodeIdDiagnostic): GoalDiagnostic | undefined;
|
|
1300
1401
|
/**
|
|
1301
|
-
*
|
|
1302
|
-
*
|
|
1402
|
+
* Per-kind palette data. `elements`/`links` entries are `false` for kinds hidden from the
|
|
1403
|
+
* palette, one entry for most element kinds, or several for a kind with more than one toolbar
|
|
1404
|
+
* button (a link's values, a dependency's dependum kinds).
|
|
1303
1405
|
*/
|
|
1304
|
-
export
|
|
1406
|
+
export interface PaletteDescription<EK extends string = ElementKind, LK extends string = LinkKind> {
|
|
1407
|
+
readonly elements: Readonly<Record<EK, PaletteEntryDescription | readonly ElementToolEntryDescription[] | false>>;
|
|
1408
|
+
readonly links: Readonly<Record<LK, readonly LinkToolEntryDescription[] | false>>;
|
|
1409
|
+
/** Labels for palette groups, keyed by `PaletteEntryDescription.group`. */
|
|
1410
|
+
readonly groups: Readonly<Record<string, PaletteGroupDescription>>;
|
|
1411
|
+
}
|
|
1412
|
+
/** A palette description of any dialect, for code that handles every kind generically. */
|
|
1413
|
+
export type AnyPaletteDescription = PaletteDescription<string, string>;
|
|
1414
|
+
/** The palette data of iStar 2.0, as piStar's toolbar presents it. */
|
|
1415
|
+
export declare const DEFAULT_PALETTE: PaletteDescription;
|
|
1305
1416
|
//#endregion
|
|
1306
1417
|
//# sourceMappingURL=index.d.cts.map
|