@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.
Files changed (218) hide show
  1. package/README.md +136 -16
  2. package/dist/cli/{index.js → bin.js} +3036 -1421
  3. package/dist/container/index.js +250 -0
  4. package/dist/context/index.js +219 -0
  5. package/dist/database/index.js +493 -0
  6. package/dist/frontend/index.js +7697 -0
  7. package/dist/health/index.js +364 -0
  8. package/dist/i18n/index.js +345 -0
  9. package/dist/index.js +11043 -6482
  10. package/dist/jobs/index.js +819 -0
  11. package/dist/lock/index.js +367 -0
  12. package/dist/logger/index.js +281 -0
  13. package/dist/metrics/index.js +289 -0
  14. package/dist/middleware/index.js +77 -0
  15. package/dist/migrations/index.js +571 -0
  16. package/dist/modules/index.js +3346 -0
  17. package/dist/notification/index.js +484 -0
  18. package/dist/observability/index.js +331 -0
  19. package/dist/openapi/index.js +776 -0
  20. package/dist/orm/index.js +1356 -0
  21. package/dist/router/index.js +886 -0
  22. package/dist/rpc/index.js +691 -0
  23. package/dist/schema/index.js +400 -0
  24. package/dist/telemetry/index.js +595 -0
  25. package/dist/template/index.js +640 -0
  26. package/dist/templates/index.js +640 -0
  27. package/dist/testing/index.js +1111 -0
  28. package/dist/types/index.js +60 -0
  29. package/package.json +121 -27
  30. package/src/cache/index.ts +2 -1
  31. package/src/cli/bin.ts +2 -2
  32. package/src/cli/commands/build.ts +183 -165
  33. package/src/cli/commands/dev.ts +96 -89
  34. package/src/cli/commands/generate.ts +142 -111
  35. package/src/cli/commands/help.ts +20 -16
  36. package/src/cli/commands/index.ts +3 -6
  37. package/src/cli/commands/migration.ts +124 -105
  38. package/src/cli/commands/new.ts +392 -438
  39. package/src/cli/commands/start.ts +81 -79
  40. package/src/cli/core/args.ts +68 -50
  41. package/src/cli/core/console.ts +89 -95
  42. package/src/cli/core/index.ts +4 -4
  43. package/src/cli/core/prompt.ts +65 -62
  44. package/src/cli/core/spinner.ts +23 -20
  45. package/src/cli/index.ts +46 -38
  46. package/src/cli/templates/database/index.ts +61 -0
  47. package/src/cli/templates/database/mysql.ts +14 -0
  48. package/src/cli/templates/database/none.ts +16 -0
  49. package/src/cli/templates/database/postgresql.ts +14 -0
  50. package/src/cli/templates/database/sqlite.ts +14 -0
  51. package/src/cli/templates/deploy.ts +29 -26
  52. package/src/cli/templates/docker.ts +41 -30
  53. package/src/cli/templates/frontend/index.ts +63 -0
  54. package/src/cli/templates/frontend/none.ts +17 -0
  55. package/src/cli/templates/frontend/react.ts +140 -0
  56. package/src/cli/templates/frontend/solid.ts +134 -0
  57. package/src/cli/templates/frontend/svelte.ts +131 -0
  58. package/src/cli/templates/frontend/vue.ts +130 -0
  59. package/src/cli/templates/generators/index.ts +339 -0
  60. package/src/cli/templates/generators/types.ts +56 -0
  61. package/src/cli/templates/index.ts +35 -2
  62. package/src/cli/templates/project/api.ts +81 -0
  63. package/src/cli/templates/project/default.ts +140 -0
  64. package/src/cli/templates/project/fullstack.ts +111 -0
  65. package/src/cli/templates/project/index.ts +95 -0
  66. package/src/cli/templates/project/minimal.ts +45 -0
  67. package/src/cli/templates/project/types.ts +94 -0
  68. package/src/cli/templates/project/website.ts +263 -0
  69. package/src/cli/utils/fs.ts +55 -41
  70. package/src/cli/utils/index.ts +3 -2
  71. package/src/cli/utils/strings.ts +47 -33
  72. package/src/cli/utils/version.ts +47 -0
  73. package/src/config/env-validation.ts +100 -0
  74. package/src/config/env.ts +169 -41
  75. package/src/config/index.ts +28 -20
  76. package/src/config/loader.ts +25 -16
  77. package/src/config/merge.ts +21 -10
  78. package/src/config/types.ts +545 -25
  79. package/src/config/validation.ts +215 -7
  80. package/src/container/forward-ref.ts +22 -22
  81. package/src/container/index.ts +34 -12
  82. package/src/context/index.ts +11 -1
  83. package/src/database/index.ts +7 -190
  84. package/src/database/orm/builder.ts +457 -0
  85. package/src/database/orm/casts/index.ts +130 -0
  86. package/src/database/orm/casts/types.ts +25 -0
  87. package/src/database/orm/compiler.ts +304 -0
  88. package/src/database/orm/hooks/index.ts +114 -0
  89. package/src/database/orm/index.ts +61 -0
  90. package/src/database/orm/model-registry.ts +59 -0
  91. package/src/database/orm/model.ts +821 -0
  92. package/src/database/orm/relationships/base.ts +146 -0
  93. package/src/database/orm/relationships/belongs-to-many.ts +179 -0
  94. package/src/database/orm/relationships/belongs-to.ts +56 -0
  95. package/src/database/orm/relationships/has-many.ts +45 -0
  96. package/src/database/orm/relationships/has-one.ts +41 -0
  97. package/src/database/orm/relationships/index.ts +11 -0
  98. package/src/database/orm/scopes/index.ts +55 -0
  99. package/src/events/__tests__/event-system.test.ts +235 -0
  100. package/src/events/config.ts +238 -0
  101. package/src/events/example-usage.ts +185 -0
  102. package/src/events/index.ts +278 -0
  103. package/src/events/manager.ts +385 -0
  104. package/src/events/registry.ts +182 -0
  105. package/src/events/types.ts +124 -0
  106. package/src/frontend/api-routes.ts +65 -23
  107. package/src/frontend/bundler.ts +76 -34
  108. package/src/frontend/console-client.ts +2 -2
  109. package/src/frontend/console-stream.ts +94 -38
  110. package/src/frontend/dev-server.ts +94 -46
  111. package/src/frontend/file-router.ts +61 -19
  112. package/src/frontend/frameworks/index.ts +37 -10
  113. package/src/frontend/frameworks/react.ts +10 -8
  114. package/src/frontend/frameworks/solid.ts +11 -9
  115. package/src/frontend/frameworks/svelte.ts +15 -9
  116. package/src/frontend/frameworks/vue.ts +13 -11
  117. package/src/frontend/hmr-client.ts +12 -10
  118. package/src/frontend/hmr.ts +146 -103
  119. package/src/frontend/index.ts +14 -5
  120. package/src/frontend/islands.ts +41 -22
  121. package/src/frontend/isr.ts +59 -37
  122. package/src/frontend/layout.ts +36 -21
  123. package/src/frontend/ssr/react.ts +74 -27
  124. package/src/frontend/ssr/solid.ts +54 -20
  125. package/src/frontend/ssr/svelte.ts +48 -14
  126. package/src/frontend/ssr/vue.ts +50 -18
  127. package/src/frontend/ssr.ts +83 -39
  128. package/src/frontend/types.ts +91 -56
  129. package/src/health/index.ts +21 -9
  130. package/src/i18n/engine.ts +305 -0
  131. package/src/i18n/index.ts +38 -0
  132. package/src/i18n/loader.ts +218 -0
  133. package/src/i18n/middleware.ts +164 -0
  134. package/src/i18n/negotiator.ts +162 -0
  135. package/src/i18n/types.ts +158 -0
  136. package/src/index.ts +179 -27
  137. package/src/jobs/drivers/memory.ts +315 -0
  138. package/src/jobs/drivers/redis.ts +459 -0
  139. package/src/jobs/index.ts +30 -0
  140. package/src/jobs/queue.ts +281 -0
  141. package/src/jobs/types.ts +295 -0
  142. package/src/jobs/worker.ts +380 -0
  143. package/src/logger/index.ts +1 -3
  144. package/src/logger/transports/index.ts +62 -22
  145. package/src/metrics/index.ts +25 -16
  146. package/src/migrations/index.ts +9 -0
  147. package/src/modules/filters.ts +13 -17
  148. package/src/modules/guards.ts +49 -26
  149. package/src/modules/index.ts +409 -298
  150. package/src/modules/interceptors.ts +58 -20
  151. package/src/modules/lazy.ts +11 -19
  152. package/src/modules/lifecycle.ts +15 -7
  153. package/src/modules/metadata.ts +15 -5
  154. package/src/modules/pipes.ts +94 -72
  155. package/src/notification/channels/base.ts +68 -0
  156. package/src/notification/channels/email.ts +105 -0
  157. package/src/notification/channels/push.ts +104 -0
  158. package/src/notification/channels/sms.ts +105 -0
  159. package/src/notification/channels/whatsapp.ts +104 -0
  160. package/src/notification/index.ts +48 -0
  161. package/src/notification/service.ts +354 -0
  162. package/src/notification/types.ts +344 -0
  163. package/src/observability/__tests__/observability.test.ts +483 -0
  164. package/src/observability/breadcrumbs.ts +114 -0
  165. package/src/observability/index.ts +136 -0
  166. package/src/observability/interceptor.ts +85 -0
  167. package/src/observability/service.ts +303 -0
  168. package/src/observability/trace.ts +37 -0
  169. package/src/observability/types.ts +196 -0
  170. package/src/openapi/__tests__/decorators.test.ts +335 -0
  171. package/src/openapi/__tests__/document-builder.test.ts +285 -0
  172. package/src/openapi/__tests__/route-scanner.test.ts +334 -0
  173. package/src/openapi/__tests__/schema-generator.test.ts +275 -0
  174. package/src/openapi/decorators.ts +328 -0
  175. package/src/openapi/document-builder.ts +274 -0
  176. package/src/openapi/index.ts +112 -0
  177. package/src/openapi/metadata.ts +112 -0
  178. package/src/openapi/route-scanner.ts +289 -0
  179. package/src/openapi/schema-generator.ts +256 -0
  180. package/src/openapi/swagger-module.ts +166 -0
  181. package/src/openapi/types.ts +398 -0
  182. package/src/orm/index.ts +10 -0
  183. package/src/rpc/index.ts +3 -1
  184. package/src/schema/index.ts +9 -0
  185. package/src/security/index.ts +15 -6
  186. package/src/ssg/index.ts +9 -8
  187. package/src/telemetry/index.ts +76 -22
  188. package/src/template/index.ts +7 -0
  189. package/src/templates/engine.ts +224 -0
  190. package/src/templates/index.ts +9 -0
  191. package/src/templates/loader.ts +331 -0
  192. package/src/templates/renderers/markdown.ts +212 -0
  193. package/src/templates/renderers/simple.ts +269 -0
  194. package/src/templates/types.ts +154 -0
  195. package/src/testing/index.ts +100 -27
  196. package/src/types/optional-deps.d.ts +347 -187
  197. package/src/validation/index.ts +92 -2
  198. package/src/validation/schemas.ts +536 -0
  199. package/tests/integration/fullstack.test.ts +4 -4
  200. package/tests/unit/database.test.ts +2 -72
  201. package/tests/unit/env-validation.test.ts +166 -0
  202. package/tests/unit/events.test.ts +910 -0
  203. package/tests/unit/i18n.test.ts +455 -0
  204. package/tests/unit/jobs.test.ts +493 -0
  205. package/tests/unit/notification.test.ts +988 -0
  206. package/tests/unit/observability.test.ts +453 -0
  207. package/tests/unit/orm/builder.test.ts +323 -0
  208. package/tests/unit/orm/casts.test.ts +179 -0
  209. package/tests/unit/orm/compiler.test.ts +220 -0
  210. package/tests/unit/orm/eager-loading.test.ts +285 -0
  211. package/tests/unit/orm/hooks.test.ts +191 -0
  212. package/tests/unit/orm/model.test.ts +373 -0
  213. package/tests/unit/orm/relationships.test.ts +303 -0
  214. package/tests/unit/orm/scopes.test.ts +74 -0
  215. package/tests/unit/templates-simple.test.ts +53 -0
  216. package/tests/unit/templates.test.ts +454 -0
  217. package/tests/unit/validation.test.ts +18 -24
  218. package/tsconfig.json +11 -3
