@antelopejs/dms-api 0.5.1 → 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 +18 -6
  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 +16 -4
  135. package/skills/dms-api/SKILL.md +1 -1
  136. package/skills/dms-api/cases.json +47 -0
@@ -8,11 +8,10 @@ import {
8
8
  isRequestId,
9
9
  NO_REDACTIONS,
10
10
  originalBodySize,
11
- type Redactions,
11
+ type RequestLog,
12
12
  type RequestPivot,
13
13
  requestPivots,
14
14
  requestUrl,
15
- type RouteLatency,
16
15
  thresholdRatio,
17
16
  withParam,
18
17
  } from '../../utils/requestDrawer'
@@ -21,6 +20,8 @@ import ApiBody from '../internal/ApiBody.vue'
21
20
  import ApiKeyValues from '../internal/ApiKeyValues.vue'
22
21
  import ApiStatusBadge from '../internal/ApiStatusBadge.vue'
23
22
  import ApiTesterBadge from '../internal/ApiTesterBadge.vue'
23
+ import RequestGeneral from '../internal/RequestGeneral.vue'
24
+ import RequestTiming from '../internal/RequestTiming.vue'
24
25
 
25
26
  // One captured request, in the DMS drawer on the right, which a request
26
27
  // table's row opens (a `drawer` row action, `src/pages/request-table.ts`).
@@ -36,54 +37,6 @@ import ApiTesterBadge from '../internal/ApiTesterBadge.vue'
36
37
  // the top sticks under the drawer's header, both at its 16px inset with an
37
38
  // inset divider, and the content lays out by the drawer's width.
38
39
 
39
- interface RequestLog {
40
- _id: string
41
- timestamp: string
42
- method: string
43
- uri: string
44
- rawPath: string
45
- route: string
46
- routeRegistered: boolean
47
- statusCode: number
48
- /** Null when the request never reached a handler. */
49
- responseTimeMs: number | null
50
- slowThresholdMs: number
51
- /** How the route behaves lately; null for a route not registered. */
52
- routeLatency?: RouteLatency | null
53
- /** The method of the handler that answered (GET for a HEAD it served). */
54
- routeMethod?: string | null
55
- /** What the capture masked, section by section. */
56
- redactions: Redactions
57
- /** `tester` for a request the console's tester sent. */
58
- source?: string | null
59
- /** Where the API answers, for the URL and the cURL; null while unknown. */
60
- apiOrigin?: string | null
61
- /** The `x-request-id` it came with, when it is not its id. */
62
- requestId?: string | null
63
- ip?: string
64
- userAgent?: string
65
- pathParams?: Record<string, string>
66
- query?: Record<string, string | string[]>
67
- requestHeaders?: Record<string, string>
68
- requestBody?: string
69
- requestBodyTruncated?: boolean
70
- requestBodyOmitted?: string | null
71
- requestBodySize?: number | null
72
- responseHeaders?: Record<string, string>
73
- responseBody?: string
74
- responseBodyTruncated?: boolean
75
- responseBodyOmitted?: string | null
76
- responseBodySize?: number | null
77
- error?: { message: string; stack?: string }
78
- links: {
79
- route: string | null
80
- tester: string | null
81
- sameError: string | null
82
- sameRoute: string
83
- samePath?: string | null
84
- }
85
- }
86
-
87
40
  /** Where the console's pages are: the page on screen names its own links. */
88
41
  const MODULE_BASE = '/modules/api'
89
42
  /** Pages a link to the request logs may name as its origin (`?from=`). */
@@ -260,19 +213,18 @@ const curl = computed(() =>
260
213
  )
261
214
 
