@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.
- package/README.md +18 -6
- package/dist/automation/query-request-logs.js.map +1 -1
- package/dist/automation/route-unhealthy.js.map +1 -1
- package/dist/db/models/request_log.model.js.map +1 -1
- package/dist/db/models/request_log.search.js +3 -3
- package/dist/db/models/request_log.search.js.map +1 -1
- package/dist/db/tables/request_log.table.js.map +1 -1
- package/dist/guards.d.ts +22 -0
- package/dist/guards.js +57 -0
- package/dist/guards.js.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/pages/blocks.d.ts +2 -2
- package/dist/pages/blocks.js +2 -2
- package/dist/pages/blocks.js.map +1 -1
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/logs.js.map +1 -1
- package/dist/pages/module.js +8 -2
- package/dist/pages/module.js.map +1 -1
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/request-table.js.map +1 -1
- package/dist/pages/routes.js.map +1 -1
- package/dist/pages/settings.js +1 -3
- package/dist/pages/settings.js.map +1 -1
- package/dist/routes/logs.js.map +1 -1
- package/dist/routes/routes.js.map +1 -1
- package/dist/routes/settings.d.ts +2 -1
- package/dist/routes/settings.js +1 -1
- package/dist/routes/settings.js.map +1 -1
- package/dist/services/activity.js.map +1 -1
- package/dist/services/attention.js +1 -1
- package/dist/services/attention.js.map +1 -1
- package/dist/services/health-rules.js.map +1 -1
- package/dist/services/introspection/auth.js +1 -2
- package/dist/services/introspection/auth.js.map +1 -1
- package/dist/services/introspection/decorators.d.ts +3 -1
- package/dist/services/introspection/decorators.js +28 -17
- package/dist/services/introspection/decorators.js.map +1 -1
- package/dist/services/introspection/errors.d.ts +1 -1
- package/dist/services/introspection/errors.js +0 -2
- package/dist/services/introspection/errors.js.map +1 -1
- package/dist/services/introspection/index.d.ts +1 -1
- package/dist/services/introspection/index.js +24 -18
- package/dist/services/introspection/index.js.map +1 -1
- package/dist/services/introspection/probe.js.map +1 -1
- package/dist/services/links.js +4 -4
- package/dist/services/links.js.map +1 -1
- package/dist/services/live.d.ts +3 -2
- package/dist/services/live.js.map +1 -1
- package/dist/services/overview-lists.d.ts +4 -4
- package/dist/services/overview-lists.js.map +1 -1
- package/dist/services/overview.d.ts +4 -4
- package/dist/services/overview.js.map +1 -1
- package/dist/services/request-log/capture.d.ts +5 -14
- package/dist/services/request-log/capture.js +28 -76
- package/dist/services/request-log/capture.js.map +1 -1
- package/dist/services/request-log/console-traffic.d.ts +12 -0
- package/dist/services/request-log/console-traffic.js +69 -0
- package/dist/services/request-log/console-traffic.js.map +1 -0
- package/dist/services/request-log/list.d.ts +1 -1
- package/dist/services/request-log/list.js.map +1 -1
- package/dist/services/request-log/read.js.map +1 -1
- package/dist/services/request-log/redaction.js +7 -6
- package/dist/services/request-log/redaction.js.map +1 -1
- package/dist/services/request-log/util.d.ts +6 -3
- package/dist/services/request-log/util.js +17 -30
- package/dist/services/request-log/util.js.map +1 -1
- package/dist/services/route-catalog.js +2 -2
- package/dist/services/route-catalog.js.map +1 -1
- package/dist/services/route-contract.d.ts +6 -1
- package/dist/services/route-contract.js +11 -12
- package/dist/services/route-contract.js.map +1 -1
- package/dist/services/route-health.d.ts +5 -1
- package/dist/services/route-health.js +4 -1
- package/dist/services/route-health.js.map +1 -1
- package/dist/services/route-statistics.d.ts +3 -4
- package/dist/services/route-statistics.js.map +1 -1
- package/dist/services/routes-sync.d.ts +2 -2
- package/dist/services/routes-sync.js +1 -2
- package/dist/services/routes-sync.js.map +1 -1
- package/dist/services/scope.js +1 -1
- package/dist/services/scope.js.map +1 -1
- package/dist/services/settings-form.d.ts +4 -3
- package/dist/services/settings-form.js +1 -1
- package/dist/services/settings-form.js.map +1 -1
- package/dist/services/settings.js.map +1 -1
- package/dist/services/statistics-write.js +4 -7
- package/dist/services/statistics-write.js.map +1 -1
- package/dist/services/traffic-samples.js.map +1 -1
- package/dist/services/traffic.js +2 -1
- package/dist/services/traffic.js.map +1 -1
- package/dist/services/window.js +1 -1
- package/dist/services/window.js.map +1 -1
- package/dist/types/constants.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/json.d.ts +2 -0
- package/dist/types/json.js +3 -0
- package/dist/types/json.js.map +1 -0
- package/frontend-vue/app/components/blocks/HealthHero.vue +8 -117
- package/frontend-vue/app/components/blocks/RequestDetail.vue +18 -153
- package/frontend-vue/app/components/blocks/RouteDocumentation.vue +2 -151
- package/frontend-vue/app/components/blocks/RouteHeader.vue +7 -8
- package/frontend-vue/app/components/blocks/RouteTester.vue +58 -1682
- package/frontend-vue/app/components/blocks/RouteTree.vue +16 -81
- package/frontend-vue/app/components/internal/HealthHeroMetrics.vue +50 -0
- package/frontend-vue/app/components/internal/RequestGeneral.vue +32 -0
- package/frontend-vue/app/components/internal/RequestTiming.vue +85 -0
- package/frontend-vue/app/components/internal/RouteInternals.vue +159 -0
- package/frontend-vue/app/components/internal/RouteTesterRequest.vue +225 -0
- package/frontend-vue/app/components/internal/RouteTesterResponse.vue +272 -0
- package/frontend-vue/app/components/internal/RouteTreeFooter.vue +62 -0
- package/frontend-vue/app/components/internal/routeTester/context.ts +8 -0
- package/frontend-vue/app/components/internal/routeTester/useTesterExtras.ts +284 -0
- package/frontend-vue/app/components/internal/routeTester/useTesterFlow.ts +637 -0
- package/frontend-vue/app/components/internal/routeTester/useTesterState.ts +601 -0
- package/frontend-vue/app/utils/health.ts +73 -0
- package/frontend-vue/app/utils/requestDrawer.ts +49 -0
- package/frontend-vue/app/utils/routeExplorer.ts +34 -0
- package/frontend-vue/app/utils/testerMasks.ts +34 -0
- package/frontend-vue/app/utils/testerRequest.ts +14 -38
- package/frontend-vue/build/backend-boundary.ts +122 -0
- package/frontend-vue/dms.frontend.build.ts +2 -0
- package/frontend-vue/eslint.config.mjs +13 -0
- package/frontend-vue/package.json +6 -3
- package/frontend-vue/pnpm-lock.yaml +348 -153
- package/frontend-vue/tests/apiErrorPresentation.test.ts +115 -0
- package/frontend-vue/tests/backend-boundary.test.ts +180 -0
- package/frontend-vue/tests/dmsServer.test.ts +11 -23
- package/frontend-vue/tests/registration.test.ts +22 -6
- package/frontend-vue/tests/stubs/server.ts +19 -0
- package/frontend-vue/tests/testerRequest.test.ts +14 -0
- package/frontend-vue/vitest.config.ts +16 -0
- package/package.json +16 -4
- package/skills/dms-api/SKILL.md +1 -1
- package/skills/dms-api/cases.json +47 -0
|
@@ -255,3 +255,52 @@ export function requestPivots(log: {
|
|
|
255
255
|
})
|
|
256
256
|
return pivots
|
|
257
257
|
}
|
|
258
|
+
|
|
259
|
+
/** One captured request, as the logs' detail route answers it. */
|
|
260
|
+
export interface RequestLog {
|
|
261
|
+
_id: string
|
|
262
|
+
timestamp: string
|
|
263
|
+
method: string
|
|
264
|
+
uri: string
|
|
265
|
+
rawPath: string
|
|
266
|
+
route: string
|
|
267
|
+
routeRegistered: boolean
|
|
268
|
+
statusCode: number
|
|
269
|
+
/** Null when the request never reached a handler. */
|
|
270
|
+
responseTimeMs: number | null
|
|
271
|
+
slowThresholdMs: number
|
|
272
|
+
/** How the route behaves lately; null for a route not registered. */
|
|
273
|
+
routeLatency?: RouteLatency | null
|
|
274
|
+
/** The method of the handler that answered (GET for a HEAD it served). */
|
|
275
|
+
routeMethod?: string | null
|
|
276
|
+
/** What the capture masked, section by section. */
|
|
277
|
+
redactions: Redactions
|
|
278
|
+
/** `tester` for a request the console's tester sent. */
|
|
279
|
+
source?: string | null
|
|
280
|
+
/** Where the API answers, for the URL and the cURL; null while unknown. */
|
|
281
|
+
apiOrigin?: string | null
|
|
282
|
+
/** The `x-request-id` it came with, when it is not its id. */
|
|
283
|
+
requestId?: string | null
|
|
284
|
+
ip?: string
|
|
285
|
+
userAgent?: string
|
|
286
|
+
pathParams?: Record<string, string>
|
|
287
|
+
query?: Record<string, string | string[]>
|
|
288
|
+
requestHeaders?: Record<string, string>
|
|
289
|
+
requestBody?: string
|
|
290
|
+
requestBodyTruncated?: boolean
|
|
291
|
+
requestBodyOmitted?: string | null
|
|
292
|
+
requestBodySize?: number | null
|
|
293
|
+
responseHeaders?: Record<string, string>
|
|
294
|
+
responseBody?: string
|
|
295
|
+
responseBodyTruncated?: boolean
|
|
296
|
+
responseBodyOmitted?: string | null
|
|
297
|
+
responseBodySize?: number | null
|
|
298
|
+
error?: { message: string; stack?: string }
|
|
299
|
+
links: {
|
|
300
|
+
route: string | null
|
|
301
|
+
tester: string | null
|
|
302
|
+
sameError: string | null
|
|
303
|
+
sameRoute: string
|
|
304
|
+
samePath?: string | null
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -23,12 +23,46 @@ export interface ExplorerRoute {
|
|
|
23
23
|
state: RouteState
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/** A route as the Routes page lists it. */
|
|
27
|
+
export interface RouteRow extends ExplorerRoute {
|
|
28
|
+
controller: string | null
|
|
29
|
+
handler: string
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
export interface RouteFolder<T extends ExplorerRoute = ExplorerRoute> {
|
|
27
33
|
path: string
|
|
28
34
|
routes: T[]
|
|
29
35
|
worst: RouteState
|
|
30
36
|
}
|
|
31
37
|
|
|
38
|
+
/** The methods the route list filters on, beside "all". */
|
|
39
|
+
export const METHOD_FILTERS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']
|
|
40
|
+
/** Rest after the last ↑ / ↓ before the page loads the route reached. */
|
|
41
|
+
export const KEYBOARD_SETTLE_MS = 150
|
|
42
|
+
/** Room kept above or below the active route as the list scrolls to it. */
|
|
43
|
+
export const REVEAL_MARGIN_PX = 8
|
|
44
|
+
|
|
45
|
+
/** A shape per issue, so slow and a high 4xx rate never read alike. */
|
|
46
|
+
export const STATE_ICON: Partial<
|
|
47
|
+
Record<RouteState, { name: string; class: string }>
|
|
48
|
+
> = {
|
|
49
|
+
failing: { name: 'i-ph-x-circle-fill', class: 'text-error' },
|
|
50
|
+
slow: { name: 'i-ph-timer-bold', class: 'text-warning' },
|
|
51
|
+
'client-errors': { name: 'i-ph-warning-fill', class: 'text-warning' },
|
|
52
|
+
recovered: {
|
|
53
|
+
name: 'i-ph-arrow-counter-clockwise-bold',
|
|
54
|
+
class: 'text-info',
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
export const STATE_DOT: Record<RouteState, string> = {
|
|
58
|
+
failing: 'bg-error',
|
|
59
|
+
slow: 'bg-warning',
|
|
60
|
+
'client-errors': 'bg-warning',
|
|
61
|
+
recovered: 'bg-info',
|
|
62
|
+
healthy: 'bg-success',
|
|
63
|
+
idle: 'bg-(--ui-border-accented)',
|
|
64
|
+
}
|
|
65
|
+
|
|
32
66
|
/**
|
|
33
67
|
* Worst first, for the list and its folders: a route still slow outranks one
|
|
34
68
|
* that has recovered. The Overview orders its Needs attention its own way
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { REDACTED } from './snippets'
|
|
2
|
+
|
|
3
|
+
const literal = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
4
|
+
/** A masked value as the capture writes it, raw or URL-encoded. */
|
|
5
|
+
const MASK = `${literal(REDACTED)}|${literal(encodeURIComponent(REDACTED))}`
|
|
6
|
+
const REDACTED_PATTERN = new RegExp(MASK, 'gi')
|
|
7
|
+
const JSON_FIELD = new RegExp(
|
|
8
|
+
`"([^"\\\\]+)"\\s*:\\s*"${literal(REDACTED)}"`,
|
|
9
|
+
'g',
|
|
10
|
+
)
|
|
11
|
+
const FORM_FIELD = new RegExp(`(?:^|&)([^&=\\s]+)=(?:${MASK})`, 'gi')
|
|
12
|
+
|
|
13
|
+
/** How many masked values `text` still holds, raw or URL-encoded. */
|
|
14
|
+
export function countRedacted(text: string | undefined): number {
|
|
15
|
+
return text ? (text.match(REDACTED_PATTERN) ?? []).length : 0
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function hasRedacted(text: string | undefined): boolean {
|
|
19
|
+
return countRedacted(text) > 0
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Names of the masked fields of a JSON or form body, for the warning. */
|
|
23
|
+
export function redactedFields(text: string): string[] {
|
|
24
|
+
const names = new Set<string>()
|
|
25
|
+
for (const match of text.matchAll(JSON_FIELD)) names.add(match[1])
|
|
26
|
+
for (const match of text.matchAll(FORM_FIELD)) {
|
|
27
|
+
try {
|
|
28
|
+
names.add(decodeURIComponent(match[1].replace(/\+/g, ' ')))
|
|
29
|
+
} catch {
|
|
30
|
+
names.add(match[1])
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return [...names]
|
|
34
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { prettyBody } from './format'
|
|
2
2
|
import { acceptsRequestBody } from './http'
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
export { countRedacted, hasRedacted, redactedFields } from './testerMasks'
|
|
4
5
|
|
|
5
6
|
/** Editable request data; stored session credentials stay on the server. */
|
|
6
7
|
export interface TesterRequest {
|
|
@@ -156,11 +157,20 @@ export function neverSent(code: TesterErrorCode | undefined): boolean {
|
|
|
156
157
|
export class TesterError extends Error {
|
|
157
158
|
readonly code: TesterErrorCode
|
|
158
159
|
readonly status?: number
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
readonly response?: Response
|
|
161
|
+
readonly data?: unknown
|
|
162
|
+
|
|
163
|
+
constructor(
|
|
164
|
+
code: TesterErrorCode,
|
|
165
|
+
message: string,
|
|
166
|
+
status?: number,
|
|
167
|
+
failure?: { response: Response; data: unknown },
|
|
168
|
+
) {
|
|
161
169
|
super(message)
|
|
162
170
|
this.code = code
|
|
163
171
|
this.status = status
|
|
172
|
+
this.response = failure?.response
|
|
173
|
+
this.data = failure?.data
|
|
164
174
|
}
|
|
165
175
|
}
|
|
166
176
|
|
|
@@ -505,6 +515,7 @@ export async function sendTesterRequest(
|
|
|
505
515
|
code,
|
|
506
516
|
`API Tester request failed (${response.status})`,
|
|
507
517
|
response.status,
|
|
518
|
+
{ response, data: payload },
|
|
508
519
|
)
|
|
509
520
|
}
|
|
510
521
|
return (await response.json()) as TesterResponse
|
|
@@ -526,41 +537,6 @@ export function revealBidi(text: string): string {
|
|
|
526
537
|
)
|
|
527
538
|
}
|
|
528
539
|
|
|
529
|
-
// --- Masked values ---
|
|
530
|
-
|
|
531
|
-
const literal = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
532
|
-
/** A masked value as the capture writes it, raw or URL-encoded. */
|
|
533
|
-
const MASK = `${literal(REDACTED)}|${literal(encodeURIComponent(REDACTED))}`
|
|
534
|
-
const REDACTED_PATTERN = new RegExp(MASK, 'gi')
|
|
535
|
-
const JSON_FIELD = new RegExp(
|
|
536
|
-
`"([^"\\\\]+)"\\s*:\\s*"${literal(REDACTED)}"`,
|
|
537
|
-
'g',
|
|
538
|
-
)
|
|
539
|
-
const FORM_FIELD = new RegExp(`(?:^|&)([^&=\\s]+)=(?:${MASK})`, 'gi')
|
|
540
|
-
|
|
541
|
-
/** How many masked values `text` still holds, raw or URL-encoded. */
|
|
542
|
-
export function countRedacted(text: string | undefined): number {
|
|
543
|
-
return text ? (text.match(REDACTED_PATTERN) ?? []).length : 0
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
export function hasRedacted(text: string | undefined): boolean {
|
|
547
|
-
return countRedacted(text) > 0
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
/** Names of the masked fields of a JSON or form body, for the warning. */
|
|
551
|
-
export function redactedFields(text: string): string[] {
|
|
552
|
-
const names = new Set<string>()
|
|
553
|
-
for (const match of text.matchAll(JSON_FIELD)) names.add(match[1])
|
|
554
|
-
for (const match of text.matchAll(FORM_FIELD)) {
|
|
555
|
-
try {
|
|
556
|
-
names.add(decodeURIComponent(match[1].replace(/\+/g, ' ')))
|
|
557
|
-
} catch {
|
|
558
|
-
names.add(match[1])
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
return [...names]
|
|
562
|
-
}
|
|
563
|
-
|
|
564
540
|
// --- Replaying a captured request ---
|
|
565
541
|
|
|
566
542
|
/** A request as the logs' detail route returns it. */
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs'
|
|
2
|
+
import { dirname, isAbsolute, join, relative, sep } from 'node:path'
|
|
3
|
+
import type { DmsVitePluginEntry } from '#dms/frontend-build'
|
|
4
|
+
|
|
5
|
+
type VitePlugin = Extract<DmsVitePluginEntry, { name: string }>
|
|
6
|
+
|
|
7
|
+
const BACKEND_PACKAGE = '@antelopejs/dms-api'
|
|
8
|
+
const BACKEND_SOURCE = 'src'
|
|
9
|
+
const QUERY_OR_HASH = /[?#].*$/
|
|
10
|
+
|
|
11
|
+
const backendRoots = new Map<string, string | null>()
|
|
12
|
+
|
|
13
|
+
/** Whether a parsed manifest names its package. */
|
|
14
|
+
function isNamedManifest(value: unknown): value is { name: string } {
|
|
15
|
+
return (
|
|
16
|
+
typeof value === 'object' &&
|
|
17
|
+
value !== null &&
|
|
18
|
+
'name' in value &&
|
|
19
|
+
typeof value.name === 'string'
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The package name a `package.json` declares, or `undefined`. */
|
|
24
|
+
function packageName(manifest: string): string | undefined {
|
|
25
|
+
try {
|
|
26
|
+
const parsed: unknown = JSON.parse(readFileSync(manifest, 'utf8'))
|
|
27
|
+
return isNamedManifest(parsed) ? parsed.name : undefined
|
|
28
|
+
} catch {
|
|
29
|
+
return undefined
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The directory of the backend package that holds `directory`, or null. */
|
|
34
|
+
function backendRoot(directory: string): string | null {
|
|
35
|
+
const known = backendRoots.get(directory)
|
|
36
|
+
if (known !== undefined) {
|
|
37
|
+
return known
|
|
38
|
+
}
|
|
39
|
+
const manifest = join(directory, 'package.json')
|
|
40
|
+
const parent = dirname(directory)
|
|
41
|
+
let root: string | null = null
|
|
42
|
+
if (existsSync(manifest)) {
|
|
43
|
+
root = packageName(manifest) === BACKEND_PACKAGE ? directory : null
|
|
44
|
+
} else if (parent !== directory) {
|
|
45
|
+
root = backendRoot(parent)
|
|
46
|
+
}
|
|
47
|
+
backendRoots.set(directory, root)
|
|
48
|
+
return root
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The real path of a resolved module id when it lies under the `src`
|
|
53
|
+
* directory of the backend package, or `undefined`. The package that owns the
|
|
54
|
+
* file decides, not a path, so the answer is the same in the repository and in
|
|
55
|
+
* the build workspace. Virtual ids and ids that are not files are ignored.
|
|
56
|
+
*/
|
|
57
|
+
function backendSourceFile(id: string): string | undefined {
|
|
58
|
+
const path = id.replace(QUERY_OR_HASH, '')
|
|
59
|
+
if (!isAbsolute(path)) {
|
|
60
|
+
return undefined
|
|
61
|
+
}
|
|
62
|
+
let real: string
|
|
63
|
+
try {
|
|
64
|
+
real = realpathSync(path)
|
|
65
|
+
} catch {
|
|
66
|
+
return undefined
|
|
67
|
+
}
|
|
68
|
+
const root = backendRoot(dirname(real))
|
|
69
|
+
if (root === null) {
|
|
70
|
+
return undefined
|
|
71
|
+
}
|
|
72
|
+
return relative(root, real).split(sep)[0] === BACKEND_SOURCE
|
|
73
|
+
? real
|
|
74
|
+
: undefined
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Fails the build and the dev server when a module of the frontend resolves to
|
|
79
|
+
* a file under the `src` of the backend package: the browser reaches the
|
|
80
|
+
* backend only through its HTTP interface. It checks what the whole resolution
|
|
81
|
+
* chain returns, an id marked external included, so an alias is seen through
|
|
82
|
+
* and a symlink the resolver returns is followed to its real path, and it runs
|
|
83
|
+
* before the other plugins (`enforce: "pre"`). Vite builds workers with their
|
|
84
|
+
* own plugin list, so the plugin adds itself there too.
|
|
85
|
+
*
|
|
86
|
+
* antelopejs-sync writes this file from `@antelopejs/tooling-configs` and
|
|
87
|
+
* restores it on every run: change the plugin in the pack, not here.
|
|
88
|
+
*/
|
|
89
|
+
export function backendBoundary(): VitePlugin {
|
|
90
|
+
return {
|
|
91
|
+
...boundaryCheck(),
|
|
92
|
+
config: () => ({ worker: { plugins: () => [boundaryCheck()] } }),
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The check alone, as a worker build runs it. */
|
|
97
|
+
function boundaryCheck(): VitePlugin {
|
|
98
|
+
return {
|
|
99
|
+
name: `${BACKEND_PACKAGE}:backend-boundary`,
|
|
100
|
+
enforce: 'pre',
|
|
101
|
+
async resolveId(source, importer, options) {
|
|
102
|
+
const resolved = await this.resolve(source, importer, {
|
|
103
|
+
...options,
|
|
104
|
+
skipSelf: true,
|
|
105
|
+
})
|
|
106
|
+
if (resolved === null) {
|
|
107
|
+
return resolved
|
|
108
|
+
}
|
|
109
|
+
const file = backendSourceFile(resolved.id)
|
|
110
|
+
if (file === undefined) {
|
|
111
|
+
return resolved
|
|
112
|
+
}
|
|
113
|
+
const from =
|
|
114
|
+
importer === undefined
|
|
115
|
+
? 'an entry point'
|
|
116
|
+
: importer.replace(QUERY_OR_HASH, '')
|
|
117
|
+
return this.error(
|
|
118
|
+
`Backend boundary: ${from} imports ${file}, which is under the src of ${BACKEND_PACKAGE}. The frontend reaches the backend only through its HTTP interface.`,
|
|
119
|
+
)
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { defineDmsFrontendBuild } from '#dms/frontend-build'
|
|
2
|
+
import { backendBoundary } from './build/backend-boundary.ts'
|
|
2
3
|
|
|
3
4
|
// The composables are shared by the blocks; the utils are imported by path,
|
|
4
5
|
// so their names never compete with the DMS's own auto-imported helpers.
|
|
5
6
|
export default defineDmsFrontendBuild((build) => {
|
|
6
7
|
build.registerAutoImports(['app/composables'])
|
|
8
|
+
build.registerVitePlugins(() => [backendBoundary()])
|
|
7
9
|
})
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import antiSlop from '@antelopejs/tooling-configs/oxc/anti-slop'
|
|
2
|
+
import guardrails from '@antelopejs/tooling-configs/oxc/guardrails'
|
|
1
3
|
import vue from 'eslint-plugin-vue'
|
|
2
4
|
import typescript from '@typescript-eslint/parser'
|
|
3
5
|
|
|
@@ -13,4 +15,15 @@ export default [
|
|
|
13
15
|
languageOptions: { parserOptions: { parser: typescript } },
|
|
14
16
|
rules: { 'vue/multi-word-component-names': 'off' },
|
|
15
17
|
},
|
|
18
|
+
{
|
|
19
|
+
files: ['tests/**/*.ts'],
|
|
20
|
+
plugins: { antelopejs: guardrails, 'anti-slop': antiSlop },
|
|
21
|
+
rules: {
|
|
22
|
+
'antelopejs/no-fs-read-in-tests': 'error',
|
|
23
|
+
'antelopejs/no-constant-value-assertion': 'error',
|
|
24
|
+
'antelopejs/no-self-import-in-tests': 'error',
|
|
25
|
+
'anti-slop/no-module-mocking': 'error',
|
|
26
|
+
'antelopejs/no-typeof-function-only-test': 'error',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
16
29
|
]
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
"main": "./dms.frontend.ts",
|
|
7
7
|
"packageManager": "pnpm@10.6.5",
|
|
8
8
|
"engines": {
|
|
9
|
-
"@antelopejs/dms-frontend": ">=0.9.
|
|
9
|
+
"@antelopejs/dms-frontend": ">=0.9.2 <0.10.0"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"dev": "pnpm --dir ../playground frontend:dev",
|
|
13
13
|
"build": "pnpm --dir ../playground exec ajs dms build",
|
|
14
14
|
"typecheck": "pnpm --dir \"${DMS_FRONTEND_WORKSPACE:?Set DMS_FRONTEND_WORKSPACE to the generated Inertia workspace}\" typecheck",
|
|
15
15
|
"format": "prettier --write .",
|
|
16
|
-
"lint": "eslint .",
|
|
16
|
+
"lint": "eslint . && node ../node_modules/@antelopejs/dms/frontend-vue/scripts/check-api-error-presentation.mjs app",
|
|
17
17
|
"lint:fix": "eslint . --fix",
|
|
18
18
|
"test": "vitest run"
|
|
19
19
|
},
|
|
@@ -21,12 +21,15 @@
|
|
|
21
21
|
"vue": "^3.5.18"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
+
"@antelopejs/tooling-configs": "^0.2.11",
|
|
24
25
|
"@typescript-eslint/parser": "^8.0.0",
|
|
25
|
-
"
|
|
26
|
+
"@vitejs/plugin-vue": "^6.0.0",
|
|
27
|
+
"eslint": "^9.39.5",
|
|
26
28
|
"eslint-plugin-vue": "^10.0.0",
|
|
27
29
|
"prettier": "^3.5.3",
|
|
28
30
|
"prettier-plugin-tailwindcss": "^0.6.11",
|
|
29
31
|
"typescript": "^6.0.3",
|
|
32
|
+
"vite": "^7.1.10",
|
|
30
33
|
"vitest": "^3.2.4"
|
|
31
34
|
}
|
|
32
35
|
}
|