koatty_router 2.0.9 → 2.1.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.
@@ -1,17 +1,17 @@
1
1
 
2
2
  
3
- > koatty_router@2.0.9 build /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-router
3
+ > koatty_router@2.1.0 build /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-router
4
4
  > npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp
5
5
 
6
6
 
7
- > koatty_router@2.0.9 build:js
7
+ > koatty_router@2.1.0 build:js
8
8
  > npx rollup --bundleConfigAsCjs -c .rollup.config.js
9
9
 
10
- 
10
+ ⠙
11
11
  ./src/index.ts → ./dist/index.js, ./dist/index.mjs...
12
- created ./dist/index.js, ./dist/index.mjs in 15.5s
12
+ created ./dist/index.js, ./dist/index.mjs in 12.6s
13
13
  ⠙⠙
14
- > koatty_router@2.0.9 build:dts
14
+ > koatty_router@2.1.0 build:dts
15
15
  > bash ../../scripts/build-dts.sh
16
16
 
17
17
  🔨 Building type declarations for koatty-router...
@@ -19,17 +19,15 @@
19
19
 
20
20
  🔍 Checking dependencies: koatty_container, koatty_core, koatty_exception, koatty_graphql, koatty_lib, koatty_logger, koatty_proto, koatty_validation
21
21
  ✓ koatty_container type declarations ready
22
+ ✓ koatty_core type declarations ready
22
23
  ✓ koatty_exception type declarations ready
23
24
  ✓ koatty_graphql type declarations ready
24
25
  ✓ koatty_lib type declarations ready
25
26
  ✓ koatty_logger type declarations ready
26
27
  ✓ koatty_proto type declarations ready
27
28
  ✓ koatty_validation type declarations ready
28
- ⏳ Waiting for: koatty_core (0s)
29
- ✗ koatty_core: missing .d.ts
30
- ✓ koatty_core type declarations ready
31
29
 
32
- ✅ All dependencies ready (waited 1004ms)
30
+ ✅ All dependencies ready (waited 2ms)
33
31
  📝 Running TypeScript compiler...
34
32
  ⠙⠙📦 Running API Extractor...
35
33
  
@@ -40,6 +38,7 @@ Analysis will use the bundled TypeScript version 5.8.2
40
38
  *** The target project appears to use TypeScript 5.9.3 which is newer than the bundled compiler engine; consider upgrading API Extractor.
41
39
  Writing: /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-router/temp/koatty_router.api.json
42
40
  Writing package typings: /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-router/dist/index.d.ts
41
+ Warning: src/RouterComponent.ts:160:38 - (tsdoc-characters-after-block-tag) The token "@OnEvent" looks like a TSDoc tag but contains an invalid character "("; if it is not a tag, use a backslash to escape the "@"
43
42
  Warning: src/params/mapping.ts:33:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
44
43
  Warning: src/params/mapping.ts:34:4 - (tsdoc-undefined-tag) The TSDoc tag "@interface" is not defined in this configuration
45
44
  Warning: src/params/mapping.ts:47:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
@@ -114,18 +113,20 @@ Analysis will use the bundled TypeScript version 5.8.2
114
113
  Warning: src/router/router.ts:54:14 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
115
114
  Warning: src/router/router.ts:55:62 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
116
115
  Warning: src/router/router.ts:55:17 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
117
- Warning: src/router/router.ts:87:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
118
- Warning: src/router/router.ts:88:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
119
- Warning: src/router/router.ts:89:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
120
- Warning: src/router/router.ts:90:15 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
121
- Warning: src/router/router.ts:90:31 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
122
- Warning: src/router/router.ts:90:13 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
123
- Warning: src/router/router.ts:90:18 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
116
+ Warning: src/router/router.ts:89:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
117
+ Warning: src/router/router.ts:90:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
118
+ Warning: src/router/router.ts:91:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
119
+ Warning: src/router/router.ts:92:15 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
120
+ Warning: src/router/router.ts:92:66 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
121
+ Warning: src/router/router.ts:92:67 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
122
+ Warning: src/router/router.ts:92:13 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
123
+ Warning: src/router/router.ts:92:18 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
124
+ Warning: src/router/router.ts:92:19 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
124
125
 
125
126
  API Extractor completed successfully
126
127
  ⠙✅ Type declarations built successfully
127
128
  ⠙
128
- > koatty_router@2.0.9 build:doc
129
+ > koatty_router@2.1.0 build:doc
129
130
  > npx api-documenter markdown --input temp --output docs/api
130
131
 
131
132
  
@@ -168,10 +169,18 @@ Unsupported block tag: @interface
168
169
  Unsupported block tag: @RequestBody
169
170
  Unsupported block tag: @RequestParam
170
171
  ⠙⠙
171
- > koatty_router@2.0.9 build:cp
172
+ > koatty_router@2.1.0 build:cp
172
173
  > copyfiles package.json LICENSE README.md dist/ && node scripts/postBuild
173
174
 
174
- ✓ Fixed main: ./dist/..../index.js
175
+ ✓ Fixed dependencies.koatty_container: workspace:*^2.0.0
176
+ ✓ Fixed dependencies.koatty_core: workspace:* → ^2.1.0
177
+ ✓ Fixed dependencies.koatty_exception: workspace:* → ^2.1.0
178
+ ✓ Fixed dependencies.koatty_graphql: workspace:* → ^1.1.4
179
+ ✓ Fixed dependencies.koatty_lib: workspace:* → ^1.4.5
180
+ ✓ Fixed dependencies.koatty_logger: workspace:* → ^2.4.0
181
+ ✓ Fixed dependencies.koatty_proto: workspace:* → ^1.3.5
182
+ ✓ Fixed dependencies.koatty_validation: workspace:* → ^2.0.0
183
+ ✓ Fixed main: ./dist/... → ./index.js
175
184
  ✓ Fixed types: ./dist/... → ./index.d.ts
