glasswork 0.1.1 → 0.2.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/dist/config/config-service.d.ts +101 -0
- package/dist/config/config-service.d.ts.map +1 -0
- package/dist/config/config-service.js +164 -0
- package/dist/config/config-service.js.map +1 -0
- package/dist/config/helpers.d.ts +101 -0
- package/dist/config/helpers.d.ts.map +1 -0
- package/dist/config/helpers.js +122 -0
- package/dist/config/helpers.js.map +1 -0
- package/dist/config/index.d.ts +39 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +41 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/providers.d.ts +163 -0
- package/dist/config/providers.d.ts.map +1 -0
- package/dist/config/providers.js +188 -0
- package/dist/config/providers.js.map +1 -0
- package/dist/config/types.d.ts +98 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +7 -0
- package/dist/config/types.js.map +1 -0
- package/dist/core/bootstrap.js +9 -3
- package/dist/core/bootstrap.js.map +1 -1
- package/dist/core/types.d.ts +2 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/http/errors.d.ts +39 -0
- package/dist/http/errors.d.ts.map +1 -1
- package/dist/http/errors.js +78 -0
- package/dist/http/errors.js.map +1 -1
- package/dist/http/route-helpers.d.ts +13 -6
- package/dist/http/route-helpers.d.ts.map +1 -1
- package/dist/http/route-helpers.js +29 -1
- package/dist/http/route-helpers.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +2 -16
- package/dist/middleware/rate-limit.js.map +1 -1
- package/dist/openapi/openapi.d.ts +1 -1
- package/dist/openapi/openapi.d.ts.map +1 -1
- package/dist/openapi/openapi.js +21 -3
- package/dist/openapi/openapi.js.map +1 -1
- package/package.json +22 -1
- package/dist/bootstrap.d.ts +0 -55
- package/dist/bootstrap.d.ts.map +0 -1
- package/dist/bootstrap.js +0 -359
- package/dist/bootstrap.js.map +0 -1
- package/dist/environment.d.ts +0 -21
- package/dist/environment.d.ts.map +0 -1
- package/dist/environment.js +0 -29
- package/dist/environment.js.map +0 -1
- package/dist/error-handler.d.ts +0 -33
- package/dist/error-handler.d.ts.map +0 -1
- package/dist/error-handler.js +0 -53
- package/dist/error-handler.js.map +0 -1
- package/dist/errors.d.ts +0 -36
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -65
- package/dist/errors.js.map +0 -1
- package/dist/get-client-ip.d.ts +0 -24
- package/dist/get-client-ip.d.ts.map +0 -1
- package/dist/get-client-ip.js +0 -49
- package/dist/get-client-ip.js.map +0 -1
- package/dist/logger.d.ts +0 -37
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -52
- package/dist/logger.js.map +0 -1
- package/dist/module.d.ts +0 -21
- package/dist/module.d.ts.map +0 -1
- package/dist/module.js +0 -85
- package/dist/module.js.map +0 -1
- package/dist/omit.d.ts +0 -20
- package/dist/omit.d.ts.map +0 -1
- package/dist/omit.js +0 -28
- package/dist/omit.js.map +0 -1
- package/dist/openapi-defaults.d.ts +0 -11
- package/dist/openapi-defaults.d.ts.map +0 -1
- package/dist/openapi-defaults.js +0 -127
- package/dist/openapi-defaults.js.map +0 -1
- package/dist/openapi-hooks.d.ts +0 -14
- package/dist/openapi-hooks.d.ts.map +0 -1
- package/dist/openapi-hooks.js +0 -80
- package/dist/openapi-hooks.js.map +0 -1
- package/dist/openapi.d.ts +0 -24
- package/dist/openapi.d.ts.map +0 -1
- package/dist/openapi.js +0 -106
- package/dist/openapi.js.map +0 -1
- package/dist/pagination.d.ts +0 -48
- package/dist/pagination.d.ts.map +0 -1
- package/dist/pagination.js +0 -43
- package/dist/pagination.js.map +0 -1
- package/dist/pick.d.ts +0 -20
- package/dist/pick.d.ts.map +0 -1
- package/dist/pick.js +0 -28
- package/dist/pick.js.map +0 -1
- package/dist/rate-limit.d.ts +0 -7
- package/dist/rate-limit.d.ts.map +0 -1
- package/dist/rate-limit.js +0 -180
- package/dist/rate-limit.js.map +0 -1
- package/dist/route-helpers.d.ts +0 -172
- package/dist/route-helpers.d.ts.map +0 -1
- package/dist/route-helpers.js +0 -249
- package/dist/route-helpers.js.map +0 -1
- package/dist/serialize-dates.d.ts +0 -27
- package/dist/serialize-dates.d.ts.map +0 -1
- package/dist/serialize-dates.js +0 -39
- package/dist/serialize-dates.js.map +0 -1
- package/dist/testing.d.ts +0 -87
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js +0 -94
- package/dist/testing.js.map +0 -1
- package/dist/types.d.ts +0 -273
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -9
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -31
- package/dist/utils.js.map +0 -1
package/dist/get-client-ip.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract the client IP address from Hono context.
|
|
3
|
-
*
|
|
4
|
-
* Checks headers in order:
|
|
5
|
-
* 1. x-forwarded-for (proxy/load balancer)
|
|
6
|
-
* 2. x-real-ip (nginx)
|
|
7
|
-
* 3. Direct connection info (if available)
|
|
8
|
-
*
|
|
9
|
-
* @param c - Hono context
|
|
10
|
-
* @returns Client IP address or 'unknown' if not determinable
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* router.post('/login', route({
|
|
15
|
-
* handler: async ({ ip }) => {
|
|
16
|
-
* // ip is automatically populated
|
|
17
|
-
* await authService.logLoginAttempt(email, ip);
|
|
18
|
-
* }
|
|
19
|
-
* }));
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export function getClientIp(c) {
|
|
23
|
-
// Check x-forwarded-for header (proxy/load balancer)
|
|
24
|
-
const xForwardedFor = c.req.header('x-forwarded-for');
|
|
25
|
-
if (xForwardedFor) {
|
|
26
|
-
const ip = xForwardedFor.split(',')[0].trim();
|
|
27
|
-
if (ip)
|
|
28
|
-
return ip;
|
|
29
|
-
}
|
|
30
|
-
// Check x-real-ip header (nginx)
|
|
31
|
-
const xRealIp = c.req.header('x-real-ip');
|
|
32
|
-
if (xRealIp)
|
|
33
|
-
return xRealIp;
|
|
34
|
-
// Try to get connection info (Node.js server)
|
|
35
|
-
try {
|
|
36
|
-
// Dynamic import to avoid bundling @hono/node-server in Lambda
|
|
37
|
-
// This will throw in non-Node environments
|
|
38
|
-
const { getConnInfo } = require('@hono/node-server/conninfo');
|
|
39
|
-
const info = getConnInfo(c);
|
|
40
|
-
if (info?.remote?.address) {
|
|
41
|
-
return info.remote.address;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
// Not in Node.js environment or module not available
|
|
46
|
-
}
|
|
47
|
-
return 'unknown';
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=get-client-ip.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-client-ip.js","sourceRoot":"","sources":["../src/get-client-ip.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,qDAAqD;IACrD,MAAM,aAAa,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IACtD,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9C,IAAI,EAAE;YAAE,OAAO,EAAE,CAAC;IACpB,CAAC;IAED,iCAAiC;IACjC,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC1C,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAE5B,8CAA8C;IAC9C,IAAI,CAAC;QACH,+DAA+D;QAC/D,2CAA2C;QAC3C,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;QAC9D,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAC7B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,qDAAqD;IACvD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/logger.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Logger interface for framework and application logging
|
|
3
|
-
*/
|
|
4
|
-
export interface Logger {
|
|
5
|
-
debug(message: string, ...meta: unknown[]): void;
|
|
6
|
-
info(message: string, ...meta: unknown[]): void;
|
|
7
|
-
warn(message: string, ...meta: unknown[]): void;
|
|
8
|
-
error(message: string, ...meta: unknown[]): void;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Default console logger (used by framework internally)
|
|
12
|
-
*/
|
|
13
|
-
export declare const defaultLogger: Logger;
|
|
14
|
-
/**
|
|
15
|
-
* Create a logger with a prefix for namespacing
|
|
16
|
-
*
|
|
17
|
-
* @param prefix - Prefix to add to all log messages
|
|
18
|
-
* @param enabled - Whether logging is enabled (default: true)
|
|
19
|
-
* @returns Logger instance
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const logger = createLogger('MyService', debug);
|
|
24
|
-
* logger.info('Starting service'); // [MyService] Starting service
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare function createLogger(prefix: string, enabled?: boolean): Logger;
|
|
28
|
-
/**
|
|
29
|
-
* Create a plain logger middleware for Lambda (strips ANSI color codes).
|
|
30
|
-
*
|
|
31
|
-
* CloudWatch Logs doesn't render ANSI colors well, so this middleware
|
|
32
|
-
* strips them for cleaner logs in production.
|
|
33
|
-
*
|
|
34
|
-
* @returns Hono logger middleware with ANSI codes stripped
|
|
35
|
-
*/
|
|
36
|
-
export declare function createPlainLogger(): import("hono").MiddlewareHandler;
|
|
37
|
-
//# sourceMappingURL=logger.d.ts.map
|
package/dist/logger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAClD;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAK3B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,UAAO,GAAG,MAAM,CAYnE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,qCAQhC"}
|
package/dist/logger.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { logger as honoLogger } from 'hono/logger';
|
|
2
|
-
/**
|
|
3
|
-
* Default console logger (used by framework internally)
|
|
4
|
-
*/
|
|
5
|
-
export const defaultLogger = {
|
|
6
|
-
debug: console.debug.bind(console),
|
|
7
|
-
info: console.log.bind(console),
|
|
8
|
-
warn: console.warn.bind(console),
|
|
9
|
-
error: console.error.bind(console),
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Create a logger with a prefix for namespacing
|
|
13
|
-
*
|
|
14
|
-
* @param prefix - Prefix to add to all log messages
|
|
15
|
-
* @param enabled - Whether logging is enabled (default: true)
|
|
16
|
-
* @returns Logger instance
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const logger = createLogger('MyService', debug);
|
|
21
|
-
* logger.info('Starting service'); // [MyService] Starting service
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export function createLogger(prefix, enabled = true) {
|
|
25
|
-
if (!enabled) {
|
|
26
|
-
const noop = () => { };
|
|
27
|
-
return { debug: noop, info: noop, warn: noop, error: noop };
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
debug: (msg, ...meta) => console.debug(`[${prefix}] ${msg}`, ...meta),
|
|
31
|
-
info: (msg, ...meta) => console.log(`[${prefix}] ${msg}`, ...meta),
|
|
32
|
-
warn: (msg, ...meta) => console.warn(`[${prefix}] ${msg}`, ...meta),
|
|
33
|
-
error: (msg, ...meta) => console.error(`[${prefix}] ${msg}`, ...meta),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Create a plain logger middleware for Lambda (strips ANSI color codes).
|
|
38
|
-
*
|
|
39
|
-
* CloudWatch Logs doesn't render ANSI colors well, so this middleware
|
|
40
|
-
* strips them for cleaner logs in production.
|
|
41
|
-
*
|
|
42
|
-
* @returns Hono logger middleware with ANSI codes stripped
|
|
43
|
-
*/
|
|
44
|
-
export function createPlainLogger() {
|
|
45
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: we want to strip ANSI color codes
|
|
46
|
-
const stripAnsi = (input) => input.replace(/\u001B\[[0-9;]*m/g, '');
|
|
47
|
-
return honoLogger((str, ...rest) => {
|
|
48
|
-
const message = [str, ...rest].join(' ');
|
|
49
|
-
console.log(stripAnsi(message));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=logger.js.map
|
package/dist/logger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAYnD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;IAClC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAChC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;CACnC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,OAAO,GAAG,IAAI;IACzD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QACtB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,MAAM,KAAK,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;QACrE,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,MAAM,KAAK,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;QAClE,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,MAAM,KAAK,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;QACnE,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,MAAM,KAAK,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;KACtE,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB;IAC/B,6FAA6F;IAC7F,MAAM,SAAS,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IAEpF,OAAO,UAAU,CAAC,CAAC,GAAW,EAAE,GAAG,IAAc,EAAE,EAAE;QACnD,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/module.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ModuleConfig } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Define a module with providers, imports, and routes.
|
|
4
|
-
*
|
|
5
|
-
* This is a pure metadata function - it just returns the configuration.
|
|
6
|
-
* The actual registration happens in the bootstrap function.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* export const AuthModule = defineModule({
|
|
11
|
-
* name: 'auth',
|
|
12
|
-
* basePath: 'auth',
|
|
13
|
-
* providers: [AuthService, UserService],
|
|
14
|
-
* imports: [CommonModule],
|
|
15
|
-
* exports: [AuthService],
|
|
16
|
-
* routes: AuthRoutes,
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function defineModule(config: ModuleConfig): ModuleConfig;
|
|
21
|
-
//# sourceMappingURL=module.d.ts.map
|
package/dist/module.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAkB,MAAM,YAAY,CAAC;AAE5E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAG/D"}
|
package/dist/module.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Define a module with providers, imports, and routes.
|
|
3
|
-
*
|
|
4
|
-
* This is a pure metadata function - it just returns the configuration.
|
|
5
|
-
* The actual registration happens in the bootstrap function.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* export const AuthModule = defineModule({
|
|
10
|
-
* name: 'auth',
|
|
11
|
-
* basePath: 'auth',
|
|
12
|
-
* providers: [AuthService, UserService],
|
|
13
|
-
* imports: [CommonModule],
|
|
14
|
-
* exports: [AuthService],
|
|
15
|
-
* routes: AuthRoutes,
|
|
16
|
-
* });
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export function defineModule(config) {
|
|
20
|
-
validateModuleConfig(config);
|
|
21
|
-
return config;
|
|
22
|
-
}
|
|
23
|
-
function validateModuleConfig(config) {
|
|
24
|
-
validateModuleName(config.name);
|
|
25
|
-
validateProviders(config);
|
|
26
|
-
validateExports(config);
|
|
27
|
-
}
|
|
28
|
-
function validateModuleName(name) {
|
|
29
|
-
if (!name) {
|
|
30
|
-
throw new Error('Module name is required');
|
|
31
|
-
}
|
|
32
|
-
if (name.includes('/') || name.includes(' ')) {
|
|
33
|
-
throw new Error('Module name must not contain "/" or spaces');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function validateProviders(config) {
|
|
37
|
-
if (!config.providers) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
for (const provider of config.providers) {
|
|
41
|
-
if (typeof provider !== 'function' && typeof provider !== 'object') {
|
|
42
|
-
throw new Error(`Invalid provider in module "${config.name}"`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function validateExports(config) {
|
|
47
|
-
if (!config.exports || !config.providers) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const providerNames = collectProviderNames(config.providers);
|
|
51
|
-
for (const exp of config.exports) {
|
|
52
|
-
const exportName = getProviderName(exp);
|
|
53
|
-
if (!providerNames.has(exportName)) {
|
|
54
|
-
throw new Error(`Module "${config.name}" exports "${exportName}" but it's not in providers`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function collectProviderNames(providers) {
|
|
59
|
-
const names = new Set();
|
|
60
|
-
for (const provider of providers) {
|
|
61
|
-
names.add(getProviderName(provider));
|
|
62
|
-
}
|
|
63
|
-
return names;
|
|
64
|
-
}
|
|
65
|
-
function getProviderName(provider) {
|
|
66
|
-
if (typeof provider === 'string') {
|
|
67
|
-
return provider;
|
|
68
|
-
}
|
|
69
|
-
if (typeof provider === 'function') {
|
|
70
|
-
return camelCase(provider.name);
|
|
71
|
-
}
|
|
72
|
-
if ('provide' in provider) {
|
|
73
|
-
return typeof provider.provide === 'string'
|
|
74
|
-
? provider.provide
|
|
75
|
-
: camelCase(provider.provide.name);
|
|
76
|
-
}
|
|
77
|
-
return '';
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Convert PascalCase to camelCase
|
|
81
|
-
*/
|
|
82
|
-
function camelCase(str) {
|
|
83
|
-
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;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
|
|
3
|
-
*
|
|
4
|
-
* This implementation preserves the object's prototype, making it suitable
|
|
5
|
-
* for use with class instances and objects with custom prototypes.
|
|
6
|
-
*
|
|
7
|
-
* @template T - The type of the source object
|
|
8
|
-
* @template K - The type of keys to omit (must be keys of T)
|
|
9
|
-
* @param object - The source object to omit keys from
|
|
10
|
-
* @param paths - Array of keys to omit from the object
|
|
11
|
-
* @returns A new object with the specified keys omitted
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const user = { id: 1, name: 'John', email: 'john@example.com', password: 'secret' };
|
|
16
|
-
* const publicUser = omit(user, ['password']); // { id: 1, name: 'John', email: 'john@example.com' }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export declare function omit<T extends object, K extends keyof T>(object: T, paths: K[]): Omit<T, K>;
|
|
20
|
-
//# sourceMappingURL=omit.d.ts.map
|
package/dist/omit.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"omit.d.ts","sourceRoot":"","sources":["../src/omit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAU3F"}
|
package/dist/omit.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new object by omitting specified keys from the source object.
|
|
3
|
-
*
|
|
4
|
-
* This implementation preserves the object's prototype, making it suitable
|
|
5
|
-
* for use with class instances and objects with custom prototypes.
|
|
6
|
-
*
|
|
7
|
-
* @template T - The type of the source object
|
|
8
|
-
* @template K - The type of keys to omit (must be keys of T)
|
|
9
|
-
* @param object - The source object to omit keys from
|
|
10
|
-
* @param paths - Array of keys to omit from the object
|
|
11
|
-
* @returns A new object with the specified keys omitted
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const user = { id: 1, name: 'John', email: 'john@example.com', password: 'secret' };
|
|
16
|
-
* const publicUser = omit(user, ['password']); // { id: 1, name: 'John', email: 'john@example.com' }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export function omit(object, paths) {
|
|
20
|
-
const result = Object.create(Object.getPrototypeOf(object));
|
|
21
|
-
for (const key in object) {
|
|
22
|
-
if (Object.hasOwn(object, key) && !paths.includes(key)) {
|
|
23
|
-
result[key] = object[key];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=omit.js.map
|
package/dist/omit.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"omit.js","sourceRoot":"","sources":["../src/omit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,IAAI,CAAsC,MAAS,EAAE,KAAU;IAC7E,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAE5D,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAmB,CAAC,EAAE,CAAC;YACvE,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
/**
|
|
3
|
-
* Default OpenAPI components provided by Glasswork.
|
|
4
|
-
* These include headers for features implemented by the framework:
|
|
5
|
-
* - Rate limiting headers
|
|
6
|
-
* - Pagination headers
|
|
7
|
-
* - CORS headers
|
|
8
|
-
* - Error response schemas
|
|
9
|
-
*/
|
|
10
|
-
export declare const defaultOpenAPIComponents: OpenAPIV3.ComponentsObject;
|
|
11
|
-
//# sourceMappingURL=openapi-defaults.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-defaults.d.ts","sourceRoot":"","sources":["../src/openapi-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAAS,CAAC,gBAuHhD,CAAC"}
|
package/dist/openapi-defaults.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default OpenAPI components provided by Glasswork.
|
|
3
|
-
* These include headers for features implemented by the framework:
|
|
4
|
-
* - Rate limiting headers
|
|
5
|
-
* - Pagination headers
|
|
6
|
-
* - CORS headers
|
|
7
|
-
* - Error response schemas
|
|
8
|
-
*/
|
|
9
|
-
export const defaultOpenAPIComponents = {
|
|
10
|
-
schemas: {
|
|
11
|
-
// Error response schemas
|
|
12
|
-
ErrorResponse: {
|
|
13
|
-
type: 'object',
|
|
14
|
-
required: ['error'],
|
|
15
|
-
properties: {
|
|
16
|
-
error: {
|
|
17
|
-
type: 'string',
|
|
18
|
-
maxLength: 1000,
|
|
19
|
-
pattern: '^[\\s\\S]*$', // Any characters including whitespace
|
|
20
|
-
description: 'Error message',
|
|
21
|
-
},
|
|
22
|
-
issues: {
|
|
23
|
-
type: 'array',
|
|
24
|
-
maxItems: 100,
|
|
25
|
-
items: {
|
|
26
|
-
type: 'object',
|
|
27
|
-
required: ['message'],
|
|
28
|
-
properties: {
|
|
29
|
-
message: {
|
|
30
|
-
type: 'string',
|
|
31
|
-
maxLength: 500,
|
|
32
|
-
},
|
|
33
|
-
path: {
|
|
34
|
-
type: 'array',
|
|
35
|
-
maxItems: 20,
|
|
36
|
-
items: {
|
|
37
|
-
oneOf: [
|
|
38
|
-
{ type: 'string', maxLength: 200 },
|
|
39
|
-
{ type: 'number', format: 'int32' },
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
description: 'Validation error details',
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
headers: {
|
|
51
|
-
// CORS headers
|
|
52
|
-
'Access-Control-Allow-Origin': {
|
|
53
|
-
description: 'Allowed origin for CORS requests',
|
|
54
|
-
schema: {
|
|
55
|
-
type: 'string',
|
|
56
|
-
maxLength: 2048,
|
|
57
|
-
pattern: '^https?://[a-zA-Z0-9.-]+(:[0-9]+)?$',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
// Rate limiting headers (from rate-limit.ts)
|
|
61
|
-
'RateLimit-Limit': {
|
|
62
|
-
description: 'Total requests allowed in the current time window',
|
|
63
|
-
schema: {
|
|
64
|
-
type: 'integer',
|
|
65
|
-
format: 'int32',
|
|
66
|
-
minimum: 0,
|
|
67
|
-
maximum: 10000,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
'RateLimit-Remaining': {
|
|
71
|
-
description: 'Remaining requests in the current window',
|
|
72
|
-
schema: {
|
|
73
|
-
type: 'integer',
|
|
74
|
-
format: 'int32',
|
|
75
|
-
minimum: 0,
|
|
76
|
-
maximum: 10000,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
'RateLimit-Reset': {
|
|
80
|
-
description: 'Seconds until the rate limit window resets',
|
|
81
|
-
schema: {
|
|
82
|
-
type: 'integer',
|
|
83
|
-
format: 'int32',
|
|
84
|
-
minimum: 0,
|
|
85
|
-
maximum: 3600,
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
'Retry-After': {
|
|
89
|
-
description: 'Seconds to wait before retrying the request (429 response)',
|
|
90
|
-
schema: {
|
|
91
|
-
type: 'integer',
|
|
92
|
-
format: 'int32',
|
|
93
|
-
minimum: 1,
|
|
94
|
-
maximum: 3600,
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
// Pagination headers (from pagination.ts)
|
|
98
|
-
'X-Total-Count': {
|
|
99
|
-
description: 'Total number of items available',
|
|
100
|
-
schema: {
|
|
101
|
-
type: 'integer',
|
|
102
|
-
format: 'int32',
|
|
103
|
-
minimum: 0,
|
|
104
|
-
maximum: 2147483647, // Max int32
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
'X-Page': {
|
|
108
|
-
description: 'Current page number',
|
|
109
|
-
schema: {
|
|
110
|
-
type: 'integer',
|
|
111
|
-
format: 'int32',
|
|
112
|
-
minimum: 1,
|
|
113
|
-
maximum: 2147483647, // Max int32
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
'X-Limit': {
|
|
117
|
-
description: 'Number of items per page',
|
|
118
|
-
schema: {
|
|
119
|
-
type: 'integer',
|
|
120
|
-
format: 'int32',
|
|
121
|
-
minimum: 1,
|
|
122
|
-
maximum: 100,
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
//# sourceMappingURL=openapi-defaults.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-defaults.js","sourceRoot":"","sources":["../src/openapi-defaults.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAA+B;IAClE,OAAO,EAAE;QACP,yBAAyB;QACzB,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,CAAC,OAAO,CAAC;YACnB,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,SAAS,EAAE,IAAI;oBACf,OAAO,EAAE,aAAa,EAAE,sCAAsC;oBAC9D,WAAW,EAAE,eAAe;iBAC7B;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O,EAAE,IAAI;aACd;SACF;QACD,aAAa,EAAE;YACb,WAAW,EAAE,4DAA4D;YACzE,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,IAAI;aACd;SACF;QAED,0CAA0C;QAC1C,eAAe,EAAE;YACf,WAAW,EAAE,iCAAiC;YAC9C,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,UAAU,EAAE,YAAY;aAClC;SACF;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,qBAAqB;YAClC,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,UAAU,EAAE,YAAY;aAClC;SACF;QACD,SAAS,EAAE;YACT,WAAW,EAAE,0BAA0B;YACvC,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;aACb;SACF;KACF;CACF,CAAC"}
|
package/dist/openapi-hooks.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIResponseHook } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Create a hook that adds CORS headers to responses
|
|
4
|
-
*/
|
|
5
|
-
export declare function createCorsHeadersHook(enabled: boolean): OpenAPIResponseHook;
|
|
6
|
-
/**
|
|
7
|
-
* Create a hook that adds rate limiting headers to responses
|
|
8
|
-
*/
|
|
9
|
-
export declare function createRateLimitHeadersHook(enabled: boolean): OpenAPIResponseHook;
|
|
10
|
-
/**
|
|
11
|
-
* Create a hook that adds pagination headers to 200 responses
|
|
12
|
-
*/
|
|
13
|
-
export declare function createPaginationHeadersHook(): OpenAPIResponseHook;
|
|
14
|
-
//# sourceMappingURL=openapi-hooks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-hooks.d.ts","sourceRoot":"","sources":["../src/openapi-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CAc3E;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CAgChF;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,mBAAmB,CAyBjE"}
|
package/dist/openapi-hooks.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a hook that adds CORS headers to responses
|
|
3
|
-
*/
|
|
4
|
-
export function createCorsHeadersHook(enabled) {
|
|
5
|
-
return (response, _context) => {
|
|
6
|
-
if (!enabled)
|
|
7
|
-
return response;
|
|
8
|
-
return {
|
|
9
|
-
...response,
|
|
10
|
-
headers: {
|
|
11
|
-
...response.headers,
|
|
12
|
-
'Access-Control-Allow-Origin': {
|
|
13
|
-
$ref: '#/components/headers/Access-Control-Allow-Origin',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Create a hook that adds rate limiting headers to responses
|
|
21
|
-
*/
|
|
22
|
-
export function createRateLimitHeadersHook(enabled) {
|
|
23
|
-
return (response, context) => {
|
|
24
|
-
if (!enabled)
|
|
25
|
-
return response;
|
|
26
|
-
const { statusCode } = context;
|
|
27
|
-
const headers = {
|
|
28
|
-
'RateLimit-Limit': {
|
|
29
|
-
$ref: '#/components/headers/RateLimit-Limit',
|
|
30
|
-
},
|
|
31
|
-
'RateLimit-Remaining': {
|
|
32
|
-
$ref: '#/components/headers/RateLimit-Remaining',
|
|
33
|
-
},
|
|
34
|
-
'RateLimit-Reset': {
|
|
35
|
-
$ref: '#/components/headers/RateLimit-Reset',
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
// Add Retry-After header for 429 responses
|
|
39
|
-
if (statusCode === '429') {
|
|
40
|
-
headers['Retry-After'] = {
|
|
41
|
-
$ref: '#/components/headers/Retry-After',
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
...response,
|
|
46
|
-
headers: {
|
|
47
|
-
...response.headers,
|
|
48
|
-
...headers,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Create a hook that adds pagination headers to 200 responses
|
|
55
|
-
*/
|
|
56
|
-
export function createPaginationHeadersHook() {
|
|
57
|
-
return (response, context) => {
|
|
58
|
-
const { statusCode, routeConfig } = context;
|
|
59
|
-
// Only add pagination headers to 200 responses with paginate flag
|
|
60
|
-
if (statusCode !== '200' || !routeConfig.paginate) {
|
|
61
|
-
return response;
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
...response,
|
|
65
|
-
headers: {
|
|
66
|
-
...response.headers,
|
|
67
|
-
'X-Total-Count': {
|
|
68
|
-
$ref: '#/components/headers/X-Total-Count',
|
|
69
|
-
},
|
|
70
|
-
'X-Page': {
|
|
71
|
-
$ref: '#/components/headers/X-Page',
|
|
72
|
-
},
|
|
73
|
-
'X-Limit': {
|
|
74
|
-
$ref: '#/components/headers/X-Limit',
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=openapi-hooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-hooks.js","sourceRoot":"","sources":["../src/openapi-hooks.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,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X,OAAO,EAAE;gBACP,GAAG,QAAQ,CAAC,OAAO;gBACnB,eAAe,EAAE;oBACf,IAAI,EAAE,oCAAoC;iBAC3C;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,6BAA6B;iBACpC;gBACD,SAAS,EAAE;oBACT,IAAI,EAAE,8BAA8B;iBACrC;aACF;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/openapi.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Hono } from 'hono';
|
|
2
|
-
import type { Environment, MiddlewareOptions, OpenAPIOptions, RateLimitOptions } from './types.js';
|
|
3
|
-
export interface ConfigureOpenAPIOptions {
|
|
4
|
-
app: Hono;
|
|
5
|
-
environment: Environment;
|
|
6
|
-
openapi: OpenAPIOptions;
|
|
7
|
-
rateLimit?: RateLimitOptions;
|
|
8
|
-
middleware?: MiddlewareOptions;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Configure OpenAPI documentation for the application.
|
|
12
|
-
*
|
|
13
|
-
* Behavior by environment:
|
|
14
|
-
* - development: Serve specs and UI at /api and /api/openapi.json
|
|
15
|
-
* - production: Write spec to disk (openapi.json), no serving
|
|
16
|
-
* - test: Disabled by default
|
|
17
|
-
*
|
|
18
|
-
* This function automatically sets up response hooks based on enabled features
|
|
19
|
-
* and merges them with any application-provided hooks.
|
|
20
|
-
*
|
|
21
|
-
* @param options - Configuration options
|
|
22
|
-
*/
|
|
23
|
-
export declare function configureOpenAPI(options: ConfigureOpenAPIOptions): void;
|
|
24
|
-
//# sourceMappingURL=openapi.d.ts.map
|
package/dist/openapi.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAUjC,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnG,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,IAAI,CAAC;IACV,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAgEvE"}
|