@kosmojs/dev 0.4.2 → 0.4.4
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/package.json +4 -3
- package/pkg/chassis.js +308 -1
- package/pkg/chassis.js.map +1 -1
- package/pkg/index.d.ts +2 -1
- package/pkg/index.js +1722 -879
- package/pkg/index.js.map +1 -1
- package/pkg/preview.d.ts +15 -0
- package/pkg/runner.d.ts +22 -0
- package/pkg/templates/run.d.ts +29 -0
- package/pkg/assets/pkg-Bkag325q.js +0 -511
- package/pkg/assets/pkg-Bkag325q.js.map +0 -1
package/pkg/preview.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ProjectSettings, SourceFolder } from "@kosmojs/core";
|
|
2
|
+
type Build = (sourceFolder: SourceFolder) => Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* Preview = production build + watcher + `dist/run.js`.
|
|
5
|
+
*
|
|
6
|
+
* The runner is a child process rather than an in-process import:
|
|
7
|
+
* a fresh process is the only way to reload an ESM graph, and it is exactly
|
|
8
|
+
* what production does - `node dist/run.js`.
|
|
9
|
+
*
|
|
10
|
+
* Watching is chokidar over the `src/<folder>` trees - no Vite server,
|
|
11
|
+
* no module graph: the unit of work is "rebuild this folder", so folder-level
|
|
12
|
+
* granularity is all the watcher needs to provide.
|
|
13
|
+
* */
|
|
14
|
+
export declare const previewFactory: (projectSettings: ProjectSettings, build: Build) => Promise<() => Promise<void>>;
|
|
15
|
+
export {};
|
package/pkg/runner.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ProjectSettings, SourceFolder } from "@kosmojs/core";
|
|
2
|
+
/**
|
|
3
|
+
* What `dist/run.js` needs to know about a built folder.
|
|
4
|
+
* Written next to the folder's build output so the runner discovers folders from disk
|
|
5
|
+
* rather than from a table that a partial build could leave stale.
|
|
6
|
+
* */
|
|
7
|
+
export type FolderManifest = {
|
|
8
|
+
name: string;
|
|
9
|
+
base: string;
|
|
10
|
+
apiBase: string;
|
|
11
|
+
api: boolean;
|
|
12
|
+
client: boolean;
|
|
13
|
+
ssr: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const folderManifestFactory: (sourceFolder: SourceFolder) => FolderManifest;
|
|
16
|
+
export declare const writeFolderManifest: (sourceFolder: SourceFolder) => Promise<void>;
|
|
17
|
+
export declare const runnerPath: ({ root, distDir }: ProjectSettings) => string;
|
|
18
|
+
/**
|
|
19
|
+
* run.js is static - it holds no folder-specific data -
|
|
20
|
+
* so rewriting it on every build, partial builds included, is idempotent.
|
|
21
|
+
* */
|
|
22
|
+
export declare const deployRunner: (projectSettings: ProjectSettings) => Promise<string>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Serves every built source folder from a single process.
|
|
4
|
+
*
|
|
5
|
+
* Written by `kosmo build` into the dist directory; `kosmo preview` restarts it after each rebuild.
|
|
6
|
+
*
|
|
7
|
+
* node dist/run.js -p 4556
|
|
8
|
+
* node dist/run.js -s /tmp/app.sock
|
|
9
|
+
*
|
|
10
|
+
* Folders are discovered at startup from `dist/<folder>/kosmo.json`,
|
|
11
|
+
* so a partial build (`kosmo build admin`) never leaves a stale folder table behind,
|
|
12
|
+
* and removing a folder's dist directory is enough to stop serving it.
|
|
13
|
+
*
|
|
14
|
+
* Per folder:
|
|
15
|
+
* - SSR folders mount `ssr/server.js` - one listener for pages, assets and the bundled API.
|
|
16
|
+
* - CSR folders mount `api/listener.js` for the API and serve `client/` statically from memory,
|
|
17
|
+
* with the SPA fallback to index.html for unmatched page URLs.
|
|
18
|
+
*
|
|
19
|
+
* Authored as TypeScript, deployed with types stripped;
|
|
20
|
+
* only node builtins are used here: `node:http` runs unchanged on Node, Bun and Deno.
|
|
21
|
+
* */
|
|
22
|
+
import type { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
23
|
+
type NodeListener = (req: IncomingMessage, res: ServerResponse) => void;
|
|
24
|
+
export declare const createListener: () => Promise<NodeListener>;
|
|
25
|
+
export declare const startServer: ({ port, sock, }: {
|
|
26
|
+
port?: string | number | undefined;
|
|
27
|
+
sock?: string | undefined;
|
|
28
|
+
}) => Promise<Server>;
|
|
29
|
+
export {};
|
|
@@ -1,511 +0,0 @@
|
|
|
1
|
-
import{dirname as e,resolve as t}from"node:path";import{styleText as n}from"node:util";import{defaults as r}from"@kosmojs/core";import{defineGenerator as i,defineGeneratorFactory as a,pathResolver as o,renderFactory as s,renderToFile as c}from"@kosmojs/lib";import l from"semver";import{routeRenderHelpers as u}from"@kosmojs/core/generators";var d={type:`module`,private:!0,name:`@kosmojs/core-generator`,version:`0.3.0`,author:`Slee Woo`,license:`MIT`,files:[`pkg/*`],exports:{".":{types:`./pkg/index.d.ts`,default:`./pkg/index.js`}},scripts:{build:`wsbuild src/index.ts`},dependencies:{"@kosmojs/core":`workspace:^`,"@kosmojs/lib":`workspace:^`,semver:`^7.8.5`},devDependencies:{"@types/semver":`^7.8.0`,"path-to-regexp":`^8.4.2`}},f=`export const base = "{{config.base}}";
|
|
2
|
-
export const apiBase = "{{config.apiBase}}";
|
|
3
|
-
`,p=`export * from "./config";
|
|
4
|
-
export * from "./routes";
|
|
5
|
-
export * from "./types";
|
|
6
|
-
`,m=`{{> routeMapperPartial}}
|
|
7
|
-
|
|
8
|
-
import { base, apiBase } from "./config";
|
|
9
|
-
|
|
10
|
-
// used by backend generators and fetch clients
|
|
11
|
-
export const apiRouteMap = {
|
|
12
|
-
{{#each apiRoutes}}
|
|
13
|
-
"{{name}}": apiRouteMapper<[{{serializeParamsTupleElements .}}]>(
|
|
14
|
-
join(base, apiBase),
|
|
15
|
-
{{serializeApiRoute .}},
|
|
16
|
-
),
|
|
17
|
-
{{/each}}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// used by frontend generators on Link component
|
|
21
|
-
export const pageRouteMap = {
|
|
22
|
-
{{#each pageRoutes}}
|
|
23
|
-
"{{name}}": pageRouteMapper<[{{serializeParamsTupleElements .}}]>(
|
|
24
|
-
base,
|
|
25
|
-
{{serializePageRoute .}},
|
|
26
|
-
),
|
|
27
|
-
{{/each}}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
{{#if pageRoutes.length}}
|
|
31
|
-
export type LinkProps =
|
|
32
|
-
{{#each pageRoutes}}
|
|
33
|
-
| [ "{{name}}", {{serializeParamsTupleElements .}} ]
|
|
34
|
-
{{/each}};
|
|
35
|
-
{{else}}
|
|
36
|
-
export type LinkProps = never;
|
|
37
|
-
{{/if}}
|
|
38
|
-
`,h=`import { compile, match } from "path-to-regexp";
|
|
39
|
-
|
|
40
|
-
import {
|
|
41
|
-
type ApiRouteSerialized,
|
|
42
|
-
type PageRouteSerialized,
|
|
43
|
-
stringifySearchParams,
|
|
44
|
-
type ValidationTarget,
|
|
45
|
-
} from "@kosmojs/core";
|
|
46
|
-
import type { HTTPMethod } from "@kosmojs/core/api";
|
|
47
|
-
import { createHost, join } from "@kosmojs/core/fetch";
|
|
48
|
-
import type { RoutePathMethods } from "@kosmojs/core/generators";
|
|
49
|
-
|
|
50
|
-
export const apiRouteMapper = <ParamsT extends readonly unknown[]>(
|
|
51
|
-
base: string,
|
|
52
|
-
{
|
|
53
|
-
name,
|
|
54
|
-
pathPattern,
|
|
55
|
-
params,
|
|
56
|
-
numericProperties,
|
|
57
|
-
booleanProperties,
|
|
58
|
-
}: ApiRouteSerialized,
|
|
59
|
-
): RoutePathMethods<ParamsT> & {
|
|
60
|
-
normalizeParams: (path: string) => Record<string, unknown>;
|
|
61
|
-
normalizeSearchParams: (
|
|
62
|
-
searchParams: Record<string, unknown>,
|
|
63
|
-
method: HTTPMethod,
|
|
64
|
-
) => Record<string, unknown>;
|
|
65
|
-
payloadResolver: <T>(
|
|
66
|
-
payload: Record<ValidationTarget, T> | undefined,
|
|
67
|
-
target: ValidationTarget,
|
|
68
|
-
method: HTTPMethod,
|
|
69
|
-
) => T | Record<string, unknown> | undefined;
|
|
70
|
-
} => {
|
|
71
|
-
const toPath = compile(pathPattern);
|
|
72
|
-
const pathMatcher = match(join(base, pathPattern));
|
|
73
|
-
|
|
74
|
-
const maybeNumber = (val: unknown) => {
|
|
75
|
-
if (val === undefined || val === null) {
|
|
76
|
-
return val;
|
|
77
|
-
}
|
|
78
|
-
const n = Number(val);
|
|
79
|
-
return Number.isFinite(n) ? n : val;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const maybeBoolean = (val: unknown) => {
|
|
83
|
-
return [true, false, "true", "false"].includes(val as never) //
|
|
84
|
-
? JSON.parse(val as never)
|
|
85
|
-
: val;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const resolveParam = (path: string, param: (typeof params)[number]) => {
|
|
89
|
-
try {
|
|
90
|
-
const match = pathMatcher(path);
|
|
91
|
-
return match ? match.params[param] : undefined;
|
|
92
|
-
} catch (e) {
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const normalizeSearchParams = (
|
|
98
|
-
searchParams: Record<string, unknown>,
|
|
99
|
-
method: HTTPMethod,
|
|
100
|
-
) => {
|
|
101
|
-
return Object.fromEntries(
|
|
102
|
-
Object.entries(searchParams).map(([k, v]) => {
|
|
103
|
-
if (numericProperties.query?.[method]?.includes(k)) {
|
|
104
|
-
return [
|
|
105
|
-
k,
|
|
106
|
-
Array.isArray(v) ? v.map((e) => maybeNumber(e)) : maybeNumber(v),
|
|
107
|
-
];
|
|
108
|
-
}
|
|
109
|
-
if (booleanProperties.query?.[method]?.includes(k)) {
|
|
110
|
-
return [
|
|
111
|
-
k,
|
|
112
|
-
Array.isArray(v) ? v.map((e) => maybeBoolean(e)) : maybeBoolean(v),
|
|
113
|
-
];
|
|
114
|
-
}
|
|
115
|
-
return [k, v];
|
|
116
|
-
}),
|
|
117
|
-
);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const normalizeParams = (path: string) => {
|
|
121
|
-
return params.reduce((map: Record<string, unknown>, param) => {
|
|
122
|
-
const value = resolveParam(path, param);
|
|
123
|
-
if (Array.isArray(value)) {
|
|
124
|
-
map[param] = numericProperties.params.includes(param)
|
|
125
|
-
? value.map((e) => maybeNumber(e))
|
|
126
|
-
: value;
|
|
127
|
-
} else if (value) {
|
|
128
|
-
map[param] = numericProperties.params.includes(param)
|
|
129
|
-
? maybeNumber(value)
|
|
130
|
-
: value;
|
|
131
|
-
}
|
|
132
|
-
return map;
|
|
133
|
-
}, {});
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const paramsMapper: RoutePathMethods<ParamsT>["paramsMapper"] = (
|
|
137
|
-
input,
|
|
138
|
-
opt,
|
|
139
|
-
) => {
|
|
140
|
-
return params.reduce<Record<string, unknown>>((map, name, i) => {
|
|
141
|
-
const coerceNumbers = opt?.coerceNumbers
|
|
142
|
-
? numericProperties.params.includes(name)
|
|
143
|
-
: false;
|
|
144
|
-
if (Array.isArray(input[i])) {
|
|
145
|
-
map[name] = coerceNumbers
|
|
146
|
-
? input[i].map((v) => maybeNumber(v))
|
|
147
|
-
: input[i].map(String);
|
|
148
|
-
} else if (input[i] !== undefined) {
|
|
149
|
-
map[name] = coerceNumbers ? maybeNumber(input[i]) : String(input[i]);
|
|
150
|
-
}
|
|
151
|
-
return map;
|
|
152
|
-
}, {});
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
const parametrize: RoutePathMethods<ParamsT>["parametrize"] = (params) => {
|
|
156
|
-
try {
|
|
157
|
-
return toPath(paramsMapper(params) as never);
|
|
158
|
-
} catch (error) {
|
|
159
|
-
console.error(\`❗ERROR: Failed building path for \${name}\`);
|
|
160
|
-
throw error;
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const path: RoutePathMethods<ParamsT>["path"] = (params, query, opt) => {
|
|
165
|
-
const path = join(
|
|
166
|
-
opt?.prefix === false
|
|
167
|
-
? "/"
|
|
168
|
-
: typeof opt?.prefix === "string"
|
|
169
|
-
? opt.prefix
|
|
170
|
-
: base,
|
|
171
|
-
parametrize(params),
|
|
172
|
-
);
|
|
173
|
-
return query //
|
|
174
|
-
? [path, stringifySearchParams(query)].join("?")
|
|
175
|
-
: path;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
const href: RoutePathMethods<ParamsT>["href"] = (
|
|
179
|
-
host,
|
|
180
|
-
params,
|
|
181
|
-
query,
|
|
182
|
-
opt,
|
|
183
|
-
) => {
|
|
184
|
-
return createHost(host) + path(params, query, opt);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const payloadResolver = <T>(
|
|
188
|
-
payload: Record<ValidationTarget, T> | undefined,
|
|
189
|
-
target: ValidationTarget,
|
|
190
|
-
method: HTTPMethod,
|
|
191
|
-
) => {
|
|
192
|
-
const data = payload?.[target];
|
|
193
|
-
|
|
194
|
-
if (target === "query") {
|
|
195
|
-
return Object.fromEntries(
|
|
196
|
-
Object.entries({ ...data }).map(([k, v]) => {
|
|
197
|
-
return [
|
|
198
|
-
k,
|
|
199
|
-
numericProperties.query[method]?.includes(k)
|
|
200
|
-
? Array.isArray(v)
|
|
201
|
-
? v.map((v) => maybeNumber(v))
|
|
202
|
-
: maybeNumber(v)
|
|
203
|
-
: v,
|
|
204
|
-
];
|
|
205
|
-
}),
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (data instanceof FormData) {
|
|
210
|
-
return [...data].reduce<
|
|
211
|
-
Record<string, FormDataEntryValue | Array<FormDataEntryValue>>
|
|
212
|
-
>((map, [key, val]) => {
|
|
213
|
-
if (key in map) {
|
|
214
|
-
map[key] = [map[key]].flat().concat(val);
|
|
215
|
-
} else {
|
|
216
|
-
map[key] = val;
|
|
217
|
-
}
|
|
218
|
-
return map;
|
|
219
|
-
}, {}) as T;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return data;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
return {
|
|
226
|
-
normalizeParams,
|
|
227
|
-
normalizeSearchParams,
|
|
228
|
-
payloadResolver,
|
|
229
|
-
paramsMapper,
|
|
230
|
-
parametrize,
|
|
231
|
-
path,
|
|
232
|
-
href,
|
|
233
|
-
};
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
export const pageRouteMapper = <ParamsT extends readonly unknown[]>(
|
|
237
|
-
base: string,
|
|
238
|
-
route: PageRouteSerialized,
|
|
239
|
-
): RoutePathMethods<ParamsT> => {
|
|
240
|
-
const toPath = compile(route.pathPattern);
|
|
241
|
-
|
|
242
|
-
const paramsMapper: RoutePathMethods<ParamsT>["paramsMapper"] = (params) => {
|
|
243
|
-
return route.params.reduce<Record<string, unknown>>((map, name, i) => {
|
|
244
|
-
if (Array.isArray(params[i])) {
|
|
245
|
-
map[name] = params[i].map(String);
|
|
246
|
-
} else if (params[i] !== undefined) {
|
|
247
|
-
map[name] = String(params[i]);
|
|
248
|
-
}
|
|
249
|
-
return map;
|
|
250
|
-
}, {});
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
const parametrize: RoutePathMethods<ParamsT>["parametrize"] = (params) => {
|
|
254
|
-
try {
|
|
255
|
-
return toPath(paramsMapper(params) as never);
|
|
256
|
-
} catch (error) {
|
|
257
|
-
console.error(\`❗ERROR: Failed building path for \${route.name}\`);
|
|
258
|
-
throw error;
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
const path: RoutePathMethods<ParamsT>["path"] = (params, query, opt) => {
|
|
263
|
-
const path = join(
|
|
264
|
-
opt?.prefix === false
|
|
265
|
-
? "/"
|
|
266
|
-
: typeof opt?.prefix === "string"
|
|
267
|
-
? opt.prefix
|
|
268
|
-
: base,
|
|
269
|
-
parametrize(params),
|
|
270
|
-
);
|
|
271
|
-
return query //
|
|
272
|
-
? [path, stringifySearchParams(query)].join("?")
|
|
273
|
-
: path;
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
const href: RoutePathMethods<ParamsT>["href"] = (
|
|
277
|
-
host,
|
|
278
|
-
params,
|
|
279
|
-
query,
|
|
280
|
-
opt,
|
|
281
|
-
) => {
|
|
282
|
-
return createHost(host) + path(params, query, opt);
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
return {
|
|
286
|
-
paramsMapper,
|
|
287
|
-
parametrize,
|
|
288
|
-
path,
|
|
289
|
-
href,
|
|
290
|
-
};
|
|
291
|
-
};
|
|
292
|
-
`,g=`export type Override<A, B> = Omit<A, keyof B> & B;
|
|
293
|
-
`,_=`declare const KOSMO_PRODUCTION_BUILD: boolean;
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Enhances base TypeScript types with JSON Schema validation constraints.
|
|
297
|
-
* Allows declaring refined types that carry validation metadata for runtime
|
|
298
|
-
* schema validation while maintaining full TypeScript type safety.
|
|
299
|
-
*
|
|
300
|
-
* Useful for generating validation schemas and ensuring
|
|
301
|
-
* data conforms to specific business rules beyond basic type checking.
|
|
302
|
-
* */
|
|
303
|
-
declare type VRefine<
|
|
304
|
-
T extends unknown[] | number | string | object,
|
|
305
|
-
_ extends T extends unknown[]
|
|
306
|
-
? TArrayOptions
|
|
307
|
-
: T extends number
|
|
308
|
-
? TNumberOptions
|
|
309
|
-
: T extends string
|
|
310
|
-
? TStringOptions
|
|
311
|
-
: TObjectOptions,
|
|
312
|
-
> = T;
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Type definitions inspired by and gently adapted from TypeBox.
|
|
316
|
-
* Original TypeBox created by sinclairzx81: https://github.com/sinclairzx81/typebox
|
|
317
|
-
* TypeBox is licensed under MIT: https://github.com/sinclairzx81/typebox/blob/main/license
|
|
318
|
-
*
|
|
319
|
-
* These types provide JSON Schema compatible type refinements for TypeScript.
|
|
320
|
-
* */
|
|
321
|
-
interface TSchema {}
|
|
322
|
-
|
|
323
|
-
// ------------------------------------------------------------------
|
|
324
|
-
// ObjectOptions
|
|
325
|
-
// ------------------------------------------------------------------
|
|
326
|
-
interface TObjectOptions {
|
|
327
|
-
/**
|
|
328
|
-
* Defines whether additional properties are allowed beyond those explicitly defined in \`properties\`.
|
|
329
|
-
*/
|
|
330
|
-
additionalProperties?: TSchema | boolean;
|
|
331
|
-
/**
|
|
332
|
-
* The minimum number of properties required in the object.
|
|
333
|
-
*/
|
|
334
|
-
minProperties?: number;
|
|
335
|
-
/**
|
|
336
|
-
* The maximum number of properties allowed in the object.
|
|
337
|
-
*/
|
|
338
|
-
maxProperties?: number;
|
|
339
|
-
/**
|
|
340
|
-
* Defines conditional requirements for properties.
|
|
341
|
-
*/
|
|
342
|
-
dependencies?: Record<string, boolean | TSchema | string[]>;
|
|
343
|
-
/**
|
|
344
|
-
* Specifies properties that *must* be present if a given property is present.
|
|
345
|
-
*/
|
|
346
|
-
dependentRequired?: Record<string, string[]>;
|
|
347
|
-
/**
|
|
348
|
-
* Defines schemas that apply if a specific property is present.
|
|
349
|
-
*/
|
|
350
|
-
dependentSchemas?: Record<string, TSchema>;
|
|
351
|
-
/**
|
|
352
|
-
* Maps regular expressions to schemas properties matching a pattern must validate against the schema.
|
|
353
|
-
*/
|
|
354
|
-
patternProperties?: Record<string, TSchema>;
|
|
355
|
-
/**
|
|
356
|
-
* A schema that all property names within the object must validate against.
|
|
357
|
-
*/
|
|
358
|
-
propertyNames?: TSchema;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// ------------------------------------------------------------------
|
|
362
|
-
// ArrayOptions
|
|
363
|
-
// ------------------------------------------------------------------
|
|
364
|
-
interface TArrayOptions {
|
|
365
|
-
/**
|
|
366
|
-
* The minimum number of items allowed in the array.
|
|
367
|
-
*/
|
|
368
|
-
minItems?: number;
|
|
369
|
-
/**
|
|
370
|
-
* The maximum number of items allowed in the array.
|
|
371
|
-
*/
|
|
372
|
-
maxItems?: number;
|
|
373
|
-
/**
|
|
374
|
-
* A schema that at least one item in the array must validate against.
|
|
375
|
-
*/
|
|
376
|
-
contains?: TSchema;
|
|
377
|
-
/**
|
|
378
|
-
* The minimum number of array items that must validate against the \`contains\` schema.
|
|
379
|
-
*/
|
|
380
|
-
minContains?: number;
|
|
381
|
-
/**
|
|
382
|
-
* The maximum number of array items that may validate against the \`contains\` schema.
|
|
383
|
-
*/
|
|
384
|
-
maxContains?: number;
|
|
385
|
-
/**
|
|
386
|
-
* An array of schemas, where each schema in \`prefixItems\` validates against items at corresponding positions from the beginning of the array.
|
|
387
|
-
*/
|
|
388
|
-
prefixItems?: TSchema[];
|
|
389
|
-
/**
|
|
390
|
-
* If \`true\`, all items in the array must be unique.
|
|
391
|
-
*/
|
|
392
|
-
uniqueItems?: boolean;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
// ------------------------------------------------------------------
|
|
396
|
-
// NumberOptions
|
|
397
|
-
// ------------------------------------------------------------------
|
|
398
|
-
interface TNumberOptions {
|
|
399
|
-
/**
|
|
400
|
-
* Specifies an exclusive upper limit for the number (number must be less than this value).
|
|
401
|
-
*/
|
|
402
|
-
exclusiveMaximum?: number | bigint;
|
|
403
|
-
/**
|
|
404
|
-
* Specifies an exclusive lower limit for the number (number must be greater than this value).
|
|
405
|
-
*/
|
|
406
|
-
exclusiveMinimum?: number | bigint;
|
|
407
|
-
/**
|
|
408
|
-
* Specifies an inclusive upper limit for the number (number must be less than or equal to this value).
|
|
409
|
-
*/
|
|
410
|
-
maximum?: number | bigint;
|
|
411
|
-
/**
|
|
412
|
-
* Specifies an inclusive lower limit for the number (number must be greater than or equal to this value).
|
|
413
|
-
*/
|
|
414
|
-
minimum?: number | bigint;
|
|
415
|
-
/**
|
|
416
|
-
* Specifies that the number must be a multiple of this value.
|
|
417
|
-
*/
|
|
418
|
-
multipleOf?: number | bigint;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
// ------------------------------------------------------------------
|
|
422
|
-
// StringOptions
|
|
423
|
-
// ------------------------------------------------------------------
|
|
424
|
-
type TFormat =
|
|
425
|
-
| "date-time"
|
|
426
|
-
| "date"
|
|
427
|
-
| "duration"
|
|
428
|
-
| "email"
|
|
429
|
-
| "hostname"
|
|
430
|
-
| "idn-email"
|
|
431
|
-
| "idn-hostname"
|
|
432
|
-
| "ipv4"
|
|
433
|
-
| "ipv6"
|
|
434
|
-
| "iri-reference"
|
|
435
|
-
| "iri"
|
|
436
|
-
| "json-pointer-uri-fragment"
|
|
437
|
-
| "json-pointer"
|
|
438
|
-
| "json-string"
|
|
439
|
-
| "regex"
|
|
440
|
-
| "relative-json-pointer"
|
|
441
|
-
| "time"
|
|
442
|
-
| "uri-reference"
|
|
443
|
-
| "uri-template"
|
|
444
|
-
| "url"
|
|
445
|
-
| "uuid";
|
|
446
|
-
|
|
447
|
-
interface TStringOptions {
|
|
448
|
-
/**
|
|
449
|
-
* Specifies the expected string format.
|
|
450
|
-
*
|
|
451
|
-
* Common values include:
|
|
452
|
-
* - \`base64\` – Base64-encoded string.
|
|
453
|
-
* - \`date-time\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time format.
|
|
454
|
-
* - \`date\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date (YYYY-MM-DD).
|
|
455
|
-
* - \`duration\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) duration format.
|
|
456
|
-
* - \`email\` – RFC 5321/5322 compliant email address.
|
|
457
|
-
* - \`hostname\` – RFC 1034/1035 compliant host name.
|
|
458
|
-
* - \`idn-email\` – Internationalized email address.
|
|
459
|
-
* - \`idn-hostname\` – Internationalized host name.
|
|
460
|
-
* - \`ipv4\` – IPv4 address.
|
|
461
|
-
* - \`ipv6\` – IPv6 address.
|
|
462
|
-
* - \`iri\` / \`iri-reference\` – Internationalized Resource Identifier.
|
|
463
|
-
* - \`json-pointer\` / \`json-pointer-uri-fragment\` – JSON Pointer format.
|
|
464
|
-
* - \`json-string\` – String containing valid JSON.
|
|
465
|
-
* - \`regex\` – Regular expression syntax.
|
|
466
|
-
* - \`relative-json-pointer\` – Relative JSON Pointer format.
|
|
467
|
-
* - \`time\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time (HH:MM:SS).
|
|
468
|
-
* - \`uri-reference\` / \`uri-template\` – URI reference or template.
|
|
469
|
-
* - \`url\` – Web URL format.
|
|
470
|
-
* - \`uuid\` – RFC 4122 UUID string.
|
|
471
|
-
*
|
|
472
|
-
* May also be a custom format string.
|
|
473
|
-
*/
|
|
474
|
-
format?: TFormat;
|
|
475
|
-
/**
|
|
476
|
-
* Specifies the minimum number of characters allowed in the string.
|
|
477
|
-
* Must be a non-negative integer.
|
|
478
|
-
*/
|
|
479
|
-
minLength?: number;
|
|
480
|
-
/**
|
|
481
|
-
* Specifies the maximum number of characters allowed in the string.
|
|
482
|
-
* Must be a non-negative integer.
|
|
483
|
-
*/
|
|
484
|
-
maxLength?: number;
|
|
485
|
-
/**
|
|
486
|
-
* Specifies a regular expression pattern that the string value must match.
|
|
487
|
-
* Can be provided as a string (ECMA-262 regex syntax) or a \`RegExp\` object.
|
|
488
|
-
*/
|
|
489
|
-
pattern?: string | RegExp;
|
|
490
|
-
}
|
|
491
|
-
`,v=`# Ignore all files
|
|
492
|
-
*
|
|
493
|
-
|
|
494
|
-
# But don't ignore directories (so Git can traverse them)
|
|
495
|
-
!*/
|
|
496
|
-
|
|
497
|
-
# And don't ignore these files at any depth
|
|
498
|
-
!cache.json
|
|
499
|
-
!types.ts
|
|
500
|
-
`,y=`export declare global {
|
|
501
|
-
interface Window {
|
|
502
|
-
__KOSMO_HYDRATION_BOOL__: boolean;
|
|
503
|
-
__KOSMO_HYDRATION_DATA__: Record<string, unknown> | undefined;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
`,b=`// stub schemas, specialized generators supposed to overwrite this file
|
|
507
|
-
import type { ValidationSchemas } from "@kosmojs/core/api";
|
|
508
|
-
export type { ValidationSchemas };
|
|
509
|
-
export const validationSchemas: ValidationSchemas = {};
|
|
510
|
-
`,x=({dependencies:e,devDependencies:t},n)=>{let i="${configDir}",a=Object.keys({...e,...t}),o={types:[`vite/client`,...[`node`,`deno`,`bun`].flatMap(e=>a.includes(`@types/${e}`)?[`@types/${e}`]:[])],moduleResolution:`bundler`,module:`ESNext`,target:`ESNext`,strict:!0,exactOptionalPropertyTypes:!0,noImplicitAny:!0,noImplicitThis:!0,noImplicitOverride:!0,noImplicitReturns:!0,noUnusedLocals:!1,noUnusedParameters:!1,allowArbitraryExtensions:!0,allowImportingTsExtensions:!0,allowUnreachableCode:!1,allowUnusedLabels:!1,useUnknownInCatchVariables:!0,noFallthroughCasesInSwitch:!0,noUncheckedSideEffectImports:!0,resolveJsonModule:!0,esModuleInterop:!0,verbatimModuleSyntax:!0,skipLibCheck:!0,noEmit:!0};return n?{include:[`${i}/`,`${i}/../../${r.libDir}/${n}/`,`${i}/../../**/*.d.ts`],compilerOptions:{...o,types:[...o.types],paths:{[`${r.appPrefix}/*`]:[`${i}/../../*`],[`${r.srcPrefix}/*`]:[`${i}/*`],[`${r.libPrefix}/*`]:[`${i}/../../${r.libDir}/${n}/*`]}}}:{include:[`${i}/`],exclude:[`${i}/${r.srcDir}/`],compilerOptions:{...o,paths:{[`${r.appPrefix}/*`]:[`${i}/*`]}}}},S=a(i=>{let{createPath:a,createImportHelpers:d}=o(i),S=async()=>{let{generators:e=[]}=i.config,{dependencies:o={},devDependencies:s={}}=await import(t(i.root,`package.json`),{with:{type:`json`}}).then(e=>e.default);{let t=[],r=[],i=e.flatMap(e=>[`dependencies`,`devDependencies`].flatMap(t=>e[t]?Object.entries(typeof e[t]==`function`?e[t](e.options):e[t]).flatMap(([e,n])=>{let r=l.minVersion(n)?.version;return r?[[e,r,t]]:[]}):[]));for(let[e,n,a]of i){let i=o[e]||s[e],c=i?l.minVersion(i)?.version:void 0;!i||!c?t.push([e,n,a]):l.lt(c,n)&&r.push([e,n,a])}if(t.length){console.error(n([`red`,`italic`],`There are ${t.length} missing dependencies, please consider installing them.`));for(let e of[`dependencies`,`devDependencies`]){let r=t.filter(t=>t[2]===e);r.length&&console.error(`${e}: ${n([`blue`],r.map(([e])=>e).join(` `))}`)}}r.length&&(console.error(n([`yellow`,`italic`],`There are ${r.length} outdated dependencies, please consider updating them:`)),console.error(r.map(([e])=>e).join(` `)),console.error())}{await c(t(i.root,`tsconfig.json`),JSON.stringify({extends:`./${r.libDir}/tsconfig.json`},void 0,2),{},{overwrite:!1}),await c(a.lib(`../tsconfig.json`),JSON.stringify(x({dependencies:o,devDependencies:s}),void 0,2),{}),await c(a.src(`tsconfig.json`),JSON.stringify({extends:`../../${r.libDir}/${i.name}/tsconfig.json`},void 0,2),{},{overwrite:!1});let e=x({dependencies:o,devDependencies:s},i.name),n={},l=new Set(e.compilerOptions.types||[]);for(let{meta:e}of i.config.generators||[]){e.jsx&&(n.jsx=e.jsx),e.jsxImportSource&&(n.jsxImportSource=e.jsxImportSource);for(let t of e.types||[])l.add(t)}await c(a.lib(`tsconfig.json`),JSON.stringify({...e,compilerOptions:{...e.compilerOptions,...n,types:[...l.values()]}},void 0,2),{})}for(let[e,t]of[[`env.d.ts`,_],[`global.d.ts`,y]])await c(a.lib(`../${e}`),t,{});await c(a.lib(`../.gitignore`),v,{},{overwrite:!1});for(let[e,t]of[[`ssg.ts`,`export default [];`]])await c(a.lib(e),t,{})},C=async t=>{let{renderToFile:n}=s({helpers:{...d({origin:`lib`}),...u()},partials:{routeMapperPartial:h}});await n(a.libCore(`routes.ts`),m,{apiRoutes:t.flatMap(({kind:e,entry:t})=>e===`apiRoute`?[t]:[]),pageRoutes:t.flatMap(({kind:e,entry:t})=>e===`pageRoute`?[t]:[])});for(let[e,t]of[[`config.ts`,f],[`types.ts`,g],[`index.ts`,p]])await n(a.libCore(e),t,i);for(let{kind:r,entry:i}of t)r===`apiRoute`&&await n(a.libApi(e(i.file),`schemas.ts`),b,{route:i},{overwrite:!1})};return{start:S,watch:C,build:C}}),C=i({meta:{name:`Core`},dependencies:{"path-to-regexp":d.devDependencies[`path-to-regexp`]},factory:S});export{C as t};
|
|
511
|
-
//# sourceMappingURL=pkg-Bkag325q.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pkg-Bkag325q.js","names":["l","t","n","o","s","i","r","u","a","e"],"sources":["../../../../generators/core-generator/pkg/index.js"],"sourcesContent":["import{defineGenerator as e,defineGeneratorFactory as t,pathResolver as n,renderFactory as r,renderToFile as i}from\"@kosmojs/lib\";import{dirname as a,resolve as o}from\"node:path\";import{styleText as s}from\"node:util\";import c from\"semver\";import{defaults as l}from\"@kosmojs/core\";import{routeRenderHelpers as u}from\"@kosmojs/core/generators\";var d={type:`module`,private:!0,name:`@kosmojs/core-generator`,version:`0.3.0`,author:`Slee Woo`,license:`MIT`,files:[`pkg/*`],exports:{\".\":{types:`./pkg/index.d.ts`,default:`./pkg/index.js`}},scripts:{build:`wsbuild src/index.ts`},dependencies:{\"@kosmojs/core\":`workspace:^`,\"@kosmojs/lib\":`workspace:^`,semver:`^7.8.5`},devDependencies:{\"@types/semver\":`^7.8.0`,\"path-to-regexp\":`^8.4.2`}},f=`export const base = \"{{config.base}}\";\nexport const apiBase = \"{{config.apiBase}}\";\n`,p=`export * from \"./config\";\nexport * from \"./routes\";\nexport * from \"./types\";\n`,m=`{{> routeMapperPartial}}\n\nimport { base, apiBase } from \"./config\";\n\n// used by backend generators and fetch clients\nexport const apiRouteMap = {\n {{#each apiRoutes}}\n \"{{name}}\": apiRouteMapper<[{{serializeParamsTupleElements .}}]>(\n join(base, apiBase),\n {{serializeApiRoute .}},\n ),\n {{/each}}\n};\n\n// used by frontend generators on Link component\nexport const pageRouteMap = {\n {{#each pageRoutes}}\n \"{{name}}\": pageRouteMapper<[{{serializeParamsTupleElements .}}]>(\n base,\n {{serializePageRoute .}},\n ),\n {{/each}}\n};\n\n{{#if pageRoutes.length}}\nexport type LinkProps =\n {{#each pageRoutes}}\n | [ \"{{name}}\", {{serializeParamsTupleElements .}} ]\n {{/each}};\n{{else}}\nexport type LinkProps = never;\n{{/if}}\n`,h=`import { compile, match } from \"path-to-regexp\";\n\nimport {\n type ApiRouteSerialized,\n type PageRouteSerialized,\n stringifySearchParams,\n type ValidationTarget,\n} from \"@kosmojs/core\";\nimport type { HTTPMethod } from \"@kosmojs/core/api\";\nimport { createHost, join } from \"@kosmojs/core/fetch\";\nimport type { RoutePathMethods } from \"@kosmojs/core/generators\";\n\nexport const apiRouteMapper = <ParamsT extends readonly unknown[]>(\n base: string,\n {\n name,\n pathPattern,\n params,\n numericProperties,\n booleanProperties,\n }: ApiRouteSerialized,\n): RoutePathMethods<ParamsT> & {\n normalizeParams: (path: string) => Record<string, unknown>;\n normalizeSearchParams: (\n searchParams: Record<string, unknown>,\n method: HTTPMethod,\n ) => Record<string, unknown>;\n payloadResolver: <T>(\n payload: Record<ValidationTarget, T> | undefined,\n target: ValidationTarget,\n method: HTTPMethod,\n ) => T | Record<string, unknown> | undefined;\n} => {\n const toPath = compile(pathPattern);\n const pathMatcher = match(join(base, pathPattern));\n\n const maybeNumber = (val: unknown) => {\n if (val === undefined || val === null) {\n return val;\n }\n const n = Number(val);\n return Number.isFinite(n) ? n : val;\n };\n\n const maybeBoolean = (val: unknown) => {\n return [true, false, \"true\", \"false\"].includes(val as never) //\n ? JSON.parse(val as never)\n : val;\n };\n\n const resolveParam = (path: string, param: (typeof params)[number]) => {\n try {\n const match = pathMatcher(path);\n return match ? match.params[param] : undefined;\n } catch (e) {\n return undefined;\n }\n };\n\n const normalizeSearchParams = (\n searchParams: Record<string, unknown>,\n method: HTTPMethod,\n ) => {\n return Object.fromEntries(\n Object.entries(searchParams).map(([k, v]) => {\n if (numericProperties.query?.[method]?.includes(k)) {\n return [\n k,\n Array.isArray(v) ? v.map((e) => maybeNumber(e)) : maybeNumber(v),\n ];\n }\n if (booleanProperties.query?.[method]?.includes(k)) {\n return [\n k,\n Array.isArray(v) ? v.map((e) => maybeBoolean(e)) : maybeBoolean(v),\n ];\n }\n return [k, v];\n }),\n );\n };\n\n const normalizeParams = (path: string) => {\n return params.reduce((map: Record<string, unknown>, param) => {\n const value = resolveParam(path, param);\n if (Array.isArray(value)) {\n map[param] = numericProperties.params.includes(param)\n ? value.map((e) => maybeNumber(e))\n : value;\n } else if (value) {\n map[param] = numericProperties.params.includes(param)\n ? maybeNumber(value)\n : value;\n }\n return map;\n }, {});\n };\n\n const paramsMapper: RoutePathMethods<ParamsT>[\"paramsMapper\"] = (\n input,\n opt,\n ) => {\n return params.reduce<Record<string, unknown>>((map, name, i) => {\n const coerceNumbers = opt?.coerceNumbers\n ? numericProperties.params.includes(name)\n : false;\n if (Array.isArray(input[i])) {\n map[name] = coerceNumbers\n ? input[i].map((v) => maybeNumber(v))\n : input[i].map(String);\n } else if (input[i] !== undefined) {\n map[name] = coerceNumbers ? maybeNumber(input[i]) : String(input[i]);\n }\n return map;\n }, {});\n };\n\n const parametrize: RoutePathMethods<ParamsT>[\"parametrize\"] = (params) => {\n try {\n return toPath(paramsMapper(params) as never);\n } catch (error) {\n console.error(\\`❗ERROR: Failed building path for \\${name}\\`);\n throw error;\n }\n };\n\n const path: RoutePathMethods<ParamsT>[\"path\"] = (params, query, opt) => {\n const path = join(\n opt?.prefix === false\n ? \"/\"\n : typeof opt?.prefix === \"string\"\n ? opt.prefix\n : base,\n parametrize(params),\n );\n return query //\n ? [path, stringifySearchParams(query)].join(\"?\")\n : path;\n };\n\n const href: RoutePathMethods<ParamsT>[\"href\"] = (\n host,\n params,\n query,\n opt,\n ) => {\n return createHost(host) + path(params, query, opt);\n };\n\n const payloadResolver = <T>(\n payload: Record<ValidationTarget, T> | undefined,\n target: ValidationTarget,\n method: HTTPMethod,\n ) => {\n const data = payload?.[target];\n\n if (target === \"query\") {\n return Object.fromEntries(\n Object.entries({ ...data }).map(([k, v]) => {\n return [\n k,\n numericProperties.query[method]?.includes(k)\n ? Array.isArray(v)\n ? v.map((v) => maybeNumber(v))\n : maybeNumber(v)\n : v,\n ];\n }),\n );\n }\n\n if (data instanceof FormData) {\n return [...data].reduce<\n Record<string, FormDataEntryValue | Array<FormDataEntryValue>>\n >((map, [key, val]) => {\n if (key in map) {\n map[key] = [map[key]].flat().concat(val);\n } else {\n map[key] = val;\n }\n return map;\n }, {}) as T;\n }\n\n return data;\n };\n\n return {\n normalizeParams,\n normalizeSearchParams,\n payloadResolver,\n paramsMapper,\n parametrize,\n path,\n href,\n };\n};\n\nexport const pageRouteMapper = <ParamsT extends readonly unknown[]>(\n base: string,\n route: PageRouteSerialized,\n): RoutePathMethods<ParamsT> => {\n const toPath = compile(route.pathPattern);\n\n const paramsMapper: RoutePathMethods<ParamsT>[\"paramsMapper\"] = (params) => {\n return route.params.reduce<Record<string, unknown>>((map, name, i) => {\n if (Array.isArray(params[i])) {\n map[name] = params[i].map(String);\n } else if (params[i] !== undefined) {\n map[name] = String(params[i]);\n }\n return map;\n }, {});\n };\n\n const parametrize: RoutePathMethods<ParamsT>[\"parametrize\"] = (params) => {\n try {\n return toPath(paramsMapper(params) as never);\n } catch (error) {\n console.error(\\`❗ERROR: Failed building path for \\${route.name}\\`);\n throw error;\n }\n };\n\n const path: RoutePathMethods<ParamsT>[\"path\"] = (params, query, opt) => {\n const path = join(\n opt?.prefix === false\n ? \"/\"\n : typeof opt?.prefix === \"string\"\n ? opt.prefix\n : base,\n parametrize(params),\n );\n return query //\n ? [path, stringifySearchParams(query)].join(\"?\")\n : path;\n };\n\n const href: RoutePathMethods<ParamsT>[\"href\"] = (\n host,\n params,\n query,\n opt,\n ) => {\n return createHost(host) + path(params, query, opt);\n };\n\n return {\n paramsMapper,\n parametrize,\n path,\n href,\n };\n};\n`,g=`export type Override<A, B> = Omit<A, keyof B> & B;\n`,_=`declare const KOSMO_PRODUCTION_BUILD: boolean;\n\n/**\n * Enhances base TypeScript types with JSON Schema validation constraints.\n * Allows declaring refined types that carry validation metadata for runtime\n * schema validation while maintaining full TypeScript type safety.\n *\n * Useful for generating validation schemas and ensuring\n * data conforms to specific business rules beyond basic type checking.\n * */\ndeclare type VRefine<\n T extends unknown[] | number | string | object,\n _ extends T extends unknown[]\n ? TArrayOptions\n : T extends number\n ? TNumberOptions\n : T extends string\n ? TStringOptions\n : TObjectOptions,\n> = T;\n\n/**\n * Type definitions inspired by and gently adapted from TypeBox.\n * Original TypeBox created by sinclairzx81: https://github.com/sinclairzx81/typebox\n * TypeBox is licensed under MIT: https://github.com/sinclairzx81/typebox/blob/main/license\n *\n * These types provide JSON Schema compatible type refinements for TypeScript.\n * */\ninterface TSchema {}\n\n// ------------------------------------------------------------------\n// ObjectOptions\n// ------------------------------------------------------------------\ninterface TObjectOptions {\n /**\n * Defines whether additional properties are allowed beyond those explicitly defined in \\`properties\\`.\n */\n additionalProperties?: TSchema | boolean;\n /**\n * The minimum number of properties required in the object.\n */\n minProperties?: number;\n /**\n * The maximum number of properties allowed in the object.\n */\n maxProperties?: number;\n /**\n * Defines conditional requirements for properties.\n */\n dependencies?: Record<string, boolean | TSchema | string[]>;\n /**\n * Specifies properties that *must* be present if a given property is present.\n */\n dependentRequired?: Record<string, string[]>;\n /**\n * Defines schemas that apply if a specific property is present.\n */\n dependentSchemas?: Record<string, TSchema>;\n /**\n * Maps regular expressions to schemas properties matching a pattern must validate against the schema.\n */\n patternProperties?: Record<string, TSchema>;\n /**\n * A schema that all property names within the object must validate against.\n */\n propertyNames?: TSchema;\n}\n\n// ------------------------------------------------------------------\n// ArrayOptions\n// ------------------------------------------------------------------\ninterface TArrayOptions {\n /**\n * The minimum number of items allowed in the array.\n */\n minItems?: number;\n /**\n * The maximum number of items allowed in the array.\n */\n maxItems?: number;\n /**\n * A schema that at least one item in the array must validate against.\n */\n contains?: TSchema;\n /**\n * The minimum number of array items that must validate against the \\`contains\\` schema.\n */\n minContains?: number;\n /**\n * The maximum number of array items that may validate against the \\`contains\\` schema.\n */\n maxContains?: number;\n /**\n * An array of schemas, where each schema in \\`prefixItems\\` validates against items at corresponding positions from the beginning of the array.\n */\n prefixItems?: TSchema[];\n /**\n * If \\`true\\`, all items in the array must be unique.\n */\n uniqueItems?: boolean;\n}\n\n// ------------------------------------------------------------------\n// NumberOptions\n// ------------------------------------------------------------------\ninterface TNumberOptions {\n /**\n * Specifies an exclusive upper limit for the number (number must be less than this value).\n */\n exclusiveMaximum?: number | bigint;\n /**\n * Specifies an exclusive lower limit for the number (number must be greater than this value).\n */\n exclusiveMinimum?: number | bigint;\n /**\n * Specifies an inclusive upper limit for the number (number must be less than or equal to this value).\n */\n maximum?: number | bigint;\n /**\n * Specifies an inclusive lower limit for the number (number must be greater than or equal to this value).\n */\n minimum?: number | bigint;\n /**\n * Specifies that the number must be a multiple of this value.\n */\n multipleOf?: number | bigint;\n}\n\n// ------------------------------------------------------------------\n// StringOptions\n// ------------------------------------------------------------------\ntype TFormat =\n | \"date-time\"\n | \"date\"\n | \"duration\"\n | \"email\"\n | \"hostname\"\n | \"idn-email\"\n | \"idn-hostname\"\n | \"ipv4\"\n | \"ipv6\"\n | \"iri-reference\"\n | \"iri\"\n | \"json-pointer-uri-fragment\"\n | \"json-pointer\"\n | \"json-string\"\n | \"regex\"\n | \"relative-json-pointer\"\n | \"time\"\n | \"uri-reference\"\n | \"uri-template\"\n | \"url\"\n | \"uuid\";\n\ninterface TStringOptions {\n /**\n * Specifies the expected string format.\n *\n * Common values include:\n * - \\`base64\\` – Base64-encoded string.\n * - \\`date-time\\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time format.\n * - \\`date\\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date (YYYY-MM-DD).\n * - \\`duration\\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) duration format.\n * - \\`email\\` – RFC 5321/5322 compliant email address.\n * - \\`hostname\\` – RFC 1034/1035 compliant host name.\n * - \\`idn-email\\` – Internationalized email address.\n * - \\`idn-hostname\\` – Internationalized host name.\n * - \\`ipv4\\` – IPv4 address.\n * - \\`ipv6\\` – IPv6 address.\n * - \\`iri\\` / \\`iri-reference\\` – Internationalized Resource Identifier.\n * - \\`json-pointer\\` / \\`json-pointer-uri-fragment\\` – JSON Pointer format.\n * - \\`json-string\\` – String containing valid JSON.\n * - \\`regex\\` – Regular expression syntax.\n * - \\`relative-json-pointer\\` – Relative JSON Pointer format.\n * - \\`time\\` – [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time (HH:MM:SS).\n * - \\`uri-reference\\` / \\`uri-template\\` – URI reference or template.\n * - \\`url\\` – Web URL format.\n * - \\`uuid\\` – RFC 4122 UUID string.\n *\n * May also be a custom format string.\n */\n format?: TFormat;\n /**\n * Specifies the minimum number of characters allowed in the string.\n * Must be a non-negative integer.\n */\n minLength?: number;\n /**\n * Specifies the maximum number of characters allowed in the string.\n * Must be a non-negative integer.\n */\n maxLength?: number;\n /**\n * Specifies a regular expression pattern that the string value must match.\n * Can be provided as a string (ECMA-262 regex syntax) or a \\`RegExp\\` object.\n */\n pattern?: string | RegExp;\n}\n`,v=`# Ignore all files\n*\n\n# But don't ignore directories (so Git can traverse them)\n!*/\n\n# And don't ignore these files at any depth\n!cache.json\n!types.ts\n`,y=`export declare global {\n interface Window {\n __KOSMO_HYDRATION_BOOL__: boolean;\n __KOSMO_HYDRATION_DATA__: Record<string, unknown> | undefined;\n }\n}\n`,b=`// stub schemas, specialized generators supposed to overwrite this file\nimport type { ValidationSchemas } from \"@kosmojs/core/api\";\nexport type { ValidationSchemas };\nexport const validationSchemas: ValidationSchemas = {};\n`,x=({dependencies:e,devDependencies:t},n)=>{let r=\"${configDir}\",i=Object.keys({...e,...t}),a={types:[`vite/client`,...[`node`,`deno`,`bun`].flatMap(e=>i.includes(`@types/${e}`)?[`@types/${e}`]:[])],moduleResolution:`bundler`,module:`ESNext`,target:`ESNext`,strict:!0,exactOptionalPropertyTypes:!0,noImplicitAny:!0,noImplicitThis:!0,noImplicitOverride:!0,noImplicitReturns:!0,noUnusedLocals:!1,noUnusedParameters:!1,allowArbitraryExtensions:!0,allowImportingTsExtensions:!0,allowUnreachableCode:!1,allowUnusedLabels:!1,useUnknownInCatchVariables:!0,noFallthroughCasesInSwitch:!0,noUncheckedSideEffectImports:!0,resolveJsonModule:!0,esModuleInterop:!0,verbatimModuleSyntax:!0,skipLibCheck:!0,noEmit:!0};return n?{include:[`${r}/`,`${r}/../../${l.libDir}/${n}/`,`${r}/../../**/*.d.ts`],compilerOptions:{...a,types:[...a.types],paths:{[`${l.appPrefix}/*`]:[`${r}/../../*`],[`${l.srcPrefix}/*`]:[`${r}/*`],[`${l.libPrefix}/*`]:[`${r}/../../${l.libDir}/${n}/*`]}}}:{include:[`${r}/`],exclude:[`${r}/${l.srcDir}/`],compilerOptions:{...a,paths:{[`${l.appPrefix}/*`]:[`${r}/*`]}}}},S=t(e=>{let{createPath:t,createImportHelpers:d}=n(e),S=async()=>{let{generators:n=[]}=e.config,{dependencies:r={},devDependencies:a={}}=await import(o(e.root,`package.json`),{with:{type:`json`}}).then(e=>e.default);{let e=[],t=[],i=n.flatMap(e=>[`dependencies`,`devDependencies`].flatMap(t=>e[t]?Object.entries(typeof e[t]==`function`?e[t](e.options):e[t]).flatMap(([e,n])=>{let r=c.minVersion(n)?.version;return r?[[e,r,t]]:[]}):[]));for(let[n,o,s]of i){let i=r[n]||a[n],l=i?c.minVersion(i)?.version:void 0;!i||!l?e.push([n,o,s]):c.lt(l,o)&&t.push([n,o,s])}if(e.length){console.error(s([`red`,`italic`],`There are ${e.length} missing dependencies, please consider installing them.`));for(let t of[`dependencies`,`devDependencies`]){let n=e.filter(e=>e[2]===t);n.length&&console.error(`${t}: ${s([`blue`],n.map(([e])=>e).join(` `))}`)}}t.length&&(console.error(s([`yellow`,`italic`],`There are ${t.length} outdated dependencies, please consider updating them:`)),console.error(t.map(([e])=>e).join(` `)),console.error())}{await i(o(e.root,`tsconfig.json`),JSON.stringify({extends:`./${l.libDir}/tsconfig.json`},void 0,2),{},{overwrite:!1}),await i(t.lib(`../tsconfig.json`),JSON.stringify(x({dependencies:r,devDependencies:a}),void 0,2),{}),await i(t.src(`tsconfig.json`),JSON.stringify({extends:`../../${l.libDir}/${e.name}/tsconfig.json`},void 0,2),{},{overwrite:!1});let n=x({dependencies:r,devDependencies:a},e.name),s={},c=new Set(n.compilerOptions.types||[]);for(let{meta:t}of e.config.generators||[]){t.jsx&&(s.jsx=t.jsx),t.jsxImportSource&&(s.jsxImportSource=t.jsxImportSource);for(let e of t.types||[])c.add(e)}await i(t.lib(`tsconfig.json`),JSON.stringify({...n,compilerOptions:{...n.compilerOptions,...s,types:[...c.values()]}},void 0,2),{})}for(let[e,n]of[[`env.d.ts`,_],[`global.d.ts`,y]])await i(t.lib(`../${e}`),n,{});await i(t.lib(`../.gitignore`),v,{},{overwrite:!1});for(let[e,n]of[[`ssg.ts`,`export default [];`]])await i(t.lib(e),n,{})},C=async n=>{let{renderToFile:i}=r({helpers:{...d({origin:`lib`}),...u()},partials:{routeMapperPartial:h}});await i(t.libCore(`routes.ts`),m,{apiRoutes:n.flatMap(({kind:e,entry:t})=>e===`apiRoute`?[t]:[]),pageRoutes:n.flatMap(({kind:e,entry:t})=>e===`pageRoute`?[t]:[])});for(let[n,r]of[[`config.ts`,f],[`types.ts`,g],[`index.ts`,p]])await i(t.libCore(n),r,e);for(let{kind:e,entry:r}of n)e===`apiRoute`&&await i(t.libApi(a(r.file),`schemas.ts`),b,{route:r},{overwrite:!1})};return{start:S,watch:C,build:C}}),C=e({meta:{name:`Core`},dependencies:{\"path-to-regexp\":d.devDependencies[`path-to-regexp`]},factory:S});export{C as default};\n//# sourceMappingURL=index.js.map"],"mappings":"sVAAsV,IAAI,EAAE,CAAC,KAAK,SAAS,QAAQ,CAAC,EAAE,KAAK,0BAA0B,QAAQ,QAAQ,OAAO,WAAW,QAAQ,MAAM,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,mBAAmB,QAAQ,gBAAgB,CAAC,EAAE,QAAQ,CAAC,MAAM,sBAAsB,EAAE,aAAa,CAAC,gBAAgB,cAAc,eAAe,cAAc,OAAO,QAAQ,EAAE,gBAAgB,CAAC,gBAAgB,SAAS,iBAAiB,QAAQ,CAAC,EAAE,EAAE;;EAE9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