@theokit/http 1.0.0 → 1.1.1
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/LICENSE +2 -2
- package/README.md +132 -86
- package/dist/action-encryption.d.ts +32 -0
- package/dist/action-encryption.js +69 -0
- package/dist/action-encryption.js.map +1 -0
- package/dist/app.d.ts +69 -2
- package/dist/app.js +5 -5
- package/dist/app.js.map +1 -1
- package/dist/{chunk-KPC7AIVC.js → chunk-AJOJXZRY.js} +2 -2
- package/dist/chunk-AJOJXZRY.js.map +1 -0
- package/dist/{chunk-HLW7YKZE.js → chunk-BSS3KPGY.js} +2 -2
- package/dist/chunk-BSS3KPGY.js.map +1 -0
- package/dist/{chunk-OBHHOS6E.js → chunk-DI7KNIMB.js} +4 -4
- package/dist/chunk-DI7KNIMB.js.map +1 -0
- package/dist/{chunk-CMPP4ULU.js → chunk-HC47QXZV.js} +4 -4
- package/dist/chunk-HC47QXZV.js.map +1 -0
- package/dist/{chunk-MQAJWR3K.js → chunk-JP4J23TV.js} +2 -2
- package/dist/chunk-JP4J23TV.js.map +1 -0
- package/dist/{chunk-ELCXHPAD.js → chunk-PBV6ZO2V.js} +3 -3
- package/dist/chunk-PBV6ZO2V.js.map +1 -0
- package/dist/{chunk-JQMJK47T.js → chunk-X7Q5HPLK.js} +15 -15
- package/dist/chunk-X7Q5HPLK.js.map +1 -0
- package/dist/{chunk-7QVYU63E.js → chunk-Z4QWC7IK.js} +1 -1
- package/dist/chunk-Z4QWC7IK.js.map +1 -0
- package/dist/{chunk-DRCRGDA3.js → chunk-ZMMIH3I2.js} +60 -33
- package/dist/chunk-ZMMIH3I2.js.map +1 -0
- package/dist/css-resource.d.ts +31 -0
- package/dist/css-resource.js +29 -0
- package/dist/css-resource.js.map +1 -0
- package/dist/exception-filter-chain-AS6BB5PF.js +10 -0
- package/dist/exception-filter-chain-AS6BB5PF.js.map +1 -0
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/dist/interceptor-chain-KMBBSUB5.js +9 -0
- package/dist/interceptor-chain-KMBBSUB5.js.map +1 -0
- package/dist/runtime-node.js +2 -2
- package/dist/runtime-node.js.map +1 -1
- package/dist/server-inserted-html.d.ts +35 -0
- package/dist/server-inserted-html.js +37 -0
- package/dist/server-inserted-html.js.map +1 -0
- package/dist/theokit-plugin.js +12 -12
- package/dist/theokit-plugin.js.map +1 -1
- package/package.json +39 -19
- package/dist/chunk-7QVYU63E.js.map +0 -1
- package/dist/chunk-CMPP4ULU.js.map +0 -1
- package/dist/chunk-DRCRGDA3.js.map +0 -1
- package/dist/chunk-ELCXHPAD.js.map +0 -1
- package/dist/chunk-HLW7YKZE.js.map +0 -1
- package/dist/chunk-JQMJK47T.js.map +0 -1
- package/dist/chunk-KPC7AIVC.js.map +0 -1
- package/dist/chunk-MQAJWR3K.js.map +0 -1
- package/dist/chunk-OBHHOS6E.js.map +0 -1
- package/dist/exception-filter-chain-V2MFO4WV.js +0 -10
- package/dist/exception-filter-chain-V2MFO4WV.js.map +0 -1
- package/dist/interceptor-chain-ELSL6KZT.js +0 -9
- package/dist/interceptor-chain-ELSL6KZT.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -137,8 +137,8 @@
|
|
|
137
137
|
|
|
138
138
|
6. Trademarks. This License does not grant permission to use the trade
|
|
139
139
|
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for
|
|
141
|
-
reproducing the content of the NOTICE file.
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
142
|
|
|
143
143
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
144
|
agreed to in writing, Licensor provides the Work (and each
|
package/README.md
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@theokit/http`
|
|
2
2
|
|
|
3
|
-
NestJS-style decorators (`@Controller`, `@Get`, `@Post`, `@Body`, `@UseGuards`)
|
|
3
|
+
NestJS-style decorators (`@Controller`, `@Get`, `@Post`, `@Body`, `@UseGuards`) over Web Standards —
|
|
4
|
+
`Request` and `Response`, not `node:http`. They compile down to the same route registrations
|
|
5
|
+
[`theokit`](https://www.npmjs.com/package/theokit) serves, so a decorator controller and a
|
|
6
|
+
`route()` builder are two authoring surfaces over one runtime.
|
|
7
|
+
|
|
8
|
+
> **Renamed.** This package was published as `@theokit/http-decorators` until 0.3.0. That name is
|
|
9
|
+
> frozen at the old surface — install `@theokit/http`.
|
|
4
10
|
|
|
5
11
|
## Install
|
|
6
12
|
|
|
7
13
|
```bash
|
|
8
|
-
pnpm add @theokit/http
|
|
14
|
+
pnpm add @theokit/http reflect-metadata
|
|
9
15
|
```
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
The decorators are the TypeScript legacy kind, so the consuming project needs:
|
|
12
18
|
|
|
13
19
|
```json
|
|
14
20
|
{
|
|
@@ -19,62 +25,75 @@ Add to your `tsconfig.json`:
|
|
|
19
25
|
}
|
|
20
26
|
```
|
|
21
27
|
|
|
28
|
+
`emitDecoratorMetadata` is only required for the DTO-class form of `@Body` (below). The preferred
|
|
29
|
+
form — `@Body(schema)` — works without it.
|
|
30
|
+
|
|
22
31
|
## Quick start
|
|
23
32
|
|
|
24
33
|
```typescript
|
|
25
|
-
import { Controller, Get, Post, Body } from '@theokit/http
|
|
34
|
+
import { Controller, Get, Post, Body, Param } from '@theokit/http'
|
|
26
35
|
import { z } from 'zod'
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
static schema = zCreateCat
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@Controller('cats')
|
|
37
|
+
// Convention: @Controller() on CatsController infers the prefix "api/cats".
|
|
38
|
+
// Pass a string to override: @Controller('api/v2/cats').
|
|
39
|
+
@Controller()
|
|
35
40
|
export class CatsController {
|
|
36
41
|
@Get()
|
|
37
|
-
findAll()
|
|
38
|
-
return
|
|
42
|
+
findAll() {
|
|
43
|
+
return { cats: [] }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Get(':id')
|
|
47
|
+
findOne(@Param('id') id: string) {
|
|
48
|
+
return { id }
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
@Post()
|
|
42
|
-
create(@Body() body:
|
|
43
|
-
return
|
|
52
|
+
create(@Body(z.object({ name: z.string(), age: z.number().min(0) })) body: unknown) {
|
|
53
|
+
return { created: body }
|
|
44
54
|
}
|
|
45
55
|
}
|
|
46
56
|
```
|
|
47
57
|
|
|
48
|
-
##
|
|
58
|
+
## Validation — Zod is the single source of truth
|
|
49
59
|
|
|
50
|
-
|
|
60
|
+
Pass the schema to `@Body` directly. The bridge validates the request against it and feeds the same
|
|
61
|
+
schema to the OpenAPI emitter and the typed-client codegen:
|
|
51
62
|
|
|
52
63
|
```typescript
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
@Post()
|
|
65
|
+
create(@Body(z.object({ name: z.string().min(2), breed: z.string() })) body: unknown) { … }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
A DTO class works too, when a shared, named shape reads better. Attach the schema as a static; this
|
|
69
|
+
form needs `emitDecoratorMetadata`, because the bridge finds the class through `design:paramtypes`:
|
|
58
70
|
|
|
71
|
+
```typescript
|
|
59
72
|
class CreateCatDto {
|
|
60
|
-
static schema =
|
|
73
|
+
static schema = z.object({ name: z.string(), age: z.number() })
|
|
61
74
|
}
|
|
75
|
+
|
|
76
|
+
@Post()
|
|
77
|
+
create(@Body() body: CreateCatDto) { … }
|
|
62
78
|
```
|
|
63
79
|
|
|
64
|
-
|
|
80
|
+
When neither is present the body is passed through raw and the bridge warns — validation is never
|
|
81
|
+
silently skipped.
|
|
82
|
+
|
|
83
|
+
## Pipeline
|
|
65
84
|
|
|
66
|
-
|
|
85
|
+
`middleware → guards → interceptors → handler`, with filters catching what escapes.
|
|
67
86
|
|
|
68
87
|
```typescript
|
|
69
|
-
import { Controller, Get, UseGuards } from '@theokit/http
|
|
88
|
+
import { Controller, Get, UseGuards, type CanActivate, type ExecutionContext } from '@theokit/http'
|
|
70
89
|
|
|
71
|
-
class AuthGuard {
|
|
72
|
-
canActivate(
|
|
73
|
-
return
|
|
90
|
+
class AuthGuard implements CanActivate {
|
|
91
|
+
canActivate(ctx: ExecutionContext): boolean {
|
|
92
|
+
return ctx.getRequest().headers.get('authorization') !== null
|
|
74
93
|
}
|
|
75
94
|
}
|
|
76
95
|
|
|
77
|
-
@Controller('admin')
|
|
96
|
+
@Controller('api/admin')
|
|
78
97
|
export class AdminController {
|
|
79
98
|
@UseGuards(AuthGuard)
|
|
80
99
|
@Get()
|
|
@@ -84,89 +103,116 @@ export class AdminController {
|
|
|
84
103
|
}
|
|
85
104
|
```
|
|
86
105
|
|
|
87
|
-
|
|
106
|
+
A guard returning `false` produces **403 Forbidden** (`ForbiddenException`); throw
|
|
107
|
+
`UnauthorizedException` from the guard when 401 is what you mean. Class-level guards run before
|
|
108
|
+
method-level ones.
|
|
88
109
|
|
|
89
|
-
|
|
110
|
+
An interceptor is `intercept(request, next)` — Web Standard `Request` in, and `next()` wrapping the
|
|
111
|
+
handler call only (the body is already parsed by then). Not calling `next()` short-circuits the
|
|
112
|
+
handler; calling it twice is memoized to one execution.
|
|
90
113
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
# Creates server/controllers/cats.controller.ts
|
|
94
|
-
```
|
|
114
|
+
An exception filter is `catch(exception, host)` returning a `Response`, where `host.getRequest()` is
|
|
115
|
+
the request that failed.
|
|
95
116
|
|
|
96
|
-
##
|
|
117
|
+
## Serving an agent from a controller
|
|
97
118
|
|
|
98
|
-
|
|
119
|
+
`@Expose` binds an agent built in `agents/<name>.ts` to a controller property, so its route, its
|
|
120
|
+
streaming and its auth are visible in one place:
|
|
99
121
|
|
|
100
122
|
```typescript
|
|
101
|
-
import {
|
|
102
|
-
import { CatsController } from './controllers/cats.controller.js'
|
|
123
|
+
import { Controller, Expose, UseGuards } from '@theokit/http'
|
|
103
124
|
|
|
104
|
-
|
|
105
|
-
|
|
125
|
+
import supportAgent from '../../agents/support.js'
|
|
126
|
+
|
|
127
|
+
@Controller('api/agents')
|
|
128
|
+
@UseGuards(AuthGuard)
|
|
129
|
+
export class AgentsController {
|
|
130
|
+
@Expose(supportAgent)
|
|
131
|
+
support!: unknown // → POST /api/agents/support, behind AuthGuard
|
|
132
|
+
}
|
|
106
133
|
```
|
|
107
134
|
|
|
135
|
+
The request is delegated straight to the one agent runtime. Guards run on that route; interceptors
|
|
136
|
+
do not.
|
|
137
|
+
|
|
108
138
|
## Decorators reference
|
|
109
139
|
|
|
110
140
|
| Decorator | Kind | Purpose |
|
|
111
141
|
|---|---|---|
|
|
112
|
-
| `@Controller(prefix?, opts?)` | Class | Route prefix scope |
|
|
113
|
-
| `@Get(path?)` | Method |
|
|
114
|
-
| `@
|
|
115
|
-
| `@
|
|
116
|
-
| `@
|
|
117
|
-
| `@Delete(path?)` | Method | DELETE endpoint |
|
|
118
|
-
| `@Options(path?)` | Method | OPTIONS endpoint |
|
|
119
|
-
| `@Head(path?)` | Method | HEAD endpoint |
|
|
120
|
-
| `@All(path?)` | Method | All HTTP methods |
|
|
121
|
-
| `@Body(key?)` | Parameter | Request body (or body[key]) |
|
|
122
|
-
| `@Param(key?)` | Parameter | Route params (or params[key]) |
|
|
123
|
-
| `@Query(key?)` | Parameter | Query string (or query[key]) |
|
|
142
|
+
| `@Controller(prefix?, opts?)` | Class | Route prefix scope (inferred from the class name when omitted) |
|
|
143
|
+
| `@Get/@Post/@Put/@Patch/@Delete/@Options/@Head/@All(path?)` | Method | HTTP verb endpoints |
|
|
144
|
+
| `@Body(schemaOrKey?)` | Parameter | Request body — Zod schema, DTO class, or `body[key]` |
|
|
145
|
+
| `@Param(key?)` | Parameter | Route params (or `params[key]`) |
|
|
146
|
+
| `@Query(key?)` | Parameter | Query string (or `query[key]`) |
|
|
124
147
|
| `@Headers(name?)` | Parameter | Request headers |
|
|
125
|
-
| `@Req()` | Parameter |
|
|
126
|
-
| `@
|
|
127
|
-
| `@
|
|
128
|
-
| `@
|
|
129
|
-
| `@HostParam(key?)` | Parameter | Host parameters |
|
|
130
|
-
| `@HttpCode(status)` | Method | Override response status code |
|
|
131
|
-
| `@Header(name, value)` | Method | Set response header |
|
|
148
|
+
| `@Req()` / `@Res(opts?)` | Parameter | The raw `Request` / response (`passthrough` option) |
|
|
149
|
+
| `@Session()` / `@Ip()` / `@HostParam(key?)` | Parameter | Session, client IP, host params |
|
|
150
|
+
| `@HttpCode(status)` | Method | Override the response status |
|
|
151
|
+
| `@Header(name, value)` | Method | Set a response header |
|
|
132
152
|
| `@Redirect(url, status?)` | Method | Redirect response |
|
|
133
|
-
| `@UseGuards(...
|
|
134
|
-
| `@UseInterceptors(...
|
|
153
|
+
| `@UseGuards(...)` | Class/Method | Attach guards |
|
|
154
|
+
| `@UseInterceptors(...)` | Class/Method | Attach interceptors |
|
|
155
|
+
| `@UseFilters(...)` / `@Catch(...)` | Class/Method | Exception filters |
|
|
156
|
+
| `@Throttle(opts)` / `@SkipThrottle()` | Class/Method | Rate-limit policy |
|
|
157
|
+
| `@SetMetadata(key, value)` / `createDecorator<T>()` | Class/Method | Custom metadata, read back with `Reflector` |
|
|
158
|
+
| `@Expose(agent, opts?)` | Property | Serve a built agent from this controller |
|
|
135
159
|
|
|
136
|
-
|
|
160
|
+
Build your own policy decorator with `createDecorator`:
|
|
137
161
|
|
|
138
|
-
|
|
162
|
+
```typescript
|
|
163
|
+
const Roles = createDecorator<string[]>()
|
|
164
|
+
// @Roles(['admin']) → read it in a guard with reflector.get(Roles, handler)
|
|
165
|
+
```
|
|
139
166
|
|
|
140
|
-
|
|
167
|
+
`HttpStatus` ships the 30 status codes the framework uses, alongside an exception class per code
|
|
168
|
+
(`BadRequestException`, `ConflictException`, `TooManyRequestsException`, …).
|
|
141
169
|
|
|
142
|
-
|
|
170
|
+
## Subpaths
|
|
143
171
|
|
|
144
|
-
|
|
172
|
+
| Subpath | What lives there |
|
|
173
|
+
|---|---|
|
|
174
|
+
| `.` | Decorators, metadata, the bridge, exceptions, `TheoApp`, `createTypedClient`, `contract`, static serving |
|
|
175
|
+
| `./theokit-plugin` | The plugin that wires controllers into a TheoKit app |
|
|
176
|
+
| `./app` | App-level composition |
|
|
177
|
+
| `./runtime/node` | The Node runtime adapter |
|
|
178
|
+
| `./action-encryption`, `./server-inserted-html`, `./css-resource` | Opt-in capabilities kept off the main bundle |
|
|
145
179
|
|
|
146
|
-
|
|
180
|
+
## `registerControllers` (low-level)
|
|
147
181
|
|
|
148
|
-
|
|
182
|
+
For advanced use without the Vite plugin:
|
|
149
183
|
|
|
150
|
-
|
|
184
|
+
```typescript
|
|
185
|
+
import { registerControllers } from '@theokit/http'
|
|
151
186
|
|
|
152
|
-
|
|
187
|
+
const routes = registerControllers([CatsController])
|
|
188
|
+
// RouteRegistration[] — verb, fullPath, and the metadata walk per method
|
|
189
|
+
```
|
|
153
190
|
|
|
154
|
-
|
|
191
|
+
## Limitations
|
|
155
192
|
|
|
156
|
-
|
|
157
|
-
{
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
193
|
+
- **Singleton-scope controllers only.** A controller is instantiated once, when the handler is
|
|
194
|
+
built — NestJS request-scoped controllers (`@Injectable({ scope: Scope.REQUEST })`) have no
|
|
195
|
+
equivalent here. Guards and interceptors are the opposite: a fresh instance per request, unless a
|
|
196
|
+
DI container resolves them.
|
|
197
|
+
- **No response object before the handler returns.** `ExecutionContext` exposes the request, the URL,
|
|
198
|
+
the controller class and the handler name — there is nothing to mutate headers on until a
|
|
199
|
+
`Response` exists. Set them with `@Header`, or return a `Response` yourself.
|
|
200
|
+
- **A handler returning a `Response` owns it.** `@HttpCode` and `@Header` are not applied on that
|
|
201
|
+
path — the same behaviour as NestJS with `@Res({ passthrough: false })`.
|
|
164
202
|
|
|
165
|
-
|
|
203
|
+
## Troubleshooting
|
|
204
|
+
|
|
205
|
+
**`HttpDecoratorsConfigError: emitDecoratorMetadata not enabled`** — add both compiler flags shown
|
|
206
|
+
under Install, or pass the schema inline as `@Body(schema)`, which does not need them.
|
|
166
207
|
|
|
167
|
-
|
|
208
|
+
**`HttpDecoratorsConfigError: missing @Controller() decorator`** — a class has `@Get`/`@Post`
|
|
209
|
+
methods but no `@Controller()`.
|
|
168
210
|
|
|
169
211
|
## Bundle cost
|
|
170
212
|
|
|
171
|
-
|
|
172
|
-
|
|
213
|
+
~8-13KB gzipped for consumers who opt in (`reflect-metadata` ~3KB plus this package); 0KB for those
|
|
214
|
+
who do not.
|
|
215
|
+
|
|
216
|
+
## Licence
|
|
217
|
+
|
|
218
|
+
Apache-2.0 — see `LICENSE`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Encryption — AES-GCM-256 via Web Crypto API.
|
|
3
|
+
*
|
|
4
|
+
* Inspired by Next.js encryption.ts (app-render/).
|
|
5
|
+
* Uses crypto.subtle (Web Standard) for action argument encryption.
|
|
6
|
+
* Random IV per call ensures ciphertext is unique even for identical inputs.
|
|
7
|
+
*
|
|
8
|
+
* Output format: base64url(iv || ciphertext)
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Derive an AES-GCM-256 CryptoKey from a string secret.
|
|
12
|
+
*
|
|
13
|
+
* Uses PBKDF2 with a fixed salt derived from the secret itself.
|
|
14
|
+
* Suitable for action encryption where the secret is a server-side
|
|
15
|
+
* session secret — not for password hashing.
|
|
16
|
+
*/
|
|
17
|
+
declare function deriveActionKey(secret: string): Promise<CryptoKey>;
|
|
18
|
+
/**
|
|
19
|
+
* Encrypt a string with AES-GCM-256.
|
|
20
|
+
*
|
|
21
|
+
* @returns base64url-encoded string containing IV + ciphertext.
|
|
22
|
+
*/
|
|
23
|
+
declare function encryptActionArgs(key: CryptoKey, data: string): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Decrypt a base64url-encoded string produced by encryptActionArgs.
|
|
26
|
+
*
|
|
27
|
+
* @returns The original plaintext string.
|
|
28
|
+
* @throws Error if decryption fails (wrong key, tampered data, etc.).
|
|
29
|
+
*/
|
|
30
|
+
declare function decryptActionArgs(key: CryptoKey, encrypted: string): Promise<string>;
|
|
31
|
+
|
|
32
|
+
export { decryptActionArgs, deriveActionKey, encryptActionArgs };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-Z4QWC7IK.js";
|
|
4
|
+
|
|
5
|
+
// src/action-encryption.ts
|
|
6
|
+
var ALGORITHM = "AES-GCM";
|
|
7
|
+
var IV_LENGTH = 12;
|
|
8
|
+
async function deriveActionKey(secret) {
|
|
9
|
+
const encoder = new TextEncoder();
|
|
10
|
+
const keyMaterial = await crypto.subtle.importKey("raw", encoder.encode(secret), "PBKDF2", false, [
|
|
11
|
+
"deriveKey"
|
|
12
|
+
]);
|
|
13
|
+
const salt = encoder.encode(`theo-action-salt:${secret.slice(0, 8)}`);
|
|
14
|
+
return crypto.subtle.deriveKey({
|
|
15
|
+
name: "PBKDF2",
|
|
16
|
+
salt,
|
|
17
|
+
iterations: 1e5,
|
|
18
|
+
hash: "SHA-256"
|
|
19
|
+
}, keyMaterial, {
|
|
20
|
+
name: ALGORITHM,
|
|
21
|
+
length: 256
|
|
22
|
+
}, false, [
|
|
23
|
+
"encrypt",
|
|
24
|
+
"decrypt"
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
__name(deriveActionKey, "deriveActionKey");
|
|
28
|
+
async function encryptActionArgs(key, data) {
|
|
29
|
+
const encoder = new TextEncoder();
|
|
30
|
+
const iv = crypto.getRandomValues(new Uint8Array(IV_LENGTH));
|
|
31
|
+
const ciphertext = await crypto.subtle.encrypt({
|
|
32
|
+
name: ALGORITHM,
|
|
33
|
+
iv
|
|
34
|
+
}, key, encoder.encode(data));
|
|
35
|
+
const combined = new Uint8Array(IV_LENGTH + ciphertext.byteLength);
|
|
36
|
+
combined.set(iv, 0);
|
|
37
|
+
combined.set(new Uint8Array(ciphertext), IV_LENGTH);
|
|
38
|
+
return toBase64Url(combined);
|
|
39
|
+
}
|
|
40
|
+
__name(encryptActionArgs, "encryptActionArgs");
|
|
41
|
+
async function decryptActionArgs(key, encrypted) {
|
|
42
|
+
const combined = fromBase64Url(encrypted);
|
|
43
|
+
const iv = combined.slice(0, IV_LENGTH);
|
|
44
|
+
const ciphertext = combined.slice(IV_LENGTH);
|
|
45
|
+
const decrypted = await crypto.subtle.decrypt({
|
|
46
|
+
name: ALGORITHM,
|
|
47
|
+
iv
|
|
48
|
+
}, key, ciphertext);
|
|
49
|
+
return new TextDecoder().decode(decrypted);
|
|
50
|
+
}
|
|
51
|
+
__name(decryptActionArgs, "decryptActionArgs");
|
|
52
|
+
function toBase64Url(bytes) {
|
|
53
|
+
const binString = Array.from(bytes, (b) => String.fromCodePoint(b)).join("");
|
|
54
|
+
return btoa(binString).replace(/\+/g, "-").replace(/\//g, "_").replaceAll("=", "");
|
|
55
|
+
}
|
|
56
|
+
__name(toBase64Url, "toBase64Url");
|
|
57
|
+
function fromBase64Url(str) {
|
|
58
|
+
const base64 = str.replace(/-/g, "+").replace(/_/g, "/");
|
|
59
|
+
const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
|
|
60
|
+
const binString = atob(padded);
|
|
61
|
+
return Uint8Array.from(binString, (c) => c.codePointAt(0));
|
|
62
|
+
}
|
|
63
|
+
__name(fromBase64Url, "fromBase64Url");
|
|
64
|
+
export {
|
|
65
|
+
decryptActionArgs,
|
|
66
|
+
deriveActionKey,
|
|
67
|
+
encryptActionArgs
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=action-encryption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/action-encryption.ts"],"mappings":";;;;;AAUA,IAAMA,YAAY;AAClB,IAAMC,YAAY;AASlB,eAAsBC,gBAAgBC,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YAAYC,MAAMC,KAAKH,OAAO,CAACI,MAAMC,OAAOC,cAAcF,CAAAA,CAAAA,EAAIG,KAAK,EAAA;AACzE,SAAOC,KAAKP,SAAAA,EAAWQ,QAAQ,OAAO,GAAA,EAAKA,QAAQ,OAAO,GAAA,EAAKC,WAAW,KAAK,EAAA;AACjF;AAHSlB;AAKT,SAASG,cAAcgB,KAAW;AAChC,QAAMC,SAASD,IAAIF,QAAQ,MAAM,GAAA,EAAKA,QAAQ,MAAM,GAAA;AACpD,QAAMI,SAASD,SAAS,IAAIE,QAAQ,IAAKF,OAAOhC,SAAS,KAAM,CAAA;AAC/D,QAAMqB,YAAYc,KAAKF,MAAAA;AACvB,SAAO3B,WAAWiB,KAAKF,WAAW,CAACe,MAAMA,EAAEC,YAAY,CAAA,CAAA;AACzD;AALStB;","names":["ALGORITHM","IV_LENGTH","deriveActionKey","secret","encoder","TextEncoder","keyMaterial","crypto","subtle","importKey","encode","salt","slice","deriveKey","name","iterations","hash","length","encryptActionArgs","key","data","iv","getRandomValues","Uint8Array","ciphertext","encrypt","combined","byteLength","set","toBase64Url","decryptActionArgs","encrypted","fromBase64Url","decrypted","decrypt","TextDecoder","decode","bytes","binString","Array","from","b","String","fromCodePoint","join","btoa","replace","replaceAll","str","base64","padded","repeat","atob","c","codePointAt"]}
|
package/dist/app.d.ts
CHANGED
|
@@ -21,7 +21,12 @@ interface AgentAppEntry {
|
|
|
21
21
|
readonly name: string;
|
|
22
22
|
/** Mount point; routes are generated under it (`<route>/chat`, `<route>/runs/:id`). */
|
|
23
23
|
readonly route: string;
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* `CompiledAgentOptions`, produced by the agent layer and opaque here.
|
|
26
|
+
*
|
|
27
|
+
* Typed `unknown` on purpose: naming the type would import it, and this package does not depend
|
|
28
|
+
* on `@theokit/agents` (G1 — agents depends on http, never the reverse).
|
|
29
|
+
*/
|
|
25
30
|
readonly compiled: unknown;
|
|
26
31
|
/** Guards to run before the agent routes (same shape the controller pipeline uses). */
|
|
27
32
|
readonly guards?: Function[];
|
|
@@ -30,6 +35,53 @@ interface AgentAppEntry {
|
|
|
30
35
|
/** Optional owning class, kept only for guard resolution parity with controllers. */
|
|
31
36
|
readonly agentClass?: Function;
|
|
32
37
|
}
|
|
38
|
+
/** One route produced by the agent runtime, in the shape this app mounts. */
|
|
39
|
+
interface AgentRuntimeRoute {
|
|
40
|
+
readonly method: string;
|
|
41
|
+
/** Express-style path; `:param` segments become capture groups when mounted. */
|
|
42
|
+
readonly path: string;
|
|
43
|
+
readonly handler: (request: Request) => Promise<Response>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The slice of the agent layer this app needs — declared HERE, supplied by the caller.
|
|
47
|
+
*
|
|
48
|
+
* This interface is the inversion. `autoWireAgents` used to reach into `@theokit/agents` with a
|
|
49
|
+
* dynamic `import()`, which put the agent layer on this package's manifest and inverted the
|
|
50
|
+
* direction `system-design-guardrails.md` § G1 fixes ("`@theokit/http` does NOT import
|
|
51
|
+
* `@theokit/agents` — agents depends on http, not the reverse").
|
|
52
|
+
*
|
|
53
|
+
* "Dynamic" and "optional" were never an escape hatch: they change WHEN the module is needed, never
|
|
54
|
+
* WHETHER this package depends on it. The manifest still had to declare the peer, pnpm still
|
|
55
|
+
* auto-installed the **published** copy next to the workspace sibling, and the resulting type cycle
|
|
56
|
+
* made the build unfixable by manifest edit (`TS5055` on `dist/app.d.ts`).
|
|
57
|
+
*
|
|
58
|
+
* Declaring the contract here and letting the caller satisfy it is DIP (`architecture.md` § 2): the
|
|
59
|
+
* consumer defines the interface, the outer layer implements it, and the wiring happens at the
|
|
60
|
+
* composition root (§ 1) — which for this monorepo is `theokit`, the one package that legitimately
|
|
61
|
+
* depends on both.
|
|
62
|
+
*/
|
|
63
|
+
interface AgentRuntime {
|
|
64
|
+
/** Build the HTTP routes for one compiled agent. `@theokit/agents` exports this by name. */
|
|
65
|
+
generateAgentRoutes(input: {
|
|
66
|
+
walkResult: {
|
|
67
|
+
route: string;
|
|
68
|
+
};
|
|
69
|
+
compiledOptions: unknown;
|
|
70
|
+
createRun: (message: string, sessionId: string) => AsyncIterable<{
|
|
71
|
+
type: string;
|
|
72
|
+
[k: string]: unknown;
|
|
73
|
+
}>;
|
|
74
|
+
}): AgentRuntimeRoute[];
|
|
75
|
+
/**
|
|
76
|
+
* Default stream factory, used when the app has an API key and no `agentStreamFactory` override.
|
|
77
|
+
*
|
|
78
|
+
* Optional because an app that always passes `agentStreamFactory` never needs it — requiring it
|
|
79
|
+
* would force such callers to supply a function they can prove is unreachable.
|
|
80
|
+
*/
|
|
81
|
+
createSdkAgentStream?(compiled: unknown, tools: unknown[], apiKey: string, overrides?: {
|
|
82
|
+
model?: string;
|
|
83
|
+
}): (message: string, sessionId: string) => AsyncIterable<unknown>;
|
|
84
|
+
}
|
|
33
85
|
interface TheoAppOptions {
|
|
34
86
|
/** Controller classes decorated with @Controller. */
|
|
35
87
|
controllers: Function[];
|
|
@@ -48,6 +100,13 @@ interface TheoAppOptions {
|
|
|
48
100
|
llmApiKey?: string;
|
|
49
101
|
/** LLM model override (default: from @Agent({ model }) metadata). */
|
|
50
102
|
llmModel?: string;
|
|
103
|
+
/**
|
|
104
|
+
* The agent layer, supplied by the caller. REQUIRED whenever `agents` is non-empty.
|
|
105
|
+
*
|
|
106
|
+
* Wire it with the two named exports of `@theokit/agents`:
|
|
107
|
+
* `agentRuntime: { generateAgentRoutes, createSdkAgentStream }`.
|
|
108
|
+
*/
|
|
109
|
+
agentRuntime?: AgentRuntime;
|
|
51
110
|
/** Agent stream factory override (for testing or custom SDK wiring). */
|
|
52
111
|
agentStreamFactory?: (
|
|
53
112
|
/** The COMPILED agent options — not the metadata walk (which carries no `model`). */
|
|
@@ -105,6 +164,14 @@ declare class TheoApp {
|
|
|
105
164
|
getServerHandle(): ServerHandle;
|
|
106
165
|
close(): Promise<void>;
|
|
107
166
|
private agentRoutes;
|
|
167
|
+
/**
|
|
168
|
+
* Synchronous since B-M67-21: the only `await` here was the dynamic `import('@theokit/agents')`
|
|
169
|
+
* that the inversion removed, and `AgentRuntime.generateAgentRoutes` returns routes directly.
|
|
170
|
+
*
|
|
171
|
+
* The call site dropped its `await` with it. Keeping one "in case a runtime resolves
|
|
172
|
+
* asynchronously later" would be a promise about a shape nothing has (YAGNI) — and the linter
|
|
173
|
+
* says so plainly: awaiting a non-thenable is noise that reads like a real suspension point.
|
|
174
|
+
*/
|
|
108
175
|
private autoWireAgents;
|
|
109
176
|
private handleReadinessCheck;
|
|
110
177
|
private createFallbackStream;
|
|
@@ -114,4 +181,4 @@ declare class TheoApp {
|
|
|
114
181
|
private buildArgs;
|
|
115
182
|
}
|
|
116
183
|
|
|
117
|
-
export { type AgentAppEntry, type ReadinessCheck, TheoApp, type TheoAppOptions };
|
|
184
|
+
export { type AgentAppEntry, type AgentRuntime, type AgentRuntimeRoute, type ReadinessCheck, TheoApp, type TheoAppOptions };
|
package/dist/app.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TheoApp
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-ZMMIH3I2.js";
|
|
4
|
+
import "./chunk-X7Q5HPLK.js";
|
|
5
|
+
import "./chunk-AJOJXZRY.js";
|
|
6
|
+
import "./chunk-BSS3KPGY.js";
|
|
7
|
+
import "./chunk-Z4QWC7IK.js";
|
|
8
8
|
export {
|
|
9
9
|
TheoApp
|
|
10
10
|
};
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"mappings":"","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__name
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Z4QWC7IK.js";
|
|
4
4
|
|
|
5
5
|
// src/metadata/keys.ts
|
|
6
6
|
var CONTROLLER_PREFIX = /* @__PURE__ */ Symbol.for("theokit:http-decorators:controller-prefix");
|
|
@@ -275,4 +275,4 @@ export {
|
|
|
275
275
|
TooManyRequestsException,
|
|
276
276
|
HttpStatus
|
|
277
277
|
};
|
|
278
|
-
//# sourceMappingURL=chunk-
|
|
278
|
+
//# sourceMappingURL=chunk-AJOJXZRY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/metadata/keys.ts","../src/metadata/storage.ts","../src/exceptions/http-exception.ts"],"mappings":";;;;;AAYO,IAAMA,oBAAoBC,uBAAOC,IAAI,2CAAA;AACrC,IAAMC,gBAAgBF,uBAAOC,IAAI,uCAAA;AACjC,IAAME,eAAeH,uBAAOC,IAAI,sCAAA;AAChC,IAAMG,eAAeJ,uBAAOC,IAAI,sCAAA;AAChC,IAAMI,gBAAgBL,uBAAOC,IAAI,uCAAA;AACjC,IAAMK,iBAAiBN,uBAAOC,IAAI,wCAAA;AAClC,IAAMM,aAAaP,uBAAOC,IAAI,oCAAA;AAC9B,IAAMO,mBAAmBR,uBAAOC,IAAI,0CAAA;AACpC,IAAMQ,cAAcT,uBAAOC,IAAI,qCAAA;AAC/B,IAAMS,mBAAmBV,uBAAOC,IAAI,0CAAA;AACpC,IAAMU,eAAeX,uBAAOC,IAAI,sCAAA;;;ACtBvC,OAAO;AAQA,SAASW,QACdC,KACAC,QACAC,OACAC,aAA6B;AAE7B,MAAIA,gBAAgBC,QAAW;AAC7BC,YAAQC,eAAeN,KAAKE,OAAOD,QAAQE,WAAAA;EAC7C,OAAO;AACLE,YAAQC,eAAeN,KAAKE,OAAOD,MAAAA;EACrC;AACF;AAXgBF;AAaT,SAASQ,QACdP,KACAC,QACAE,aAA6B;AAE7B,MAAIA,gBAAgBC,QAAW;AAC7B,WAAOC,QAAQG,YAAYR,KAAKC,QAAQE,WAAAA;EAC1C;AACA,SAAOE,QAAQ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C/E,IAAMqB,0BAAN,cAAsCrB,QAAQ,KAAK,iBAAA,EAAA;EAxF1D,OAwF0D;;;AAAoB;AACvE,IAAMsB,mCAAN,cAA+CtB,QAAQ,KAAK,4BAAA,EAAA;EAzFnE,OAyFmE;;;AAA+B;AAC3F,IAAMuB,2BAAN,cAAuCvB,QAAQ,KAAK,mBAAA,EAAA;EA1F3D,OA0F2D;;;AAAsB;AAgB1E,IAAMwB,aAAa;;EAExBC,IAAI;EACJC,SAAS;EACTC,UAAU;EACVC,YAAY;;EAGZC,mBAAmB;EACnBC,OAAO;EACPC,cAAc;EACdC,oBAAoB;EACpBC,oBAAoB;;EAGpBC,aAAa;EACbC,cAAc;EACdC,kBAAkB;EAClBC,WAAW;EACXC,WAAW;EACXC,oBAAoB;EACpBC,gBAAgB;EAChBC,iBAAiB;EACjBC,UAAU;EACVC,MAAM;EACNC,qBAAqB;EACrBC,mBAAmB;EACnBC,wBAAwB;EACxBC,aAAa;EACbC,sBAAsB;EACtBC,mBAAmB;;EAGnBC,uBAAuB;EACvBC,iBAAiB;EACjBC,aAAa;EACbC,qBAAqB;EACrBC,iBAAiB;AACnB;","names":["CONTROLLER_PREFIX","Symbol","for","ROUTE_METHODS","ROUTE_PARAMS","ROUTE_STATUS","ROUTE_HEADERS","ROUTE_REDIRECT","USE_GUARDS","USE_INTERCEPTORS","USE_FILTERS","CATCH_EXCEPTIONS","EXPOSE_AGENT","setMeta","key","target","value","propertyKey","undefined","Reflect","defineMetadata","getMeta","getMetadata","STATUS_CODES","HttpException","Error","statusCode","code","description","message","options","cause","undefined","name","toJSON","error","factory","status","defaultMsg","BadRequestException","UnauthorizedException","ForbiddenException","NotFoundException","MethodNotAllowedException","NotAcceptableException","RequestTimeoutException","ConflictException","GoneException","PreconditionFailedException","PayloadTooLargeException","UnsupportedMediaTypeException","ImATeapotException","UnprocessableEntityException","InternalServerErrorException","NotImplementedException","BadGatewayException","ServiceUnavailableException","GatewayTimeoutException","HttpVersionNotSupportedException","TooManyRequestsException","HttpStatus","OK","CREATED","ACCEPTED","NO_CONTENT","MOVED_PERMANENTLY","FOUND","NOT_MODIFIED","TEMPORARY_REDIRECT","PERMANENT_REDIRECT","BAD_REQUEST","UNAUTHORIZED","PAYMENT_REQUIRED","FORBIDDEN","NOT_FOUND","METHOD_NOT_ALLOWED","NOT_ACCEPTABLE","REQUEST_TIMEOUT","CONFLICT","GONE","PRECONDITION_FAILED","PAYLOAD_TOO_LARGE","UNSUPPORTED_MEDIA_TYPE","IM_A_TEAPOT","UNPROCESSABLE_ENTITY","TOO_MANY_REQUESTS","INTERNAL_SERVER_ERROR","NOT_IMPLEMENTED","BAD_GATEWAY","SERVICE_UNAVAILABLE","GATEWAY_TIMEOUT"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__name
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Z4QWC7IK.js";
|
|
4
4
|
|
|
5
5
|
// src/bridge/runtime/node.ts
|
|
6
6
|
import { createServer } from "http";
|
|
@@ -96,4 +96,4 @@ export {
|
|
|
96
96
|
writeResponseToNode,
|
|
97
97
|
createNodeAdapter
|
|
98
98
|
};
|
|
99
|
-
//# sourceMappingURL=chunk-
|
|
99
|
+
//# sourceMappingURL=chunk-BSS3KPGY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bridge/runtime/node.ts"],"mappings":";;;;;AAQA,SAASA,oBAA+D;AACxE,SAASC,gBAAgB;AAKlB,SAASC,sBAAsBC,SAAwB;AAC5D,QAAMC,QAAQD,QAAQE,QAAQ,mBAAA,KAAwB;AACtD,QAAMC,OAAOH,QAAQE,QAAQC,QAAQ;AACrC,QAAMC,MAAM,GAAGH,KAAAA,MAAWE,IAAAA,GAAOH,QAAQI,OAAO,GAAA;AAChD,QAAMC,SAASL,QAAQK,UAAU;AAEjC,QAAMH,UAAU,IAAII,QAAAA;AACpB,aAAW,CAACC,KAAKC,KAAAA,KAAU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AACjB,QAAQS,WAAW;AACtBT,sBAAQC,UAAU,KAAK;gBAAE,gBAAgB;cAAmB,CAAA;AAC5DD,sBAAQI,IACNc,KAAKC,UAAU;gBACbC,OAAO;kBACLC,MAAM;kBACNC,SAASL,eAAeM,QAAQN,IAAIK,UAAU;gBAChD;cACF,CAAA,CAAA;YAEJ;UACF;QACF,GAAA;MACF,CAAA;AAEA,aAAO;QACLE,QAAQ,wBAACC,MAAcC,OAAoBX,OAAOS,OAAOC,MAAMC,EAAAA,GAAvD;QACRC,OAAO,wBAACD,OAAoBX,OAAOY,MAAMD,EAAAA,GAAlC;QACPE,SAAS,6BAAA;AACP,gBAAMC,OAAOd,OAAOa,QAAO;AAC3B,cAAI,OAAOC,SAAS,YAAYA,SAAS,KAAM,QAAO;AACtD,iBAAO;YAAEJ,MAAMI,KAAKJ;UAAK;QAC3B,GAJS;MAKX;IACF;EACF;AACF;AApCgBb;","names":["createServer","Readable","nodeIncomingToRequest","nodeReq","proto","headers","host","url","method","Headers","key","value","Object","entries","undefined","Array","isArray","v","append","set","hasBody","body","Readable","toWeb","Request","duplex","writeResponseToNode","response","nodeRes","writeHead","status","fromEntries","end","reader","getReader","done","read","destroyed","write","releaseLock","createNodeAdapter","createServer","handler","server","request","err","JSON","stringify","error","code","message","Error","listen","port","cb","close","address","addr"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HttpDecoratorsConfigError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-X7Q5HPLK.js";
|
|
4
4
|
import {
|
|
5
5
|
resolveOrNew
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JP4J23TV.js";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-Z4QWC7IK.js";
|
|
10
10
|
|
|
11
11
|
// src/bridge/middleware-consumer.ts
|
|
12
12
|
var MiddlewareConsumerImpl = class {
|
|
@@ -254,4 +254,4 @@ export {
|
|
|
254
254
|
loadControllersFromGlob,
|
|
255
255
|
isControllerClass
|
|
256
256
|
};
|
|
257
|
-
//# sourceMappingURL=chunk-
|
|
257
|
+
//# sourceMappingURL=chunk-DI7KNIMB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bridge/middleware-consumer.ts","../src/bridge/swc-loader.ts"],"mappings":";;;;;;;;;;;AAqCO,IAAMA,yBAAN,MAAMA;EArCb,OAqCaA;;;EACHC,UAAgC,CAAA;EAChCC;EAER,YAAYA,WAAyB;AACnC,SAAKA,YAAYA;EACnB;EAEAC,SAASC,YAAgE;AACvE,UAAMC,WAAWD,WAAWE,IAAI,CAACC,MAAM,KAAKC,kBAAkBD,CAAAA,CAAAA;AAC9D,UAAME,kBAA4B,CAAA;AAElC,UAAMC,QAA+B;MACnCC,SAAS,2BAAIC,WAAAA;AACX,mBAAWC,KAAKD,OAAQH,iBAAgBK,KAAK,OAAOD,MAAM,WAAWA,IAAIA,EAAEE,IAAI;AAC/E,eAAOL;MACT,GAHS;MAITM,WAAW,2BAAIJ,WAAAA;AACb,cAAMK,gBAAgBL,OAAON,IAAI,CAACO,MAAO,OAAOA,MAAM,WAAWA,IAAIA,EAAEE,IAAI;AAC3E,mBAAWG,WAAWb,UAAU;AAC9B,eAAKJ,QAAQa,KAAK;YAChBI;YACAD,eAAe;iBAAIA;;YACnBR,iBAAiB;iBAAIA;;UACvB,CAAA;QACF;AACA,eAAO;MACT,GAVW;IAWb;AACA,WAAOC;EACT;EAEAS,aAAmC;AACjC,WAAO,KAAKlB;EACd;EAEQO,kBAAkBD,GAA0C;AAClE,QAAI,OAAOA,MAAM,cAAc,CAACA,EAAEa,WAAWC,KAAK;AAChD,aAAOd;IACT;AACA,UAAMe,WAAWC,aAAahB,GAAG,KAAKL,SAAS;AAC/C,WAAO,CAACsB,SAASC,SAASH,SAASD,IAAIG,SAASC,IAAAA;EAClD;AACF;AAEO,SAASC,sBAAsBC,O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;AACN,WAAO;EACT;AACF;AANgBF;AAahB,SAASX,oBAAoBH,SAAiBC,SAAe;AAC3D,QAAMoB,QAAQpB,QAAQqB,MAAM,GAAA;AAC5B,QAAMC,WAAqB,CAAA;AAC3B,aAAWC,QAAQH,OAAO;AACxB,QAAIG,KAAKC,SAAS,GAAA,EAAM;AACxBF,aAASR,KAAKS,IAAAA;EAChB;AACA,QAAME,UAAUzE,KAAK+C,SAAAA,GAAYuB,QAAAA;AAGjC,QAAMI,WAAWN,MAAMA,MAAMjB,SAAS,CAAA;AACtC,QAAMwB,SAASD,SAASjC,QAAQ,OAAO,EAAA;AAEvC,QAAMQ,QAAkB,CAAA;AACxB,WAAS2B,KAAKhF,KAAW;AACvB,QAAI;AACF,iBAAWiF,SAASC,YAAYlF,KAAK;QAAEmF,eAAe;MAAK,CAAA,GAAI;AAC7D,cAAMC,OAAOhF,KAAKJ,KAAKiF,MAAMI,IAAI;AACjC,YAAIJ,MAAMK,YAAW,EAAIN,MAAKI,IAAAA;iBACrBH,MAAMI,KAAKE,SAASR,MAAAA,EAAS1B,OAAMa,KAAKsB,SAASrC,SAASiC,IAAAA,CAAAA;MACrE;IACF,QAAQ;IAER;EACF;AAVSJ;AAWTA,OAAKH,OAAAA;AACL,SAAOxB;AACT;AA3BSC;","names":["MiddlewareConsumerImpl","entries","container","apply","middleware","resolved","map","m","resolveMiddleware","excludePatterns","proxy","exclude","routes","r","push","path","forRoutes","routePatterns","handler","getEntries","prototype","use","instance","resolveOrNew","request","next","middlewareMatchesPath","entry","requestPath","pattern","pathMatches","normPath","replace","normPattern","startsWith","runMiddleware","response","Promise","resolve","readFileSync","writeFileSync","unlinkSync","readdirSync","createRequire","resolve","dirname","join","relative","pathToFileURL","fileURLToPath","getSwcrcTarget","swcrc","jsc","target","consumerSwcrcCache","readConsumerSwcrc","startDir","undefined","dir","root","dirname","candidate","join","raw","readFileSync","parsed","JSON","parse","$schema","parent","swcCoreCache","loadSwcCore","thisDir","fileURLToPath","url","req","createRequire","resolve","resolved","pathToFileURL","href","transformControllerSource","source","filename","loadSwc","swc","HttpDecoratorsConfigError","consumerSwcrc","consumerJsc","code","transformSync","parser","syntax","decorators","transform","legacyDecorator","decoratorMetadata","module","type","sourceMaps","loadControllerWithSwc","absoluteFilePath","tmpPath","replace","writeFileSync","Date","now","unlinkSync","loadControllersFromGlob","rootDir","pattern","files","scanControllerFiles","length","console","warn","controllers","file","absPath","mod","exported","Object","values","isControllerClass","push","fn","Reflect","hasMetadata","Symbol","for","parts","split","dirParts","part","includes","baseDir","lastPart","suffix","walk","entry","readdirSync","withFileTypes","full","name","isDirectory","endsWith","relative"]}
|