@buenojs/bueno 0.8.3 → 0.8.5
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 +136 -16
- package/dist/cli/{index.js → bin.js} +3036 -1421
- package/dist/container/index.js +250 -0
- package/dist/context/index.js +219 -0
- package/dist/database/index.js +493 -0
- package/dist/frontend/index.js +7697 -0
- package/dist/health/index.js +364 -0
- package/dist/i18n/index.js +345 -0
- package/dist/index.js +11043 -6482
- package/dist/jobs/index.js +819 -0
- package/dist/lock/index.js +367 -0
- package/dist/logger/index.js +281 -0
- package/dist/metrics/index.js +289 -0
- package/dist/middleware/index.js +77 -0
- package/dist/migrations/index.js +571 -0
- package/dist/modules/index.js +3346 -0
- package/dist/notification/index.js +484 -0
- package/dist/observability/index.js +331 -0
- package/dist/openapi/index.js +776 -0
- package/dist/orm/index.js +1356 -0
- package/dist/router/index.js +886 -0
- package/dist/rpc/index.js +691 -0
- package/dist/schema/index.js +400 -0
- package/dist/telemetry/index.js +595 -0
- package/dist/template/index.js +640 -0
- package/dist/templates/index.js +640 -0
- package/dist/testing/index.js +1111 -0
- package/dist/types/index.js +60 -0
- package/package.json +121 -27
- package/src/cache/index.ts +2 -1
- package/src/cli/bin.ts +2 -2
- package/src/cli/commands/build.ts +183 -165
- package/src/cli/commands/dev.ts +96 -89
- package/src/cli/commands/generate.ts +142 -111
- package/src/cli/commands/help.ts +20 -16
- package/src/cli/commands/index.ts +3 -6
- package/src/cli/commands/migration.ts +124 -105
- package/src/cli/commands/new.ts +392 -438
- package/src/cli/commands/start.ts +81 -79
- package/src/cli/core/args.ts +68 -50
- package/src/cli/core/console.ts +89 -95
- package/src/cli/core/index.ts +4 -4
- package/src/cli/core/prompt.ts +65 -62
- package/src/cli/core/spinner.ts +23 -20
- package/src/cli/index.ts +46 -38
- package/src/cli/templates/database/index.ts +61 -0
- package/src/cli/templates/database/mysql.ts +14 -0
- package/src/cli/templates/database/none.ts +16 -0
- package/src/cli/templates/database/postgresql.ts +14 -0
- package/src/cli/templates/database/sqlite.ts +14 -0
- package/src/cli/templates/deploy.ts +29 -26
- package/src/cli/templates/docker.ts +41 -30
- package/src/cli/templates/frontend/index.ts +63 -0
- package/src/cli/templates/frontend/none.ts +17 -0
- package/src/cli/templates/frontend/react.ts +140 -0
- package/src/cli/templates/frontend/solid.ts +134 -0
- package/src/cli/templates/frontend/svelte.ts +131 -0
- package/src/cli/templates/frontend/vue.ts +130 -0
- package/src/cli/templates/generators/index.ts +339 -0
- package/src/cli/templates/generators/types.ts +56 -0
- package/src/cli/templates/index.ts +35 -2
- package/src/cli/templates/project/api.ts +81 -0
- package/src/cli/templates/project/default.ts +140 -0
- package/src/cli/templates/project/fullstack.ts +111 -0
- package/src/cli/templates/project/index.ts +95 -0
- package/src/cli/templates/project/minimal.ts +45 -0
- package/src/cli/templates/project/types.ts +94 -0
- package/src/cli/templates/project/website.ts +263 -0
- package/src/cli/utils/fs.ts +55 -41
- package/src/cli/utils/index.ts +3 -2
- package/src/cli/utils/strings.ts +47 -33
- package/src/cli/utils/version.ts +47 -0
- package/src/config/env-validation.ts +100 -0
- package/src/config/env.ts +169 -41
- package/src/config/index.ts +28 -20
- package/src/config/loader.ts +25 -16
- package/src/config/merge.ts +21 -10
- package/src/config/types.ts +545 -25
- package/src/config/validation.ts +215 -7
- package/src/container/forward-ref.ts +22 -22
- package/src/container/index.ts +34 -12
- package/src/context/index.ts +11 -1
- package/src/database/index.ts +7 -190
- package/src/database/orm/builder.ts +457 -0
- package/src/database/orm/casts/index.ts +130 -0
- package/src/database/orm/casts/types.ts +25 -0
- package/src/database/orm/compiler.ts +304 -0
- package/src/database/orm/hooks/index.ts +114 -0
- package/src/database/orm/index.ts +61 -0
- package/src/database/orm/model-registry.ts +59 -0
- package/src/database/orm/model.ts +821 -0
- package/src/database/orm/relationships/base.ts +146 -0
- package/src/database/orm/relationships/belongs-to-many.ts +179 -0
- package/src/database/orm/relationships/belongs-to.ts +56 -0
- package/src/database/orm/relationships/has-many.ts +45 -0
- package/src/database/orm/relationships/has-one.ts +41 -0
- package/src/database/orm/relationships/index.ts +11 -0
- package/src/database/orm/scopes/index.ts +55 -0
- package/src/events/__tests__/event-system.test.ts +235 -0
- package/src/events/config.ts +238 -0
- package/src/events/example-usage.ts +185 -0
- package/src/events/index.ts +278 -0
- package/src/events/manager.ts +385 -0
- package/src/events/registry.ts +182 -0
- package/src/events/types.ts +124 -0
- package/src/frontend/api-routes.ts +65 -23
- package/src/frontend/bundler.ts +76 -34
- package/src/frontend/console-client.ts +2 -2
- package/src/frontend/console-stream.ts +94 -38
- package/src/frontend/dev-server.ts +94 -46
- package/src/frontend/file-router.ts +61 -19
- package/src/frontend/frameworks/index.ts +37 -10
- package/src/frontend/frameworks/react.ts +10 -8
- package/src/frontend/frameworks/solid.ts +11 -9
- package/src/frontend/frameworks/svelte.ts +15 -9
- package/src/frontend/frameworks/vue.ts +13 -11
- package/src/frontend/hmr-client.ts +12 -10
- package/src/frontend/hmr.ts +146 -103
- package/src/frontend/index.ts +14 -5
- package/src/frontend/islands.ts +41 -22
- package/src/frontend/isr.ts +59 -37
- package/src/frontend/layout.ts +36 -21
- package/src/frontend/ssr/react.ts +74 -27
- package/src/frontend/ssr/solid.ts +54 -20
- package/src/frontend/ssr/svelte.ts +48 -14
- package/src/frontend/ssr/vue.ts +50 -18
- package/src/frontend/ssr.ts +83 -39
- package/src/frontend/types.ts +91 -56
- package/src/health/index.ts +21 -9
- package/src/i18n/engine.ts +305 -0
- package/src/i18n/index.ts +38 -0
- package/src/i18n/loader.ts +218 -0
- package/src/i18n/middleware.ts +164 -0
- package/src/i18n/negotiator.ts +162 -0
- package/src/i18n/types.ts +158 -0
- package/src/index.ts +179 -27
- package/src/jobs/drivers/memory.ts +315 -0
- package/src/jobs/drivers/redis.ts +459 -0
- package/src/jobs/index.ts +30 -0
- package/src/jobs/queue.ts +281 -0
- package/src/jobs/types.ts +295 -0
- package/src/jobs/worker.ts +380 -0
- package/src/logger/index.ts +1 -3
- package/src/logger/transports/index.ts +62 -22
- package/src/metrics/index.ts +25 -16
- package/src/migrations/index.ts +9 -0
- package/src/modules/filters.ts +13 -17
- package/src/modules/guards.ts +49 -26
- package/src/modules/index.ts +409 -298
- package/src/modules/interceptors.ts +58 -20
- package/src/modules/lazy.ts +11 -19
- package/src/modules/lifecycle.ts +15 -7
- package/src/modules/metadata.ts +15 -5
- package/src/modules/pipes.ts +94 -72
- package/src/notification/channels/base.ts +68 -0
- package/src/notification/channels/email.ts +105 -0
- package/src/notification/channels/push.ts +104 -0
- package/src/notification/channels/sms.ts +105 -0
- package/src/notification/channels/whatsapp.ts +104 -0
- package/src/notification/index.ts +48 -0
- package/src/notification/service.ts +354 -0
- package/src/notification/types.ts +344 -0
- package/src/observability/__tests__/observability.test.ts +483 -0
- package/src/observability/breadcrumbs.ts +114 -0
- package/src/observability/index.ts +136 -0
- package/src/observability/interceptor.ts +85 -0
- package/src/observability/service.ts +303 -0
- package/src/observability/trace.ts +37 -0
- package/src/observability/types.ts +196 -0
- package/src/openapi/__tests__/decorators.test.ts +335 -0
- package/src/openapi/__tests__/document-builder.test.ts +285 -0
- package/src/openapi/__tests__/route-scanner.test.ts +334 -0
- package/src/openapi/__tests__/schema-generator.test.ts +275 -0
- package/src/openapi/decorators.ts +328 -0
- package/src/openapi/document-builder.ts +274 -0
- package/src/openapi/index.ts +112 -0
- package/src/openapi/metadata.ts +112 -0
- package/src/openapi/route-scanner.ts +289 -0
- package/src/openapi/schema-generator.ts +256 -0
- package/src/openapi/swagger-module.ts +166 -0
- package/src/openapi/types.ts +398 -0
- package/src/orm/index.ts +10 -0
- package/src/rpc/index.ts +3 -1
- package/src/schema/index.ts +9 -0
- package/src/security/index.ts +15 -6
- package/src/ssg/index.ts +9 -8
- package/src/telemetry/index.ts +76 -22
- package/src/template/index.ts +7 -0
- package/src/templates/engine.ts +224 -0
- package/src/templates/index.ts +9 -0
- package/src/templates/loader.ts +331 -0
- package/src/templates/renderers/markdown.ts +212 -0
- package/src/templates/renderers/simple.ts +269 -0
- package/src/templates/types.ts +154 -0
- package/src/testing/index.ts +100 -27
- package/src/types/optional-deps.d.ts +347 -187
- package/src/validation/index.ts +92 -2
- package/src/validation/schemas.ts +536 -0
- package/tests/integration/fullstack.test.ts +4 -4
- package/tests/unit/database.test.ts +2 -72
- package/tests/unit/env-validation.test.ts +166 -0
- package/tests/unit/events.test.ts +910 -0
- package/tests/unit/i18n.test.ts +455 -0
- package/tests/unit/jobs.test.ts +493 -0
- package/tests/unit/notification.test.ts +988 -0
- package/tests/unit/observability.test.ts +453 -0
- package/tests/unit/orm/builder.test.ts +323 -0
- package/tests/unit/orm/casts.test.ts +179 -0
- package/tests/unit/orm/compiler.test.ts +220 -0
- package/tests/unit/orm/eager-loading.test.ts +285 -0
- package/tests/unit/orm/hooks.test.ts +191 -0
- package/tests/unit/orm/model.test.ts +373 -0
- package/tests/unit/orm/relationships.test.ts +303 -0
- package/tests/unit/orm/scopes.test.ts +74 -0
- package/tests/unit/templates-simple.test.ts +53 -0
- package/tests/unit/templates.test.ts +454 -0
- package/tests/unit/validation.test.ts +18 -24
- package/tsconfig.json +11 -3
package/src/frontend/types.ts
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
/**
|
|
11
11
|
* Supported frontend frameworks
|
|
12
12
|
*/
|
|
13
|
-
export type FrontendFramework =
|
|
13
|
+
export type FrontendFramework = "react" | "vue" | "svelte" | "solid";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Framework detection mode
|
|
17
17
|
*/
|
|
18
|
-
export type FrameworkDetectionMode = FrontendFramework |
|
|
18
|
+
export type FrameworkDetectionMode = FrontendFramework | "auto";
|
|
19
19
|
|
|
20
20
|
// ============= Dev Server Configuration =============
|
|
21
21
|
|
|
@@ -75,7 +75,8 @@ export interface DevServerConfig {
|
|
|
75
75
|
/**
|
|
76
76
|
* Partial configuration for creating a dev server
|
|
77
77
|
*/
|
|
78
|
-
export type PartialDevServerConfig = Partial<DevServerConfig> &
|
|
78
|
+
export type PartialDevServerConfig = Partial<DevServerConfig> &
|
|
79
|
+
Pick<DevServerConfig, "rootDir">;
|
|
79
80
|
|
|
80
81
|
// ============= Server State Types =============
|
|
81
82
|
|
|
@@ -197,7 +198,7 @@ export interface FrameworkDetectionResult {
|
|
|
197
198
|
/**
|
|
198
199
|
* Source of detection ('package.json' or 'config')
|
|
199
200
|
*/
|
|
200
|
-
source:
|
|
201
|
+
source: "package.json" | "config";
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
// ============= Build/Transform Types =============
|
|
@@ -254,7 +255,7 @@ export interface TransformOptions {
|
|
|
254
255
|
*/
|
|
255
256
|
export type DevServerMiddleware = (
|
|
256
257
|
request: Request,
|
|
257
|
-
next: () => Promise<Response
|
|
258
|
+
next: () => Promise<Response>,
|
|
258
259
|
) => Response | Promise<Response>;
|
|
259
260
|
|
|
260
261
|
// ============= Event Types =============
|
|
@@ -263,12 +264,12 @@ export type DevServerMiddleware = (
|
|
|
263
264
|
* Dev server event types
|
|
264
265
|
*/
|
|
265
266
|
export type DevServerEvent =
|
|
266
|
-
| { type:
|
|
267
|
-
| { type:
|
|
268
|
-
| { type:
|
|
269
|
-
| { type:
|
|
270
|
-
| { type:
|
|
271
|
-
| { type:
|
|
267
|
+
| { type: "start"; port: number; hostname: string }
|
|
268
|
+
| { type: "stop"; reason?: string }
|
|
269
|
+
| { type: "request"; method: string; path: string; duration: number }
|
|
270
|
+
| { type: "error"; error: Error }
|
|
271
|
+
| { type: "file-change"; path: string }
|
|
272
|
+
| { type: "framework-detected"; framework: FrontendFramework };
|
|
272
273
|
|
|
273
274
|
/**
|
|
274
275
|
* Dev server event listener
|
|
@@ -356,7 +357,7 @@ export interface HMRUpdate {
|
|
|
356
357
|
/**
|
|
357
358
|
* Type of update
|
|
358
359
|
*/
|
|
359
|
-
type:
|
|
360
|
+
type: "update" | "reload" | "error";
|
|
360
361
|
|
|
361
362
|
/**
|
|
362
363
|
* Unique identifier for this update
|
|
@@ -467,18 +468,18 @@ export interface HMRModuleUpdate {
|
|
|
467
468
|
* HMR client message types
|
|
468
469
|
*/
|
|
469
470
|
export type HMRClientMessage =
|
|
470
|
-
| { type:
|
|
471
|
-
| { type:
|
|
472
|
-
| { type:
|
|
473
|
-
| { type:
|
|
471
|
+
| { type: "subscribe"; fileId: string }
|
|
472
|
+
| { type: "unsubscribe"; fileId: string }
|
|
473
|
+
| { type: "ping" }
|
|
474
|
+
| { type: "module-accepted"; moduleId: string; dependencies: string[] };
|
|
474
475
|
|
|
475
476
|
/**
|
|
476
477
|
* HMR server message types
|
|
477
478
|
*/
|
|
478
479
|
export type HMRServerMessage =
|
|
479
480
|
| HMRUpdate
|
|
480
|
-
| { type:
|
|
481
|
-
| { type:
|
|
481
|
+
| { type: "pong" }
|
|
482
|
+
| { type: "connected"; clientId: string };
|
|
482
483
|
|
|
483
484
|
/**
|
|
484
485
|
* File change event information
|
|
@@ -492,7 +493,7 @@ export interface FileChangeEvent {
|
|
|
492
493
|
/**
|
|
493
494
|
* Type of change
|
|
494
495
|
*/
|
|
495
|
-
event:
|
|
496
|
+
event: "create" | "update" | "delete";
|
|
496
497
|
|
|
497
498
|
/**
|
|
498
499
|
* Timestamp of the change
|
|
@@ -505,7 +506,14 @@ export interface FileChangeEvent {
|
|
|
505
506
|
/**
|
|
506
507
|
* Console message types that can be captured
|
|
507
508
|
*/
|
|
508
|
-
export type ConsoleMessageType =
|
|
509
|
+
export type ConsoleMessageType =
|
|
510
|
+
| "log"
|
|
511
|
+
| "info"
|
|
512
|
+
| "warn"
|
|
513
|
+
| "error"
|
|
514
|
+
| "debug"
|
|
515
|
+
| "trace"
|
|
516
|
+
| "table";
|
|
509
517
|
|
|
510
518
|
/**
|
|
511
519
|
* Console message captured from the browser
|
|
@@ -619,7 +627,7 @@ export interface ConsoleClientMessage {
|
|
|
619
627
|
/**
|
|
620
628
|
* Message type identifier
|
|
621
629
|
*/
|
|
622
|
-
type:
|
|
630
|
+
type: "console";
|
|
623
631
|
|
|
624
632
|
/**
|
|
625
633
|
* Console method called (log, warn, error, etc.)
|
|
@@ -666,8 +674,8 @@ export interface ConsoleClientMessage {
|
|
|
666
674
|
* Server message for console stream
|
|
667
675
|
*/
|
|
668
676
|
export type ConsoleServerMessage =
|
|
669
|
-
| { type:
|
|
670
|
-
| { type:
|
|
677
|
+
| { type: "connected"; clientId: string }
|
|
678
|
+
| { type: "pong" };
|
|
671
679
|
|
|
672
680
|
// ============= Bundler Types =============
|
|
673
681
|
|
|
@@ -694,17 +702,17 @@ export interface BuildPlugin {
|
|
|
694
702
|
/**
|
|
695
703
|
* Source map generation options
|
|
696
704
|
*/
|
|
697
|
-
export type SourcemapOption =
|
|
705
|
+
export type SourcemapOption = "linked" | "external" | "none";
|
|
698
706
|
|
|
699
707
|
/**
|
|
700
708
|
* Build target environment
|
|
701
709
|
*/
|
|
702
|
-
export type BuildTarget =
|
|
710
|
+
export type BuildTarget = "browser" | "node" | "bun";
|
|
703
711
|
|
|
704
712
|
/**
|
|
705
713
|
* Output module format
|
|
706
714
|
*/
|
|
707
|
-
export type OutputFormat =
|
|
715
|
+
export type OutputFormat = "esm" | "cjs" | "iife";
|
|
708
716
|
|
|
709
717
|
/**
|
|
710
718
|
* Bundler configuration options
|
|
@@ -727,7 +735,7 @@ export interface BundlerConfig {
|
|
|
727
735
|
* 'auto' will detect from package.json
|
|
728
736
|
* @default 'auto'
|
|
729
737
|
*/
|
|
730
|
-
framework: FrontendFramework |
|
|
738
|
+
framework: FrontendFramework | "auto";
|
|
731
739
|
|
|
732
740
|
/**
|
|
733
741
|
* Minify output
|
|
@@ -801,13 +809,14 @@ export interface BundlerConfig {
|
|
|
801
809
|
/**
|
|
802
810
|
* Environment mode
|
|
803
811
|
*/
|
|
804
|
-
mode?:
|
|
812
|
+
mode?: "development" | "production";
|
|
805
813
|
}
|
|
806
814
|
|
|
807
815
|
/**
|
|
808
816
|
* Partial bundler configuration
|
|
809
817
|
*/
|
|
810
|
-
export type PartialBundlerConfig = Partial<BundlerConfig> &
|
|
818
|
+
export type PartialBundlerConfig = Partial<BundlerConfig> &
|
|
819
|
+
Pick<BundlerConfig, "entryPoints">;
|
|
811
820
|
|
|
812
821
|
/**
|
|
813
822
|
* Build output file information
|
|
@@ -821,7 +830,7 @@ export interface BuildOutput {
|
|
|
821
830
|
/**
|
|
822
831
|
* Type of output file
|
|
823
832
|
*/
|
|
824
|
-
type:
|
|
833
|
+
type: "js" | "css" | "asset";
|
|
825
834
|
|
|
826
835
|
/**
|
|
827
836
|
* File size in bytes
|
|
@@ -956,7 +965,7 @@ export interface FrameworkBuildConfig {
|
|
|
956
965
|
/**
|
|
957
966
|
* JSX runtime to use
|
|
958
967
|
*/
|
|
959
|
-
jsxRuntime:
|
|
968
|
+
jsxRuntime: "automatic" | "classic";
|
|
960
969
|
|
|
961
970
|
/**
|
|
962
971
|
* JSX import source for automatic runtime
|
|
@@ -991,7 +1000,10 @@ export interface FrameworkBuildConfig {
|
|
|
991
1000
|
/**
|
|
992
1001
|
* Additional loader configurations
|
|
993
1002
|
*/
|
|
994
|
-
loaders?: Record<
|
|
1003
|
+
loaders?: Record<
|
|
1004
|
+
string,
|
|
1005
|
+
"js" | "jsx" | "ts" | "tsx" | "css" | "file" | "dataurl" | "text"
|
|
1006
|
+
>;
|
|
995
1007
|
}
|
|
996
1008
|
|
|
997
1009
|
/**
|
|
@@ -1006,15 +1018,18 @@ export interface BuildManifest {
|
|
|
1006
1018
|
/**
|
|
1007
1019
|
* All output files
|
|
1008
1020
|
*/
|
|
1009
|
-
files: Record<
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1021
|
+
files: Record<
|
|
1022
|
+
string,
|
|
1023
|
+
{
|
|
1024
|
+
type: "js" | "css" | "asset";
|
|
1025
|
+
size: number;
|
|
1026
|
+
hash?: string;
|
|
1027
|
+
imports?: string[];
|
|
1028
|
+
dynamicImports?: string[];
|
|
1029
|
+
}
|
|
1030
|
+
>;
|
|
1016
1031
|
|
|
1017
|
-
|
|
1032
|
+
/**
|
|
1018
1033
|
* CSS files for each entry point
|
|
1019
1034
|
*/
|
|
1020
1035
|
css: Record<string, string[]>;
|
|
@@ -1298,13 +1313,19 @@ export interface SSRConfig {
|
|
|
1298
1313
|
/**
|
|
1299
1314
|
* Custom HTML template function
|
|
1300
1315
|
*/
|
|
1301
|
-
templateFn?: (
|
|
1316
|
+
templateFn?: (
|
|
1317
|
+
ctx: SSRContext,
|
|
1318
|
+
content: string,
|
|
1319
|
+
head: string,
|
|
1320
|
+
body: string,
|
|
1321
|
+
) => string;
|
|
1302
1322
|
}
|
|
1303
1323
|
|
|
1304
1324
|
/**
|
|
1305
1325
|
* Partial SSR configuration
|
|
1306
1326
|
*/
|
|
1307
|
-
export type PartialSSRConfig = Partial<SSRConfig> &
|
|
1327
|
+
export type PartialSSRConfig = Partial<SSRConfig> &
|
|
1328
|
+
Pick<SSRConfig, "entry" | "clientEntry" | "clientManifest" | "framework">;
|
|
1308
1329
|
|
|
1309
1330
|
/**
|
|
1310
1331
|
* Framework-specific SSR renderer
|
|
@@ -1318,7 +1339,10 @@ export interface FrameworkSSRRenderer {
|
|
|
1318
1339
|
/**
|
|
1319
1340
|
* Render a component to a stream
|
|
1320
1341
|
*/
|
|
1321
|
-
renderToStream(
|
|
1342
|
+
renderToStream(
|
|
1343
|
+
component: unknown,
|
|
1344
|
+
context: SSRContext,
|
|
1345
|
+
): ReadableStream<Uint8Array>;
|
|
1322
1346
|
|
|
1323
1347
|
/**
|
|
1324
1348
|
* Get head elements from component
|
|
@@ -1428,12 +1452,12 @@ export interface PreloadLink {
|
|
|
1428
1452
|
/**
|
|
1429
1453
|
* Link rel type
|
|
1430
1454
|
*/
|
|
1431
|
-
rel:
|
|
1455
|
+
rel: "preload" | "prefetch" | "modulepreload";
|
|
1432
1456
|
|
|
1433
1457
|
/**
|
|
1434
1458
|
* As attribute
|
|
1435
1459
|
*/
|
|
1436
|
-
as?:
|
|
1460
|
+
as?: "script" | "style" | "font" | "image" | "fetch";
|
|
1437
1461
|
|
|
1438
1462
|
/**
|
|
1439
1463
|
* Additional attributes
|
|
@@ -1616,7 +1640,7 @@ export interface ISRStats {
|
|
|
1616
1640
|
/**
|
|
1617
1641
|
* Island hydration strategy
|
|
1618
1642
|
*/
|
|
1619
|
-
export type IslandHydrationStrategy =
|
|
1643
|
+
export type IslandHydrationStrategy = "eager" | "lazy" | "visible" | "idle";
|
|
1620
1644
|
|
|
1621
1645
|
/**
|
|
1622
1646
|
* Island configuration options
|
|
@@ -1769,14 +1793,14 @@ export interface IslandHydrationScript {
|
|
|
1769
1793
|
/**
|
|
1770
1794
|
* Script type
|
|
1771
1795
|
*/
|
|
1772
|
-
type:
|
|
1796
|
+
type: "module" | "text/javascript";
|
|
1773
1797
|
}
|
|
1774
1798
|
// ============= File-based Routing Types =============
|
|
1775
1799
|
|
|
1776
1800
|
/**
|
|
1777
1801
|
* Route type
|
|
1778
1802
|
*/
|
|
1779
|
-
export type RouteType =
|
|
1803
|
+
export type RouteType = "page" | "api" | "layout";
|
|
1780
1804
|
|
|
1781
1805
|
/**
|
|
1782
1806
|
* Route definition from file
|
|
@@ -1853,7 +1877,7 @@ export type RouteHandler = (request: Request) => Response | Promise<Response>;
|
|
|
1853
1877
|
*/
|
|
1854
1878
|
export type RouteMiddleware = (
|
|
1855
1879
|
request: Request,
|
|
1856
|
-
next: () => Promise<Response
|
|
1880
|
+
next: () => Promise<Response>,
|
|
1857
1881
|
) => Response | Promise<Response>;
|
|
1858
1882
|
|
|
1859
1883
|
/**
|
|
@@ -1996,7 +2020,7 @@ export interface LayoutProps {
|
|
|
1996
2020
|
*/
|
|
1997
2021
|
export type LayoutRenderer = (
|
|
1998
2022
|
props: LayoutProps,
|
|
1999
|
-
context: SSRContext
|
|
2023
|
+
context: SSRContext,
|
|
2000
2024
|
) => Promise<string | LayoutRenderResult> | string | LayoutRenderResult;
|
|
2001
2025
|
|
|
2002
2026
|
/**
|
|
@@ -2005,7 +2029,7 @@ export type LayoutRenderer = (
|
|
|
2005
2029
|
export type LayoutMiddleware = (
|
|
2006
2030
|
props: LayoutProps,
|
|
2007
2031
|
context: SSRContext,
|
|
2008
|
-
next: () => Promise<string
|
|
2032
|
+
next: () => Promise<string>,
|
|
2009
2033
|
) => Promise<string> | string;
|
|
2010
2034
|
|
|
2011
2035
|
/**
|
|
@@ -2090,7 +2114,14 @@ export interface LayoutSegment {
|
|
|
2090
2114
|
/**
|
|
2091
2115
|
* HTTP methods supported by API routes
|
|
2092
2116
|
*/
|
|
2093
|
-
export type HTTPMethod =
|
|
2117
|
+
export type HTTPMethod =
|
|
2118
|
+
| "GET"
|
|
2119
|
+
| "POST"
|
|
2120
|
+
| "PUT"
|
|
2121
|
+
| "PATCH"
|
|
2122
|
+
| "DELETE"
|
|
2123
|
+
| "HEAD"
|
|
2124
|
+
| "OPTIONS";
|
|
2094
2125
|
|
|
2095
2126
|
/**
|
|
2096
2127
|
* API route definition
|
|
@@ -2130,7 +2161,9 @@ export interface APIRouteDefinition {
|
|
|
2130
2161
|
/**
|
|
2131
2162
|
* API route handler function
|
|
2132
2163
|
*/
|
|
2133
|
-
export type APIRouteHandler = (
|
|
2164
|
+
export type APIRouteHandler = (
|
|
2165
|
+
ctx: APIContext,
|
|
2166
|
+
) => APIResponse | Promise<APIResponse>;
|
|
2134
2167
|
|
|
2135
2168
|
/**
|
|
2136
2169
|
* API response type
|
|
@@ -2142,7 +2175,7 @@ export type APIResponse = Response | string | Record<string, unknown> | null;
|
|
|
2142
2175
|
*/
|
|
2143
2176
|
export type APIMiddleware = (
|
|
2144
2177
|
ctx: APIContext,
|
|
2145
|
-
next: () => Promise<Response
|
|
2178
|
+
next: () => Promise<Response>,
|
|
2146
2179
|
) => Response | Promise<Response>;
|
|
2147
2180
|
|
|
2148
2181
|
/**
|
|
@@ -2237,7 +2270,9 @@ export interface APIRouteModule {
|
|
|
2237
2270
|
/**
|
|
2238
2271
|
* Default export (config or handler)
|
|
2239
2272
|
*/
|
|
2240
|
-
default?:
|
|
2273
|
+
default?:
|
|
2274
|
+
| APIRouteHandler
|
|
2275
|
+
| { handler: APIRouteHandler; config?: APIRouteConfig };
|
|
2241
2276
|
}
|
|
2242
2277
|
|
|
2243
2278
|
/**
|
|
@@ -2271,4 +2306,4 @@ export interface APIRouteConfig {
|
|
|
2271
2306
|
/**
|
|
2272
2307
|
* Partial API route configuration
|
|
2273
2308
|
*/
|
|
2274
|
-
export type PartialAPIRouteConfig = Partial<APIRouteConfig>;
|
|
2309
|
+
export type PartialAPIRouteConfig = Partial<APIRouteConfig>;
|
package/src/health/index.ts
CHANGED
|
@@ -73,7 +73,10 @@ export interface HealthMiddlewareOptions {
|
|
|
73
73
|
/** Whether to expose metrics in response (default: true) */
|
|
74
74
|
exposeMetrics?: boolean;
|
|
75
75
|
/** Initial health checks to register */
|
|
76
|
-
checks?: Record<
|
|
76
|
+
checks?: Record<
|
|
77
|
+
string,
|
|
78
|
+
HealthCheckFn | { fn: HealthCheckFn; options?: CheckOptions }
|
|
79
|
+
>;
|
|
77
80
|
/** Custom version string (default: from package.json) */
|
|
78
81
|
version?: string;
|
|
79
82
|
}
|
|
@@ -164,7 +167,10 @@ export class HealthCheckManager {
|
|
|
164
167
|
check.fn(),
|
|
165
168
|
new Promise<never>((_, reject) =>
|
|
166
169
|
setTimeout(
|
|
167
|
-
() =>
|
|
170
|
+
() =>
|
|
171
|
+
reject(
|
|
172
|
+
new Error(`Check timed out after ${check.options.timeout}ms`),
|
|
173
|
+
),
|
|
168
174
|
check.options.timeout,
|
|
169
175
|
),
|
|
170
176
|
),
|
|
@@ -286,9 +292,10 @@ export class HealthCheckManager {
|
|
|
286
292
|
/**
|
|
287
293
|
* Create health check middleware
|
|
288
294
|
*/
|
|
289
|
-
export function createHealthMiddleware(
|
|
290
|
-
|
|
291
|
-
|
|
295
|
+
export function createHealthMiddleware(options: HealthMiddlewareOptions = {}): {
|
|
296
|
+
middleware: Middleware;
|
|
297
|
+
manager: HealthCheckManager;
|
|
298
|
+
} {
|
|
292
299
|
const {
|
|
293
300
|
healthPath = "/health",
|
|
294
301
|
readyPath = "/ready",
|
|
@@ -367,7 +374,9 @@ export function createDatabaseCheck(
|
|
|
367
374
|
return {
|
|
368
375
|
status: isHealthy ? "healthy" : "unhealthy",
|
|
369
376
|
latency: Date.now() - start,
|
|
370
|
-
message: isHealthy
|
|
377
|
+
message: isHealthy
|
|
378
|
+
? "Database connection OK"
|
|
379
|
+
: "Database health check failed",
|
|
371
380
|
};
|
|
372
381
|
}
|
|
373
382
|
|
|
@@ -399,7 +408,8 @@ export function createDatabaseCheck(
|
|
|
399
408
|
return {
|
|
400
409
|
status: "unhealthy",
|
|
401
410
|
latency: Date.now() - start,
|
|
402
|
-
message:
|
|
411
|
+
message:
|
|
412
|
+
error instanceof Error ? error.message : "Database check failed",
|
|
403
413
|
};
|
|
404
414
|
}
|
|
405
415
|
};
|
|
@@ -424,7 +434,9 @@ export function createCacheCheck(
|
|
|
424
434
|
return {
|
|
425
435
|
status: isHealthy ? "healthy" : "unhealthy",
|
|
426
436
|
latency: Date.now() - start,
|
|
427
|
-
message: isHealthy
|
|
437
|
+
message: isHealthy
|
|
438
|
+
? "Cache connection OK"
|
|
439
|
+
: "Cache health check failed",
|
|
428
440
|
};
|
|
429
441
|
}
|
|
430
442
|
|
|
@@ -601,4 +613,4 @@ export function createHTTPCheck(
|
|
|
601
613
|
*/
|
|
602
614
|
export function createHealthManager(version?: string): HealthCheckManager {
|
|
603
615
|
return new HealthCheckManager(version);
|
|
604
|
-
}
|
|
616
|
+
}
|