@antelopejs/dms-api 0.5.0 → 0.6.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 (136) hide show
  1. package/README.md +19 -7
  2. package/dist/automation/query-request-logs.js.map +1 -1
  3. package/dist/automation/route-unhealthy.js.map +1 -1
  4. package/dist/db/models/request_log.model.js.map +1 -1
  5. package/dist/db/models/request_log.search.js +3 -3
  6. package/dist/db/models/request_log.search.js.map +1 -1
  7. package/dist/db/tables/request_log.table.js.map +1 -1
  8. package/dist/guards.d.ts +22 -0
  9. package/dist/guards.js +57 -0
  10. package/dist/guards.js.map +1 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/pages/blocks.d.ts +2 -2
  13. package/dist/pages/blocks.js +2 -2
  14. package/dist/pages/blocks.js.map +1 -1
  15. package/dist/pages/index.js.map +1 -1
  16. package/dist/pages/logs.js.map +1 -1
  17. package/dist/pages/module.js +8 -2
  18. package/dist/pages/module.js.map +1 -1
  19. package/dist/pages/overview.js.map +1 -1
  20. package/dist/pages/request-table.js.map +1 -1
  21. package/dist/pages/routes.js.map +1 -1
  22. package/dist/pages/settings.js +1 -3
  23. package/dist/pages/settings.js.map +1 -1
  24. package/dist/routes/logs.js.map +1 -1
  25. package/dist/routes/routes.js.map +1 -1
  26. package/dist/routes/settings.d.ts +2 -1
  27. package/dist/routes/settings.js +1 -1
  28. package/dist/routes/settings.js.map +1 -1
  29. package/dist/services/activity.js.map +1 -1
  30. package/dist/services/attention.js +1 -1
  31. package/dist/services/attention.js.map +1 -1
  32. package/dist/services/health-rules.js.map +1 -1
  33. package/dist/services/introspection/auth.js +1 -2
  34. package/dist/services/introspection/auth.js.map +1 -1
  35. package/dist/services/introspection/decorators.d.ts +3 -1
  36. package/dist/services/introspection/decorators.js +28 -17
  37. package/dist/services/introspection/decorators.js.map +1 -1
  38. package/dist/services/introspection/errors.d.ts +1 -1
  39. package/dist/services/introspection/errors.js +0 -2
  40. package/dist/services/introspection/errors.js.map +1 -1
  41. package/dist/services/introspection/index.d.ts +1 -1
  42. package/dist/services/introspection/index.js +24 -18
  43. package/dist/services/introspection/index.js.map +1 -1
  44. package/dist/services/introspection/probe.js.map +1 -1
  45. package/dist/services/links.js +4 -4
  46. package/dist/services/links.js.map +1 -1
  47. package/dist/services/live.d.ts +3 -2
  48. package/dist/services/live.js.map +1 -1
  49. package/dist/services/overview-lists.d.ts +4 -4
  50. package/dist/services/overview-lists.js.map +1 -1
  51. package/dist/services/overview.d.ts +4 -4
  52. package/dist/services/overview.js.map +1 -1
  53. package/dist/services/request-log/capture.d.ts +5 -14
  54. package/dist/services/request-log/capture.js +28 -76
  55. package/dist/services/request-log/capture.js.map +1 -1
  56. package/dist/services/request-log/console-traffic.d.ts +12 -0
  57. package/dist/services/request-log/console-traffic.js +69 -0
  58. package/dist/services/request-log/console-traffic.js.map +1 -0
  59. package/dist/services/request-log/list.d.ts +1 -1
  60. package/dist/services/request-log/list.js.map +1 -1
  61. package/dist/services/request-log/read.js.map +1 -1
  62. package/dist/services/request-log/redaction.js +7 -6
  63. package/dist/services/request-log/redaction.js.map +1 -1
  64. package/dist/services/request-log/util.d.ts +6 -3
  65. package/dist/services/request-log/util.js +17 -30
  66. package/dist/services/request-log/util.js.map +1 -1
  67. package/dist/services/route-catalog.js +2 -2
  68. package/dist/services/route-catalog.js.map +1 -1
  69. package/dist/services/route-contract.d.ts +6 -1
  70. package/dist/services/route-contract.js +11 -12
  71. package/dist/services/route-contract.js.map +1 -1
  72. package/dist/services/route-health.d.ts +5 -1
  73. package/dist/services/route-health.js +4 -1
  74. package/dist/services/route-health.js.map +1 -1
  75. package/dist/services/route-statistics.d.ts +3 -4
  76. package/dist/services/route-statistics.js.map +1 -1
  77. package/dist/services/routes-sync.d.ts +2 -2
  78. package/dist/services/routes-sync.js +1 -2
  79. package/dist/services/routes-sync.js.map +1 -1
  80. package/dist/services/scope.js +1 -1
  81. package/dist/services/scope.js.map +1 -1
  82. package/dist/services/settings-form.d.ts +4 -3
  83. package/dist/services/settings-form.js +1 -1
  84. package/dist/services/settings-form.js.map +1 -1
  85. package/dist/services/settings.js.map +1 -1
  86. package/dist/services/statistics-write.js +4 -7
  87. package/dist/services/statistics-write.js.map +1 -1
  88. package/dist/services/traffic-samples.js.map +1 -1
  89. package/dist/services/traffic.js +2 -1
  90. package/dist/services/traffic.js.map +1 -1
  91. package/dist/services/window.js +1 -1
  92. package/dist/services/window.js.map +1 -1
  93. package/dist/types/constants.js.map +1 -1
  94. package/dist/types/index.d.ts +1 -0
  95. package/dist/types/index.js +1 -0
  96. package/dist/types/index.js.map +1 -1
  97. package/dist/types/json.d.ts +2 -0
  98. package/dist/types/json.js +3 -0
  99. package/dist/types/json.js.map +1 -0
  100. package/frontend-vue/app/components/blocks/HealthHero.vue +8 -117
  101. package/frontend-vue/app/components/blocks/RequestDetail.vue +18 -153
  102. package/frontend-vue/app/components/blocks/RouteDocumentation.vue +2 -151
  103. package/frontend-vue/app/components/blocks/RouteHeader.vue +7 -8
  104. package/frontend-vue/app/components/blocks/RouteTester.vue +58 -1682
  105. package/frontend-vue/app/components/blocks/RouteTree.vue +16 -81
  106. package/frontend-vue/app/components/internal/HealthHeroMetrics.vue +50 -0
  107. package/frontend-vue/app/components/internal/RequestGeneral.vue +32 -0
  108. package/frontend-vue/app/components/internal/RequestTiming.vue +85 -0
  109. package/frontend-vue/app/components/internal/RouteInternals.vue +159 -0
  110. package/frontend-vue/app/components/internal/RouteTesterRequest.vue +225 -0
  111. package/frontend-vue/app/components/internal/RouteTesterResponse.vue +272 -0
  112. package/frontend-vue/app/components/internal/RouteTreeFooter.vue +62 -0
  113. package/frontend-vue/app/components/internal/routeTester/context.ts +8 -0
  114. package/frontend-vue/app/components/internal/routeTester/useTesterExtras.ts +284 -0
  115. package/frontend-vue/app/components/internal/routeTester/useTesterFlow.ts +637 -0
  116. package/frontend-vue/app/components/internal/routeTester/useTesterState.ts +601 -0
  117. package/frontend-vue/app/utils/health.ts +73 -0
  118. package/frontend-vue/app/utils/requestDrawer.ts +49 -0
  119. package/frontend-vue/app/utils/routeExplorer.ts +34 -0
  120. package/frontend-vue/app/utils/testerMasks.ts +34 -0
  121. package/frontend-vue/app/utils/testerRequest.ts +14 -38
  122. package/frontend-vue/build/backend-boundary.ts +122 -0
  123. package/frontend-vue/dms.frontend.build.ts +2 -0
  124. package/frontend-vue/eslint.config.mjs +13 -0
  125. package/frontend-vue/package.json +6 -3
  126. package/frontend-vue/pnpm-lock.yaml +348 -153
  127. package/frontend-vue/tests/apiErrorPresentation.test.ts +115 -0
  128. package/frontend-vue/tests/backend-boundary.test.ts +180 -0
  129. package/frontend-vue/tests/dmsServer.test.ts +11 -23
  130. package/frontend-vue/tests/registration.test.ts +22 -6
  131. package/frontend-vue/tests/stubs/server.ts +19 -0
  132. package/frontend-vue/tests/testerRequest.test.ts +14 -0
  133. package/frontend-vue/vitest.config.ts +16 -0
  134. package/package.json +20 -8
  135. package/skills/dms-api/SKILL.md +1 -1
  136. package/skills/dms-api/cases.json +47 -0