@@ -1,219 +1,379 @@
1
1
  /**
2
2
  * Type declarations for optional peer dependencies
3
- *
3
+ *
4
4
  * These modules are optional peer dependencies for SSR rendering.
5
5
  * Users need to install them separately if they want to use SSR features.
6
6
  */
7
7
 
8
8
  // React types
9
9
  declare module "react" {
10
- export type ReactElement = {
11
- type: unknown;
12
- props: Record<string, unknown>;
13
- key: string | number | null;
14
- };
15
-
16
- export type ReactNode = ReactElement | string | number | boolean | null | undefined | Iterable<ReactNode>;
17
-
18
- export function createElement(
19
- type: string | ((props: unknown) => ReactElement),
20
- props?: Record<string, unknown> | null,
21
- ...children: ReactNode[]
22
- ): ReactElement;
23
-
24
- export const Suspense: {
25
- (props: { fallback?: ReactNode; children?: ReactNode }): ReactElement;
26
- };
27
-
28
- export const Fragment: unique symbol;
29
-
30
- export function useState<T>(initialState: T): [T, (value: T | ((prev: T) => T)) => void];
31
- export function useEffect(effect: () => void | (() => void), deps?: unknown[]): void;
32
- export function useContext<T>(context: ReactContext<T>): T;
33
- export function createContext<T>(defaultValue: T): ReactContext<T>;
34
- export function useRef<T>(initialValue: T): { current: T };
35
- export function useMemo<T>(factory: () => T, deps?: unknown[]): T;
36
- export function useCallback<T extends (...args: unknown[]) => unknown>(callback: T, deps?: unknown[]): T;
37
- export function useReducer<S, A>(reducer: (state: S, action: A) => S, initialArg: S): [S, (action: A) => void];
38
-
39
- export interface ReactContext<T> {
40
- Provider: (props: { value: T; children?: ReactNode }) => ReactElement;
41
- Consumer: (props: { children: (value: T) => ReactNode }) => ReactElement;
42
- displayName?: string;
43
- }
44
-
45
- export const version: string;
46
- export default { createElement, Suspense, Fragment, useState, useEffect, useContext, createContext, useRef, useMemo, useCallback, useReducer, version };
10
+ export type ReactElement = {
11
+ type: unknown;
12
+ props: Record<string, unknown>;
13
+ key: string | number | null;
14
+ };
15
+
16
+ export type ReactNode =
17
+ | ReactElement
18
+ | string
19
+ | number
20
+ | boolean
21
+ | null
22
+ | undefined
23
+ | Iterable<ReactNode>;
24
+
25
+ export function createElement(
26
+ type: string | ((props: unknown) => ReactElement),
27
+ props?: Record<string, unknown> | null,
28
+ ...children: ReactNode[]
29
+ ): ReactElement;
30
+
31
+ export const Suspense: (props: {
32
+ fallback?: ReactNode;
33
+ children?: ReactNode;
34
+ }) => ReactElement;
35
+
36
+ export const Fragment: unique symbol;
37
+
38
+ export function useState<T>(
39
+ initialState: T,
40
+ ): [T, (value: T | ((prev: T) => T)) => void];
41
+ export function useEffect(
42
+ effect: () => void | (() => void),
43
+ deps?: unknown[],
44
+ ): void;
45
+ export function useContext<T>(context: ReactContext<T>): T;
46
+ export function createContext<T>(defaultValue: T): ReactContext<T>;
47
+ export function useRef<T>(initialValue: T): { current: T };
48
+ export function useMemo<T>(factory: () => T, deps?: unknown[]): T;
49
+ export function useCallback<T extends (...args: unknown[]) => unknown>(
50
+ callback: T,
51
+ deps?: unknown[],
52
+ ): T;
53
+ export function useReducer<S, A>(
54
+ reducer: (state: S, action: A) => S,
55
+ initialArg: S,
56
+ ): [S, (action: A) => void];
57
+
58
+ export interface ReactContext<T> {
59
+ Provider: (props: { value: T; children?: ReactNode }) => ReactElement;
60
+ Consumer: (props: { children: (value: T) => ReactNode }) => ReactElement;
61
+ displayName?: string;
62
+ }
63
+
64
+ export const version: string;
65
+ export default {
66
+ createElement,
67
+ Suspense,
68
+ Fragment,
69
+ useState,
70
+ useEffect,
71
+ useContext,
72
+ createContext,
73
+ useRef,
74
+ useMemo,
75
+ useCallback,
76
+ useReducer,
77
+ version,
78
+ };
47
79
  }
