@emeryld/rrroutes-export 1.0.19 → 1.0.20

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@emeryld/rrroutes-export",
3
3
  "description": "Finalized leaves export helpers and CLI for RRRoutes",
4
- "version": "1.0.19",
4
+ "version": "1.0.20",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "main": "dist/index.cjs",
@@ -403,6 +403,45 @@
403
403
  color: var(--schema-accent);
404
404
  }
405
405
 
406
+ .event-title-row {
407
+ display: inline-flex;
408
+ flex-wrap: wrap;
409
+ gap: 8px;
410
+ align-items: center;
411
+ }
412
+
413
+ .event-action-added {
414
+ color: var(--ok);
415
+ font-weight: 700;
416
+ }
417
+
418
+ .event-action-removed {
419
+ color: var(--danger);
420
+ }
421
+
422
+ .event-action-modified {
423
+ color: var(--accent);
424
+ font-weight: 700;
425
+ }
426
+
427
+ .event-icon {
428
+ display: inline-flex;
429
+ width: 14px;
430
+ height: 14px;
431
+ color: var(--muted);
432
+ }
433
+
434
+ .event-icon svg {
435
+ width: 14px;
436
+ height: 14px;
437
+ display: block;
438
+ }
439
+
440
+ .event-name {
441
+ font-weight: 700;
442
+ color: var(--text);
443
+ }
444
+
406
445
  .schema-block {
407
446
  border-top: 1px solid var(--border);
408
447
  padding: 8px 0 2px;
@@ -1652,7 +1691,12 @@
1652
1691
 
1653
1692
  const routeChangelogBody = el('div', 'leaf-content')
1654
1693
  routeHistoryNewestFirst.forEach((event) => {
1655
- routeChangelogBody.appendChild(renderEventCard(event, commitBySha))
1694
+ routeChangelogBody.appendChild(
1695
+ renderEventCard(event, commitBySha, {
1696
+ showTitle: true,
1697
+ item: { eventKind: 'route', routeKey: leaf.key, event },
1698
+ }),
1699
+ )
1656
1700
  })
1657
1701
  routeChangelogDetails.appendChild(routeChangelogBody)
1658
1702
  routeChangelogSection.appendChild(routeChangelogDetails)
@@ -1714,9 +1758,9 @@
1714
1758
  return `${type}${schemaFlags(Boolean(entry.nullable), Boolean(entry.optional))}`
1715
1759
  }
1716
1760
 
