@miragon/dmn-modeler 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,12 +1,91 @@
1
+ /** Stand up one read-only DMN diff pane in `container`. */
2
+ export declare function createDiffViewer(container: HTMLElement, options?: DmnDiffViewerOptions): DmnDiffViewerHandle;
3
+
1
4
  /** Factory signature for one independent DMN modeler instance. */
2
5
  export declare type CreateDmnModeler = (container: HTMLElement, options: DmnModelerOptions) => Promise<DmnModelerHandle>;
3
6
 
4
7
  /** Stand up one independent DMN modeler bound to the supplied DOM hosts. */
5
8
  export declare function createModeler(container: HTMLElement, options: DmnModelerOptions): Promise<DmnModelerHandle>;
6
9
 
10
+ /** A kind of change a diff counts and marks. */
11
+ declare type DiffCategory = keyof DiffCounts;
12
+
13
+ /**
14
+ * Summary counts across the four diff categories, used for the legend chip.
15
+ */
16
+ declare interface DiffCounts {
17
+ readonly added: number;
18
+ readonly removed: number;
19
+ readonly changed: number;
20
+ readonly layoutChanged: number;
21
+ }
22
+
7
23
  /** Additional dmn-js dependency-injection modules, grouped by view editor. */
8
24
  export declare type DmnAdditionalModules = Partial<Record<DmnViewType, unknown[]>>;
9
25
 
26
+ export declare interface DmnDiffMarkOptions {
27
+ /** Puts each changed table's counts on its decision in the DRD. */
28
+ readonly countBadges?: boolean;
29
+ }
30
+
31
+ /** What one DMN diff pane marks: the DRD's changes, each changed table's and the changed expressions. */
32
+ export declare interface DmnDiffMarks {
33
+ readonly added: readonly string[];
34
+ readonly removed: readonly string[];
35
+ readonly changed: readonly string[];
36
+ readonly layoutChanged: readonly string[];
37
+ readonly tables: Readonly<Record<string, DmnTableMarks>>;
38
+ readonly expressions: readonly string[];
39
+ }
40
+
41
+ /** How an element a diff pane shows differs; a move is a DRD layout change only. */
42
+ export declare type DmnDiffStatus = Exclude<DiffCategory, "layoutChanged">;
43
+
44
+ /**
45
+ * A read-only DMN view of one side of a diff: the DRD with pan and zoom, and
46
+ * the decision tables and expressions dmn-js opens from it.
47
+ */
48
+ export declare interface DmnDiffViewerHandle {
49
+ importXML(xml: string): Promise<void>;
50
+ /** Marks this pane's changes; every view it opens shows them. */
51
+ setMarks(marks: DmnDiffMarks, options?: DmnDiffMarkOptions): void;
52
+ /**
53
+ * Opens the DRD (`null`) or the view of a decision or business knowledge
54
+ * model. Resolves `false` when this version has no such element.
55
+ */
56
+ openView(elementId: string | null): Promise<boolean>;
57
+ /** The open view: `null` for the DRD, else its element's id. */
58
+ getActiveElementId(): string | null;
59
+ /**
60
+ * How the open view's element differs, as its view is marked; `undefined`
61
+ * for the DRD, a changed table, an element without changes or before marks.
62
+ */
63
+ getViewStatus(): DmnDiffStatus | undefined;
64
+ /** Calls back when the user opens another view; not for {@link openView}. */
65
+ onViewChanged(listener: (elementId: string | null) => void): () => void;
66
+ /** Outlines and scrolls to a DRD element, rule, column or table, or clears the outline. */
67
+ focus(id: string | undefined): void;
68
+ /** Brings a DRD element, rule, column or table into view without outlining it. */
69
+ reveal(id: string): void;
70
+ getViewport(): Viewport | undefined;
71
+ setViewport(viewport: Viewport): void;
72
+ /** Calls back when the user pans or zooms the DRD. */
73
+ onViewportChanged(listener: (viewport: Viewport) => void): () => void;
74
+ getTableScroll(): TableScroll | undefined;
75
+ setTableScroll(scroll: TableScroll): void;
76
+ /** Calls back when the user scrolls the open decision table. */
77
+ onTableScroll(listener: (scroll: TableScroll) => void): () => void;
78
+ setTheme(theme: DmnThemeMode): void;
79
+ setLocale(locale: string): Promise<void>;
80
+ destroy(): void;
81
+ }
82
+
83
+ export declare interface DmnDiffViewerOptions {
84
+ readonly theme?: DmnThemeMode;
85
+ /** Pixels at the top of the pane the first DRD fit leaves free, for chrome floating there. */
86
+ readonly topInset?: number;
87
+ }
88
+
10
89
  /** One expression language shown by decision editors. */