48
80
 
49
81
  declare module "react-dom/server" {
50
- import { ReactElement } from "react";
51
-
52
- export function renderToString(element: ReactElement): string;
53
- export function renderToStaticMarkup(element: ReactElement): string;
54
- export function renderToPipeableStream(element: ReactElement, options?: {
55
- bootstrapScripts?: string[];
56
- bootstrapModules?: string[];
57
- identifierPrefix?: string;
58
- namespaceURI?: string;
59
- nonce?: string;
60
- onAllReady?: () => void;
61
- onError?: (error: Error) => void;
62
- onShellReady?: () => void;
63
- onShellError?: (error: Error) => void;
64
- }): { pipe: (destination: unknown) => void; abort: () => void };
65
-
66
- export function renderToReadableStream(element: ReactElement, options?: {
67
- bootstrapScripts?: string[];
68
- bootstrapModules?: string[];
69
- identifierPrefix?: string;
70
- namespaceURI?: string;
71
- nonce?: string;
72
- onError?: (error: Error) => void;
73
- }): Promise<ReadableStream<Uint8Array> & { allReady: Promise<void> }>;
82
+ import type { ReactElement } from "react";
83
+
84
+ export function renderToString(element: ReactElement): string;
85
+ export function renderToStaticMarkup(element: ReactElement): string;
86
+ export function renderToPipeableStream(
87
+ element: ReactElement,
88
+ options?: {
89
+ bootstrapScripts?: string[];
90
+ bootstrapModules?: string[];
91
+ identifierPrefix?: string;
92
+ namespaceURI?: string;
93
+ nonce?: string;
94
+ onAllReady?: () => void;
95
+ onError?: (error: Error) => void;
96
+ onShellReady?: () => void;
97
+ onShellError?: (error: Error) => void;
98
+ },
99
+ ): { pipe: (destination: unknown) => void; abort: () => void };
100
+
101
+ export function renderToReadableStream(
102
+ element: ReactElement,
103
+ options?: {
104
+ bootstrapScripts?: string[];
105
+ bootstrapModules?: string[];
106
+ identifierPrefix?: string;
107
+ namespaceURI?: string;
108
+ nonce?: string;
109
+ onError?: (error: Error) => void;
110
+ },
111
+ ): Promise<ReadableStream<Uint8Array> & { allReady: Promise<void> }>;
74
112
  }
