@wolfstar/schema 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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2022 Wolfstar Project
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ <div align="center">
2
+ <picture>
3
+ <img src="https://cdn.wolfstar.rocks/wolfstar-assets/stars-components/wordmark.webp" alt="Stars Components" width="440" />
4
+ </picture>
5
+
6
+ # @wolfstar/schema
7
+
8
+ **Typed `stars.config.*` schema and loader shared by `@wolfstar/http-framework` and `@wolfstar/cli`.**
9
+
10
+ [![version](https://npmx.dev/api/registry/badge/version/@wolfstar/schema)](https://npmx.dev/package/@wolfstar/schema)
11
+ [![downloads](https://npmx.dev/api/registry/badge/downloads/@wolfstar/schema)](https://npmx.dev/package/@wolfstar/schema)
12
+ [![license](https://img.shields.io/github/license/wolfstar-project/stars-components?style=flat-square&color=informational)](https://github.com/wolfstar-project/stars-components/blob/main/LICENSE)
13
+
14
+ </div>
15
+
16
+ ## Description
17
+
18
+ The `defineConfig` helper, the `StarsConfig` schema, and the `stars.config.{ts,mts,cts,js,mjs,cjs}` loader/validator,
19
+ in their own package so `@wolfstar/http-framework` and `@wolfstar/cli` can each depend on it without depending on
20
+ each other — the way `@nuxt/schema` sits between `nuxt` and `@nuxt/cli`.
21
+
22
+ This module is intentionally tiny and side-effect free: importing it from a `stars.config.ts` file must never start
23
+ a bot nor pull in the CLI's runtime.
24
+
25
+ `@wolfstar/http-framework` re-exports this package's public surface from `@wolfstar/http-framework/config`, so
26
+ existing `import { defineConfig } from '@wolfstar/http-framework/config'` code keeps working unchanged — most
27
+ projects should keep importing it from there rather than depending on this package directly. See the
28
+ [`@wolfstar/http-framework` README](../http-framework#project-configuration-starsconfig) for the full configuration
29
+ reference.
30
+
31
+ ## Usage
32
+
33
+ ```typescript
34
+ // stars.config.ts
35
+ import { defineConfig } from '@wolfstar/schema';
36
+
37
+ export default defineConfig({});
38
+ ```
39
+
40
+ ## Package structure
41
+
42
+ - `src/types/config.ts` defines the public input types without runtime dependencies.
43
+ - `src/config.ts` provides the identity helper and type exports. The `@wolfstar/schema/config` entry is suitable
44
+ for configuration files that only need `defineConfig`, without loading filesystem resolution or diagnostics.
45
+ - `src/config/` owns discovery, validation, defaults, and resolution.
46
+ - `src/index.ts` preserves the complete public API, including the helper and loader.
47
+
48
+ The framework exposes package-root `config.js`/`config.d.ts` and `schema.js`/`schema.d.ts` facades, following
49
+ [Nuxt's package layout](https://github.com/nuxt/nuxt/tree/main/packages/nuxt). Both forward this package unchanged
50
+ for backwards compatibility. The CLI depends directly on this package, keeping the dependency graph acyclic.
51
+
52
+ ## Server integrations
53
+
54
+ Stars separates the optional integrations into [`@wolfstar/vite-server`](../vite-server) and
55
+ [`@wolfstar/nitro-server`](../nitro-server), following Nuxt's server package boundaries.
56
+ Both implement the `Builder` contract exported by this schema package. The CLI loads them on demand and supplies
57
+ a `BuilderContext` for project dependency resolution and plugin registration, so neither integration depends on
58
+ the CLI or framework runtime. Process supervision and the external-build watcher remain in the CLI.
@@ -0,0 +1,398 @@
1
+ //#region src/types/config.d.ts
2
+ /**
3
+ * The build tool used to turn the project sources into runnable JavaScript.
4
+ *
5
+ * - `tsdown`: run the project's own `tsdown` programmatically, configured from {@link StarsConfig.tsdown} (and, with
6
+ * {@link StarsFutureConfig.compatibilityVersion} `3`, from the project's `tsdown.config.*` too).
7
+ * - `tsc`: run the project's `tsc -b` on the configured `tsconfig`.
8
+ * - `vite`: run the project's own `vite` (configuration file included), requires `experimental.enableVite`.
9
+ * - `none`: the entry is runnable as-is (JavaScript projects), no build step.
10
+ * - `auto`: detect from the project (default).
11
+ */
12
+ type StarsBuildTool = 'tsdown' | 'tsc' | 'none' | 'vite';
13
+ interface StarsBuildConfig {
14
+ /**
15
+ * The build tool to use.
16
+ * @default 'auto'
17
+ */
18
+ tool?: StarsBuildTool | 'auto';
19
+ /**
20
+ * The directory, relative to {@link StarsConfig.root}, the build writes into.
21
+ * @default 'dist', or '.output' when `experimental.enableNitro` is on (Nitro's own convention)
22
+ */
23
+ outDir?: string;
24
+ /**
25
+ * The `tsconfig.json` the `tsc` and `tsdown` build tools use, relative to {@link StarsConfig.root}.
26
+ * @default 'src/tsconfig.json' when it exists, 'tsconfig.json' otherwise
27
+ */
28
+ tsconfig?: string;
29
+ }
30
+ /**
31
+ * Raw options merged into the project's own `vite.config.*`, the way `vite: {}` in a Nuxt config is merged into
32
+ * Nuxt's own Vite config. Kept as `unknown` here (the CLI, not the framework, depends on `vite`'s types) and passed
33
+ * to Vite's `mergeConfig` as-is.
34
+ */
35
+ type StarsViteConfig = Record<string, unknown>;
36
+ /**
37
+ * Options for `tsdown`, the bundler `stars build` uses by default.
38
+ *
39
+ * With {@link StarsFutureConfig.compatibilityVersion} `4` these replace `tsdown.config.*` outright: the build is
40
+ * derived from `stars.config` (the entry's directory, `build.outDir`, `build.tsconfig`) and these options are layered
41
+ * on top, so a project keeps one configuration file instead of two. With `3` the project's own `tsdown.config.*` is
42
+ * still loaded and these are merged over it, the way `vite: {}` in a Nuxt config is merged into the project's own
43
+ * Vite config: values here win, and `plugins` are appended rather than replaced.
44
+ *
45
+ * The options named below are the ones a bot usually reaches for. Every other `tsdown` option is accepted as-is —
46
+ * the framework does not depend on `tsdown`, so they stay loosely typed here and `tsdown`'s own `UserConfig` is the
47
+ * reference.
48
+ */
49
+ interface StarsTsdownConfig {
50
+ /** Entry files or glob patterns, relative to the project root. Defaults to every source file next to `entry`. */
51
+ entry?: string | readonly string[] | Record<string, string>;
52
+ /** @default 'esm' */
53
+ format?: 'esm' | 'cjs' | 'iife' | 'umd' | readonly string[] | Record<string, unknown>;
54
+ /** @default 'node' */
55
+ platform?: 'node' | 'neutral' | 'browser';
56
+ target?: string | readonly string[] | false;
57
+ /**
58
+ * Emits one output file per source file instead of a single bundle, so pieces stay loadable from `dist/commands`
59
+ * and friends at runtime.
60
+ * @default true
61
+ */
62
+ unbundle?: boolean;
63
+ /** Rolldown plugins. Appended to the ones `stars` adds (auto imports) and to those of a `tsdown.config.*`. */
64
+ plugins?: readonly unknown[];
65
+ alias?: Record<string, string>;
66
+ define?: Record<string, string>;
67
+ external?: unknown;
68
+ noExternal?: unknown;
69
+ deps?: Record<string, unknown>;
70
+ /** @default () => ({ js: extname(build.output) }) */
71
+ outExtensions?: unknown;
72
+ /** @default true */
73
+ sourcemap?: boolean | 'inline' | 'hidden';
74
+ minify?: unknown;
75
+ /** @default false — a bot is not a library, so no declaration files are emitted. */
76
+ dts?: boolean | Record<string, unknown>;
77
+ /** @default true */
78
+ clean?: boolean | readonly string[];
79
+ treeshake?: boolean;
80
+ copy?: unknown;
81
+ hooks?: Record<string, unknown>;
82
+ [option: string]: unknown;
83
+ }
84
+ /**
85
+ * The build-default generation the project runs on. Version 4 is current; version 3 remains available for projects
86
+ * that still load a standalone `tsdown.config.*`.
87
+ */
88
+ type StarsCompatibilityVersion = 3 | 4;
89
+ /**
90
+ * Nuxt-style compatibility block. New projects need not set it; version 3 is retained as an explicit migration
91
+ * escape hatch for projects that still use a standalone `tsdown.config.*`.
92
+ */
93
+ interface StarsFutureConfig {
94
+ /**
95
+ * The major whose defaults apply.
96
+ *
97
+ * `4` is the default build pipeline:
98
+ * - auto imports are on by default with the `tsdown` build tool ({@link StarsImportsConfig}), and the
99
+ * `autoImports()` plugin is wired into the build by `stars` itself.
100
+ * - `tsdown` is configured from {@link StarsConfig.tsdown} only. A `tsdown.config.*` in the project root is
101
+ * rejected rather than silently ignored, so a build never loses the plugins it declares.
102
+ * - `build.tool: 'auto'` resolves to `tsdown` for any TypeScript entry, without looking for a `tsdown.config.*`
103
+ * or a `tsdown` dependency first.
104
+ *
105
+ * `3` keeps the legacy behaviour: auto imports off unless asked for, and a `tsdown.config.*` loaded and merged with
106
+ * {@link StarsConfig.tsdown}.
107
+ * @default 4
108
+ */
109
+ compatibilityVersion?: StarsCompatibilityVersion;
110
+ }
111
+ /**
112
+ * The type checker `stars dev` runs next to the bot.
113
+ *
114
+ * - `tsc`: the project's own TypeScript, in watch mode.
115
+ * - `golar`: the project's `golar`, forwarding to TypeScript (`golar tsc`), in watch mode.
116
+ * - `tsz`: the project's `tsz` (or `try-tsz`). It has no watch mode, so it is re-run after every build instead.
117
+ * - `auto`: `golar` when the project depends on it, `tsc` otherwise (default).
118
+ */
119
+ type StarsTypechecker = 'tsc' | 'golar' | 'tsz';
120
+ interface StarsTypecheckConfig {
121
+ /**
122
+ * The `tsconfig.json` the type checker runs against, relative to {@link StarsConfig.root}.
123
+ * @default the build tool's tsconfig, 'src/tsconfig.json' or 'tsconfig.json'
124
+ */
125
+ tsconfig?: string;
126
+ /**
127
+ * Which type checker to run.
128
+ * @default 'auto'
129
+ */
130
+ checker?: StarsTypechecker | 'auto';
131
+ }
132
+ interface StarsTunnelConfig {
133
+ /**
134
+ * An https URL you already serve; when unset a `cloudflared` quick tunnel is opened instead.
135
+ */
136
+ url?: string;
137
+ /**
138
+ * Writes the tunnel's URL to the Discord application's `interactions_endpoint_url` when it changes.
139
+ *
140
+ * This edits a live Discord application, so it is opt-in: it needs `DISCORD_TOKEN` and `DISCORD_APPLICATION_ID`
141
+ * (or `APPLICATION_ID`) in the environment or the project's `.env`.
142
+ * @default false
143
+ */
144
+ updateEndpoint?: boolean;
145
+ /**
146
+ * The path the interactions endpoint is served on, appended to the tunnel URL.
147
+ * @default '/'
148
+ */
149
+ path?: string;
150
+ }
151
+ interface StarsDevConfig {
152
+ /** Custom terminal wordmark (one or more lines), or `false` to hide it. Defaults to the Stars wordmark. */
153
+ banner?: string | readonly string[] | false;
154
+ /**
155
+ * Extra paths to watch, relative to {@link StarsConfig.root}. Only used when
156
+ * the build tool is `none`; `tsdown` and `tsc` watch through their own build.
157
+ * @default [dirname(entry)]
158
+ */
159
+ watch?: string[];
160
+ /**
161
+ * Glob patterns or paths to ignore while watching, relative to {@link StarsConfig.root}.
162
+ * @default ['**\/node_modules/**', '**\/dist/**', '**\/.git/**']
163
+ */
164
+ ignore?: string[];
165
+ /**
166
+ * Milliseconds to wait after a change before restarting the bot.
167
+ * @default 150
168
+ */
169
+ debounce?: number;
170
+ /**
171
+ * Environment variables added to the bot process.
172
+ */
173
+ env?: Record<string, string>;
174
+ /**
175
+ * Arguments passed to `node` before the entry file.
176
+ * @default ['--enable-source-maps']
177
+ */
178
+ nodeArgs?: string[];
179
+ /**
180
+ * Arguments passed to the bot after the entry file.
181
+ * @default []
182
+ */
183
+ args?: string[];
184
+ /**
185
+ * The URL the bot listens on, shown in the dev UI's status line and used for {@link StarsDevConfig.health}.
186
+ *
187
+ * Resolved automatically, the way Vite's and Nuxt's dev servers do, from (in order) `dev.env.HTTP_PORT`, the
188
+ * process's `HTTP_PORT`, the project's `src/.env*`/`.env*` (`HTTP_PORT` or `PORT`), or `3000`. `stars dev` also
189
+ * resolves whether `localhost` should be shown as `127.0.0.1` instead, the same DNS-order check Vite does, so the
190
+ * printed URL is always the one that is actually reachable.
191
+ * @default `http://localhost:3000` (or whichever port is found)
192
+ */
193
+ url?: string;
194
+ /**
195
+ * A path, relative to {@link StarsDevConfig.url}, polled to report the bot's health in the dev UI.
196
+ * When unset the dev UI only reports process state.
197
+ */
198
+ health?: string;
199
+ /**
200
+ * Milliseconds to wait for the bot to exit after `SIGTERM` before killing it.
201
+ * @default 5000
202
+ */
203
+ killTimeout?: number;
204
+ /**
205
+ * Runs a type checker next to the bot and reports type errors on the dev UI's `tsc` channel, without blocking
206
+ * builds or restarts. `true` uses the project's own tsconfig and type checker, an object picks either
207
+ * ({@link StarsTypecheckConfig.checker}).
208
+ * @default false
209
+ */
210
+ typecheck?: boolean | StarsTypecheckConfig;
211
+ /**
212
+ * Exposes the bot's HTTP interactions endpoint publicly while `stars dev` runs, so Discord can reach it.
213
+ *
214
+ * `true` opens a `cloudflared` quick tunnel (its hostname changes on every run), a string is an https URL you
215
+ * already serve yourself (named tunnel, reverse proxy, …) that the CLI only checks for reachability.
216
+ * @default false
217
+ */
218
+ tunnel?: boolean | string | StarsTunnelConfig;
219
+ /**
220
+ * The file `stars dev` mirrors its logs into, relative to {@link StarsConfig.root}, so a session can be read back
221
+ * after the terminal UI is gone. `false` disables it.
222
+ * @default '.stars/dev.log'
223
+ */
224
+ logFile?: string | false;
225
+ }
226
+ interface StarsI18nCodegenConfig {
227
+ /**
228
+ * The base locale directory, relative to {@link StarsConfig.root}.
229
+ * @default 'src/locales/en-US'
230
+ */
231
+ locales?: string;
232
+ /**
233
+ * The generated declaration file, relative to {@link StarsConfig.root}.
234
+ * @default 'src/@types/i18next.d.ts'
235
+ */
236
+ output?: string;
237
+ }
238
+ interface StarsCodegenConfig {
239
+ /**
240
+ * i18next type generation through `@wolfstar/i18next-type-generator`.
241
+ * `false` disables it, an object enables it, unset auto-detects from the presence of the locales directory.
242
+ */
243
+ i18n?: StarsI18nCodegenConfig | false;
244
+ }
245
+ interface StarsImportsConfig {
246
+ /**
247
+ * Whether auto imports are enabled. Requires the `tsdown` build tool: the imports are injected at build time by
248
+ * the `autoImports()` plugin from `@wolfstar/http-framework/auto-imports`, which the other tools cannot run.
249
+ * @default true when the build tool is 'tsdown', false otherwise
250
+ */
251
+ enabled?: boolean;
252
+ /**
253
+ * Directories, relative to {@link StarsConfig.root}, whose exported values are auto-importable. Entries are glob
254
+ * path patterns: `'src/lib'` scans only the files directly inside it, `'src/lib/**'` scans recursively.
255
+ * @default ['src/lib/**', 'src/utils/**']
256
+ */
257
+ dirs?: string[];
258
+ /**
259
+ * Packages whose exports are auto-importable. Packages that are not installed are skipped.
260
+ * @default ['@wolfstar/http-framework', '@wolfstar/env-utilities']
261
+ */
262
+ presets?: string[];
263
+ /**
264
+ * Export names excluded from auto imports, e.g. to avoid clashes with project-local names.
265
+ * @default []
266
+ */
267
+ exclude?: string[];
268
+ /**
269
+ * The generated declaration file that types the auto imports, relative to {@link StarsConfig.root}.
270
+ * Include it in the project's tsconfig and add its directory to .gitignore.
271
+ * @default '.stars/imports.d.ts'
272
+ */
273
+ dts?: string;
274
+ }
275
+ /**
276
+ * The [Nitro preset](https://nitro.build/deploy) `stars build` targets, only reachable once
277
+ * {@link StarsExperimentalConfig.enableNitro} (itself gated on {@link StarsExperimentalConfig.enableVite}) is `true`
278
+ * — see {@link StarsExperimentalConfig}.
279
+ */
280
+ interface StarsNitroConfig {
281
+ /** Additional Nitro options (routeRules, runtimeConfig, storage, publicAssets, hooks, etc.).
282
+ * Use `defineNitroConfig` from `@wolfstar/nitro-server` for upstream option completion.
283
+ * Stars owns rootDir, serverEntry, output.dir and the reserved virtual entry.
284
+ */
285
+ [option: string]: unknown;
286
+ /**
287
+ * `'node-server'` (the default, runs locally with plain `node`), `'cloudflare-module'`, `'aws-lambda'`,
288
+ * `'vercel'`, `'netlify'`, `'bun'`, `'deno-deploy'`, and more — see Nitro's own preset list.
289
+ * @default 'node-server'
290
+ */
291
+ preset?: string;
292
+ }
293
+ /**
294
+ * Opt-in flags for work that is still landing, in the shape Nuxt's own `experimental` block has: every flag is a
295
+ * boolean, defaults to `false`, and is documented with what it changes and what it still needs. A flag stays here
296
+ * until the behaviour it guards is the default (or is dropped), so enabling one is a statement that breakage is
297
+ * acceptable in exchange for the feature.
298
+ *
299
+ * `enableExternalVite`, `enableNitro` and `nitro` build on `enableVite` (and `nitro` on `enableNitro` too): the type
300
+ * only accepts them once their prerequisite is `true`, so turning one on without the other is a type error here
301
+ * instead of a diagnostic at load time.
302
+ */
303
+ type StarsExperimentalConfig = {
304
+ enableVite?: false;
305
+ enableExternalVite?: false;
306
+ enableNitro?: false;
307
+ } | {
308
+ /**
309
+ * Uses Vite as the project's build tool, in place of `tsdown`. `build.tool` may then be set to `'vite'`
310
+ * (and `'auto'` detects a `vite.config.*`); the bot keeps calling `client.listen()` and running as a
311
+ * plain `node:http` process, restarted on every change — this only swaps the bundler.
312
+ */
313
+ enableVite: true;
314
+ /**
315
+ * Runs the bot through Vite itself, the way `nuxt dev` runs on Vite's own dev server: instead of
316
+ * building then restarting a child `node` process on every change, `stars dev` loads the entry through
317
+ * Vite's SSR module graph and serves it — through `Client#fetch` — from one long-lived process,
318
+ * invalidating and re-evaluating just the entry's module graph on a change instead of restarting.
319
+ *
320
+ * With this on, the entry's default export must be the `Client` instance (already `load()`ed, not
321
+ * `listen()`ed) rather than a script that calls `client.listen()` itself — `stars dev` owns the socket.
322
+ * @default false
323
+ */
324
+ enableExternalVite?: boolean;
325
+ enableNitro?: false;
326
+ } | {
327
+ enableVite: true;
328
+ enableExternalVite?: boolean;
329
+ /**
330
+ * Builds the bot through [Nitro](https://nitro.build) instead of a `node:http` server, so `stars build`
331
+ * produces a server deployable to any of Nitro's presets (`node-server` locally, `cloudflare-module`,
332
+ * `aws-lambda`, `vercel`, `netlify`, `bun`, `deno-deploy`, and more). Nitro v3 is itself a Vite plugin, so
333
+ * this builds through the project's own `vite.config.*`/{@link StarsConfig.vite} the same way `build.tool:
334
+ * 'vite'` does, with a generated server entry that wraps the entry's default export (the `Client`
335
+ * instance, already `load()`ed rather than `listen()`ed — `stars build`/`stars dev` own the socket) in a
336
+ * call to `Client#fetch` — no per-preset adapter to maintain.
337
+ *
338
+ * Output goes to `.output/` (Nitro's own convention) instead of `build.outDir`. `stars dev` rebuilds and
339
+ * restarts on every change, the same as the other build tools.
340
+ */
341
+ enableNitro: true;
342
+ /** Nitro-specific options, reachable only with `enableNitro: true`. */
343
+ nitro?: StarsNitroConfig;
344
+ };
345
+ interface StarsConfig {
346
+ /**
347
+ * The project root. Relative paths are resolved from the configuration file.
348
+ * @default dirname(configFile)
349
+ */
350
+ root?: string;
351
+ /**
352
+ * The source entry point of the bot, relative to {@link StarsConfig.root}.
353
+ * @default the first of 'src/main.ts', 'src/main.js', 'src/index.ts', 'src/index.js' that exists
354
+ */
355
+ entry?: string;
356
+ build?: StarsBuildConfig;
357
+ dev?: StarsDevConfig;
358
+ codegen?: StarsCodegenConfig;
359
+ /**
360
+ * Nuxt-style auto imports of the framework's exports and the project's own modules.
361
+ * `false` disables them, `true` forces them on (requires the `tsdown` build tool). On by default with
362
+ * `future.compatibilityVersion: 4`.
363
+ */
364
+ imports?: StarsImportsConfig | boolean;
365
+ /** Opt-in flags for behaviour that is still landing. */
366
+ experimental?: StarsExperimentalConfig;
367
+ /** Build-default compatibility. Omit for version 4; set version 3 only while migrating a standalone tsdown config. */
368
+ future?: StarsFutureConfig;
369
+ /**
370
+ * Raw options merged into `vite.config.*`, the way `vite: {}` in a Nuxt config is merged into Nuxt's own Vite
371
+ * config. Only used with `build.tool: 'vite'` (see `experimental.enableVite`).
372
+ */
373
+ vite?: StarsViteConfig;
374
+ /**
375
+ * The project's `tsdown` build. Replaces `tsdown.config.*` with `future.compatibilityVersion: 4`, and is merged
376
+ * over it with `3`. Only used with `build.tool: 'tsdown'`.
377
+ */
378
+ tsdown?: StarsTsdownConfig;
379
+ }
380
+ //#endregion
381
+ //#region src/config.d.ts
382
+ /**
383
+ * Typed helper for `stars.config.{ts,mts,cts,js,mjs,cjs}` files.
384
+ *
385
+ * @example
386
+ * ```ts
387
+ * import { defineConfig } from '@wolfstar/http-framework/config';
388
+ *
389
+ * export default defineConfig({
390
+ * entry: 'src/main.ts',
391
+ * build: { tool: 'tsdown' }
392
+ * });
393
+ * ```
394
+ */
395
+ export declare function defineConfig(config: StarsConfig): StarsConfig;
396
+ //#endregion
397
+ export type { StarsBuildConfig, StarsBuildTool, StarsCodegenConfig, StarsCompatibilityVersion, StarsConfig, StarsDevConfig, StarsExperimentalConfig, StarsFutureConfig, StarsI18nCodegenConfig, StarsImportsConfig, StarsNitroConfig, StarsTsdownConfig, StarsTunnelConfig, StarsTypecheckConfig, StarsTypechecker, StarsViteConfig };
398
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","names":[],"sources":["../../src/types/config.ts","../../src/config.ts"],"mappings":";;;;;;;;;;;KAUY;UAEK;;;;;EAKhB,OAAO;;;;;EAKP;;;;;EAKA;;;;;;;KAQW,kBAAkB;;;;;;;;;;;;;;UAeb;;EAEhB,qCAAqC;;EAErC,8DAA8D;;EAE9D;EACA;;;;;;EAMA;;EAEA;EACA,QAAQ;EACR,SAAS;EACT;EACA;EACA,OAAO;;EAEP;;EAEA;EACA;;EAEA,gBAAgB;;EAEhB;EACA;EACA;EACA,QAAQ;GACP;;;;;;KAOU;;;;;UAMK;;;;;;;;;;;;;;;;EAgBhB,uBAAuB;;;;;;;;;;KAWZ;UAEK;;;;;EAKhB;;;;;EAKA,UAAU;;UAGM;;;;EAIhB;;;;;;;;EAQA;;;;;EAKA;;UAGgB;;EAEhB;;;;;;EAMA;;;;;EAKA;;;;;EAKA;;;;EAIA,MAAM;;;;;EAKN;;;;;EAKA;;;;;;;;;;EAUA;;;;;EAKA;;;;;EAKA;;;;;;;EAOA,sBAAsB;;;;;;;;EAQtB,4BAA4B;;;;;;EAM5B;;UAGgB;;;;;EAKhB;;;;;EAKA;;UAGgB;;;;;EAKhB,OAAO;;UAGS;;;;;;EAMhB;;;;;;EAMA;;;;;EAKA;;;;;EAKA;;;;;;EAMA;;;;;;;UAQgB;;;;;GAKf;;;;;;EAMD;;;;;;;;;;;;KAaW;EACP;EAAoB;EAA4B;;;;;;;EAOlD;;;;;;;;;;;EAWA;EACA;;EAGA;EACA;;;;;;;;;;;;;EAaA;;EAEA,QAAQ;;UAGM;;;;;EAKhB;;;;;EAKA;EACA,QAAQ;EACR,MAAM;EACN,UAAU;;;;;;EAMV,UAAU;;EAEV,eAAe;;EAEf,SAAS;;;;;EAKT,OAAO;;;;;EAKP,SAAS;;;;;;;;;;;;;;;;;wBCrXM,aAAa,QAAQ,cAAc"}