@muonroi/ui-engine-rule-components 0.1.21 → 0.1.23

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,510 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ class g {
7
+ constructor(i) {
8
+ this._map = /* @__PURE__ */ new Map(), this._roundAverageSize = !1, this.totalSize = 0, (i == null ? void 0 : i.roundAverageSize) === !0 && (this._roundAverageSize = !0);
9
+ }
10
+ set(i, t) {
11
+ const s = this._map.get(i) || 0;
12
+ this._map.set(i, t), this.totalSize += t - s;
13
+ }
14
+ get averageSize() {
15
+ if (this._map.size > 0) {
16
+ const i = this.totalSize / this._map.size;
17
+ return this._roundAverageSize ? Math.round(i) : i;
18
+ }
19
+ return 0;
20
+ }
21
+ getSize(i) {
22
+ return this._map.get(i);
23
+ }
24
+ clear() {
25
+ this._map.clear(), this.totalSize = 0;
26
+ }
27
+ }
28
+ /**
29
+ * @license
30
+ * Copyright 2021 Google LLC
31
+ * SPDX-License-Identifier: BSD-3-Clause
32
+ */
33
+ function f(o) {
34
+ return o === "horizontal" ? "width" : "height";
35
+ }
36
+ class d {
37
+ _getDefaultConfig() {
38
+ return {
39
+ direction: "vertical"
40
+ };
41
+ }
42
+ constructor(i, t) {
43
+ this._latestCoords = { left: 0, top: 0 }, this._direction = null, this._viewportSize = { width: 0, height: 0 }, this.totalScrollSize = { width: 0, height: 0 }, this.offsetWithinScroller = { left: 0, top: 0 }, this._pendingReflow = !1, this._pendingLayoutUpdate = !1, this._pin = null, this._firstVisible = 0, this._lastVisible = 0, this._physicalMin = 0, this._physicalMax = 0, this._first = -1, this._last = -1, this._sizeDim = "height", this._secondarySizeDim = "width", this._positionDim = "top", this._secondaryPositionDim = "left", this._scrollPosition = 0, this._scrollError = 0, this._items = [], this._scrollSize = 1, this._overhang = 1e3, this._hostSink = i, Promise.resolve().then(() => this.config = t || this._getDefaultConfig());
44
+ }
45
+ set config(i) {
46
+ Object.assign(this, Object.assign({}, this._getDefaultConfig(), i));
47
+ }
48
+ get config() {
49
+ return {
50
+ direction: this.direction
51
+ };
52
+ }
53
+ /**
54
+ * Maximum index of children + 1, to help estimate total height of the scroll
55
+ * space.
56
+ */
57
+ get items() {
58
+ return this._items;
59
+ }
60
+ set items(i) {
61
+ this._setItems(i);
62
+ }
63
+ _setItems(i) {
64
+ i !== this._items && (this._items = i, this._scheduleReflow());
65
+ }
66
+ /**
67
+ * Primary scrolling direction.
68
+ */
69
+ get direction() {
70
+ return this._direction;
71
+ }
72
+ set direction(i) {
73
+ i = i === "horizontal" ? i : "vertical", i !== this._direction && (this._direction = i, this._sizeDim = i === "horizontal" ? "width" : "height", this._secondarySizeDim = i === "horizontal" ? "height" : "width", this._positionDim = i === "horizontal" ? "left" : "top", this._secondaryPositionDim = i === "horizontal" ? "top" : "left", this._triggerReflow());
74
+ }
75
+ /**
76
+ * Height and width of the viewport.
77
+ */
78
+ get viewportSize() {
79
+ return this._viewportSize;
80
+ }
81
+ set viewportSize(i) {
82
+ const { _viewDim1: t, _viewDim2: s } = this;
83
+ Object.assign(this._viewportSize, i), s !== this._viewDim2 ? this._scheduleLayoutUpdate() : t !== this._viewDim1 && this._checkThresholds();
84
+ }
85
+ /**
86
+ * Scroll offset of the viewport.
87
+ */
88
+ get viewportScroll() {
89
+ return this._latestCoords;
90
+ }
91
+ set viewportScroll(i) {
92
+ Object.assign(this._latestCoords, i);
93
+ const t = this._scrollPosition;
94
+ this._scrollPosition = this._latestCoords[this._positionDim], Math.abs(t - this._scrollPosition) >= 1 && this._checkThresholds();
95
+ }
96
+ /**
97
+ * Perform a reflow if one has been scheduled.
98
+ */
99
+ reflowIfNeeded(i = !1) {
100
+ (i || this._pendingReflow) && (this._pendingReflow = !1, this._reflow());
101
+ }
102
+ set pin(i) {
103
+ this._pin = i, this._triggerReflow();
104
+ }
105
+ get pin() {
106
+ if (this._pin !== null) {
107
+ const { index: i, block: t } = this._pin;
108
+ return {
109
+ index: Math.max(0, Math.min(i, this.items.length - 1)),
110
+ block: t
111
+ };
112
+ }
113
+ return null;
114
+ }
115
+ _clampScrollPosition(i) {
116
+ return Math.max(-this.offsetWithinScroller[this._positionDim], Math.min(i, this.totalScrollSize[f(this.direction)] - this._viewDim1));
117
+ }
118
+ unpin() {
119
+ this._pin !== null && (this._sendUnpinnedMessage(), this._pin = null);
120
+ }
121
+ _updateLayout() {
122
+ }
123
+ // protected _viewDim2Changed(): void {
124
+ // this._scheduleLayoutUpdate();
125
+ // }
126
+ /**
127
+ * The height or width of the viewport, whichever corresponds to the scrolling direction.
128
+ */
129
+ get _viewDim1() {
130
+ return this._viewportSize[this._sizeDim];
131
+ }
132
+ /**
133
+ * The height or width of the viewport, whichever does NOT correspond to the scrolling direction.
134
+ */
135
+ get _viewDim2() {
136
+ return this._viewportSize[this._secondarySizeDim];
137
+ }
138
+ _scheduleReflow() {
139
+ this._pendingReflow = !0;
140
+ }
141
+ _scheduleLayoutUpdate() {
142
+ this._pendingLayoutUpdate = !0, this._scheduleReflow();
143
+ }
144
+ // For triggering a reflow based on incoming changes to
145
+ // the layout config.
146
+ _triggerReflow() {
147
+ this._scheduleLayoutUpdate(), Promise.resolve().then(() => this.reflowIfNeeded());
148
+ }
149
+ _reflow() {
150
+ this._pendingLayoutUpdate && (this._updateLayout(), this._pendingLayoutUpdate = !1), this._updateScrollSize(), this._setPositionFromPin(), this._getActiveItems(), this._updateVisibleIndices(), this._sendStateChangedMessage();
151
+ }
152
+ /**
153
+ * If we are supposed to be pinned to a particular
154
+ * item or set of coordinates, we set `_scrollPosition`
155
+ * accordingly and adjust `_scrollError` as needed
156
+ * so that the virtualizer can keep the scroll
157
+ * position in the DOM in sync
158
+ */
159
+ _setPositionFromPin() {
160
+ if (this.pin !== null) {
161
+ const i = this._scrollPosition, { index: t, block: s } = this.pin;
162
+ this._scrollPosition = this._calculateScrollIntoViewPosition({
163
+ index: t,
164
+ block: s || "start"
165
+ }) - this.offsetWithinScroller[this._positionDim], this._scrollError = i - this._scrollPosition;
166
+ }
167
+ }
168
+ /**
169
+ * Calculate the coordinates to scroll to, given
170
+ * a request to scroll to the element at a specific
171
+ * index.
172
+ *
173
+ * Supports the same positioning options (`start`,
174
+ * `center`, `end`, `nearest`) as the standard
175
+ * `Element.scrollIntoView()` method, but currently
176
+ * only considers the provided value in the `block`
177
+ * dimension, since we don't yet have any layouts
178
+ * that support virtualization in two dimensions.
179
+ */
180
+ _calculateScrollIntoViewPosition(i) {
181
+ const { block: t } = i, s = Math.min(this.items.length, Math.max(0, i.index)), h = this._getItemPosition(s)[this._positionDim];
182
+ let n = h;
183
+ if (t !== "start") {
184
+ const l = this._getItemSize(s)[this._sizeDim];
185
+ if (t === "center")
186
+ n = h - 0.5 * this._viewDim1 + 0.5 * l;
187
+ else {
188
+ const e = h - this._viewDim1 + l;
189
+ if (t === "end")
190
+ n = e;
191
+ else {
192
+ const r = this._scrollPosition;
193
+ n = Math.abs(r - h) < Math.abs(r - e) ? h : e;
194
+ }
195
+ }
196
+ }
197
+ return n += this.offsetWithinScroller[this._positionDim], this._clampScrollPosition(n);
198
+ }
199
+ getScrollIntoViewCoordinates(i) {
200
+ return {
201
+ [this._positionDim]: this._calculateScrollIntoViewPosition(i)
202
+ };
203
+ }
204
+ _sendUnpinnedMessage() {
205
+ this._hostSink({
206
+ type: "unpinned"
207
+ });
208
+ }
209
+ _sendVisibilityChangedMessage() {
210
+ this._hostSink({
211
+ type: "visibilityChanged",
212
+ firstVisible: this._firstVisible,
213
+ lastVisible: this._lastVisible
214
+ });
215
+ }
216
+ _sendStateChangedMessage() {
217
+ const i = /* @__PURE__ */ new Map();
218
+ if (this._first !== -1 && this._last !== -1)
219
+ for (let s = this._first; s <= this._last; s++)
220
+ i.set(s, this._getItemPosition(s));
221
+ const t = {
222
+ type: "stateChanged",
223
+ scrollSize: {
224
+ [this._sizeDim]: this._scrollSize,
225
+ [this._secondarySizeDim]: null
226
+ },
227
+ range: {
228
+ first: this._first,
229
+ last: this._last,
230
+ firstVisible: this._firstVisible,
231
+ lastVisible: this._lastVisible
232
+ },
233
+ childPositions: i
234
+ };
235
+ this._scrollError && (t.scrollError = {
236
+ [this._positionDim]: this._scrollError,
237
+ [this._secondaryPositionDim]: 0
238
+ }, this._scrollError = 0), this._hostSink(t);
239
+ }
240
+ /**
241
+ * Number of items to display.
242
+ */
243
+ get _num() {
244
+ return this._first === -1 || this._last === -1 ? 0 : this._last - this._first + 1;
245
+ }
246
+ _checkThresholds() {
247
+ if (this._viewDim1 === 0 && this._num > 0 || this._pin !== null)
248
+ this._scheduleReflow();
249
+ else {
250
+ const i = Math.max(0, this._scrollPosition - this._overhang), t = Math.min(this._scrollSize, this._scrollPosition + this._viewDim1 + this._overhang);
251
+ this._physicalMin > i || this._physicalMax < t ? this._scheduleReflow() : this._updateVisibleIndices({ emit: !0 });
252
+ }
253
+ }
254
+ /**
255
+ * Find the indices of the first and last items to intersect the viewport.
256
+ * Emit a visibleindiceschange event when either index changes.
257
+ */
258
+ _updateVisibleIndices(i) {
259
+ if (this._first === -1 || this._last === -1)
260
+ return;
261
+ let t = this._first;
262
+ for (; t < this._last && Math.round(this._getItemPosition(t)[this._positionDim] + this._getItemSize(t)[this._sizeDim]) <= Math.round(this._scrollPosition); )
263
+ t++;
264
+ let s = this._last;
265
+ for (; s > this._first && Math.round(this._getItemPosition(s)[this._positionDim]) >= Math.round(this._scrollPosition + this._viewDim1); )
266
+ s--;
267
+ (t !== this._firstVisible || s !== this._lastVisible) && (this._firstVisible = t, this._lastVisible = s, i && i.emit && this._sendVisibilityChangedMessage());
268
+ }
269
+ }
270
+ /**
271
+ * @license
272
+ * Copyright 2021 Google LLC
273
+ * SPDX-License-Identifier: BSD-3-Clause
274
+ */
275
+ function m(o) {
276
+ return o === "horizontal" ? "marginLeft" : "marginTop";
277
+ }
278
+ function u(o) {
279
+ return o === "horizontal" ? "marginRight" : "marginBottom";
280
+ }
281
+ function S(o) {
282
+ return o === "horizontal" ? "xOffset" : "yOffset";
283
+ }
284
+ function z(o, i) {
285
+ const t = [o, i].sort();
286
+ return t[1] <= 0 ? Math.min(...t) : t[0] >= 0 ? Math.max(...t) : t[0] + t[1];
287
+ }
288
+ class p {
289
+ constructor() {
290
+ this._childSizeCache = new g(), this._marginSizeCache = new g(), this._metricsCache = /* @__PURE__ */ new Map();
291
+ }
292
+ update(i, t) {
293
+ var h, n;
294
+ const s = /* @__PURE__ */ new Set();
295
+ Object.keys(i).forEach((l) => {
296
+ const e = Number(l);
297
+ this._metricsCache.set(e, i[e]), this._childSizeCache.set(e, i[e][f(t)]), s.add(e), s.add(e + 1);
298
+ });
299
+ for (const l of s) {
300
+ const e = ((h = this._metricsCache.get(l)) == null ? void 0 : h[m(t)]) || 0, r = ((n = this._metricsCache.get(l - 1)) == null ? void 0 : n[u(t)]) || 0;
301
+ this._marginSizeCache.set(l, z(e, r));
302
+ }
303
+ }
304
+ get averageChildSize() {
305
+ return this._childSizeCache.averageSize;
306
+ }
307
+ get totalChildSize() {
308
+ return this._childSizeCache.totalSize;
309
+ }
310
+ get averageMarginSize() {
311
+ return this._marginSizeCache.averageSize;
312
+ }
313
+ get totalMarginSize() {
314
+ return this._marginSizeCache.totalSize;
315
+ }
316
+ getLeadingMarginValue(i, t) {
317
+ var s;
318
+ return ((s = this._metricsCache.get(i)) == null ? void 0 : s[m(t)]) || 0;
319
+ }
320
+ getChildSize(i) {
321
+ return this._childSizeCache.getSize(i);
322
+ }
323
+ getMarginSize(i) {
324
+ return this._marginSizeCache.getSize(i);
325
+ }
326
+ clear() {
327
+ this._childSizeCache.clear(), this._marginSizeCache.clear(), this._metricsCache.clear();
328
+ }
329
+ }
330
+ class M extends d {
331
+ constructor() {
332
+ super(...arguments), this._itemSize = { width: 100, height: 100 }, this._physicalItems = /* @__PURE__ */ new Map(), this._newPhysicalItems = /* @__PURE__ */ new Map(), this._metricsCache = new p(), this._anchorIdx = null, this._anchorPos = null, this._stable = !0, this._measureChildren = !0, this._estimate = !0;
333
+ }
334
+ // protected _defaultConfig: BaseLayoutConfig = Object.assign({}, super._defaultConfig, {
335
+ // })
336
+ // constructor(config: Layout1dConfig) {
337
+ // super(config);
338
+ // }
339
+ get measureChildren() {
340
+ return this._measureChildren;
341
+ }
342
+ /**
343
+ * Determine the average size of all children represented in the sizes
344
+ * argument.
345
+ */
346
+ updateItemSizes(i) {
347
+ this._metricsCache.update(i, this.direction), this._scheduleReflow();
348
+ }
349
+ /**
350
+ * Set the average item size based on the total length and number of children
351
+ * in range.
352
+ */
353
+ // _updateItemSize() {
354
+ // // Keep integer values.
355
+ // this._itemSize[this._sizeDim] = this._metricsCache.averageChildSize;
356
+ // }
357
+ _getPhysicalItem(i) {
358
+ return this._newPhysicalItems.get(i) ?? this._physicalItems.get(i);
359
+ }
360
+ _getSize(i) {
361
+ return this._getPhysicalItem(i) && this._metricsCache.getChildSize(i);
362
+ }
363
+ _getAverageSize() {
364
+ return this._metricsCache.averageChildSize || this._itemSize[this._sizeDim];
365
+ }
366
+ _estimatePosition(i) {
367
+ const t = this._metricsCache;
368
+ if (this._first === -1 || this._last === -1)
369
+ return t.averageMarginSize + i * (t.averageMarginSize + this._getAverageSize());
370
+ if (i < this._first) {
371
+ const s = this._first - i;
372
+ return this._getPhysicalItem(this._first).pos - (t.getMarginSize(this._first - 1) || t.averageMarginSize) - (s * t.averageChildSize + (s - 1) * t.averageMarginSize);
373
+ } else {
374
+ const s = i - this._last;
375
+ return this._getPhysicalItem(this._last).pos + (t.getChildSize(this._last) || t.averageChildSize) + (t.getMarginSize(this._last) || t.averageMarginSize) + s * (t.averageChildSize + t.averageMarginSize);
376
+ }
377
+ }
378
+ /**
379
+ * Returns the position in the scrolling direction of the item at idx.
380
+ * Estimates it if the item at idx is not in the DOM.
381
+ */
382
+ _getPosition(i) {
383
+ const t = this._getPhysicalItem(i), { averageMarginSize: s } = this._metricsCache;
384
+ return i === 0 ? this._metricsCache.getMarginSize(0) ?? s : t ? t.pos : this._estimatePosition(i);
385
+ }
386
+ _calculateAnchor(i, t) {
387
+ return i <= 0 ? 0 : t > this._scrollSize - this._viewDim1 ? this.items.length - 1 : Math.max(0, Math.min(this.items.length - 1, Math.floor((i + t) / 2 / this._delta)));
388
+ }
389
+ _getAnchor(i, t) {
390
+ if (this._physicalItems.size === 0)
391
+ return this._calculateAnchor(i, t);
392
+ if (this._first < 0)
393
+ return this._calculateAnchor(i, t);
394
+ if (this._last < 0)
395
+ return this._calculateAnchor(i, t);
396
+ const s = this._getPhysicalItem(this._first), h = this._getPhysicalItem(this._last), n = s.pos;
397
+ if (h.pos + this._metricsCache.getChildSize(this._last) < i)
398
+ return this._calculateAnchor(i, t);
399
+ if (n > t)
400
+ return this._calculateAnchor(i, t);
401
+ let r = this._firstVisible - 1, a = -1 / 0;
402
+ for (; a < i; )
403
+ a = this._getPhysicalItem(++r).pos + this._metricsCache.getChildSize(r);
404
+ return r;
405
+ }
406
+ /**
407
+ * Updates _first and _last based on items that should be in the current
408
+ * viewed range.
409
+ */
410
+ _getActiveItems() {
411
+ this._viewDim1 === 0 || this.items.length === 0 ? this._clearItems() : this._getItems();
412
+ }
413
+ /**
414
+ * Sets the range to empty.
415
+ */
416
+ _clearItems() {
417
+ this._first = -1, this._last = -1, this._physicalMin = 0, this._physicalMax = 0;
418
+ const i = this._newPhysicalItems;
419
+ this._newPhysicalItems = this._physicalItems, this._newPhysicalItems.clear(), this._physicalItems = i, this._stable = !0;
420
+ }
421
+ /*
422
+ * Updates _first and _last based on items that should be in the given range.
423
+ */
424
+ _getItems() {
425
+ const i = this._newPhysicalItems;
426
+ this._stable = !0;
427
+ let t, s;
428
+ if (this.pin !== null) {
429
+ const { index: a } = this.pin;
430
+ this._anchorIdx = a, this._anchorPos = this._getPosition(a);
431
+ }
432
+ if (t = this._scrollPosition - this._overhang, s = this._scrollPosition + this._viewDim1 + this._overhang, s < 0 || t > this._scrollSize) {
433
+ this._clearItems();
434
+ return;
435
+ }
436
+ (this._anchorIdx === null || this._anchorPos === null) && (this._anchorIdx = this._getAnchor(t, s), this._anchorPos = this._getPosition(this._anchorIdx));
437
+ let h = this._getSize(this._anchorIdx);
438
+ h === void 0 && (this._stable = !1, h = this._getAverageSize());
439
+ const n = this._metricsCache.getMarginSize(this._anchorIdx) ?? this._metricsCache.averageMarginSize, l = this._metricsCache.getMarginSize(this._anchorIdx + 1) ?? this._metricsCache.averageMarginSize;
440
+ this._anchorIdx === 0 && (this._anchorPos = n), this._anchorIdx === this.items.length - 1 && (this._anchorPos = this._scrollSize - l - h);
441
+ let e = 0;
442
+ for (this._anchorPos + h + l < t && (e = t - (this._anchorPos + h + l)), this._anchorPos - n > s && (e = s - (this._anchorPos - n)), e && (this._scrollPosition -= e, t -= e, s -= e, this._scrollError += e), i.set(this._anchorIdx, { pos: this._anchorPos, size: h }), this._first = this._last = this._anchorIdx, this._physicalMin = this._anchorPos - n, this._physicalMax = this._anchorPos + h + l; this._physicalMin > t && this._first > 0; ) {
443
+ let a = this._getSize(--this._first);
444
+ a === void 0 && (this._stable = !1, a = this._getAverageSize());
445
+ let _ = this._metricsCache.getMarginSize(this._first);
446
+ _ === void 0 && (this._stable = !1, _ = this._metricsCache.averageMarginSize), this._physicalMin -= a;
447
+ const c = this._physicalMin;
448
+ if (i.set(this._first, { pos: c, size: a }), this._physicalMin -= _, this._stable === !1 && this._estimate === !1)
449
+ break;
450
+ }
451
+ for (; this._physicalMax < s && this._last < this.items.length - 1; ) {
452
+ let a = this._getSize(++this._last);
453
+ a === void 0 && (this._stable = !1, a = this._getAverageSize());
454
+ let _ = this._metricsCache.getMarginSize(this._last);
455
+ _ === void 0 && (this._stable = !1, _ = this._metricsCache.averageMarginSize);
456
+ const c = this._physicalMax;
457
+ if (i.set(this._last, { pos: c, size: a }), this._physicalMax += a + _, !this._stable && !this._estimate)
458
+ break;
459
+ }
460
+ const r = this._calculateError();
461
+ r && (this._physicalMin -= r, this._physicalMax -= r, this._anchorPos -= r, this._scrollPosition -= r, i.forEach((a) => a.pos -= r), this._scrollError += r), this._stable && (this._newPhysicalItems = this._physicalItems, this._newPhysicalItems.clear(), this._physicalItems = i);
462
+ }
463
+ _calculateError() {
464
+ return this._first === 0 ? this._physicalMin : this._physicalMin <= 0 ? this._physicalMin - this._first * this._delta : this._last === this.items.length - 1 ? this._physicalMax - this._scrollSize : this._physicalMax >= this._scrollSize ? this._physicalMax - this._scrollSize + (this.items.length - 1 - this._last) * this._delta : 0;
465
+ }
466
+ _reflow() {
467
+ const { _first: i, _last: t } = this;
468
+ super._reflow(), (this._first === -1 && this._last == -1 || this._first === i && this._last === t) && this._resetReflowState();
469
+ }
470
+ _resetReflowState() {
471
+ this._anchorIdx = null, this._anchorPos = null, this._stable = !0;
472
+ }
473
+ _updateScrollSize() {
474
+ const { averageMarginSize: i } = this._metricsCache;
475
+ this._scrollSize = Math.max(1, this.items.length * (i + this._getAverageSize()) + i);
476
+ }
477
+ /**
478
+ * Returns the average size (precise or estimated) of an item in the scrolling direction,
479
+ * including any surrounding space.
480
+ */
481
+ get _delta() {
482
+ const { averageMarginSize: i } = this._metricsCache;
483
+ return this._getAverageSize() + i;
484
+ }
485
+ /**
486
+ * Returns the top and left positioning of the item at idx.
487
+ */
488
+ _getItemPosition(i) {
489
+ return {
490
+ [this._positionDim]: this._getPosition(i),
491
+ [this._secondaryPositionDim]: 0,
492
+ [S(this.direction)]: -(this._metricsCache.getLeadingMarginValue(i, this.direction) ?? this._metricsCache.averageMarginSize)
493
+ };
494
+ }
495
+ /**
496
+ * Returns the height and width of the item at idx.
497
+ */
498
+ _getItemSize(i) {
499
+ return {
500
+ [this._sizeDim]: this._getSize(i) || this._getAverageSize(),
501
+ [this._secondarySizeDim]: this._itemSize[this._secondarySizeDim]
502
+ };
503
+ }
504
+ _viewDim2Changed() {
505
+ this._metricsCache.clear(), this._scheduleReflow();
506
+ }
507
+ }
508
+ export {
509
+ M as FlowLayout
510
+ };
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Mirrors the C# record: Muonroi.ControlPlane.Api.LivingDocs.Traceability.Models.TestCoverageState
3
+ *
4
+ * Serialized by NAME (JsonStringEnumConverter) — MUST be a string union, never an ordinal.
5
+ * Do NOT compare against integers: compare against "UnitTestLinked" | "DryRunExampleOnly" | "None".
6
+ */
7
+ export type TestCoverageState = "UnitTestLinked" | "DryRunExampleOnly" | "None";
8
+ /**
9
+ * Mirrors the C# record: Muonroi.ControlPlane.Api.LivingDocs.Models.FactRef
10
+ */
11
+ export interface FactRef {
12
+ name: string;
13
+ label: string;
14
+ dataType: string;
15
+ description?: string | null;
16
+ }
17
+ /**
18
+ * Mirrors the C# record: Muonroi.ControlPlane.Api.LivingDocs.Models.DecisionNarrative
19
+ * One section of the living doc — one rule node's BA-readable description.
20
+ */
21
+ export interface DecisionNarrative {
22
+ nodeId: string;
23
+ title: string;
24
+ inputs: FactRef[];
25
+ outputs: FactRef[];
26
+ logicProse: string;
27
+ sourceKind: string;
28
+ }
29
+ /**
30
+ * Mirrors the C# record: Muonroi.ControlPlane.Api.LivingDocs.Models.Coverage
31
+ */
32
+ export interface Coverage {
33
+ unitTestLinkedCount: number;
34
+ dryRunExampleCount: number;
35
+ noCoverageCount: number;
36
+ totalNodes: number;
37
+ }
38
+ /**
39
+ * Mirrors the C# record: Muonroi.ControlPlane.Api.LivingDocs.Models.LivingDoc
40
+ *
41
+ * The top-level response from GET /api/v1/living-docs/{workflow}/{version}.
42
+ * Provenance: drift-proofing covers rule-logic layer only (C-04).
43
+ */
44
+ export interface LivingDocModel {
45
+ workflow: string;
46
+ version: number;
47
+ tenantId: string;
48
+ generatedAt: string;
49
+ generatedFromVersionHash: string;
50
+ sections: DecisionNarrative[];
51
+ factDictionary: FactRef[];
52
+ coverage: Coverage;
53
+ }
54
+ /**
55
+ * Mirrors C# TestCoverageInfo (inner object in TraceabilityMatrixRow + ImpactRow).
56
+ *
57
+ * Authoritative shape from plan-01 serialized ImpactListResponse:
58
+ * { state, exampleId?, unitTestCode? }
59
+ * DRIFT FIX: replaced stale { linkedTestIds?, exampleCount? } with correct fields.
60
+ */
61
+ export interface TestCoverageInfo {
62
+ state: TestCoverageState;
63
+ exampleId?: string | null;
64
+ unitTestCode?: string | null;
65
+ }
66
+ /**
67
+ * Mirrors C# RequirementRef (inner object in TraceabilityMatrixRow + ImpactRow).
68
+ *
69
+ * Authoritative shape from plan-01 serialized ImpactListResponse:
70
+ * { id, title, sourceRef?, approver? }
71
+ * DRIFT FIX: replaced stale { requirementId, title?, source? } with correct camelCase fields.
72
+ * approver is required for the D-05 Approver column.
73
+ */
74
+ export interface RequirementRef {
75
+ id: string;
76
+ title?: string | null;
77
+ sourceRef?: string | null;
78
+ approver?: string | null;
79
+ }
80
+ /**
81
+ * Mirrors C# DecisionTableCellInfo (optional inner object in TraceabilityMatrixRow).
82
+ *
83
+ * DRIFT FIX: replaced stale { columnCount, rowCount, hitPolicy } with full 5-field shape.
84
+ */
85
+ export interface DecisionTableCellInfo {
86
+ tableId: string;
87
+ hitPolicy: string;
88
+ inputColumnCount: number;
89
+ outputColumnCount: number;
90
+ rowCount: number;
91
+ }
92
+ /**
93
+ * One row in the impact list (D-05 columns).
94
+ * Mirrors C# ImpactRow (ImpactListResponse.cs).
95
+ */
96
+ export interface ImpactRow {
97
+ nodeId: string;
98
+ title: string;
99
+ /** RequirementRef MUST carry approver after the drift fix above. */
100
+ requirements: RequirementRef[];
101
+ /** Three-state coverage. DryRunExampleOnly is NEVER "covered" (C-01). */
102
+ testCoverage: TestCoverageInfo;
103
+ /** "allow→block" | "block→allow" | "none" (Unicode → U+2192) */
104
+ impactType: string;
105
+ }
106
+ /**
107
+ * One UAT checklist case (D-02 — grouped under a UatRuleGroup).
108
+ * Mirrors C# UatCase (ImpactListResponse.cs).
109
+ */
110
+ export interface UatCase {
111
+ exampleId: string;
112
+ expectedOutcome: "allow" | "block";
113
+ /** Three-state; DryRunExampleOnly is NEVER badge--success (C-01). */
114
+ coverageBadge: TestCoverageState;
115
+ }
116
+ /**
117
+ * Top-level impact list response.
118
+ * Mirrors C# ImpactListResponse (ImpactListResponse.cs).
119
+ * Authoritative JSON shape confirmed in plan-01 SUMMARY §ImpactListResponse JSON Shape.
120
+ */
121
+ export interface ImpactListResponse {
122
+ workflow: string;
123
+ fromVersion: number;
124
+ toVersion: number;
125
+ rows: ImpactRow[];
126
+ uatChecklist: {
127
+ nodeId: string;
128
+ title: string;
129
+ cases: UatCase[];
130
+ }[];
131
+ }
132
+ /**
133
+ * Mirrors the C# record: Muonroi.ControlPlane.Api.LivingDocs.Traceability.Models.TraceabilityMatrixRow
134
+ *
135
+ * One row in the traceability matrix — one rule node mapped to its requirements + test coverage.
136
+ * Consumed from GET /api/v1/traceability/{workflow}/{version}.
137
+ */
138
+ export interface TraceabilityMatrixRow {
139
+ nodeId: string;
140
+ title: string;
141
+ nodeType: string;
142
+ requirements: RequirementRef[];
143
+ testCoverage: TestCoverageInfo;
144
+ decisionTable?: DecisionTableCellInfo | null;
145
+ }
146
+ //# sourceMappingURL=living-docs-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"living-docs-models.d.ts","sourceRoot":"","sources":["../../src/models/living-docs-models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,MAAM,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IAC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