75
113
 
76
114
  // SolidJS types
77
115
  declare module "solid-js" {
78
- export type Accessor<T> = () => T;
79
- export type Setter<T> = (value: T | ((prev: T) => T)) => void;
80
- export type Signal<T> = [Accessor<T>, Setter<T>];
81
-
82
- export function createSignal<T>(value: T, options?: { equals?: boolean | ((prev: T, next: T) => boolean) }): Signal<T>;
83
- export function createEffect(fn: () => void | (() => void)): void;
84
- export function createMemo<T>(fn: () => T, value?: T, options?: { equals?: boolean | ((prev: T, next: T) => boolean) }): Accessor<T>;
85
- export function onMount(fn: () => void): void;
86
- export function onCleanup(fn: () => void): void;
87
- export function onError(fn: (err: Error) => void): void;
88
-
89
- export function untrack<T>(fn: () => T): T;
90
- export function batch<T>(fn: () => T): T;
91
-
92
- export function For<T>(props: { each: T[]; fallback?: unknown; children: (item: T, index: Accessor<number>) => unknown }): unknown;
93
- export function Show(props: { when: unknown; keyed?: boolean; fallback?: unknown; children: unknown }): unknown;
94
- export function Switch(props: { fallback?: unknown; children: unknown }): unknown;
95
- export function Match(props: { when: unknown; keyed?: boolean; children: unknown }): unknown;
96
- export function Index<T>(props: { each: T[]; fallback?: unknown; children: (item: Accessor<T>, index: number) => unknown }): unknown;
97
-
98
- export function children(fn: () => unknown): Accessor<unknown>;
99
- export function mergeProps<T extends object>(...sources: T[]): T;
100
- export function splitProps<T extends object>(props: T, ...keys: (keyof T)[][]): T[];
101
-
102
- export const Suspense: (props: { fallback?: unknown; children?: unknown }) => unknown;
103
-
104
- export interface JSX {
105
- Element: unknown;
106
- IntrinsicElements: Record<string, unknown>;
107
- }
116
+ export type Accessor<T> = () => T;
117
+ export type Setter<T> = (value: T | ((prev: T) => T)) => void;
118
+ export type Signal<T> = [Accessor<T>, Setter<T>];
119
+
120
+ export function createSignal<T>(
121
+ value: T,
122
+ options?: { equals?: boolean | ((prev: T, next: T) => boolean) },
123
+ ): Signal<T>;
124
+ export function createEffect(fn: () => void | (() => void)): void;
125
+ export function createMemo<T>(
126
+ fn: () => T,
127
+ value?: T,
128
+ options?: { equals?: boolean | ((prev: T, next: T) => boolean) },
129
+ ): Accessor<T>;
130
+ export function onMount(fn: () => void): void;
131
+ export function onCleanup(fn: () => void): void;
132
+ export function onError(fn: (err: Error) => void): void;
133
+
134
+ export function untrack<T>(fn: () => T): T;
135
+ export function batch<T>(fn: () => T): T;
136
+
137
+ export function For<T>(props: {
138
+ each: T[];
139
+ fallback?: unknown;
140
+ children: (item: T, index: Accessor<number>) => unknown;
141
+ }): unknown;
142
+ export function Show(props: {
143
+ when: unknown;
144
+ keyed?: boolean;
145
+ fallback?: unknown;
146
+ children: unknown;
147
+ }): unknown;
148
+ export function Switch(props: {
149
+ fallback?: unknown;
150
+ children: unknown;
151
+ }): unknown;
152
+ export function Match(props: {
153
+ when: unknown;
154
+ keyed?: boolean;
155
+ children: unknown;
156
+ }): unknown;
157
+ export function Index<T>(props: {
158
+ each: T[];
159
+ fallback?: unknown;
160
+ children: (item: Accessor<T>, index: number) => unknown;
161
+ }): unknown;
162
+
163
+ export function children(fn: () => unknown): Accessor<unknown>;
164
+ export function mergeProps<T extends object>(...sources: T[]): T;
165
+ export function splitProps<T extends object>(
166
+ props: T,
167
+ ...keys: (keyof T)[][]
168
+ ): T[];
169
+
170
+ export const Suspense: (props: {
171
+ fallback?: unknown;
172
+ children?: unknown;
173
+ }) => unknown;
174
+
175
+ export interface JSX {
176
+ Element: unknown;
177
+ IntrinsicElements: Record<string, unknown>;
178
+ }
108
179
  }
