glasswork 0.6.2 → 0.7.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/README.md +37 -9
- package/dist/core/bootstrap.d.ts.map +1 -1
- package/dist/core/bootstrap.js +43 -6
- package/dist/core/bootstrap.js.map +1 -1
- package/dist/core/types.d.ts +103 -23
- package/dist/core/types.d.ts.map +1 -1
- package/dist/http/route-helpers.d.ts +102 -44
- package/dist/http/route-helpers.d.ts.map +1 -1
- package/dist/http/route-helpers.js +137 -129
- package/dist/http/route-helpers.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/list-query/casl.d.ts +9 -8
- package/dist/list-query/casl.d.ts.map +1 -1
- package/dist/list-query/casl.js +29 -11
- package/dist/list-query/casl.js.map +1 -1
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +47 -13
- package/dist/middleware/rate-limit.js.map +1 -1
- package/dist/openapi/defaults.d.ts.map +1 -1
- package/dist/openapi/defaults.js +5 -3
- package/dist/openapi/defaults.js.map +1 -1
- package/dist/openapi/openapi-processors.d.ts +51 -0
- package/dist/openapi/openapi-processors.d.ts.map +1 -0
- package/dist/openapi/openapi-processors.js +166 -0
- package/dist/openapi/openapi-processors.js.map +1 -0
- package/dist/openapi/openapi.d.ts +36 -3
- package/dist/openapi/openapi.d.ts.map +1 -1
- package/dist/openapi/openapi.js +27 -39
- package/dist/openapi/openapi.js.map +1 -1
- package/dist/utils/serialize-prisma-types.d.ts +63 -30
- package/dist/utils/serialize-prisma-types.d.ts.map +1 -1
- package/dist/utils/serialize-prisma-types.js +8 -4
- package/dist/utils/serialize-prisma-types.js.map +1 -1
- package/package.json +11 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describeRoute as honoDescribeRoute, resolver, validator, } from 'hono-openapi';
|
|
2
2
|
import { safeParseAsync } from 'valibot';
|
|
3
|
+
import { applyProcessors } from '../openapi/openapi-processors.js';
|
|
3
4
|
import { getClientIp } from '../utils/get-client-ip.js';
|
|
4
5
|
import { createLogger } from '../utils/logger.js';
|
|
5
6
|
import { defaultConfig as defaultSerializationConfig, serializePrismaTypes, } from '../utils/serialize-prisma-types.js';
|
|
@@ -8,49 +9,26 @@ import { defaultConfig as defaultSerializationConfig, serializePrismaTypes, } fr
|
|
|
8
9
|
*/
|
|
9
10
|
const logger = createLogger('Routes');
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* Storage for OpenAPI context per Hono app instance.
|
|
13
|
+
* Uses WeakMap to avoid memory leaks and support multiple app instances.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
const openAPIContextMap = new WeakMap();
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* Used when building route security (public: false routes).
|
|
19
|
-
*/
|
|
20
|
-
let globalSecuritySchemes = [];
|
|
21
|
-
/**
|
|
22
|
-
* Set the global OpenAPI response hooks.
|
|
23
|
-
* This is called during bootstrap and makes hooks available to route definitions.
|
|
17
|
+
* Set the OpenAPI context for a Hono app instance.
|
|
18
|
+
* This is called during bootstrap and makes processors/schemes available to route definitions.
|
|
24
19
|
*
|
|
25
20
|
* @internal
|
|
26
21
|
*/
|
|
27
|
-
export function
|
|
28
|
-
|
|
22
|
+
export function setOpenAPIContext(app, context) {
|
|
23
|
+
openAPIContextMap.set(app, context);
|
|
29
24
|
}
|
|
30
25
|
/**
|
|
31
|
-
* Get the
|
|
26
|
+
* Get the OpenAPI context for a Hono app instance.
|
|
32
27
|
*
|
|
33
28
|
* @internal
|
|
34
29
|
*/
|
|
35
|
-
export function
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Set the global OpenAPI security schemes.
|
|
40
|
-
* This is called during bootstrap and makes security schemes available to route definitions.
|
|
41
|
-
*
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
export function setGlobalSecuritySchemes(schemes) {
|
|
45
|
-
globalSecuritySchemes = schemes;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get the current global OpenAPI security schemes.
|
|
49
|
-
*
|
|
50
|
-
* @internal
|
|
51
|
-
*/
|
|
52
|
-
export function getGlobalSecuritySchemes() {
|
|
53
|
-
return globalSecuritySchemes;
|
|
30
|
+
export function getOpenAPIContext(app) {
|
|
31
|
+
return openAPIContextMap.get(app) ?? { processors: [], securitySchemes: [] };
|
|
54
32
|
}
|
|
55
33
|
/**
|
|
56
34
|
* HTTP status codes with descriptions
|
|
@@ -74,7 +52,10 @@ const STATUS_DESCRIPTIONS = {
|
|
|
74
52
|
500: 'Internal Server Error',
|
|
75
53
|
};
|
|
76
54
|
/**
|
|
77
|
-
* Create routes with typed service injection.
|
|
55
|
+
* Create routes with typed service injection and pre-bound route function.
|
|
56
|
+
*
|
|
57
|
+
* The `route` function passed to your factory is pre-bound to the router's
|
|
58
|
+
* OpenAPI context, so you don't need to pass the router to every route call.
|
|
78
59
|
*
|
|
79
60
|
* @template TServices - The shape of services required by these routes
|
|
80
61
|
*
|
|
@@ -85,15 +66,54 @@ const STATUS_DESCRIPTIONS = {
|
|
|
85
66
|
* userService: UserService;
|
|
86
67
|
* }
|
|
87
68
|
*
|
|
88
|
-
* export const authRoutes = createRoutes<AuthRoutesServices>((router, services) => {
|
|
69
|
+
* export const authRoutes = createRoutes<AuthRoutesServices>((router, services, route) => {
|
|
89
70
|
* // services.authService is typed as AuthService!
|
|
90
|
-
* //
|
|
91
|
-
* router.post('/login', ...
|
|
71
|
+
* // route is pre-bound to this router's OpenAPI context
|
|
72
|
+
* router.post('/login', ...route({
|
|
73
|
+
* body: LoginDto,
|
|
74
|
+
* responses: { 200: SessionDto },
|
|
75
|
+
* handler: async ({ body }) => {
|
|
76
|
+
* return services.authService.login(body);
|
|
77
|
+
* }
|
|
78
|
+
* }));
|
|
92
79
|
* });
|
|
93
80
|
* ```
|
|
94
81
|
*/
|
|
95
82
|
export function createRoutes(factory) {
|
|
96
|
-
return
|
|
83
|
+
return (router, services) => {
|
|
84
|
+
// Create a bound route function for this router
|
|
85
|
+
const boundRoute = (config) => route(router, config);
|
|
86
|
+
factory(router, services, boundRoute);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Detect if a query schema includes pagination fields (page, pageSize).
|
|
91
|
+
* Used to auto-detect pagination for OpenAPI documentation.
|
|
92
|
+
*/
|
|
93
|
+
function hasPaginationFields(schema) {
|
|
94
|
+
if (!schema)
|
|
95
|
+
return false;
|
|
96
|
+
// Check if schema has page or pageSize entries
|
|
97
|
+
// This works for Valibot object schemas
|
|
98
|
+
const schemaAny = schema;
|
|
99
|
+
if (schemaAny.entries) {
|
|
100
|
+
return 'page' in schemaAny.entries || 'pageSize' in schemaAny.entries;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create a validation middleware for request validation.
|
|
106
|
+
* Returns 422 Unprocessable Entity on validation failure (instead of Hono's default 400).
|
|
107
|
+
*
|
|
108
|
+
* @param type - The validation target ('json' for body, 'query', or 'param')
|
|
109
|
+
* @param schema - The Valibot schema to validate against
|
|
110
|
+
*/
|
|
111
|
+
function createValidationMiddleware(type, schema) {
|
|
112
|
+
return validator(type, schema, (result, c) => {
|
|
113
|
+
if (!result.success) {
|
|
114
|
+
return c.json({ error: 'Validation failed', issues: result.error }, 422);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
97
117
|
}
|
|
98
118
|
/**
|
|
99
119
|
* Create a route handler with validation and OpenAPI metadata.
|
|
@@ -111,20 +131,23 @@ export function createRoutes(factory) {
|
|
|
111
131
|
* - If multiple 2xx schemas are defined, each is tried in order (200, 201)
|
|
112
132
|
* - The first schema that successfully validates determines the status code
|
|
113
133
|
*
|
|
134
|
+
* @param router - The Hono router instance (needed for OpenAPI context)
|
|
135
|
+
* @param config - Route configuration
|
|
136
|
+
*
|
|
114
137
|
* @example
|
|
115
138
|
* ```typescript
|
|
116
139
|
* // Single response type
|
|
117
|
-
* route({
|
|
140
|
+
* router.post('/session', ...route(router, {
|
|
118
141
|
* body: StartSessionDto,
|
|
119
142
|
* responses: { 200: StartSessionResponseDto },
|
|
120
143
|
* handler: async ({ body }) => {
|
|
121
144
|
* // body is typed as InferOutput<typeof StartSessionDto>
|
|
122
145
|
* return { email: body.email }; // Must match StartSessionResponseDto
|
|
123
146
|
* }
|
|
124
|
-
* })
|
|
147
|
+
* }))
|
|
125
148
|
*
|
|
126
149
|
* // Union response type (multiple 2xx responses with automatic status)
|
|
127
|
-
* route({
|
|
150
|
+
* router.post('/login', ...route(router, {
|
|
128
151
|
* body: LoginDto,
|
|
129
152
|
* responses: {
|
|
130
153
|
* 200: MfaRequiredDto, // Returns 200 if data matches this
|
|
@@ -136,55 +159,52 @@ export function createRoutes(factory) {
|
|
|
136
159
|
* if (needsMfa) return { mfaRequired: true, methods: ['totp'] }; // 200
|
|
137
160
|
* return { sessionId: '123', token: 'abc' }; // 201
|
|
138
161
|
* }
|
|
139
|
-
* })
|
|
162
|
+
* }))
|
|
140
163
|
*
|
|
141
|
-
* //
|
|
142
|
-
* route({
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
164
|
+
* // With pagination (auto-detected from ListQuerySchema)
|
|
165
|
+
* router.get('/users', ...route(router, {
|
|
166
|
+
* query: ListQuerySchema, // Contains page, pageSize - pagination headers auto-added
|
|
167
|
+
* responses: { 200: UsersResponseDto },
|
|
168
|
+
* handler: async ({ query }) => { ... }
|
|
169
|
+
* }))
|
|
170
|
+
*
|
|
171
|
+
* // With custom response headers
|
|
172
|
+
* router.get('/data', ...route(router, {
|
|
173
|
+
* openapi: {
|
|
174
|
+
* responseHeaders: ['Api-Version', 'Server-Timing']
|
|
175
|
+
* },
|
|
176
|
+
* responses: { 200: DataDto },
|
|
177
|
+
* handler: async () => { ... }
|
|
178
|
+
* }))
|
|
151
179
|
* ```
|
|
152
180
|
*/
|
|
153
|
-
export function route(config) {
|
|
181
|
+
export function route(router, config) {
|
|
154
182
|
const middlewares = [];
|
|
183
|
+
// Get OpenAPI context from the router
|
|
184
|
+
const openAPIContext = getOpenAPIContext(router);
|
|
185
|
+
// Detect pagination from query schema
|
|
186
|
+
const hasPagination = hasPaginationFields(config.query);
|
|
155
187
|
// Add OpenAPI metadata
|
|
156
|
-
middlewares.push(buildOpenAPIMiddleware(config));
|
|
188
|
+
middlewares.push(buildOpenAPIMiddleware(config, openAPIContext, hasPagination));
|
|
157
189
|
// Add custom middleware (e.g., auth) before validation
|
|
158
190
|
if (config.middleware) {
|
|
159
191
|
middlewares.push(...config.middleware);
|
|
160
192
|
}
|
|
161
|
-
// Add validation middleware
|
|
193
|
+
// Add validation middleware (returns 422 instead of Hono's default 400)
|
|
162
194
|
if (config.body) {
|
|
163
|
-
middlewares.push(
|
|
164
|
-
if (!result.success) {
|
|
165
|
-
return c.json({ error: 'Validation failed', issues: result.error }, 422);
|
|
166
|
-
}
|
|
167
|
-
}));
|
|
195
|
+
middlewares.push(createValidationMiddleware('json', config.body));
|
|
168
196
|
}
|
|
169
197
|
if (config.query) {
|
|
170
|
-
middlewares.push(
|
|
171
|
-
if (!result.success) {
|
|
172
|
-
return c.json({ error: 'Validation failed', issues: result.error }, 422);
|
|
173
|
-
}
|
|
174
|
-
}));
|
|
198
|
+
middlewares.push(createValidationMiddleware('query', config.query));
|
|
175
199
|
}
|
|
176
200
|
if (config.params) {
|
|
177
|
-
middlewares.push(
|
|
178
|
-
if (!result.success) {
|
|
179
|
-
return c.json({ error: 'Validation failed', issues: result.error }, 422);
|
|
180
|
-
}
|
|
181
|
-
}));
|
|
201
|
+
middlewares.push(createValidationMiddleware('param', config.params));
|
|
182
202
|
}
|
|
183
203
|
// Add handler wrapper
|
|
184
204
|
middlewares.push(async (c) => {
|
|
185
205
|
const routeContext = buildRouteContext(c);
|
|
186
206
|
const result = await config.handler(routeContext);
|
|
187
|
-
return handleResponse(result, config.responses, config.serialization, config.summary, c);
|
|
207
|
+
return handleResponse(result, config.responses, config.serialization, config.strictTypes, config.summary, c);
|
|
188
208
|
});
|
|
189
209
|
return middlewares;
|
|
190
210
|
}
|
|
@@ -217,7 +237,7 @@ function serializeResponseData(data, serializationConfig) {
|
|
|
217
237
|
* @param context - Hono context
|
|
218
238
|
* @returns Response object or undefined if handled
|
|
219
239
|
*/
|
|
220
|
-
async function handleResponse(result, responses, serializationConfig, routeSummary, context) {
|
|
240
|
+
async function handleResponse(result, responses, serializationConfig, strictTypes, routeSummary, context) {
|
|
221
241
|
// If handler returned a Response, return it directly (for custom responses like text)
|
|
222
242
|
if (result instanceof Response) {
|
|
223
243
|
return result;
|
|
@@ -230,7 +250,14 @@ async function handleResponse(result, responses, serializationConfig, routeSumma
|
|
|
230
250
|
// Serialize Prisma types and custom transformers
|
|
231
251
|
let serializedResult;
|
|
232
252
|
try {
|
|
233
|
-
|
|
253
|
+
// Only serialize if strictTypes is disabled (default)
|
|
254
|
+
// If strictTypes is true, we expect the handler to return exact types
|
|
255
|
+
if (!strictTypes) {
|
|
256
|
+
serializedResult = serializeResponseData(result, serializationConfig);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
serializedResult = result;
|
|
260
|
+
}
|
|
234
261
|
}
|
|
235
262
|
catch (error) {
|
|
236
263
|
// Handle serialization errors (circular references, max depth exceeded)
|
|
@@ -300,13 +327,15 @@ async function parseResponse(data, responses) {
|
|
|
300
327
|
'This would throw an error in production.');
|
|
301
328
|
return { data };
|
|
302
329
|
}
|
|
303
|
-
function buildOpenAPIMiddleware(config) {
|
|
304
|
-
const responses = buildOpenAPIResponses(config);
|
|
305
|
-
// Build security requirement based on
|
|
330
|
+
function buildOpenAPIMiddleware(config, openAPIContext, hasPagination) {
|
|
331
|
+
const responses = buildOpenAPIResponses(config, openAPIContext, hasPagination);
|
|
332
|
+
// Build security requirement based on security schemes from context
|
|
306
333
|
// Public routes have no security, authenticated routes use all available schemes
|
|
307
334
|
const security = config.public
|
|
308
335
|
? []
|
|
309
|
-
:
|
|
336
|
+
: openAPIContext.securitySchemes.map((scheme) => ({ [scheme]: [] }));
|
|
337
|
+
// Extract responseHeaders from openapi config to avoid passing it to hono-openapi
|
|
338
|
+
const { responseHeaders: _responseHeaders, ...restOpenapi } = config.openapi ?? {};
|
|
310
339
|
const openApiConfig = {
|
|
311
340
|
operationId: config.operationId || config.summary,
|
|
312
341
|
tags: config.tags,
|
|
@@ -314,53 +343,30 @@ function buildOpenAPIMiddleware(config) {
|
|
|
314
343
|
description: config.description,
|
|
315
344
|
responses: responses,
|
|
316
345
|
security,
|
|
317
|
-
...
|
|
318
|
-
...config.openapi,
|
|
346
|
+
...restOpenapi,
|
|
319
347
|
};
|
|
320
348
|
return honoDescribeRoute(openApiConfig);
|
|
321
349
|
}
|
|
322
|
-
|
|
323
|
-
* Build pagination parameters for OpenAPI spec
|
|
324
|
-
*/
|
|
325
|
-
function buildPaginationParameters() {
|
|
326
|
-
return [
|
|
327
|
-
{
|
|
328
|
-
name: 'page',
|
|
329
|
-
in: 'query',
|
|
330
|
-
required: false,
|
|
331
|
-
schema: {
|
|
332
|
-
type: 'integer',
|
|
333
|
-
format: 'int32',
|
|
334
|
-
minimum: 1,
|
|
335
|
-
maximum: 2147483647, // Max int32
|
|
336
|
-
default: 1,
|
|
337
|
-
},
|
|
338
|
-
description: 'Page number',
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
name: 'limit',
|
|
342
|
-
in: 'query',
|
|
343
|
-
required: false,
|
|
344
|
-
schema: {
|
|
345
|
-
type: 'integer',
|
|
346
|
-
format: 'int32',
|
|
347
|
-
minimum: 1,
|
|
348
|
-
maximum: 100,
|
|
349
|
-
default: 50,
|
|
350
|
-
},
|
|
351
|
-
description: 'Number of items per page',
|
|
352
|
-
},
|
|
353
|
-
];
|
|
354
|
-
}
|
|
355
|
-
function buildOpenAPIResponses(config) {
|
|
350
|
+
function buildOpenAPIResponses(config, openAPIContext, hasPagination) {
|
|
356
351
|
const responses = {};
|
|
357
352
|
// Add default error responses
|
|
353
|
+
// Include 422 when body, query, or params validation is configured
|
|
354
|
+
const hasValidation = !!(config.body || config.query || config.params);
|
|
358
355
|
const defaultResponses = config.public
|
|
359
|
-
? {
|
|
360
|
-
|
|
356
|
+
? {
|
|
357
|
+
400: undefined,
|
|
358
|
+
...(hasValidation && { 422: undefined }),
|
|
359
|
+
429: undefined,
|
|
360
|
+
500: undefined,
|
|
361
|
+
}
|
|
362
|
+
: {
|
|
363
|
+
400: undefined,
|
|
364
|
+
401: undefined,
|
|
365
|
+
...(hasValidation && { 422: undefined }),
|
|
366
|
+
429: undefined,
|
|
367
|
+
500: undefined,
|
|
368
|
+
};
|
|
361
369
|
const allResponses = { ...defaultResponses, ...(config.responses || {}) };
|
|
362
|
-
// Get global hooks
|
|
363
|
-
const hooks = getGlobalResponseHooks();
|
|
364
370
|
for (const [statusCode, schema] of Object.entries(allResponses)) {
|
|
365
371
|
const code = Number(statusCode);
|
|
366
372
|
const description = STATUS_DESCRIPTIONS[code] || 'Response';
|
|
@@ -393,18 +399,20 @@ function buildOpenAPIResponses(config) {
|
|
|
393
399
|
}
|
|
394
400
|
: {}),
|
|
395
401
|
};
|
|
396
|
-
//
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
}
|
|
402
|
+
// Build processor context
|
|
403
|
+
const processorContext = {
|
|
404
|
+
statusCode,
|
|
405
|
+
hasPagination,
|
|
406
|
+
routeConfig: {
|
|
407
|
+
...config,
|
|
408
|
+
public: config.public,
|
|
409
|
+
tags: config.tags,
|
|
410
|
+
summary: config.summary,
|
|
411
|
+
openapi: config.openapi,
|
|
412
|
+
},
|
|
413
|
+
};
|
|
414
|
+
// Apply processors to build up headers
|
|
415
|
+
response = applyProcessors(response, processorContext, openAPIContext.processors);
|
|
408
416
|
responses[statusCode] = response;
|
|
409
417
|
}
|
|
410
418
|
return responses;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-helpers.js","sourceRoot":"","sources":["../../src/http/route-helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,aAAa,IAAI,iBAAiB,EAClC,QAAQ,EACR,SAAS,GACV,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"route-helpers.js","sourceRoot":"","sources":["../../src/http/route-helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,aAAa,IAAI,iBAAiB,EAClC,QAAQ,EACR,SAAS,GACV,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAOzC,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAEL,aAAa,IAAI,0BAA0B,EAE3C,oBAAoB,GACrB,MAAM,oCAAoC,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAWtC;;;GAGG;AACH,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAwB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAS,EAAE,OAAuB;IAClE,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAS;IACzC,OAAO,iBAAiB,CAAC,GAAG,C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BACjB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB;SACF,CAAC;QAEF,uCAAuC;QACvC,QAAQ,GAAG,eAAe,CAAC,QAAQ,EAAE,gBAAgB,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;QAElF,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;IACnC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,iBAAiB,CAAC,CAAU;IAKnC,MAAM,GAAG,GAAG,CAAC,CAAC,GAAkC,CAAC;IAEjD,yDAAyD;IACzD,iFAAiF;IACjF,gEAAgE;IAChE,iFAAiF;IACjF,OAAO;QACL,GAAG,CAAC,CAAC,GAAG;QACR,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;QACvB,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAA2B;QACnD,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAA2B;QACpD,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE;QACjC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC;QACzB,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;QAClB,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC;QACrC,OAAO,EAAE,CAAC;KACX,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,19 +12,19 @@ export type { OpenAPIV3 } from 'openapi-types';
|
|
|
12
12
|
export { type Config, type ConfigOptions, type ConfigProvider, ConfigValidationException, createConfig, type DotenvProviderOptions, dotenvProvider, type EnvProviderOptions, envProvider, objectProvider, parseArray, parseBoolean, parseJson, type SsmProviderOptions, ssmProvider, toCamelCase, toSnakeCase, validateConfig, } from './config/index.js';
|
|
13
13
|
export { bootstrap } from './core/bootstrap.js';
|
|
14
14
|
export { defineModule } from './core/module.js';
|
|
15
|
-
export type { BootstrapOptions, BootstrapResult, Constructor, Environment, LoggerOptions, MiddlewareOptions, ModuleConfig, OpenAPIDocumentation, OpenAPIOptions,
|
|
15
|
+
export type { BootstrapOptions, BootstrapResult, Constructor, Environment, LoggerOptions, MiddlewareOptions, ModuleConfig, OpenAPIDocumentation, OpenAPIOptions, OpenAPIProcessorContext, OpenAPIResponseObject, OpenAPIResponseProcessor, ProviderConfig, RateLimitOptions, RateLimitStorage, RouteConfigExtensions, ServiceScope, } from './core/types.js';
|
|
16
16
|
export { createErrorHandler, defaultErrorHandler } from './http/error-handler.js';
|
|
17
17
|
export { type ErrorResponse, ErrorResponseDto, type ValidationErrorResponse, ValidationErrorResponseDto, type ValidationIssue, ValidationIssueDto, } from './http/error-response.dto.js';
|
|
18
18
|
export { BadGatewayException, BadRequestException, ConflictException, DomainException, ForbiddenException, GatewayTimeoutException, GoneException, InternalServerErrorException, LockedException, MethodNotAllowedException, NotFoundException, NotImplementedException, PayloadTooLargeException, PreconditionFailedException, RequestTimeoutException, ServiceUnavailableException, TooManyRequestsException, UnauthorizedException, UnprocessableEntityException, UnsupportedMediaTypeException, ValidationException, } from './http/errors.js';
|
|
19
|
-
export type { RouteConfig, RouteContext, RouteFactory, ValibotSchema, } from './http/route-helpers.js';
|
|
19
|
+
export type { BoundRouteFunction, RouteConfig, RouteContext, RouteFactory, RouteOpenAPIOptions, ValibotSchema, } from './http/route-helpers.js';
|
|
20
20
|
export { createRoutes, route } from './http/route-helpers.js';
|
|
21
21
|
export { createCaslScope, withCaslScope } from './list-query/casl.js';
|
|
22
22
|
export type { AggregationConfig, AggregationResult, AggregationType, FieldPath, FilterOperator, ParsedFilter, ParsedQueryParams, ParsedSort, PrismaAggregationParams, PrismaListParams, RawQueryParams, SchemaValidationConfig, SearchFieldInput, SortDirection, ValidatedListParams, } from './list-query/index.js';
|
|
23
23
|
export { booleanFilterSchema, createFilterSchema, createListQuery, createSortSchema, dateFilterSchema, enumFilterSchema, type ListQueryBuilder, type ListQueryConfig, ListQuerySchema, numberFilterSchema, type PaginatedResult, relationFilterSchema, sortDirectionSchema, stringFilterSchema, } from './list-query/index.js';
|
|
24
24
|
export { createRateLimitMiddleware } from './middleware/rate-limit.js';
|
|
25
25
|
export { defaultOpenAPIComponents } from './openapi/defaults.js';
|
|
26
|
-
export { createCorsHeadersHook, createPaginationHeadersHook, createRateLimitHeadersHook, } from './openapi/hooks.js';
|
|
27
26
|
export { configureOpenAPI } from './openapi/openapi.js';
|
|
27
|
+
export { applyProcessors, createBuiltinProcessors, createCorsHeadersProcessor, createRateLimitHeadersProcessor, paginationHeadersProcessor, responseHeadersProcessor, } from './openapi/openapi-processors.js';
|
|
28
28
|
export { deepMerge } from './utils/deep-merge.js';
|
|
29
29
|
export { isDevelopment, isLambda, isProduction, isTest } from './utils/environment.js';
|
|
30
30
|
export { getClientIp } from './utils/get-client-ip.js';
|
|
@@ -32,6 +32,6 @@ export type { Logger } from './utils/logger.js';
|
|
|
32
32
|
export { createLogger, createPlainLogger, defaultLogger } from './utils/logger.js';
|
|
33
33
|
export { omit } from './utils/omit.js';
|
|
34
34
|
export { pick } from './utils/pick.js';
|
|
35
|
-
export type { AcceptPrismaTypes, SerializationConfig, SerializedTypes, TypeTransformer, } from './utils/serialize-prisma-types.js';
|
|
35
|
+
export type { AcceptPrismaTypes, PrismaDecimalLike, SerializationConfig, SerializedTypes, TypeTransformer, } from './utils/serialize-prisma-types.js';
|
|
36
36
|
export { defaultConfig, serializePrismaTypes } from './utils/serialize-prisma-types.js';
|
|
37
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,M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ortSch
|
|
|
24
24
|
export { createRateLimitMiddleware } from './middleware/rate-limit.js';
|
|
25
25
|
// OpenAPI
|
|
26
26
|
export { defaultOpenAPIComponents } from './openapi/defaults.js';
|
|
27
|
-
export { createCorsHeadersHook, createPaginationHeadersHook, createRateLimitHeadersHook, } from './openapi/hooks.js';
|
|
28
27
|
export { configureOpenAPI } from './openapi/openapi.js';
|
|
28
|
+
export { applyProcessors, createBuiltinProcessors, createCorsHeadersProcessor, createRateLimitHeadersProcessor, paginationHeadersProcessor, responseHeadersProcessor, } from './openapi/openapi-processors.js';
|
|
29
29
|
// Utilities
|
|
30
30
|
export { deepMerge } from './utils/deep-merge.js';
|
|
31
31
|
export { isDevelopment, isLambda, isProduction, isTest } from './utils/environment.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,gBAAgB;AAChB,OAAO,EAIL,yBAAyB,EACzB,YAAY,EAEZ,cAAc,EAEd,WAAW,EACX,cAAc,EACd,UAAU,EACV,YAAY,EACZ,SAAS,EAET,WAAW,EACX,WAAW,EACX,WAAW,EACX,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,iBAAiB;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,gBAAgB;AAChB,OAAO,EAIL,yBAAyB,EACzB,YAAY,EAEZ,cAAc,EAEd,WAAW,EACX,cAAc,EACd,UAAU,EACV,YAAY,EACZ,SAAS,EAET,WAAW,EACX,WAAW,EACX,WAAW,EACX,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,iBAAiB;AACjB,OAAO,EAAE,SAAS,EAAE,MA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YAAY;AACZ,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAQvC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
import type { PureAbility } from '@casl/ability';
|
|
2
1
|
import type { ListQueryBuilder } from './builder.js';
|
|
3
2
|
/**
|
|
4
3
|
* Create a CASL scope function that can be applied to a ListQueryBuilder
|
|
5
4
|
*
|
|
6
|
-
* @param ability - The CASL ability instance
|
|
5
|
+
* @param ability - The CASL ability instance (any object that works with @casl/prisma's accessibleBy)
|
|
7
6
|
* @param subject - The Prisma model name (e.g., 'User', 'Organization')
|
|
8
7
|
* @returns A function that applies the CASL conditions to a builder
|
|
9
8
|
*
|
|
10
9
|
* @example
|
|
11
10
|
* ```typescript
|
|
12
|
-
*
|
|
11
|
+
* import { PureAbility } from '@casl/ability';
|
|
12
|
+
* const scope = await createCaslScope(ability, 'User');
|
|
13
13
|
* const params = createListQuery({ filter: UserFilterSchema })
|
|
14
14
|
* .parse(query)
|
|
15
15
|
* .apply(scope)
|
|
16
16
|
* .build();
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export declare function createCaslScope<TAbility
|
|
19
|
+
export declare function createCaslScope<TAbility = any>(ability: TAbility, subject: string): Promise<(builder: ListQueryBuilder<any, any>) => ListQueryBuilder<any, any>>;
|
|
20
20
|
/**
|
|
21
21
|
* Create a CASL scope helper that extracts ability from context
|
|
22
22
|
*
|
|
23
23
|
* @param subject - The Prisma model name (e.g., 'User', 'Organization')
|
|
24
|
-
* @returns
|
|
24
|
+
* @returns An async function that takes a builder and ability, and applies the CASL conditions
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* ```typescript
|
|
28
|
+
* import { PureAbility } from '@casl/ability';
|
|
28
29
|
* const scopeUsers = withCaslScope('User');
|
|
29
|
-
* const params = createListQuery({ filter: UserFilterSchema })
|
|
30
|
+
* const params = await createListQuery({ filter: UserFilterSchema })
|
|
30
31
|
* .parse(query)
|
|
31
|
-
* .
|
|
32
|
+
* .applyAsync(scopeUsers, ability)
|
|
32
33
|
* .build();
|
|
33
34
|
* ```
|
|
34
35
|
*/
|
|
35
|
-
export declare function withCaslScope(subject: string): <TAbility
|
|
36
|
+
export declare function withCaslScope(subject: string): <TAbility = any>(builder: ListQueryBuilder<any, any>, ability: TAbility) => Promise<ListQueryBuilder<any, any>>;
|
|
36
37
|
//# sourceMappingURL=casl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"casl.d.ts","sourceRoot":"","sources":["../../src/list-query/casl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"casl.d.ts","sourceRoot":"","sources":["../../src/list-query/casl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAkBrD;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAsB,eAAe,CAAC,QAAQ,GAAG,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,qBAKrE,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,iCAC5C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,IAE7B,QAAQ,GAAG,GAAG,EAE1B,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,EACnC,SAAS,QAAQ,yCAMpB"}
|