176
185
  ✓ Fixed exports.require: ./dist/index.js → ./index.js
177
186
  ✓ Fixed exports.import: ./dist/index.mjs → ./index.mjs
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - build
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - koatty_container@2.0.0
13
+ - koatty_core@2.1.0
14
+ - koatty_exception@2.1.0
15
+ - koatty_logger@2.4.0
16
+ - koatty_validation@2.0.0
17
+
3
18
  ## 2.0.9
4
19
 
5
20
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2026-01-28 17:21:09
3
+ * @Date: 2026-01-31 09:50:30
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
7
7
  */
8
8
  import { Application } from 'koatty_container';
9
- import { IPlugin } from 'koatty_core';
10
- import { IPluginCapability } from 'koatty_core';
9
+ import { IComponent } from 'koatty_core';
11
10
  import { KoattyApplication } from 'koatty_core';
12
11
  import { KoattyContext } from 'koatty_core';
13
12
  import { KoattyNext } from 'koatty_core';
@@ -214,9 +213,12 @@ export declare type MiddlewareFunction = <T = unknown>(ctx: KoattyContext, next:
214
213
  * @export
215
214
  * @param {KoattyApplication} app
216
215
  * @param {RouterOptions} options
217
- * @returns {*} {KoattyRouter}
216
+ * @returns {*} {{ router: KoattyRouter, factory: RouterFactory }}
218
217
  */
219
- export declare function NewRouter(app: KoattyApplication, opt?: RouterOptions): KoattyRouter;
218
+ export declare function NewRouter(app: KoattyApplication, opt?: RouterOptions): {
219
+ router: KoattyRouter;
220
+ factory: RouterFactory;
221
+ };
220
222
 
221
223
  /**
222
224
  * Routes HTTP OPTIONS requests to the specified path.
@@ -359,6 +361,42 @@ export declare enum RequestMethod {
359
361
  */
360
362
  export declare function RequestParam(): ParameterDecorator;
361
363
 
364
+ /**
365
+ * Router Component
366
+ * Responsible for initializing and managing routing
367
+ *
368
+ * Implements IComponent interface (base interface)
369
+ *
370
+ * Event bindings:
371
+ * - loadRouter: Initialize router
372
+ * - appStop: Cleanup router resources
373
+ */
374
+ export declare class RouterComponent implements IComponent {
375
+ events: Record<string, any>;
376
+ /**
377
+ * Initialize router and load routes
378
+ *
379
+ * This method handles the complete router initialization:
380
+ * 1. Create router instance(s) for configured protocol(s)
381
+ * 2. Bind router to app.router
382
+ * 3. Load controller routes into router
383
+ */
384
+ initRouter(app: KoattyApplication): Promise<void>;
385
+ /**
386
+ * Load controller routes into router
387
+ *
388
+ * @param app - Koatty application instance
389
+ */
390
+ run(app: KoattyApplication): Promise<void>;
391
+ /**
392
+ * Cleanup router resources on app stop
393
+ *
394
+ * NOTE: Original app.once("appStop", ...) listener in router.ts
395
+ * is now unified to be handled by @OnEvent(AppEvent.appStop) decorator
396
+ */
397
+ cleanup(_app: KoattyApplication): Promise<void>;
398
+ }
399
+
362
400
  /**
363
401
  * Router constructor type
364
402
  */
@@ -614,38 +652,32 @@ export declare interface RouterOptions {
614
652
  *
615
653
  * @example
616
654
  * ```typescript
617
- * // WebSocket 配置
618
- * ext: {
619
- * maxFrameSize: 1024 * 1024,
620
- * heartbeatInterval: 15000,
621
- * maxConnections: 1000
622
- * }
623
- *
624
- * // gRPC 配置
625
655
  * ext: {
626
- * protoFile: "./proto/service.proto",
627
- * poolSize: 10,
628
- * streamConfig: { maxConcurrentStreams: 50 }
629
- * }
630
- *
631
- * // GraphQL 配置
632
- * ext: {
633
- * schemaFile: "./schema/schema.graphql",
634
- * playground: true
656
+ * http: {},
657
+ * grpc: {
658
+ * protoFile: "./proto/service.proto",
659
+ * poolSize: 10,
660
+ * streamConfig: { maxConcurrentStreams: 50 }
661
+ * },
662
+ * graphql: {
663
+ * schemaFile: "./resource/graphql/schema.graphql",
664
+ * // Optional: Enable HTTP/2 with SSL for GraphQL
665
+ * // keyFile: "./ssl/server.key",
666
+ * // crtFile: "./ssl/server.crt",
667
+ * // ssl: { mode: 'auto', allowHTTP1: true },
668
+ * // http2: { maxConcurrentStreams: 100 }
669
+ * },
670
+ * ws: {
671
+ * maxFrameSize: 1024 * 1024,
672
+ * heartbeatInterval: 15000,
673
+ * maxConnections: 1000
674
+ * }
635
675
  * }
636
676
  * ```
637
677
  */
638
678
  ext?: Record<string, any>;
639
679
  }
640
680
 
641
- export declare class RouterPlugin implements IPlugin {
642
- readonly provides: IPluginCapability[];
643
- readonly events: {
644
- beforeRouterLoad: (app: KoattyApplication) => Promise<void>;
645
- };
646
- uninstall(_app: KoattyApplication): Promise<void>;
647
- }
648
-
649
681
  /**
650
682
  * gRPC 流配置
651
683
  */