109
180
 
110
181
  declare module "solid-js/web" {
111
- export function renderToString(code: () => unknown, options?: { nonce?: string; renderId?: string }): string;
112
- export function renderToStringAsync(code: () => unknown, options?: { timeoutMs?: number; nonce?: string; renderId?: string }): Promise<string>;
113
- export function renderToStream(code: () => unknown, options?: { nonce?: string; renderId?: string }): ReadableStream<Uint8Array>;
114
- export function hydrate(code: () => unknown, element: Element): void;
115
- export function Dynamic(props: { component: unknown; [key: string]: unknown }): unknown;
116
- export function Portal(props: { mount?: Element; useShadow?: boolean; children: unknown }): unknown;
117
- export function Assets(props: { children: unknown }): unknown;
118
- export function HydrationScript(props?: { nonce?: string }): unknown;
182
+ export function renderToString(
183
+ code: () => unknown,
184
+ options?: { nonce?: string; renderId?: string },
185
+ ): string;
186
+ export function renderToStringAsync(
187
+ code: () => unknown,
188
+ options?: { timeoutMs?: number; nonce?: string; renderId?: string },
189
+ ): Promise<string>;
190
+ export function renderToStream(
191
+ code: () => unknown,
192
+ options?: { nonce?: string; renderId?: string },
193
+ ): ReadableStream<Uint8Array>;
194
+ export function hydrate(code: () => unknown, element: Element): void;
195
+ export function Dynamic(props: {
196
+ component: unknown;
197
+ [key: string]: unknown;
198
+ }): unknown;
199
+ export function Portal(props: {
200
+ mount?: Element;
201
+ useShadow?: boolean;
202
+ children: unknown;
203
+ }): unknown;
204
+ export function Assets(props: { children: unknown }): unknown;
205
+ export function HydrationScript(props?: { nonce?: string }): unknown;
119
206
  }