1717
- function formatPathLabel(path, entry) {
1761
+ function formatPathLabel(path) {
1718
1762
  const basePath = typeof path === 'string' ? path : ''
1719
- return `${basePath}${schemaFlags(Boolean(entry?.nullable), Boolean(entry?.optional))}`
1763
+ return basePath
1720
1764
  }
1721
1765
 
1722
1766
  function parseSignatureTypeLabel(signature) {
@@ -1812,7 +1856,7 @@
1812
1856
  if ('path' in delta) {
1813
1857
  if (delta.op === 'added') {
1814
1858
  const afterType = formatEntryTypeLabel(delta.after)
1815
- const pathLabel = formatPathLabel(delta.path, delta.after)
1859
+ const pathLabel = formatPathLabel(delta.path)
1816
1860
  if (afterType) return buildSchemaDiffLine(delta.op, afterType, pathLabel)
1817
1861
  return buildLegacySchemaDiffLine(
1818
1862
  `added ${delta.path}: ${formatRouteSchemaEntry(delta.after)}`,
@@ -1820,7 +1864,7 @@
1820
1864
  }
1821
1865
  if (delta.op === 'removed') {
1822
1866
  const beforeType = formatEntryTypeLabel(delta.before)
1823
- const pathLabel = formatPathLabel(delta.path, delta.before)
1867
+ const pathLabel = formatPathLabel(delta.path)
1824
1868
  if (beforeType)
1825
1869
  return buildSchemaDiffLine(delta.op, beforeType, pathLabel)
1826
1870
  return buildLegacySchemaDiffLine(
@@ -1830,7 +1874,7 @@
1830
1874
  const beforeType = formatEntryTypeLabel(delta.before) || 'unknown'
1831
1875
  const afterType = formatEntryTypeLabel(delta.after) || 'unknown'
1832
1876
  const pathLabel =
1833
- formatPathLabel(delta.path, delta.after || delta.before) || delta.path
1877
+ formatPathLabel(delta.path) || delta.path
1834
1878
  return buildSchemaDiffLine(delta.op, beforeType, pathLabel, afterType)
1835
1879
  }
1836
1880
  return null
@@ -1841,7 +1885,92 @@
1841
1885
  return `${diff.field}: ${JSON.stringify(diff.before)} -> ${JSON.stringify(diff.after)}`
1842
1886
  }
1843
1887
 
1844
- function renderEventCard(event, commitBySha) {
1888
+ const EVENT_ICON_SVGS = {
1889
+ route:
1890
+ '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M2.5 13V3.5h11V13"/><path d="M8 3.5v9.5"/><path d="M5.5 6h.01M10.5 10h.01"/></svg>',
1891
+ source:
1892
+ '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="8" cy="3.5" rx="4.8" ry="2.2"/><path d="M3.2 3.5v7c0 1.2 2.1 2.2 4.8 2.2s4.8-1 4.8-2.2v-7"/><path d="M3.2 7c0 1.2 2.1 2.2 4.8 2.2s4.8-1 4.8-2.2"/></svg>',
1893
+ schema:
1894
+ '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"><path d="M2.5 4.2L8 1.8l5.5 2.4L8 6.6 2.5 4.2Z"/><path d="M2.5 8L8 5.6 13.5 8 8 10.4 2.5 8Z"/><path d="M2.5 11.8 8 9.4l5.5 2.4L8 14.2l-5.5-2.4Z"/></svg>',
1895
+ config:
1896
+ '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"><path d="M2 4h12"/><path d="M2 8h12"/><path d="M2 12h12"/><circle cx="6" cy="4" r="1.6" fill="currentColor" stroke="none"/><circle cx="10.5" cy="8" r="1.6" fill="currentColor" stroke="none"/><circle cx="4.5" cy="12" r="1.6" fill="currentColor" stroke="none"/></svg>',
1897
+ }
1898
+
1899
+ function eventVisualByType(type) {
1900
+ switch (type) {
1901
+ case 'route_added':
1902
+ return { actionText: 'added', actionClass: 'event-action-added', icon: 'route' }
1903
+ case 'route_removed':
1904
+ return {
1905
+ actionText: 'removed',
1906
+ actionClass: 'event-action-removed',
1907
+ icon: 'route',
1908
+ }
1909
+ case 'schema_changed':
1910
+ return {
1911
+ actionText: 'modified schema',
1912
+ actionClass: 'event-action-modified',
1913
+ icon: 'schema',
1914
+ }
1915
+ case 'cfg_changed':
1916
+ return {
1917
+ actionText: 'modified config',
1918
+ actionClass: 'event-action-modified',
1919
+ icon: 'config',
1920
+ }
1921
+ case 'source_object_added':
1922
+ return { actionText: 'added', actionClass: 'event-action-added', icon: 'source' }
1923
+ case 'source_object_removed':
1924
+ return {
1925
+ actionText: 'removed',
1926
+ actionClass: 'event-action-removed',
1927
+ icon: 'source',
1928
+ }
1929
+ case 'source_schema_changed':
1930
+ return {
1931
+ actionText: 'modified source object',
1932
+ actionClass: 'event-action-modified',
1933
+ icon: 'source',
1934
+ }
1935
+ default:
1936
+ return {
1937
+ actionText: 'modified',
1938
+ actionClass: 'event-action-modified',
1939
+ icon: 'schema',
1940
+ }
1941
+ }
1942
+ }
1943
+
1944
+ function resolveEventName(item) {
1945
+ if (!item || item.eventKind === 'source') {
1946
+ return item?.displayName || item?.sourceObjectId || 'source object'
1947
+ }
1948
+ const method =
1949
+ typeof item?.event?.method === 'string' ? item.event.method.trim() : ''
1950
+ const path =
1951
+ typeof item?.event?.path === 'string' ? item.event.path.trim() : ''
1952
+ if (method && path) return `${method.toUpperCase()} ${path}`
1953
+ if (path) return path
1954
+ return item?.routeKey || 'route'
1955
+ }
1956
+
1957
+ function renderEventIcon(iconType) {
1958
+ const icon = el('span', `event-icon event-icon-${iconType}`)
1959
+ icon.setAttribute('aria-hidden', 'true')
1960
+ icon.innerHTML = EVENT_ICON_SVGS[iconType] || EVENT_ICON_SVGS.schema
1961
+ return icon
1962
+ }
1963
+
1964
+ function renderEventTitle(item) {
1965
+ const row = el('div', 'event-title-row mono')
1966
+ const visual = eventVisualByType(item?.event?.type)
1967
+ row.appendChild(el('span', visual.actionClass, visual.actionText))
1968
+ row.appendChild(renderEventIcon(visual.icon))
1969
+ row.appendChild(el('span', 'event-name', `[${resolveEventName(item)}]`))
1970
+ return row
1971
+ }
1972
+
1973
+ function renderEventCard(event, commitBySha, options = {}) {
1845
1974
  const card = el('div', 'leaf-content')
1846
1975
  const commit = commitBySha.get(event.commitSha)
1847
1976
  const commitDateTime = formatCommitDateTime(commit?.authorDate)
@@ -1854,7 +1983,9 @@
1854
1983
  .filter(Boolean)
1855
1984
  .join(' - ')
1856
1985
  card.appendChild(el('div', 'meta', commitMeta))
1857
- card.appendChild(el('div', 'mono', event.type))
1986
+ if (options.showTitle && options.item) {
1987
+ card.appendChild(renderEventTitle(options.item))
1988
+ }
1858
1989
  if (Array.isArray(event.schemaDiff) && event.schemaDiff.length > 0) {
1859
1990
  card.appendChild(
1860
1991
  el('div', 'meta', `schema changes: ${event.schemaDiff.length}`),
@@ -1907,12 +2038,13 @@
1907
2038
  .join(' - ')
1908
2039
  }
1909
2040
 
1910
- function renderChangelogEventLines(event, commitBySha, contextLabel) {
2041
+ function renderChangelogEventLines(item, commitBySha) {
2042
+ const event = item.event
1911
2043
  const row = el('div', 'changelog-line-item')
1912
2044
  row.appendChild(
1913
2045
  el('div', 'meta', buildCommitMetaLine(event, commitBySha)),
1914
2046
  )
1915
- row.appendChild(el('div', 'mono', `${contextLabel} (${event.type})`))
2047
+ row.appendChild(renderEventTitle(item))
1916
2048
 
1917
2049
  if (Array.isArray(event.schemaDiff) && event.schemaDiff.length > 0) {
1918
2050
  event.schemaDiff.forEach((delta) => {
@@ -2118,17 +2250,7 @@
2118
2250
  if (state.viewerMode === VIEWER_MODE.changelog) {
2119
2251
  renderCollection(
2120
2252
  filtered,
2121
- (item) => {
2122
- const contextLabel =
2123
- item.eventKind === 'route'
2124
- ? `Route: ${item.routeKey}`
2125
- : `Source: ${item.displayName || item.sourceObjectId}`
2126
- return renderChangelogEventLines(
2127
- item.event,
2128
- commitBySha,
2129
- contextLabel,
2130
- )
2131
- },
2253
+ (item) => renderChangelogEventLines(item, commitBySha),
2132
2254
  'No matches.',
2133
2255
  )
2134
2256
  } else {
@@ -2136,9 +2258,15 @@
2136
2258
  filtered,
2137
2259
  (item) => {
2138
2260
  const details = el('details', 'leaf')
2139
- const title = `${item.eventKind === 'route' ? `Route: ${item.routeKey}` : `Source: ${item.displayName || item.sourceObjectId}`} (${item.event.type})`
2140
- details.appendChild(el('summary', '', title))
2141
- details.appendChild(renderEventCard(item.event, commitBySha))
2261
+ const summary = el('summary')
2262
+ summary.appendChild(renderEventTitle(item))
2263
+ details.appendChild(summary)
2264
+ details.appendChild(
2265
+ renderEventCard(item.event, commitBySha, {
2266
+ showTitle: false,
2267
+ item,
2268
+ }),
2269
+ )
2142
2270
  return details
2143
2271
  },
2144
2272
  'No matches.',