@veloxts/router 0.6.56 → 0.6.58
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/CHANGELOG.md +18 -0
- package/GUIDE.md +237 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +36 -0
- package/dist/openapi/generator.d.ts +52 -0
- package/dist/openapi/generator.js +442 -0
- package/dist/openapi/index.d.ts +37 -0
- package/dist/openapi/index.js +51 -0
- package/dist/openapi/path-extractor.d.ts +212 -0
- package/dist/openapi/path-extractor.js +256 -0
- package/dist/openapi/plugin.d.ts +101 -0
- package/dist/openapi/plugin.js +228 -0
- package/dist/openapi/schema-converter.d.ts +119 -0
- package/dist/openapi/schema-converter.js +246 -0
- package/dist/openapi/security-mapper.d.ts +131 -0
- package/dist/openapi/security-mapper.js +226 -0
- package/dist/openapi/types.d.ts +437 -0
- package/dist/openapi/types.js +8 -0
- package/dist/providers.d.ts +90 -0
- package/dist/providers.js +145 -0
- package/dist/tokens.d.ts +107 -0
- package/dist/tokens.js +78 -0
- package/package.json +8 -3
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DI Tokens for @veloxts/router
|
|
3
|
+
*
|
|
4
|
+
* Symbol-based tokens for type-safe dependency injection.
|
|
5
|
+
* These tokens allow router services to be registered, resolved, and mocked via the DI container.
|
|
6
|
+
*
|
|
7
|
+
* @module router/tokens
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { Container } from '@veloxts/core';
|
|
12
|
+
* import { TRPC_INSTANCE, trpcInstanceProvider, registerRouterProviders } from '@veloxts/router';
|
|
13
|
+
*
|
|
14
|
+
* const container = new Container();
|
|
15
|
+
* registerRouterProviders(container);
|
|
16
|
+
*
|
|
17
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
import type { TRPCPluginOptions } from './trpc/index.js';
|
|
21
|
+
import type { ProcedureCollection } from './types.js';
|
|
22
|
+
/**
|
|
23
|
+
* Router configuration for DI registration
|
|
24
|
+
*/
|
|
25
|
+
export interface RouterConfig {
|
|
26
|
+
/**
|
|
27
|
+
* Procedure collections to register
|
|
28
|
+
*/
|
|
29
|
+
procedures?: ProcedureCollection[];
|
|
30
|
+
/**
|
|
31
|
+
* REST API prefix
|
|
32
|
+
* @default '/api'
|
|
33
|
+
*/
|
|
34
|
+
apiPrefix?: string;
|
|
35
|
+
/**
|
|
36
|
+
* tRPC endpoint prefix
|
|
37
|
+
* @default '/trpc'
|
|
38
|
+
*/
|
|
39
|
+
rpcPrefix?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* REST adapter configuration for DI
|
|
43
|
+
*/
|
|
44
|
+
export interface RestAdapterConfig {
|
|
45
|
+
/**
|
|
46
|
+
* API prefix for routes
|
|
47
|
+
* @default '/api'
|
|
48
|
+
*/
|
|
49
|
+
prefix?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* tRPC instance token
|
|
53
|
+
*
|
|
54
|
+
* The tRPC instance used for building routers and procedures.
|
|
55
|
+
* This is created by `trpc()` and provides the base for procedure definitions.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
60
|
+
* const router = t.router({
|
|
61
|
+
* hello: t.procedure.query(() => 'Hello World'),
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare const TRPC_INSTANCE: import("@veloxts/core").SymbolToken<import("@trpc/server").TRPCRootObject<import("@veloxts/core").BaseContext, object, import("@trpc/server").TRPCRuntimeConfigOptions<import("@veloxts/core").BaseContext, object>, {
|
|
66
|
+
ctx: import("@veloxts/core").BaseContext;
|
|
67
|
+
meta: object;
|
|
68
|
+
errorShape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
69
|
+
transformer: false;
|
|
70
|
+
}>>;
|
|
71
|
+
/**
|
|
72
|
+
* App router token
|
|
73
|
+
*
|
|
74
|
+
* The merged tRPC router from all procedure collections.
|
|
75
|
+
* This is the router exported for type inference on the client.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const router = container.resolve(APP_ROUTER);
|
|
80
|
+
* export type AppRouter = typeof router;
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare const APP_ROUTER: import("@veloxts/core").SymbolToken<import("@trpc/server").AnyRouter>;
|
|
84
|
+
/**
|
|
85
|
+
* Router configuration token
|
|
86
|
+
*
|
|
87
|
+
* Contains router settings including procedure collections and prefixes.
|
|
88
|
+
*/
|
|
89
|
+
export declare const ROUTER_CONFIG: import("@veloxts/core").SymbolToken<RouterConfig>;
|
|
90
|
+
/**
|
|
91
|
+
* REST adapter configuration token
|
|
92
|
+
*
|
|
93
|
+
* Configuration for the REST adapter including prefix settings.
|
|
94
|
+
*/
|
|
95
|
+
export declare const REST_ADAPTER_CONFIG: import("@veloxts/core").SymbolToken<RestAdapterConfig>;
|
|
96
|
+
/**
|
|
97
|
+
* tRPC plugin options token
|
|
98
|
+
*
|
|
99
|
+
* Configuration for the tRPC Fastify plugin including prefix and router.
|
|
100
|
+
*/
|
|
101
|
+
export declare const TRPC_PLUGIN_OPTIONS: import("@veloxts/core").SymbolToken<TRPCPluginOptions>;
|
|
102
|
+
/**
|
|
103
|
+
* Procedure collections token
|
|
104
|
+
*
|
|
105
|
+
* Array of procedure collections to register with the router.
|
|
106
|
+
*/
|
|
107
|
+
export declare const PROCEDURE_COLLECTIONS: import("@veloxts/core").SymbolToken<ProcedureCollection<import("./types.js").ProcedureRecord>[]>;
|
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DI Tokens for @veloxts/router
|
|
3
|
+
*
|
|
4
|
+
* Symbol-based tokens for type-safe dependency injection.
|
|
5
|
+
* These tokens allow router services to be registered, resolved, and mocked via the DI container.
|
|
6
|
+
*
|
|
7
|
+
* @module router/tokens
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { Container } from '@veloxts/core';
|
|
12
|
+
* import { TRPC_INSTANCE, trpcInstanceProvider, registerRouterProviders } from '@veloxts/router';
|
|
13
|
+
*
|
|
14
|
+
* const container = new Container();
|
|
15
|
+
* registerRouterProviders(container);
|
|
16
|
+
*
|
|
17
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
import { token } from '@veloxts/core';
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Core Router Tokens
|
|
23
|
+
// ============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* tRPC instance token
|
|
26
|
+
*
|
|
27
|
+
* The tRPC instance used for building routers and procedures.
|
|
28
|
+
* This is created by `trpc()` and provides the base for procedure definitions.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
33
|
+
* const router = t.router({
|
|
34
|
+
* hello: t.procedure.query(() => 'Hello World'),
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export const TRPC_INSTANCE = token.symbol('TRPC_INSTANCE');
|
|
39
|
+
/**
|
|
40
|
+
* App router token
|
|
41
|
+
*
|
|
42
|
+
* The merged tRPC router from all procedure collections.
|
|
43
|
+
* This is the router exported for type inference on the client.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const router = container.resolve(APP_ROUTER);
|
|
48
|
+
* export type AppRouter = typeof router;
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export const APP_ROUTER = token.symbol('APP_ROUTER');
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// Configuration Tokens
|
|
54
|
+
// ============================================================================
|
|
55
|
+
/**
|
|
56
|
+
* Router configuration token
|
|
57
|
+
*
|
|
58
|
+
* Contains router settings including procedure collections and prefixes.
|
|
59
|
+
*/
|
|
60
|
+
export const ROUTER_CONFIG = token.symbol('ROUTER_CONFIG');
|
|
61
|
+
/**
|
|
62
|
+
* REST adapter configuration token
|
|
63
|
+
*
|
|
64
|
+
* Configuration for the REST adapter including prefix settings.
|
|
65
|
+
*/
|
|
66
|
+
export const REST_ADAPTER_CONFIG = token.symbol('REST_ADAPTER_CONFIG');
|
|
67
|
+
/**
|
|
68
|
+
* tRPC plugin options token
|
|
69
|
+
*
|
|
70
|
+
* Configuration for the tRPC Fastify plugin including prefix and router.
|
|
71
|
+
*/
|
|
72
|
+
export const TRPC_PLUGIN_OPTIONS = token.symbol('TRPC_PLUGIN_OPTIONS');
|
|
73
|
+
/**
|
|
74
|
+
* Procedure collections token
|
|
75
|
+
*
|
|
76
|
+
* Array of procedure collections to register with the router.
|
|
77
|
+
*/
|
|
78
|
+
export const PROCEDURE_COLLECTIONS = token.symbol('PROCEDURE_COLLECTIONS');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veloxts/router",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.58",
|
|
4
4
|
"description": "Procedure definitions with tRPC and REST routing for VeloxTS framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"./trpc": {
|
|
18
18
|
"types": "./dist/trpc/index.d.ts",
|
|
19
19
|
"import": "./dist/trpc/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./openapi": {
|
|
22
|
+
"types": "./dist/openapi/index.d.ts",
|
|
23
|
+
"import": "./dist/openapi/index.js"
|
|
20
24
|
}
|
|
21
25
|
},
|
|
22
26
|
"tsd": {
|
|
@@ -35,8 +39,9 @@
|
|
|
35
39
|
"dependencies": {
|
|
36
40
|
"@trpc/server": "11.8.0",
|
|
37
41
|
"fastify": "5.6.2",
|
|
38
|
-
"
|
|
39
|
-
"@veloxts/
|
|
42
|
+
"zod-to-json-schema": "3.24.5",
|
|
43
|
+
"@veloxts/validation": "0.6.58",
|
|
44
|
+
"@veloxts/core": "0.6.58"
|
|
40
45
|
},
|
|
41
46
|
"devDependencies": {
|
|
42
47
|
"@vitest/coverage-v8": "4.0.16",
|