120
207
 
121
208
  // Svelte types
122
209
  declare module "svelte/server" {
123
- export interface SvelteComponent {
124
- render(props?: Record<string, unknown>): { html: string; head: string; css: { code: string } };
125
- }
126
-
127
- export function render(component: typeof SvelteComponent, options?: { props?: Record<string, unknown> }): { html: string; head: string; css: { code: string } };
210
+ export interface SvelteComponent {
211
+ render(props?: Record<string, unknown>): {
212
+ html: string;
213
+ head: string;
214
+ css: { code: string };
215
+ };
216
+ }
217
+
218
+ export function render(
219
+ component: typeof SvelteComponent,
220
+ options?: { props?: Record<string, unknown> },
221
+ ): { html: string; head: string; css: { code: string } };
128
222
  }
129
223
 
130
224
  // Vue types
131
225
  declare module "vue" {
132
- export type Component = unknown;
133
-
134
- export function createApp(rootComponent: Component, rootProps?: Record<string, unknown>): {
135
- mount(rootContainer: Element | string): unknown;
136
- unmount(): void;
137
- provide<T>(key: string | symbol, value: T): void;
138
- component(name: string, component: Component): void;
139
- directive(name: string, directive: unknown): void;
140
- use(plugin: unknown, ...options: unknown[]): void;
141
- };
142
-
143
- export function createSSRApp(rootComponent: Component, rootProps?: Record<string, unknown>): ReturnType<typeof createApp>;
144
-
145
- export function defineComponent(options: {
146
- name?: string;
147
- props?: Record<string, unknown>;
148
- setup?: (props: Record<string, unknown>, ctx: unknown) => unknown;
149
- render?: (ctx: unknown) => unknown;
150
- template?: string;
151
- components?: Record<string, Component>;
152
- directives?: Record<string, unknown>;
153
- data?: () => Record<string, unknown>;
154
- computed?: Record<string, (this: unknown) => unknown>;
155
- methods?: Record<string, (this: unknown, ...args: unknown[]) => unknown>;
156
- watch?: Record<string, unknown>;
157
- emits?: string[] | Record<string, unknown>;
158
- [key: string]: unknown;
159
- }): Component;
160
-
161
- export function ref<T>(value: T): { value: T };
162
- export function reactive<T extends object>(obj: T): T;
163
- export function computed<T>(fn: () => T): { readonly value: T };
164
- export function watch(source: unknown, callback: (value: unknown, oldValue: unknown, onCleanup: (fn: () => void) => void) => void, options?: { immediate?: boolean; deep?: boolean }): () => void;
165
- export function watchEffect(fn: (onCleanup: (fn: () => void) => void) => void): () => void;
166
- export function onMounted(fn: () => void): void;
167
- export function onUnmounted(fn: () => void): void;
168
- export function onServerPrefetch(fn: () => Promise<void>): void;
169
-
170
- export function h(type: string | Component, props?: Record<string, unknown> | null, children?: unknown): unknown;
171
- export function defineAsyncComponent(loader: () => Promise<{ default: Component }>): Component;
172
- export function provide(key: string | symbol, value: unknown): void;
173
- export function inject<T>(key: string | symbol, defaultValue?: T): T | undefined;
174
- export function useSSRContext(): Record<string, unknown>;
175
-
176
- export const version: string;
226
+ export type Component = unknown;
227
+
228
+ export function createApp(
229
+ rootComponent: Component,
230
+ rootProps?: Record<string, unknown>,
231
+ ): {
232
+ mount(rootContainer: Element | string): unknown;
233
+ unmount(): void;
234
+ provide<T>(key: string | symbol, value: T): void;
235
+ component(name: string, component: Component): void;
236
+ directive(name: string, directive: unknown): void;
237
+ use(plugin: unknown, ...options: unknown[]): void;
238
+ };
239
+
240
+ export function createSSRApp(
241
+ rootComponent: Component,
242
+ rootProps?: Record<string, unknown>,
243
+ ): ReturnType<typeof createApp>;
244
+
245
+ export function defineComponent(options: {
246
+ name?: string;
247
+ props?: Record<string, unknown>;
248
+ setup?: (props: Record<string, unknown>, ctx: unknown) => unknown;
249
+ render?: (ctx: unknown) => unknown;
250
+ template?: string;
251
+ components?: Record<string, Component>;
252
+ directives?: Record<string, unknown>;
253
+ data?: () => Record<string, unknown>;
254
+ computed?: Record<string, (this: unknown) => unknown>;
255
+ methods?: Record<string, (this: unknown, ...args: unknown[]) => unknown>;
256
+ watch?: Record<string, unknown>;
257
+ emits?: string[] | Record<string, unknown>;
258
+ [key: string]: unknown;
259
+ }): Component;
260
+
261
+ export function ref<T>(value: T): { value: T };
262
+ export function reactive<T extends object>(obj: T): T;
263
+ export function computed<T>(fn: () => T): { readonly value: T };
264
+ export function watch(
265
+ source: unknown,
266
+ callback: (
267
+ value: unknown,
268
+ oldValue: unknown,
269
+ onCleanup: (fn: () => void) => void,
270
+ ) => void,
271
+ options?: { immediate?: boolean; deep?: boolean },
272
+ ): () => void;
273
+ export function watchEffect(
274
+ fn: (onCleanup: (fn: () => void) => void) => void,
275
+ ): () => void;
276
+ export function onMounted(fn: () => void): void;
277
+ export function onUnmounted(fn: () => void): void;
278
+ export function onServerPrefetch(fn: () => Promise<void>): void;
279
+
280
+ export function h(
281
+ type: string | Component,
282
+ props?: Record<string, unknown> | null,
283
+ children?: unknown,
284
+ ): unknown;
285
+ export function defineAsyncComponent(
286
+ loader: () => Promise<{ default: Component }>,
287
+ ): Component;
288
+ export function provide(key: string | symbol, value: unknown): void;
289
+ export function inject<T>(
290
+ key: string | symbol,
291
+ defaultValue?: T,
292
+ ): T | undefined;
293
+ export function useSSRContext(): Record<string, unknown>;
294
+
295
+ export const version: string;
177
296
  }