11
90
  export declare interface DmnExpressionLanguage {
12
91
  readonly value: string;
@@ -120,6 +199,27 @@ export declare interface DmnOperationResult {
120
199
 
121
200
  /* Excluded from this release type: DmnPendingInputHandle */
122
201
 
202
+ /** One decision table's changes, as one diff pane marks them. */
203
+ export declare interface DmnTableMarks {
204
+ readonly columns: {
205
+ readonly added: readonly string[];
206
+ readonly removed: readonly string[];
207
+ readonly changed: readonly string[];
208
+ };
209
+ readonly rules: {
210
+ readonly added: readonly string[];
211
+ readonly removed: readonly string[];
212
+ readonly changed: readonly string[];
213
+ readonly moved: readonly string[];
214
+ };
215
+ readonly cells: readonly string[];
216
+ readonly annotations: readonly string[];
217
+ readonly properties: readonly string[];
218
+ readonly counts: DiffCounts;
219
+ /** The table's id when its attributes changed and it has one: the step that focuses them. */
220
+ readonly attributesStep?: string;
221
+ }
222
+
123
223
  /**
124
224
  * Theme selection for a single instance. The modeler toggles a
125
225
  * `data-dmn-theme` attribute on its container + panel parent (the authoritative
@@ -182,8 +282,76 @@ export declare class NoModelerError extends Error {
182
282
  */
183
283
  declare type SurfaceThemeMode = "light" | "dark" | "automatic";
184
284
 
285
+ /**
286
+ * A decision table's scroll position in a DMN diff pane, anchored on the
287
+ * topmost visible rule both versions share, so the partner pane lines up the
288
+ * same rule even when rules were added or removed above it.
289
+ */
290
+ declare interface TableScroll {
291
+ /** The rule at the top of the view; absent when no shared rule is visible. */
292
+ readonly rule?: string;
293
+ /** Pixels scrolled past the top of that rule, or past the table's top without one. */
294
+ readonly offset: number;
295
+ readonly left: number;
296
+ }
297
+
298
+ /**
299
+ * Canvas viewbox used for pan/zoom synchronisation between panes.
300
+ */
301
+ declare interface Viewport {
302
+ readonly x: number;
303
+ readonly y: number;
304
+ readonly width: number;
305
+ readonly height: number;
306
+ }
307
+
185
308
  export { }
186
309
 
310
+ /**
311
+ * Ambient type declarations for `bpmn-js-differ`, which ships without its own
312
+ * `.d.ts`. Covers only the subset used by the BPMN diff feature — `diff()`
313
+ * and the shape of its return value.
314
+ */
315
+ declare module "bpmn-js-differ" {
316
+ /**
317
+ * A bpmn-moddle element reference — opaque here because the differ only
318
+ * consumes objects produced by `bpmn-moddle` and we never inspect them
319
+ * beyond reading `$type` and `id`.
320
+ */
321
+ interface ModdleElement {
322
+ $type: string;
323
+ id?: string;
324
+ [key: string]: unknown;
325
+ }
326
+
327
+ export interface ChangedEntry {
328
+ model: ModdleElement;
329
+ attrs: Record<string, { oldValue: unknown; newValue: unknown }>;
330
+ }
331
+
332
+ export interface DiffResult {
333
+ _added: Record<string, ModdleElement>;
334
+ _removed: Record<string, ModdleElement>;
335
+ _changed: Record<string, ChangedEntry>;
336
+ _layoutChanged: Record<string, ModdleElement>;
337
+ }
338
+
339
+ export function diff(before: ModdleElement, after: ModdleElement): DiffResult;
340
+ }
341
+
342
+ /**
343
+ * Minimal ambient shim for `bpmn-moddle`, which ships no `.d.ts`.
344
+ *
345
+ * `computeDiff` casts the dynamic moddle import fully (`as unknown as …`), so it
346
+ * needs the module to *resolve* but never its member types. An empty module
347
+ * declaration does exactly that — and, unlike a richer shim, it merges without
348
+ * conflict alongside a consumer program's own `bpmn-moddle` declaration
349
+ * (modeler-core and the package each ship a fuller one with divergent shapes).
350
+ * Keeping this empty is what lets the differ lib be pulled into any of those
351
+ * programs — including `modeler-types`, which has no moddle shim of its own.
352
+ */
353
+ declare module "bpmn-moddle" {}
354
+
187
355
  declare module "diagram-js/lib/core/EventBus" {
188
356
  export default class EventBus {
189
357
  on<T extends string>(event: T, callback: EventCallback, that?: any): void;