@@ -3,18 +3,25 @@ import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
3
3
  import { formatCount } from '../../utils/format'
4
4
  import {
5
5
  bySeverity,
6
+ KEYBOARD_SETTLE_MS,
7
+ METHOD_FILTERS,
8
+ REVEAL_MARGIN_PX,
6
9
  groupRoutes,
7
10
  initialRoute,
8
11
  listedFolders,
9
12
  needsAttention,
10
13
  optionId,
14
+ type RouteRow,
11
15
  type RouteState,
16
+ STATE_DOT,
17
+ STATE_ICON,
12
18
  stepFrom,
13
19
  windowParts,
14
20
  } from '../../utils/routeExplorer'
15
21
  import { closestMatch } from '../../utils/search'
16
22
  import ApiMethodBadge from '../internal/ApiMethodBadge.vue'
17
23
  import ApiPath from '../internal/ApiPath.vue'
24
+ import RouteTreeFooter from '../internal/RouteTreeFooter.vue'
18
25
 
19
26
  // Every route in scope, grouped by folder, with its traffic and health over
20
27
  // the health window the list states. The selection is the page's `?route=`,
@@ -39,41 +46,6 @@ const props = withDefaults(
39
46
  },
40
47
  )
41
48
 
42
- interface RouteRow {
43
- ref: string
44
- method: string
45
- path: string
46
- folder: string
47
- controller: string | null
48
- handler: string
49
- requests: number
50
- state: RouteState
51
- }
52
-
53
- const METHOD_FILTERS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']
54
- /** A shape per issue, so slow and a high 4xx rate never read alike. */
55
- const STATE_ICON: Partial<Record<RouteState, { name: string; class: string }>> =
56
- {
57
- failing: { name: 'i-ph-x-circle-fill', class: 'text-error' },
58
- slow: { name: 'i-ph-timer-bold', class: 'text-warning' },
59
- 'client-errors': { name: 'i-ph-warning-fill', class: 'text-warning' },
60
- recovered: {
61
- name: 'i-ph-arrow-counter-clockwise-bold',
62
- class: 'text-info',
63
- },
64
- }
65
- const STATE_DOT: Record<RouteState, string> = {
66
- failing: 'bg-error',
67
- slow: 'bg-warning',
68
- 'client-errors': 'bg-warning',
69
- recovered: 'bg-info',
70
- healthy: 'bg-success',
71
- idle: 'bg-(--ui-border-accented)',
72
- }
73
- /** Rest after the last ↑ / ↓ before the page loads the route reached. */
74
- const KEYBOARD_SETTLE_MS = 150
75
- const REVEAL_MARGIN_PX = 8
76
-
77
49
  const { t } = useI18n()