262
215
  async function copyCurl() {
263
- try {
264
- await navigator.clipboard.writeText(curl.value)
216
+ const copied = await navigator.clipboard.writeText(curl.value).then(
217
+ () => true,
218
+ () => false,
219
+ )
220
+ if (copied) {
265
221
  toast.add({
266
222
  title: t('api.request.curl_copied'),
267
223
  color: 'success',
268
224
  icon: 'i-ph-check',
269
225
  })
270
- } catch {
271
- toast.add({
272
- title: t('api.request.copy_failed'),
273
- color: 'error',
274
- icon: 'i-ph-warning',
275
- })
226
+ } else {
227
+ toast.add({ title: t('api.request.copy_failed'), color: 'warning' })
276
228
  }
277
229
  }
278
230
 
@@ -513,102 +465,15 @@ const dateFormat = useDateFormat()
513
465
  />
514
466
  </section>
515
467
 
516
- <section class="flex flex-col gap-2">
517
- <DmsEyebrow :label="t('api.request.general')" />
518
- <dl
519
- class="grid grid-cols-[max-content_minmax(0,1fr)] gap-x-4 gap-y-1.5 text-[12.5px]"
520
- >
521
- <template v-for="row in general" :key="row.key">
522
- <dt class="text-muted">{{ row.label }}</dt>
523
- <dd class="text-default flex min-w-0 items-start gap-1">
524
- <bdi
525
- class="min-w-0 font-mono text-[12px] [overflow-wrap:anywhere]"
526
- >
527
- {{ row.value }}
528
- </bdi>
529
- <DmsCopyButton
530
- v-if="row.copy"
531
- :value="row.value"
532
- class="-my-1.5"
533
- />
534
- </dd>
535
- </template>
536
- <template v-if="isTester">
537
- <dt class="text-muted">{{ t('api.request.fields.source') }}</dt>
538
- <dd class="text-default">{{ t('api.request.source_tester') }}</dd>
539
- </template>
540
- </dl>
541
- </section>
468
+ <RequestGeneral :general="general" :is-tester="isTester" />
542
469
 
543
- <section class="flex flex-col gap-2">
544
- <DmsEyebrow :label="t('api.request.timing')" />
545
- <template v-if="timing">
546
- <div class="flex flex-wrap items-baseline gap-x-2 gap-y-1">
547
- <span class="text-highlighted font-mono text-xl font-semibold">
548
- {{ ms(log.responseTimeMs ?? 0) }}
549
- </span>
550
- <span
551
- class="text-xs"
552
- :class="
553
- timing.slow ? 'text-warning font-semibold' : 'text-dimmed'
554
- "
555
- >
556
- {{
557
- timing.slow
558
- ? t('api.request.slow_ratio', { ratio })
559
- : t('api.request.threshold_ratio', { ratio })
560
- }}
561
- </span>
562
- </div>
563
- <div
564
- class="bg-elevated relative my-1 h-2 rounded-full"
565
- role="meter"
566
- :aria-label="t('api.request.meter_label')"
567
- aria-valuemin="0"
568
- :aria-valuemax="Math.round(timing.max)"
569
- :aria-valuenow="Math.round(log.responseTimeMs ?? 0)"
570
- :aria-valuetext="ms(log.responseTimeMs ?? 0)"
571
- >
572
- <div
573
- class="h-full rounded-full"
574
- :class="timing.slow ? 'bg-warning' : 'bg-primary'"
575
- :style="{ width: `${timing.share}%` }"
576
- />
577
- <div
578
- class="bg-inverted/60 absolute -inset-y-1 w-0.5 rounded-full"
579
- :style="{ left: `${timing.threshold}%` }"
580
- aria-hidden="true"
581
- />
582
- </div>
583
- <!-- The threshold, then how the route does lately: each its own
584
- line, at every width. -->
585
- <div class="text-dimmed flex flex-col gap-1 text-xs">
586
- <p>
587
- {{
588
- t('api.request.threshold', {
589
- threshold: ms(log.slowThresholdMs),
590
- })
591
- }}
592
- </p>
593
- <p v-if="log.routeLatency" class="font-mono tabular-nums">
594
- {{
595
- t(
596
- 'api.request.route_latency',
597
- {
598
- days: count(log.routeLatency.windowDays),
599
- p50: ms(log.routeLatency.p50),
600
- p95: ms(log.routeLatency.p95),
601
- },
602
- log.routeLatency.windowDays,
603
- )
604
- }}
605
- </p>
606
- </div>
607
- </template>
608
- <p v-else class="text-dimmed text-sm">
609
- {{ t('api.request.not_measured_hint') }}
610
- </p>
611
- </section>
470
+ <RequestTiming
471
+ :log="log"
472
+ :timing="timing"
473
+ :ratio="ratio"
474
+ :ms="ms"
475
+ :count="count"
476
+ />
612
477
 
613
478
  <section class="flex flex-col gap-2">
614
479
  <DmsEyebrow :label="t('api.request.path_params')" />
@@ -5,6 +5,7 @@ import { hasRequestBody, statusText } from '../../utils/http'
5
5
  import { listedMessages } from '../../utils/routeExplorer'
6
6
  import { routeSnippetRequest, toCurl, toFetch } from '../../utils/snippets'
7
7
  import ApiStatusBadge from '../internal/ApiStatusBadge.vue'
8
+ import RouteInternals from '../internal/RouteInternals.vue'
8
9
 
9
10
  // The contract of a route, read first: how to call it, who may, what it
10
11
  // expects and what it answers. Everything is inferred, and the block says so:
@@ -156,24 +157,6 @@ const latency = computed(() => {
156
157
 
157
158
  const exampleResponse = computed(() => route.value?.contract.exampleResponse)
158
159
 
159
- // Internals worth a row: a parameter the introspection could name or place,
160
- // a class member. An unnamed `unknown` row says nothing.
161
- const internalParameters = computed(() =>
162
- (route.value?.inspection.parameters ?? []).filter(
163
- (parameter) => parameter.name || parameter.source !== 'unknown',
164
- ),
165
- )
166
- const internalProperties = computed(
167
- () => route.value?.inspection.properties ?? [],
168
- )
169
-
170
- const PIPELINE_TONE = {
171
- prefix: 'info',
172
- handler: 'primary',
173
- postfix: 'neutral',
174
- monitor: 'neutral',
175
- } as const
176
-
177
160
  function openTester() {
178
161
  void router.push({ query: { ...currentRoute.query, tab: '2' } })
179
162
  }
@@ -472,139 +455,7 @@ function exampleOf(value: string | number | boolean | null | undefined) {
472
455
  </p>
473
456
  </DmsCard>
474
457
 
475
- <DmsCard :title="t('api.routes.docs.pipeline')" :padded="false">
476
- <p class="text-dimmed px-4 pt-3 text-xs">
477
- {{ t('api.routes.docs.pipeline_description') }}
478
- </p>
479
- <ol class="flex flex-col gap-0 px-4 py-3">
480
- <li
481
- v-for="(step, index) in route.pipeline"
482
- :key="`${step.kind}-${step.name}-${index}`"
483
- class="flex items-center gap-3 py-1.5"
484
- >
485
- <span class="text-dimmed w-5 text-right font-mono text-[11px]">
486
- {{ index + 1 }}
487
- </span>
488
- <span class="min-w-0 grow">
489
- <span
490
- class="text-highlighted block truncate font-mono text-[12.5px]"
491
- :class="
492
- step.kind === 'handler' && 'text-primary font-semibold'
493
- "
494
- >
495
- {{ step.name }}
496
- </span>
497
- <span class="text-dimmed font-mono text-[11px]">
498
- {{ t(`api.routes.docs.kind_${step.kind}`) }} ·
499
- {{ step.location }}
500
- </span>
501
- </span>
502
- <DmsStatusPill
503
- v-if="step.isAuth"
504
- tone="info"
505
- size="sm"
506
- dot="none"
507
- icon="i-ph-lock-simple"
508
- :label="t('api.routes.docs.auth')"
509
- />
510
- <DmsStatusPill
511
- :tone="PIPELINE_TONE[step.kind]"
512
- size="sm"
513
- dot="none"
514
- :label="t(`api.routes.docs.kind_${step.kind}`)"
515
- />
516
- </li>
517
- </ol>
518
- </DmsCard>
519
-
520
- <details
521
- v-if="internalParameters.length || internalProperties.length"
522
- class="dms-card group overflow-hidden rounded-lg"
523
- >
524
- <summary
525
- class="text-muted hover:text-default flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm"
526
- >
527
- <UIcon
528
- name="i-ph-caret-right"
529
- class="size-3.5 transition-transform group-open:rotate-90"
530
- />
531
- {{ t('api.routes.docs.internals') }}
532
- <span class="text-dimmed text-xs">
533
- ·
534
- {{
535
- t(
536
- 'api.routes.docs.internals_parameters',
537
- { count: internalParameters.length },
538
- internalParameters.length,
539
- )
540
- }},
541
- {{
542
- t(
543
- 'api.routes.docs.internals_members',
544
- { count: internalProperties.length },
545
- internalProperties.length,
546
- )
547
- }}
548
- </span>
549
- </summary>
550
- <div class="border-default overflow-x-auto border-t">
551
- <table class="w-full text-[12px]">
552
- <thead class="text-dimmed font-mono text-[10.5px] uppercase">
553
- <tr>
554
- <th class="px-4 py-2 text-left font-medium">#</th>
555
- <th class="px-2 py-2 text-left font-medium">
556
- {{ t('api.routes.docs.internal_name') }}
557
- </th>
558
- <th class="px-2 py-2 text-left font-medium">
559
- {{ t('api.routes.docs.internal_source') }}
560
- </th>
561
- <th class="px-2 py-2 text-left font-medium">
562
- {{ t('api.routes.docs.internal_type') }}
563
- </th>
564
- <th class="px-4 py-2 text-right font-medium">
565
- {{ t('api.routes.docs.internal_modifiers') }}
566
- </th>
567
- </tr>
568
- </thead>
569
- <tbody class="divide-default divide-y font-mono">
570
- <tr
571
- v-for="parameter in internalParameters"
572
- :key="`p-${parameter.index}`"
573
- >
574
- <td class="text-dimmed px-4 py-1.5">{{ parameter.index }}</td>
575
- <td class="px-2 py-1.5">
576
- {{ parameter.name ?? parameter.decorator ?? '—' }}
577
- </td>
578
- <td class="text-muted px-2 py-1.5">
579
- {{ parameter.hint ?? parameter.source }}
580
- </td>
581
- <td class="text-muted px-2 py-1.5">
582
- {{ parameter.inferredType }}
583
- </td>
584
- <td class="text-muted px-4 py-1.5 text-right">
585
- {{ parameter.modifierCount }}
586
- </td>
587
- </tr>
588
- <tr
589
- v-for="property in internalProperties"
590
- :key="`m-${property.key}`"
591
- >
592
- <td class="text-dimmed px-4 py-1.5">—</td>
593
- <td class="px-2 py-1.5">{{ property.key }}</td>
594
- <td class="text-muted px-2 py-1.5">
595
- {{ property.decorator }}
596
- </td>
597
- <td class="text-muted px-2 py-1.5">
598
- {{ t('api.routes.docs.class_member') }}
599
- </td>
600
- <td class="text-muted px-4 py-1.5 text-right">
601
- {{ property.modifierCount }}
602
- </td>
603
- </tr>
604
- </tbody>
605
- </table>
606
- </div>
607
- </details>
458
+ <RouteInternals :route="route" />
608
459
  </div>
609
460
  </div>
610
461
  </div>
@@ -163,19 +163,18 @@ async function copyCurl() {
163
163
  hasRequestBody(route.value.method),
164
164
  ),
165
165
  )
166
- try {
167
- await navigator.clipboard.writeText(curl)
166
+ const copied = await navigator.clipboard.writeText(curl).then(
167
+ () => true,
168
+ () => false,
169
+ )
170
+ if (copied) {
168
171
  toast.add({
169
172
  title: t('api.request.curl_copied'),
170
173
  color: 'success',
171
174
  icon: 'i-ph-check',
172
175
  })
173
- } catch {
174
- toast.add({
175
- title: t('api.request.copy_failed'),
176
- color: 'error',
177
- icon: 'i-ph-warning',
178
- })
176
+ } else {
177
+ toast.add({ title: t('api.request.copy_failed'), color: 'warning' })
179
178
  }
180
179
  }
181
180
  </script>