@antelopejs/dms-api 0.7.2-next.119.g2a575a1 → 0.7.2-next.123.g4338d33

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 CHANGED
@@ -57,7 +57,7 @@ pnpm --dir playground traffic # a few hundred demo requests
57
57
  | `@antelopejs/interface-core` | `>=0.5.1 <0.6.0` | `0.5.1` |
58
58
  | `@antelopejs/interface-database` | `>=0.4.0 <0.5.0` | `0.4.1` |
59
59
  | `@antelopejs/interface-database-decorators` | `>=0.5.2 <0.6.0` | `0.5.2` |
60
- | `@antelopejs/interface-dms` | `>=0.14.0 <0.15.0` | `0.14.0` |
60
+ | `@antelopejs/interface-dms` | `>=0.14.0 <0.15.0` | `0.14.2` |
61
61
  | `@antelopejs/interface-dms-automation` | `>=0.7.0 <0.8.0` | `0.7.0` |
62
62
 
63
63
  <!-- antelopejs-docs-compat:end -->
@@ -4,6 +4,9 @@ settings:
4
4
  autoInstallPeers: true
5
5
  excludeLinksFromLockfile: false
6
6
 
7
+ overrides:
8
+ '@antelopejs/interface-dms': '>=0.14.0 <0.15.0'
9
+
7
10
  importers:
8
11
 
9
12
  .:
@@ -45,14 +45,6 @@ const UNSAFE_PATH = /[\\#\u0000- \u007f]/
45
45
  // Decoded path segments need the same boundary after every decoding pass.
46
46
  const UNSAFE_DECODED_SEGMENT = /[\\/#\u0000- \u007f]/
47
47
 
48
- interface TesterInput {
49
- path?: unknown
50
- method?: unknown
51
- headers?: unknown
52
- body?: unknown
53
- useSession?: unknown
54
- }
55
-
56
48
  interface ValidInput {
57
49
  method: string
58
50
  headers: Record<string, string>
@@ -117,33 +109,46 @@ function filteredHeaders(input: HeadersInit, allowAuthorization = false) {
117
109
  )
118
110
  }
119
111
 
120
- function validateInput(event: DmsServerEvent, input: TesterInput) {
121
- if (!input || typeof input !== 'object' || Array.isArray(input))
122
- invalidInput()
112
+ function isRecord(value: unknown): value is Record<string, unknown> {
113
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
114
+ }
115
+
116
+ function stringRecord(value: unknown): Record<string, string> {
117
+ if (!isRecord(value)) invalidInput()
118
+ return Object.fromEntries(
119
+ Object.entries(value).map(([name, entry]): [string, string] => {
120
+ if (typeof entry !== 'string') invalidInput()
121
+ return [name, entry]
122
+ }),
123
+ )
124
+ }
125
+
126
+ function validateInput(
127
+ event: DmsServerEvent,
128
+ input: unknown,
129
+ ): { target: URL; input: ValidInput } {
130
+ if (!isRecord(input)) invalidInput()
131
+ const { method, useSession, body } = input
123
132
  if (
124
- typeof input.method !== 'string' ||
125
- !METHODS.has(input.method) ||
126
- typeof input.useSession !== 'boolean'
133
+ typeof method !== 'string' ||
134
+ !METHODS.has(method) ||
135
+ typeof useSession !== 'boolean'
127
136
  )
128
137
  invalidInput()
129
- const headers = input.headers
130
- if (!headers || typeof headers !== 'object' || Array.isArray(headers))
131
- invalidInput()
132
- if (Object.values(headers).some((value) => typeof value !== 'string'))
133
- invalidInput()
138
+ const headers = stringRecord(input.headers)
134
139
  if (
135
- input.body !== undefined &&
136
- (typeof input.body !== 'string' || ['GET', 'HEAD'].includes(input.method))
140
+ body !== undefined &&
141
+ (typeof body !== 'string' || ['GET', 'HEAD'].includes(method))
137
142
  )
138
143
  invalidInput()
139
144
  try {
140
- new Headers(headers as Record<string, string>)
145
+ new Headers(headers)
141
146
  } catch {
142
147
  invalidInput()
143
148
  }
144
149
  return {
145
150
  target: targetUrl(event, input.path),
146
- input: input as ValidInput,
151
+ input: { method, headers, body, useSession },
147
152
  }
148
153
  }
149
154
 
@@ -237,7 +242,7 @@ function failure(status: number, error: string): Response {
237
242
  }
238
243
 
239
244
  function inputFailureStatus(error: unknown): number | undefined {
240
- const status = (error as { status?: unknown } | undefined)?.status
245
+ const status = isRecord(error) ? error.status : undefined
241
246
  return status === 400 || status === 413 ? status : undefined
242
247
  }
243
248
 
@@ -249,10 +254,7 @@ export async function testerRoute(event: DmsServerEvent): Promise<Response> {
249
254
  try {
250
255
  const session = event.session.read()
251
256
  if (!session?.accessToken) return failure(401, 'Not authenticated')
252
- const { input, target } = validateInput(
253
- event,
254
- await event.readJson<TesterInput>(),
255
- )
257
+ const { input, target } = validateInput(event, await event.readJson())
256
258
  const signal = AbortSignal.timeout(REQUEST_TIMEOUT_MS)
257
259
  if (!(await isOwner(event, session, signal)))
258
260
  return failure(403, 'Forbidden')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms-api",
3
- "version": "0.7.2-next.119.g2a575a1",
3
+ "version": "0.7.2-next.123.g4338d33",
4
4
  "description": "API console for the AntelopeJS DMS: API health, request logs, per-route statistics, inferred contracts and a request tester.",
5
5
  "keywords": [
6
6
  "antelopejs",
@@ -30,27 +30,6 @@
30
30
  "provenance": true,
31
31
  "registry": "https://registry.npmjs.org/"
32
32
  },
33
- "scripts": {
34
- "build": "rimraf dist && tsc",
35
- "dev": "ajs project dev -w -p playground",
36
- "lint:fix": "oxlint --fix --max-warnings=1000000 && oxfmt . && pnpm --dir frontend-vue lint:fix",
37
- "lint": "oxlint && pnpm --dir frontend-vue lint",
38
- "typecheck": "tsc -p tests",
39
- "test": "vitest run && pnpm --dir frontend-vue test",
40
- "format": "oxfmt . && pnpm --dir frontend-vue format",
41
- "frontend:dev": "cd playground && pnpm frontend:dev",
42
- "prepack": "pnpm run build",
43
- "knip": "knip --dependencies",
44
- "knip:all": "knip",
45
- "prepare": "if [ -e .git ] && command -v git >/dev/null 2>&1 && command -v lefthook >/dev/null 2>&1 && GIT_DIR=.git GIT_WORK_TREE=. git rev-parse --git-dir >/dev/null 2>&1; then GIT_DIR=.git GIT_WORK_TREE=. lefthook install; fi",
46
- "checks": "antelopejs-checks",
47
- "size": "antelopejs-check-size",
48
- "sync": "antelopejs-sync",
49
- "sync:check": "antelopejs-sync --check",
50
- "format:check": "oxfmt --check .",
51
- "suppressions": "antelopejs-suppressions",
52
- "suppressions:update": "antelopejs-suppressions --update"
53
- },
54
33
  "dependencies": {
55
34
  "@antelopejs/interface-api": ">=0.3.3 <0.4.0",
56
35
  "@antelopejs/interface-api-util": ">=0.3.0 <0.4.0",
@@ -63,12 +42,15 @@
63
42
  },
64
43
  "devDependencies": {
65
44
  "@antelopejs/core": "~1.24.0",
66
- "@antelopejs/dms": ">=0.20.2 <0.21.0",
45
+ "@antelopejs/dms": "0.20.8-next.936.g1313dd7",
46
+ "@antelopejs/dms-frontend": ">=0.11.4 <0.12.0",
67
47
  "@antelopejs/interface-data-api": ">=0.8.0 <0.9.0",
68
- "@antelopejs/tooling-configs": ">=0.8.0 <0.9.0",
48
+ "@antelopejs/tooling-configs": "0.8.1-next.372.g1d7ef26",
49
+ "@playwright/test": "~1.65.0",
69
50
  "@types/node": "^24.0.0",
70
51
  "knip": "^6.34.0",
71
52
  "lefthook": "^2.2.2",
53
+ "mongodb-memory-server-core": "^11.0.1",
72
54
  "oxfmt": "^0.66.0",
73
55
  "oxlint": "1.81.0",
74
56
  "oxlint-tsgolint": "^7.0.2001",
@@ -81,7 +63,6 @@
81
63
  "optionalDependencies": {
82
64
  "@antelopejs/interface-dms-automation": ">=0.7.0 <0.8.0"
83
65
  },
84
- "packageManager": "pnpm@10.6.5",
85
66
  "antelopeJs": {
86
67
  "baseUrl": "dist",
87
68
  "paths": {
@@ -93,5 +74,27 @@
93
74
  "./skills"
94
75
  ]
95
76
  },
96
- "dmsFrontend": "dist/frontend-module.js"
97
- }
77
+ "dmsFrontend": "dist/frontend-module.js",
78
+ "gitHead": "4338d3333a9fe21454e7a8c56b2cda8fde89f1bc",
79
+ "scripts": {
80
+ "build": "rimraf dist && tsc",
81
+ "dev": "ajs project dev -w -p playground",
82
+ "e2e": "playwright test -c e2e",
83
+ "lint:fix": "oxlint --fix --max-warnings=1000000 && oxfmt . && pnpm --dir frontend-vue lint:fix",
84
+ "lint": "oxlint && pnpm --dir frontend-vue lint",
85
+ "typecheck": "tsc -p tests",
86
+ "test": "vitest run && pnpm --dir frontend-vue test",
87
+ "test:frontend": "ajs dms verify-source --layer node_modules/@antelopejs/dms/frontend-vue --module frontend-vue",
88
+ "format": "oxfmt . && pnpm --dir frontend-vue format",
89
+ "frontend:dev": "cd playground && pnpm frontend:dev",
90
+ "knip": "knip --dependencies",
91
+ "knip:all": "knip",
92
+ "checks": "antelopejs-checks",
93
+ "size": "antelopejs-check-size",
94
+ "sync": "antelopejs-sync",
95
+ "sync:check": "antelopejs-sync --check",
96
+ "format:check": "oxfmt --check .",
97
+ "suppressions": "antelopejs-suppressions",
98
+ "suppressions:update": "antelopejs-suppressions --update"
99
+ }
100
+ }