78
50
  const { formatLocale: locale, formatNumber } = useRegionalFormat({
79
51
  locale: 'format',
@@ -624,52 +596,15 @@ const count = (value: number) =>
624
596
  </div>
625
597
  </div>
626
598
 
627
- <div
628
- class="border-default text-dimmed flex items-center gap-2 border-t px-3 py-2 font-mono text-[11px]"
629
- >
630
- <!-- The count wraps rather than being cut: the toggle beside it is an
631
- icon, its name in a tooltip, so the line usually holds it all. -->
632
- <span class="min-w-0">
633
- {{
634
- t(
635
- flatMode
636
- ? 'api.routes.tree.footer_flat'
637
- : 'api.routes.tree.footer',
638
- {
639
- shown: formatCount(visible.length, locale),
640
- total: formatCount(routes.length, locale),
641
- folders: folders.length,
642
- },
643
- )
644
- }}
645
- </span>
646
- <span class="grow" />
647
- <UTooltip
648
- v-if="!flatMode && folders.length > 1"
649
- :text="
650
- allCollapsed
651
- ? t('api.routes.tree.expand_all')
652
- : t('api.routes.tree.collapse_all')
653
- "
654
- >
655
- <UButton
656
- size="xs"
657
- color="neutral"
658
- variant="ghost"
659
- square
660
- class="shrink-0"
661
- :icon="allCollapsed ? 'i-ph-caret-up-down' : 'i-ph-caret-line-up'"
662
- :aria-label="
663
- allCollapsed
664
- ? t('api.routes.tree.expand_all')
665
- : t('api.routes.tree.collapse_all')
666
- "
667
- @click="toggleAll"
668
- />
669
- </UTooltip>
670
- <UKbd value="↑" size="sm" class="@max-5xl:hidden shrink-0" />
671
- <UKbd value="↓" size="sm" class="@max-5xl:hidden shrink-0" />
672
- </div>
599
+ <RouteTreeFooter
600
+ :visible="visible"
601
+ :routes="routes"
602
+ :folders="folders"
603
+ :flat-mode="flatMode"
604
+ :all-collapsed="allCollapsed"
605
+ :locale="locale"
606
+ :toggle-all="toggleAll"
607
+ />
673
608
  </div>
674
609
  </DmsCard>
675
610
  </template>
@@ -0,0 +1,50 @@
1
+ <script setup lang="ts">
2
+ import type { HeroMetric, MetricTone } from '../../utils/health'
3
+
4
+ // The figures beside the verdict, each with its label and the line under it.
5
+ defineProps<{ metrics: HeroMetric[] }>()
6
+
7
+ const METRIC_TONE: Record<MetricTone, string> = {
8
+ default: 'text-highlighted',
9
+ warning: 'text-warning',
10
+ error: 'text-error',
11
+ muted: 'text-muted',
12
+ }
13
+ </script>
14
+
15
+ <template>
16
+ <dl
17
+ class="grid flex-1 grid-cols-2 gap-x-6 gap-y-4 sm:grid-cols-[repeat(auto-fit,minmax(96px,1fr))] lg:grid-cols-4"
18
+ >
19
+ <div
20
+ v-for="(metric, index) in metrics"
21
+ :key="metric.id"
22
+ class="min-w-0"
23
+ :class="index > 0 && 'sm:border-muted sm:-ml-6 sm:border-l sm:pl-6'"
24
+ >
25
+ <dt
26
+ class="text-dimmed font-mono text-[10px] font-semibold uppercase tracking-[0.12em]"
27
+ >
28
+ {{ metric.label }}
29
+ </dt>
30
+ <dd
31
+ :class="[
32
+ METRIC_TONE[metric.tone],
33
+ metric.secondary ? 'text-base' : 'text-xl',
34
+ ]"
35
+ class="mt-[7px] whitespace-nowrap font-mono font-semibold tabular-nums leading-[1.1] tracking-[-0.03em]"
36
+ >
37
+ {{ metric.value }}
38
+ <span
39
+ v-if="metric.unit"
40
+ class="text-dimmed ml-0.5 font-sans text-xs font-medium tracking-normal"
41
+ >
42
+ {{ metric.unit }}
43
+ </span>
44
+ </dd>
45
+ <dd class="text-dimmed mt-1 text-[11.5px]">
46
+ {{ metric.sub }}
47
+ </dd>
48
+ </div>
49
+ </dl>
50
+ </template>
@@ -0,0 +1,32 @@
1
+ <script setup lang="ts">
2
+ // What the request was: its URL, date, route and where it came from.
3
+ defineProps<{
4
+ general: { key: string; label: string; value: string; copy?: boolean }[]
5
+ isTester: boolean
6
+ }>()
7
+
8
+ const { t } = useI18n()
9
+ </script>
10
+
11
+ <template>
12
+ <section class="flex flex-col gap-2">
13
+ <DmsEyebrow :label="t('api.request.general')" />
14
+ <dl
15
+ class="grid grid-cols-[max-content_minmax(0,1fr)] gap-x-4 gap-y-1.5 text-[12.5px]"
16
+ >
17
+ <template v-for="row in general" :key="row.key">
18
+ <dt class="text-muted">{{ row.label }}</dt>
19
+ <dd class="text-default flex min-w-0 items-start gap-1">
20
+ <bdi class="min-w-0 font-mono text-[12px] [overflow-wrap:anywhere]">
21
+ {{ row.value }}
22
+ </bdi>
23
+ <DmsCopyButton v-if="row.copy" :value="row.value" class="-my-1.5" />
24
+ </dd>
25
+ </template>
26
+ <template v-if="isTester">
27
+ <dt class="text-muted">{{ t('api.request.fields.source') }}</dt>
28
+ <dd class="text-default">{{ t('api.request.source_tester') }}</dd>
29
+ </template>
30
+ </dl>
31
+ </section>
32
+ </template>
@@ -0,0 +1,85 @@
1
+ <script setup lang="ts">
2
+ import type { DurationScale, RequestLog } from '../../utils/requestDrawer'
3
+
4
+ // How long the request took against the slow threshold, and how its route
5
+ // does lately.
6
+ defineProps<{
7
+ log: RequestLog
8
+ timing: DurationScale | null
9
+ ratio: string
10
+ ms: (value: number) => string
11
+ count: (value: number) => string
12
+ }>()
13
+
14
+ const { t } = useI18n()
15
+ </script>
16
+
17
+ <template>
18
+ <section class="flex flex-col gap-2">
19
+ <DmsEyebrow :label="t('api.request.timing')" />
20
+ <template v-if="timing">
21
+ <div class="flex flex-wrap items-baseline gap-x-2 gap-y-1">
22
+ <span class="text-highlighted font-mono text-xl font-semibold">
23
+ {{ ms(log.responseTimeMs ?? 0) }}
24
+ </span>
25
+ <span
26
+ class="text-xs"
27
+ :class="timing.slow ? 'text-warning font-semibold' : 'text-dimmed'"
28
+ >
29
+ {{
30
+ timing.slow
31
+ ? t('api.request.slow_ratio', { ratio })
32
+ : t('api.request.threshold_ratio', { ratio })
33
+ }}
34
+ </span>
35
+ </div>
36
+ <div
37
+ class="bg-elevated relative my-1 h-2 rounded-full"
38
+ role="meter"
39
+ :aria-label="t('api.request.meter_label')"
40
+ aria-valuemin="0"
41
+ :aria-valuemax="Math.round(timing.max)"
42
+ :aria-valuenow="Math.round(log.responseTimeMs ?? 0)"
43
+ :aria-valuetext="ms(log.responseTimeMs ?? 0)"
44
+ >
45
+ <div
46
+ class="h-full rounded-full"
47
+ :class="timing.slow ? 'bg-warning' : 'bg-primary'"
48
+ :style="{ width: `${timing.share}%` }"
49
+ />
50
+ <div
51
+ class="bg-inverted/60 absolute -inset-y-1 w-0.5 rounded-full"
52
+ :style="{ left: `${timing.threshold}%` }"
53
+ aria-hidden="true"
54
+ />
55
+ </div>
56
+ <!-- The threshold, then how the route does lately: each its own
57
+ line, at every width. -->
58
+ <div class="text-dimmed flex flex-col gap-1 text-xs">
59
+ <p>
60
+ {{
61
+ t('api.request.threshold', {
62
+ threshold: ms(log.slowThresholdMs),
63
+ })
64
+ }}
65
+ </p>
66
+ <p v-if="log.routeLatency" class="font-mono tabular-nums">
67
+ {{
68
+ t(
69
+ 'api.request.route_latency',
70
+ {
71
+ days: count(log.routeLatency.windowDays),
72
+ p50: ms(log.routeLatency.p50),
73
+ p95: ms(log.routeLatency.p95),
74
+ },
75
+ log.routeLatency.windowDays,
76
+ )
77
+ }}
78
+ </p>
79
+ </div>
80
+ </template>
81
+ <p v-else class="text-dimmed text-sm">
82
+ {{ t('api.request.not_measured_hint') }}
83
+ </p>
84
+ </section>
85
+ </template>
@@ -0,0 +1,159 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import type { RouteDetail } from '../../composables/useRouteDetail'
4
+
5
+ // The documentation's last column: the pipeline a request meets, then the
6
+ // controller's internals, folded.
7
+ const props = defineProps<{ route: RouteDetail }>()
8
+
9
+ const { t } = useI18n()
10
+
11
+ // Internals worth a row: a parameter the introspection could name or place,
12
+ // a class member. An unnamed `unknown` row says nothing.
13
+ const internalParameters = computed(() =>
14
+ (props.route.inspection.parameters ?? []).filter(
15
+ (parameter) => parameter.name || parameter.source !== 'unknown',
16
+ ),
17
+ )
18
+ const internalProperties = computed(
19
+ () => props.route.inspection.properties ?? [],
20
+ )
21
+
22
+ const PIPELINE_TONE = {
23
+ prefix: 'info',
24
+ handler: 'primary',
25
+ postfix: 'neutral',
26
+ monitor: 'neutral',
27
+ } as const
28
+ </script>
29
+
30
+ <template>
31
+ <DmsCard :title="t('api.routes.docs.pipeline')" :padded="false">
32
+ <p class="text-dimmed px-4 pt-3 text-xs">
33
+ {{ t('api.routes.docs.pipeline_description') }}
34
+ </p>
35
+ <ol class="flex flex-col gap-0 px-4 py-3">
36
+ <li
37
+ v-for="(step, index) in route.pipeline"
38
+ :key="`${step.kind}-${step.name}-${index}`"
39
+ class="flex items-center gap-3 py-1.5"
40
+ >
41
+ <span class="text-dimmed w-5 text-right font-mono text-[11px]">
42
+ {{ index + 1 }}
43
+ </span>
44
+ <span class="min-w-0 grow">
45
+ <span
46
+ class="text-highlighted block truncate font-mono text-[12.5px]"
47
+ :class="step.kind === 'handler' && 'text-primary font-semibold'"
48
+ >
49
+ {{ step.name }}
50
+ </span>
51
+ <span class="text-dimmed font-mono text-[11px]">
52
+ {{ t(`api.routes.docs.kind_${step.kind}`) }} ·
53
+ {{ step.location }}
54
+ </span>
55
+ </span>
56
+ <DmsStatusPill
57
+ v-if="step.isAuth"
58
+ tone="info"
59
+ size="sm"
60
+ dot="none"
61
+ icon="i-ph-lock-simple"
62
+ :label="t('api.routes.docs.auth')"
63
+ />
64
+ <DmsStatusPill
65
+ :tone="PIPELINE_TONE[step.kind]"
66
+ size="sm"
67
+ dot="none"
68
+ :label="t(`api.routes.docs.kind_${step.kind}`)"
69
+ />
70
+ </li>
71
+ </ol>
72
+ </DmsCard>
73
+
74
+ <details
75
+ v-if="internalParameters.length || internalProperties.length"
76
+ class="dms-card group overflow-hidden rounded-lg"
77
+ >
78
+ <summary
79
+ class="text-muted hover:text-default flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm"
80
+ >
81
+ <UIcon
82
+ name="i-ph-caret-right"
83
+ class="size-3.5 transition-transform group-open:rotate-90"
84
+ />
85
+ {{ t('api.routes.docs.internals') }}
86
+ <span class="text-dimmed text-xs">
87
+ ·
88
+ {{
89
+ t(
90
+ 'api.routes.docs.internals_parameters',
91
+ { count: internalParameters.length },
92
+ internalParameters.length,
93
+ )
94
+ }},
95
+ {{
96
+ t(
97
+ 'api.routes.docs.internals_members',
98
+ { count: internalProperties.length },
99
+ internalProperties.length,
100
+ )
101
+ }}
102
+ </span>
103
+ </summary>
104
+ <div class="border-default overflow-x-auto border-t">
105
+ <table class="w-full text-[12px]">
106
+ <thead class="text-dimmed font-mono text-[10.5px] uppercase">
107
+ <tr>
108
+ <th class="px-4 py-2 text-left font-medium">#</th>
109
+ <th class="px-2 py-2 text-left font-medium">
110
+ {{ t('api.routes.docs.internal_name') }}
111
+ </th>
112
+ <th class="px-2 py-2 text-left font-medium">
113
+ {{ t('api.routes.docs.internal_source') }}
114
+ </th>
115
+ <th class="px-2 py-2 text-left font-medium">
116
+ {{ t('api.routes.docs.internal_type') }}
117
+ </th>
118
+ <th class="px-4 py-2 text-right font-medium">
119
+ {{ t('api.routes.docs.internal_modifiers') }}
120
+ </th>
121
+ </tr>
122
+ </thead>
123
+ <tbody class="divide-default divide-y font-mono">
124
+ <tr
125
+ v-for="parameter in internalParameters"
126
+ :key="`p-${parameter.index}`"
127
+ >
128
+ <td class="text-dimmed px-4 py-1.5">{{ parameter.index }}</td>
129
+ <td class="px-2 py-1.5">
130
+ {{ parameter.name ?? parameter.decorator ?? '—' }}
131
+ </td>
132
+ <td class="text-muted px-2 py-1.5">
133
+ {{ parameter.hint ?? parameter.source }}
134
+ </td>
135
+ <td class="text-muted px-2 py-1.5">
136
+ {{ parameter.inferredType }}
137
+ </td>
138
+ <td class="text-muted px-4 py-1.5 text-right">
139
+ {{ parameter.modifierCount }}
140
+ </td>
141
+ </tr>
142
+ <tr v-for="property in internalProperties" :key="`m-${property.key}`">
143
+ <td class="text-dimmed px-4 py-1.5">—</td>
144
+ <td class="px-2 py-1.5">{{ property.key }}</td>
145
+ <td class="text-muted px-2 py-1.5">
146
+ {{ property.decorator }}
147
+ </td>
148
+ <td class="text-muted px-2 py-1.5">
149
+ {{ t('api.routes.docs.class_member') }}
150
+ </td>
151
+ <td class="text-muted px-4 py-1.5 text-right">
152
+ {{ property.modifierCount }}
153
+ </td>
154
+ </tr>
155
+ </tbody>
156
+ </table>
157
+ </div>
158
+ </details>
159
+ </template>
@@ -0,0 +1,225 @@
1
+ <script setup lang="ts">
2
+ import { hasRedacted } from '../../utils/testerRequest'
3
+ import type { TesterContext } from './routeTester/context'
4
+
5
+ // The tester's request card: the body, the query, the headers and the auth, by tab.
6
+ const props = defineProps<{ tester: TesterContext }>()
7
+
8
+ const {
9
+ body,
10
+ bodyAllowed,
11
+ bodyHint,
12
+ bodyHintId,
13
+ bodyMode,
14
+ bodyModeItems,
15
+ editBody,
16
+ editors,
17
+ formatBody,
18
+ formattedBody,
19
+ jsonWarning,
20
+ modified,
21
+ queryHint,
22
+ redactedBodyFields,
23
+ resetToExample,
24
+ row,
25
+ shownImpliedHeaders,
26
+ t,
27
+ tab,
28
+ tabs,
29
+ } = props.tester
30
+ </script>
31
+
32
+ <template>
33
+ <DmsCard :padded="false" class="@container min-w-0">
34
+ <div
35
+ class="border-default flex flex-wrap items-center gap-x-2 border-b px-3"
36
+ >
37
+ <!-- overflow-x-auto alone turns overflow-y to auto: the active
38
+ tab's underline would show a scrollbar. -->
39
+ <UTabs
40
+ v-model="tab"
41
+ :items="tabs"
42
+ :content="false"
43
+ variant="link"
44
+ size="sm"
45
+ class="min-w-0 grow overflow-x-auto overflow-y-hidden"
46
+ />
47
+ <template v-if="modified">
48
+ <span class="text-dimmed inline-flex items-center gap-1.5 text-xs">
49
+ <span class="bg-warning size-1.5 rounded-full" aria-hidden="true" />
50
+ {{ t('api.tester.draft_modified') }}
51
+ </span>
52
+ <UButton
53
+ size="xs"
54
+ color="neutral"
55
+ variant="ghost"
56
+ icon="i-ph-arrow-counter-clockwise"
57
+ :label="t('api.tester.reset')"
58
+ @click="resetToExample()"
59
+ />
60
+ </template>
61
+ </div>
62
+ <div class="p-3">
63
+ <div
64
+ v-if="tab === 'body' && bodyAllowed"
65
+ class="mb-2 flex flex-wrap items-center gap-2"
66
+ >
67
+ <USelect
68
+ v-model="bodyMode"
69
+ :items="bodyModeItems"
70
+ size="xs"
71
+ class="w-36"
72
+ :aria-label="t('api.tester.body_mode')"
73
+ />
74
+ <span class="grow" />
75
+ <UButton
76
+ v-if="bodyMode === 'json'"
77
+ size="xs"
78
+ color="neutral"
79
+ variant="outline"
80
+ icon="i-ph-brackets-curly"
81
+ :disabled="formattedBody === null || formattedBody === body"
82
+ :label="t('api.tester.format')"
83
+ @click="formatBody"
84
+ />
85
+ </div>
86
+
87
+ <template
88
+ v-if="
89
+ tab === 'body' &&
90
+ bodyAllowed &&
91
+ (bodyMode === 'json' || bodyMode === 'text')
92
+ "
93
+ >
94
+ <DmsInputCode
95
+ :key="bodyMode"
96
+ :model-value="body"
97
+ :language="bodyMode === 'json' ? 'json' : 'text'"
98
+ :min-lines="12"
99
+ :max-lines="24"
100
+ :aria-describedby="bodyHintId"
101
+ @update:model-value="editBody"
102
+ />
103
+ </template>
104
+
105
+ <div
106
+ v-else-if="tab !== 'body' || (bodyAllowed && bodyMode === 'form')"
107
+ class="flex flex-col gap-4"
108
+ >
109
+ <div
110
+ v-if="tab === 'headers' && shownImpliedHeaders.length"
111
+ class="text-dimmed flex flex-col gap-1 font-mono text-xs"
112
+ >
113
+ <span v-for="[name, value] in shownImpliedHeaders" :key="name">
114
+ {{ name }}: {{ value }}
115
+ <span class="font-sans">
116
+ · {{ t('api.tester.implied_header') }}
117
+ </span>
118
+ </span>
119
+ </div>
120
+ <div
121
+ v-for="editor in editors"
122
+ :key="editor.key"
123
+ class="@sm:gap-2 flex flex-col gap-3"
124
+ >
125
+ <p
126
+ v-if="editor.title"
127
+ class="text-default border-default border-t pt-3 text-xs font-medium"
128
+ >
129
+ {{ editor.title }}
130
+ </p>
131
+ <!-- In a narrow card the name takes a line of its own, the
132
+ value and its button the next: a name is never cut. -->
133
+ <div
134
+ v-for="(entry, index) in editor.list"
135
+ :key="entry.id"
136
+ class="@sm:flex-nowrap flex flex-wrap gap-2"
137
+ >
138
+ <UInput
139
+ v-model="entry.name"
140
+ size="sm"
141
+ class="@sm:w-2/5 w-full font-mono"
142
+ :placeholder="t('dms.form.key_value.key')"
143
+ :aria-label="t('dms.form.key_value.key')"
144
+ />
145
+ <UInput
146
+ v-model="entry.value"
147
+ size="sm"
148
+ class="min-w-0 flex-1 font-mono"
149
+ :placeholder="t('dms.form.key_value.value')"
150
+ :aria-label="t('dms.form.key_value.value')"
151
+ :color="hasRedacted(entry.value) ? 'warning' : undefined"
152
+ :highlight="hasRedacted(entry.value)"
153
+ :title="
154
+ hasRedacted(entry.value)
155
+ ? t('api.tester.redacted_value')
156
+ : undefined
157
+ "
158
+ />
159
+ <UButton
160
+ size="sm"
161
+ color="neutral"
162
+ variant="ghost"
163
+ icon="i-ph-x"
164
+ :aria-label="t('api.tester.remove')"
165
+ @click="editor.list.splice(index, 1)"
166
+ />
167
+ </div>
168
+ <div>
169
+ <UButton
170
+ size="xs"
171
+ color="neutral"
172
+ variant="outline"
173
+ icon="i-ph-plus"
174
+ :label="editor.add"
175
+ @click="editor.list.push(row())"
176
+ />
177
+ </div>
178
+ <p v-if="editor.hint" class="text-dimmed text-xs">
179
+ {{ editor.hint }}
180
+ </p>
181
+ <p
182
+ v-if="editor.warning"
183
+ class="text-warning inline-flex items-start gap-1 text-xs"
184
+ >
185
+ <UIcon name="i-ph-key" class="mt-px size-3.5 shrink-0" />
186
+ {{ editor.warning }}
187
+ </p>
188
+ </div>
189
+ <p v-if="tab !== 'body'" class="text-dimmed text-xs">
190
+ <template v-if="tab === 'headers'">
191
+ {{ t('api.tester.headers_hint') }}
192
+ {{ t('api.tester.marks_hint') }}
193
+ </template>
194
+ <template v-else-if="tab === 'query'">{{ queryHint }}</template>
195
+ </p>
196
+ </div>
197
+
198
+ <template v-if="tab === 'body' && bodyAllowed">
199
+ <p v-if="jsonWarning" class="text-warning mt-1.5 text-xs">
200
+ {{ t('api.tester.json_warning', { message: jsonWarning }) }}
201
+ </p>
202
+ <p v-if="redactedBodyFields.length" class="text-warning mt-1.5 text-xs">
203
+ {{
204
+ t(
205
+ 'api.tester.body_redacted',
206
+ {
207
+ count: redactedBodyFields.length,
208
+ names: redactedBodyFields.join(', '),
209
+ },
210
+ redactedBodyFields.length,
211
+ )
212
+ }}
213
+ </p>
214
+ <p
215
+ v-if="bodyHint.text"
216
+ :id="bodyHintId"
217
+ class="mt-1.5 text-xs"
218
+ :class="bodyHint.tone === 'warning' ? 'text-warning' : 'text-dimmed'"
219
+ >
220
+ {{ bodyHint.text }}
221
+ </p>
222
+ </template>
223
+ </div>
224
+ </DmsCard>
225
+ </template>