178
297
 
179
298
  declare module "vue/server-renderer" {
180
- export function renderToString(app: unknown, options?: { context?: Record<string, unknown> }): Promise<string>;
181
- export function renderToStream(app: unknown, options?: { context?: Record<string, unknown> }): ReadableStream<Uint8Array>;
182
- export function renderToWebStream(app: unknown, options?: { context?: Record<string, unknown> }): ReadableStream<Uint8Array>;
183
- export function renderToNodeStream(app: unknown, options?: { context?: Record<string, unknown> }): NodeJS.ReadableStream;
299
+ export function renderToString(
300
+ app: unknown,
301
+ options?: { context?: Record<string, unknown> },
302
+ ): Promise<string>;
303
+ export function renderToStream(
304
+ app: unknown,
305
+ options?: { context?: Record<string, unknown> },
306
+ ): ReadableStream<Uint8Array>;
307
+ export function renderToWebStream(
308
+ app: unknown,
309
+ options?: { context?: Record<string, unknown> },
310
+ ): ReadableStream<Uint8Array>;
311
+ export function renderToNodeStream(
312
+ app: unknown,
313
+ options?: { context?: Record<string, unknown> },
314
+ ): NodeJS.ReadableStream;
184
315
  }
185
316
 
186
317
  declare module "vue-router" {
187
- import { Component } from "vue";
188
-
189
- export interface RouteRecordRaw {
190
- path: string;
191
- name?: string;
192
- component?: Component;
193
- components?: Record<string, Component>;
194
- redirect?: string | ((to: unknown) => string);
195
- alias?: string | string[];
196
- children?: RouteRecordRaw[];
197
- meta?: Record<string, unknown>;
198
- beforeEnter?: (to: unknown, from: unknown, next: () => void) => void;
199
- props?: boolean | Record<string, unknown> | ((to: unknown) => Record<string, unknown>);
200
- }
201
-
202
- export interface Router {
203
- isReady(): Promise<void>;
204
- push(to: string | { path: string; query?: Record<string, string>; params?: Record<string, string> }): void;
205
- replace(to: string | { path: string; query?: Record<string, string>; params?: Record<string, string> }): void;
206
- go(delta: number): void;
207
- back(): void;
208
- forward(): void;
209
- beforeEach(guard: (to: unknown, from: unknown, next: () => void) => void): () => void;
210
- currentRoute: { path: string; params: Record<string, string>; query: Record<string, string>; name: string | symbol | null };
211
- }
212
-
213
- export function createRouter(options: { history: unknown; routes: RouteRecordRaw[] }): Router;
214
- export function createWebHistory(base?: string): unknown;
215
- export function createWebHashHistory(base?: string): unknown;
216
- export function createMemoryHistory(base?: string): unknown;
217
- export function useRoute(): Router["currentRoute"];
218
- export function useRouter(): Router;
219
- }
318
+ import type { Component } from "vue";
319
+
320
+ export interface RouteRecordRaw {
321
+ path: string;
322
+ name?: string;
323
+ component?: Component;
324
+ components?: Record<string, Component>;
325
+ redirect?: string | ((to: unknown) => string);
326
+ alias?: string | string[];
327
+ children?: RouteRecordRaw[];
328
+ meta?: Record<string, unknown>;
329
+ beforeEnter?: (to: unknown, from: unknown, next: () => void) => void;
330
+ props?:
331
+ | boolean
332
+ | Record<string, unknown>
333
+ | ((to: unknown) => Record<string, unknown>);
334
+ }
335
+
336
+ export interface Router {
337
+ isReady(): Promise<void>;
338
+ push(
339
+ to:
340
+ | string
341
+ | {
342
+ path: string;
343
+ query?: Record<string, string>;
344
+ params?: Record<string, string>;
345
+ },
346
+ ): void;
347
+ replace(
348
+ to:
349
+ | string
350
+ | {
351
+ path: string;
352
+ query?: Record<string, string>;
353
+ params?: Record<string, string>;
354
+ },
355
+ ): void;
356
+ go(delta: number): void;
357
+ back(): void;
358
+ forward(): void;
359
+ beforeEach(
360
+ guard: (to: unknown, from: unknown, next: () => void) => void,
361
+ ): () => void;
362
+ currentRoute: {
363
+ path: string;
364
+ params: Record<string, string>;
365
+ query: Record<string, string>;
366
+ name: string | symbol | null;
367
+ };
368
+ }
369
+
370
+ export function createRouter(options: {
371
+ history: unknown;
372
+ routes: RouteRecordRaw[];
373
+ }): Router;
374
+ export function createWebHistory(base?: string): unknown;
375
+ export function createWebHashHistory(base?: string): unknown;
376
+ export function createMemoryHistory(base?: string): unknown;
377
+ export function useRoute(): Router["currentRoute"];
378
+ export function useRouter(): Router;
379
+ }
@@ -270,7 +270,97 @@ export function assertStandardSchema(
270
270
  ): asserts schema is StandardSchema {
271
271
  if (!isStandardSchema(schema)) {
272
272
  throw new Error(
273
- `${name} must implement Standard Schema interface. Supported: Zod 4+, Valibot v1+, ArkType, Typia 7+`,
274
- );
273
+ `${name} must implement Standard Schema interface. Supported: Zod 4+, Valibot v1+, ArkType, Typia 7+`,
274
+ );
275
+ }
276
+ }
277
+
278
+ // ============= Environment Variable Validation =============
279
+
280
+ /**
281
+ * Validate environment variables against a schema
282
+ *
283
+ * @param schema - Validation schema for environment variables
284
+ * @param envVars - Environment variables to validate
285
+ * @returns Validation result with transformed values or error details
286
+ */
287
+ export async function validateEnv<T>(
288
+ schema: StandardSchema<unknown, T>,
289
+ envVars: Record<string, string>,
290
+ ): Promise<ValidationResult<T>> {
291
+ try {
292
+ // Validate the environment variables
293
+ const result = await validate(schema, envVars);
294
+
295
+ if (!result.success) {
296
+ // Format error messages with context
297
+ const formattedIssues = result.issues.map((issue) => {
298
+ const path = issue.path?.join(".") || "root";
299
+ return {
300
+ ...issue,
301
+ message: `Environment variable validation failed for ${path}: ${issue.message}`,
302
+ };
303
+ });
304
+
305
+ return {
306
+ success: false,
307
+ issues: formattedIssues,
308
+ };
309
+ }
310
+
311
+ return result;
312
+ } catch (error) {
313
+ return {
314
+ success: false,
315
+ issues: [
316
+ {
317
+ message: `Environment variable validation failed: ${error instanceof Error ? error.message : "Unknown error"}`,
318
+ },
319
+ ],
320
+ };
321
+ }
322
+ }
323
+
324
+ /**
325
+ * Validate environment variables with detailed error reporting
326
+ *
327
+ * @param schema - Validation schema for environment variables
328
+ * @param envVars - Environment variables to validate
329
+ * @returns Validation result with transformed values or detailed error information
330
+ */
331
+ export function validateEnvSync<T>(
332
+ schema: StandardSchema<unknown, T>,
333
+ envVars: Record<string, string>,
334
+ ): ValidationResult<T> {
335
+ try {
336
+ // Validate the environment variables
337
+ const result = validateSync(schema, envVars);
338
+
339
+ if (!result.success) {
340
+ // Format error messages with context
341
+ const formattedIssues = result.issues.map((issue) => {
342
+ const path = issue.path?.join(".") || "root";
343
+ return {
344
+ ...issue,
345
+ message: `Environment variable validation failed for ${path}: ${issue.message}`,
346
+ };
347
+ });
348
+
349
+ return {
350
+ success: false,
351
+ issues: formattedIssues,
352
+ };
353
+ }
354
+
355
+ return result;
356
+ } catch (error) {
357
+ return {
358
+ success: false,
359
+ issues: [
360
+ {
361
+ message: `Environment variable validation failed: ${error instanceof Error ? error.message : "Unknown error"}`,
362
+ },
363
+ ],
364
+ };
275
365
  }
276
366
  }