@kernlang/python 3.5.2

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 (63) hide show
  1. package/LICENSE +678 -0
  2. package/README.md +26 -0
  3. package/dist/codegen-body-python.d.ts +152 -0
  4. package/dist/codegen-body-python.js +1648 -0
  5. package/dist/codegen-body-python.js.map +1 -0
  6. package/dist/codegen-helpers.d.ts +21 -0
  7. package/dist/codegen-helpers.js +352 -0
  8. package/dist/codegen-helpers.js.map +1 -0
  9. package/dist/codegen-python.d.ts +17 -0
  10. package/dist/codegen-python.js +106 -0
  11. package/dist/codegen-python.js.map +1 -0
  12. package/dist/fastapi-middleware.d.ts +8 -0
  13. package/dist/fastapi-middleware.js +87 -0
  14. package/dist/fastapi-middleware.js.map +1 -0
  15. package/dist/fastapi-portable.d.ts +9 -0
  16. package/dist/fastapi-portable.js +295 -0
  17. package/dist/fastapi-portable.js.map +1 -0
  18. package/dist/fastapi-raw-handler.d.ts +28 -0
  19. package/dist/fastapi-raw-handler.js +282 -0
  20. package/dist/fastapi-raw-handler.js.map +1 -0
  21. package/dist/fastapi-response.d.ts +13 -0
  22. package/dist/fastapi-response.js +150 -0
  23. package/dist/fastapi-response.js.map +1 -0
  24. package/dist/fastapi-route.d.ts +12 -0
  25. package/dist/fastapi-route.js +629 -0
  26. package/dist/fastapi-route.js.map +1 -0
  27. package/dist/fastapi-types.d.ts +39 -0
  28. package/dist/fastapi-types.js +5 -0
  29. package/dist/fastapi-types.js.map +1 -0
  30. package/dist/fastapi-utils.d.ts +16 -0
  31. package/dist/fastapi-utils.js +99 -0
  32. package/dist/fastapi-utils.js.map +1 -0
  33. package/dist/fastapi-websocket.d.ts +6 -0
  34. package/dist/fastapi-websocket.js +77 -0
  35. package/dist/fastapi-websocket.js.map +1 -0
  36. package/dist/generators/core.d.ts +23 -0
  37. package/dist/generators/core.js +906 -0
  38. package/dist/generators/core.js.map +1 -0
  39. package/dist/generators/data.d.ts +15 -0
  40. package/dist/generators/data.js +443 -0
  41. package/dist/generators/data.js.map +1 -0
  42. package/dist/generators/ground.d.ts +20 -0
  43. package/dist/generators/ground.js +333 -0
  44. package/dist/generators/ground.js.map +1 -0
  45. package/dist/generators/infra.d.ts +8 -0
  46. package/dist/generators/infra.js +109 -0
  47. package/dist/generators/infra.js.map +1 -0
  48. package/dist/index.d.ts +6 -0
  49. package/dist/index.js +7 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/ir-semantics/python-leg.d.ts +45 -0
  52. package/dist/ir-semantics/python-leg.js +291 -0
  53. package/dist/ir-semantics/python-leg.js.map +1 -0
  54. package/dist/python-stdlib-preamble.d.ts +32 -0
  55. package/dist/python-stdlib-preamble.js +86 -0
  56. package/dist/python-stdlib-preamble.js.map +1 -0
  57. package/dist/transpiler-fastapi.d.ts +8 -0
  58. package/dist/transpiler-fastapi.js +593 -0
  59. package/dist/transpiler-fastapi.js.map +1 -0
  60. package/dist/type-map.d.ts +14 -0
  61. package/dist/type-map.js +288 -0
  62. package/dist/type-map.js.map +1 -0
  63. package/package.json +37 -0
@@ -0,0 +1,593 @@
1
+ /**
2
+ * @kernlang/python — FastAPI Python backend transpiler
3
+ *
4
+ * IR → Python/FastAPI multi-file output.
5
+ * Blueprint: transpiler-express.ts — same IR nodes, same multi-file pattern, Python output.
6
+ */
7
+ import { accountNode, buildDiagnostics, countTokens, getChildren, getFirstChild, getProps, serializeIR, } from '@kernlang/core';
8
+ import { dirname, resolve } from 'path';
9
+ import { generatePythonCoreNode } from './codegen-python.js';
10
+ import { buildCorsMiddlewareLine, resolveMiddlewareUsage } from './fastapi-middleware.js';
11
+ import { buildRouteArtifact } from './fastapi-route.js';
12
+ import { analyzeRouteCapabilities, findServerNode } from './fastapi-utils.js';
13
+ import { buildWebSocketArtifact } from './fastapi-websocket.js';
14
+ import { buildPythonStdlibPreamble } from './python-stdlib-preamble.js';
15
+ const KERN_GENERATED_HEADER_MARKER = '@generated by kern';
16
+ function relativePythonModuleSpec(sourceModulePath, targetModulePath) {
17
+ const sourceParts = sourceModulePath.split('.').filter(Boolean);
18
+ const sourcePackage = sourceParts.slice(0, -1);
19
+ const targetParts = targetModulePath.split('.').filter(Boolean);
20
+ let common = 0;
21
+ while (common < sourcePackage.length &&
22
+ common < targetParts.length &&
23
+ sourcePackage[common] === targetParts[common]) {
24
+ common++;
25
+ }
26
+ if (common === 0)
27
+ return targetModulePath;
28
+ const upLevels = sourcePackage.length - common;
29
+ const relativePrefix = '.'.repeat(upLevels + 1);
30
+ return `${relativePrefix}${targetParts.slice(common).join('.')}`;
31
+ }
32
+ function generatedArtifactModuleSpecifier(sourceModulePath, artifactParts) {
33
+ if (!sourceModulePath)
34
+ return artifactParts.join('.');
35
+ const sourceParts = sourceModulePath.split('.').filter(Boolean);
36
+ const sourcePackage = sourceParts.slice(0, -1);
37
+ const targetModulePath = [...sourcePackage, ...artifactParts].join('.');
38
+ return relativePythonModuleSpec(sourceModulePath, targetModulePath);
39
+ }
40
+ function plannedSourceFile(rawTargetFile, moduleMap) {
41
+ if (!moduleMap)
42
+ return undefined;
43
+ for (const candidate of [rawTargetFile, `${rawTargetFile}.kern`, `${rawTargetFile}.ir`]) {
44
+ if (moduleMap[candidate])
45
+ return candidate;
46
+ }
47
+ return undefined;
48
+ }
49
+ function plannedPythonModuleSpecifier(rawPath, sourceFile, moduleNameByFile, modulePathByFile) {
50
+ if (!sourceFile || (!moduleNameByFile && !modulePathByFile))
51
+ return undefined;
52
+ if (!rawPath.startsWith('./') && !rawPath.startsWith('../'))
53
+ return undefined;
54
+ const targetFile = resolve(dirname(sourceFile), rawPath);
55
+ const targetSourceFile = plannedSourceFile(targetFile, modulePathByFile);
56
+ const sourceModulePath = modulePathByFile?.[sourceFile];
57
+ const targetModulePath = targetSourceFile ? modulePathByFile?.[targetSourceFile] : undefined;
58
+ if (sourceModulePath && targetModulePath)
59
+ return relativePythonModuleSpec(sourceModulePath, targetModulePath);
60
+ const targetModuleNameFile = plannedSourceFile(targetFile, moduleNameByFile);
61
+ const plannedModuleName = targetModuleNameFile ? moduleNameByFile?.[targetModuleNameFile] : undefined;
62
+ if (!plannedModuleName)
63
+ return undefined;
64
+ const withoutExt = rawPath.replace(/\.(kern|py|js|ts)$/u, '');
65
+ const pathParts = withoutExt.split('/').filter((part) => part.length > 0 && part !== '.');
66
+ const relativePrefix = pathParts.filter((part) => part === '..').length;
67
+ const importParts = pathParts.filter((part) => part !== '..');
68
+ if (importParts.length === 0)
69
+ return undefined;
70
+ const moduleParts = importParts.flatMap((part, index) => index === importParts.length - 1
71
+ ? [plannedModuleName]
72
+ : part
73
+ .split('.')
74
+ .filter(Boolean)
75
+ .map((segment) => segment.replace(/-/gu, '_')));
76
+ return `${'.'.repeat(relativePrefix + 1)}${moduleParts.join('.')}`;
77
+ }
78
+ // ── Main transpiler ──────────────────────────────────────────────────────
79
+ export function transpileFastAPI(root, _config) {
80
+ const sourceMap = [];
81
+ const accounted = new Map();
82
+ const middlewareArtifacts = new Map();
83
+ const serverNode = findServerNode(root) || root;
84
+ accountNode(accounted, root, 'consumed', 'parse root');
85
+ if (serverNode !== root)
86
+ accountNode(accounted, serverNode, 'consumed', 'server container');
87
+ const serverProps = getProps(serverNode);
88
+ const serverName = String(serverProps.name || 'KernFastAPIServer');
89
+ const port = String(serverProps.port || '8000');
90
+ const serverMiddlewares = getChildren(serverNode, 'middleware');
91
+ for (const mw of serverMiddlewares)
92
+ accountNode(accounted, mw, 'consumed', 'server middleware', true);
93
+ const routeNodes = getChildren(serverNode, 'route');
94
+ for (const rn of routeNodes)
95
+ accountNode(accounted, rn, 'consumed', 'route artifact', true);
96
+ const websocketNodes = getChildren(serverNode, 'websocket');
97
+ for (const ws of websocketNodes)
98
+ accountNode(accounted, ws, 'consumed', 'websocket handler', true);
99
+ const hasHealthRoute = routeNodes.some((routeNode) => {
100
+ const props = getProps(routeNode);
101
+ return String(props.path || '/') === '/health' && String(props.method || 'get').toLowerCase() === 'get';
102
+ });
103
+ const isStrict = !_config || (_config.fastapi?.security ?? 'strict') === 'strict';
104
+ const corsEnabled = _config?.fastapi?.cors ?? false;
105
+ const gzipEnabled = _config?.fastapi?.gzip ?? false;
106
+ const uvicornHost = _config?.fastapi?.uvicorn?.host ?? '127.0.0.1';
107
+ const uvicornReload = isStrict ? false : (_config?.fastapi?.uvicorn?.reload ?? false);
108
+ const uvicornWorkers = _config?.fastapi?.uvicorn?.workers;
109
+ const uvicornNeedsImportString = uvicornReload || (uvicornWorkers !== undefined && uvicornWorkers > 1);
110
+ const fastApiConfig = _config;
111
+ const alembicEntryModules = fastApiConfig?.fastapi?.entryModules ?? [];
112
+ const sourceModulePath = fastApiConfig?.fastapi?.sourceFile && fastApiConfig.fastapi.modulePathByFile
113
+ ? fastApiConfig.fastapi.modulePathByFile[fastApiConfig.fastapi.sourceFile]
114
+ : undefined;
115
+ const sourcePackageDepth = sourceModulePath ? Math.max(0, sourceModulePath.split('.').filter(Boolean).length - 1) : 0;
116
+ const artifactModuleSpec = (...artifactParts) => generatedArtifactModuleSpecifier(sourceModulePath, artifactParts);
117
+ const pythonCodegenOptions = {
118
+ resolveKernModuleSpec: (rawPath, _node) => plannedPythonModuleSpecifier(rawPath, fastApiConfig?.fastapi?.sourceFile, fastApiConfig?.fastapi?.moduleNameByFile, fastApiConfig?.fastapi?.modulePathByFile),
119
+ };
120
+ // Collect top-level core language nodes (type, interface, fn, machine, etc.)
121
+ // Exclude child-only types (field, transition, handler, describe, it, etc.)
122
+ const TOP_LEVEL_CORE = new Set([
123
+ 'type',
124
+ 'interface',
125
+ 'fn',
126
+ 'machine',
127
+ 'error',
128
+ 'module',
129
+ 'config',
130
+ 'store',
131
+ 'test',
132
+ 'event',
133
+ 'import',
134
+ 'extern',
135
+ 'use',
136
+ 'const',
137
+ // Data layer
138
+ 'model',
139
+ 'repository',
140
+ 'cache',
141
+ 'dependency',
142
+ 'service',
143
+ 'union',
144
+ // Backend infrastructure
145
+ 'job',
146
+ 'storage',
147
+ 'email',
148
+ // Ground layer
149
+ 'derive',
150
+ 'transform',
151
+ 'action',
152
+ 'guard',
153
+ 'assume',
154
+ 'invariant',
155
+ 'each',
156
+ 'collect',
157
+ 'branch',
158
+ 'resolve',
159
+ 'expect',
160
+ 'recover',
161
+ ]);
162
+ // Core nodes may live as siblings of server under the parse root, or as server children.
163
+ const rootChildren = root.children || [];
164
+ const serverChildren = serverNode !== root ? serverNode.children || [] : [];
165
+ const coreNodes = [
166
+ ...rootChildren.filter((c) => TOP_LEVEL_CORE.has(c.type)),
167
+ ...serverChildren.filter((c) => TOP_LEVEL_CORE.has(c.type)),
168
+ ];
169
+ // If the root itself is a core node (parser wraps first top-level node as root), include it
170
+ if (TOP_LEVEL_CORE.has(root.type) && root !== serverNode) {
171
+ coreNodes.unshift(root);
172
+ }
173
+ for (const cn of coreNodes)
174
+ accountNode(accounted, cn, 'expressed', 'core artifact', true);
175
+ const serverImports = new Set();
176
+ const middlewareLines = [];
177
+ serverImports.add('from fastapi import FastAPI');
178
+ serverImports.add('from fastapi.responses import JSONResponse');
179
+ serverImports.add('import os');
180
+ if (uvicornNeedsImportString) {
181
+ serverImports.add('import sys');
182
+ serverImports.add('from pathlib import Path');
183
+ }
184
+ if (!isStrict ||
185
+ routeNodes.some((r) => {
186
+ const caps = analyzeRouteCapabilities(r);
187
+ return caps.hasTimer;
188
+ })) {
189
+ serverImports.add('from fastapi import HTTPException');
190
+ }
191
+ if (isStrict) {
192
+ serverImports.add('import logging');
193
+ serverImports.add('from uuid import uuid4');
194
+ }
195
+ serverImports.add('import uvicorn');
196
+ // Config-level cors/gzip
197
+ if (corsEnabled) {
198
+ serverImports.add('from fastapi.middleware.cors import CORSMiddleware');
199
+ middlewareLines.push(buildCorsMiddlewareLine(isStrict));
200
+ }
201
+ if (gzipEnabled) {
202
+ serverImports.add('from fastapi.middleware.gzip import GZipMiddleware');
203
+ middlewareLines.push('app.add_middleware(GZipMiddleware)');
204
+ }
205
+ // IR-level middleware
206
+ for (const middlewareNode of serverMiddlewares) {
207
+ const usage = resolveMiddlewareUsage(middlewareNode, middlewareArtifacts, isStrict, (fileBase) => artifactModuleSpec('middleware', fileBase));
208
+ if (usage.importLine)
209
+ serverImports.add(usage.importLine);
210
+ middlewareLines.push(usage.addLine);
211
+ }
212
+ // Build route artifacts
213
+ const routeArtifacts = routeNodes.map((routeNode, index) => buildRouteArtifact(routeNode, index, sourceMap));
214
+ // Auth: generate auth.py artifact when any route uses auth
215
+ const hasAuth = routeNodes.some((r) => getFirstChild(r, 'auth'));
216
+ let authArtifact = null;
217
+ if (hasAuth) {
218
+ authArtifact = {
219
+ path: 'auth.py',
220
+ content: [
221
+ `from fastapi import Depends, HTTPException`,
222
+ `from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials`,
223
+ `from jose import JWTError, jwt`,
224
+ `import os`,
225
+ ``,
226
+ ...(isStrict
227
+ ? [
228
+ `JWT_SECRET = os.environ.get("JWT_SECRET")`,
229
+ ``,
230
+ `if not JWT_SECRET:`,
231
+ ` raise RuntimeError("JWT_SECRET environment variable is required in strict mode")`,
232
+ ]
233
+ : [`JWT_SECRET = os.environ.get("JWT_SECRET", "change-me-in-production")`]),
234
+ `JWT_ALGORITHM = os.environ.get("JWT_ALGORITHM", "HS256")`,
235
+ ``,
236
+ `security = HTTPBearer()`,
237
+ `security_optional = HTTPBearer(auto_error=False)`,
238
+ ``,
239
+ ``,
240
+ `async def auth_required(`,
241
+ ` credentials: HTTPAuthorizationCredentials = Depends(security),`,
242
+ `) -> dict:`,
243
+ ` try:`,
244
+ ` payload = jwt.decode(credentials.credentials, JWT_SECRET, algorithms=[JWT_ALGORITHM])`,
245
+ ` return payload`,
246
+ ` except JWTError:`,
247
+ ` raise HTTPException(status_code=401, detail="Invalid or expired token")`,
248
+ ``,
249
+ ``,
250
+ `async def auth_optional(`,
251
+ ` credentials: HTTPAuthorizationCredentials | None = Depends(security_optional),`,
252
+ `) -> dict | None:`,
253
+ ` if not credentials:`,
254
+ ` return None`,
255
+ ` try:`,
256
+ ` return jwt.decode(credentials.credentials, JWT_SECRET, algorithms=[JWT_ALGORITHM])`,
257
+ ` except JWTError:`,
258
+ ` return None`,
259
+ ].join('\n'),
260
+ type: 'lib',
261
+ };
262
+ serverImports.add(`from ${artifactModuleSpec('auth')} import auth_required, auth_optional`);
263
+ }
264
+ // Build websocket artifacts
265
+ const wsArtifacts = websocketNodes.map((wsNode, index) => buildWebSocketArtifact(wsNode, index, sourceMap));
266
+ // WebSocket imports
267
+ if (wsArtifacts.length > 0) {
268
+ serverImports.add('from fastapi import WebSocket');
269
+ serverImports.add('from starlette.websockets import WebSocketDisconnect');
270
+ }
271
+ // Route imports
272
+ for (const route of routeArtifacts) {
273
+ serverImports.add(`from ${artifactModuleSpec('routes', route.fileBase)} import router as ${route.routerName}`);
274
+ }
275
+ // WebSocket imports
276
+ for (const ws of wsArtifacts) {
277
+ serverImports.add(`from ${artifactModuleSpec('ws', ws.fileBase)} import ${ws.funcName}`);
278
+ }
279
+ // Collect imports needed by core language nodes
280
+ const coreTypes = new Set(coreNodes.map((n) => n.type));
281
+ const hasExplicitDb = coreNodes.some((n) => n.type === 'dependency' && String(n.props?.kind) === 'database');
282
+ if (coreTypes.has('model')) {
283
+ serverImports.add('from sqlmodel import SQLModel, Field, Relationship');
284
+ // Implicit DB connection: add engine/session imports when models exist but no explicit database dependency
285
+ if (!hasExplicitDb) {
286
+ serverImports.add('import os');
287
+ serverImports.add('from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession');
288
+ serverImports.add('from sqlalchemy.orm import sessionmaker');
289
+ }
290
+ }
291
+ if (coreTypes.has('union')) {
292
+ serverImports.add('from pydantic import BaseModel');
293
+ serverImports.add('from typing import Literal, Union');
294
+ }
295
+ if (coreTypes.has('repository')) {
296
+ serverImports.add('from sqlalchemy.ext.asyncio import AsyncSession');
297
+ }
298
+ if (coreNodes.some(usesFunctionTypeSyntax)) {
299
+ serverImports.add('from typing import Callable');
300
+ }
301
+ // Scan model columns for type-specific imports
302
+ for (const node of coreNodes) {
303
+ if (node.type === 'model') {
304
+ for (const col of getChildren(node, 'column')) {
305
+ const colType = col.props?.type || '';
306
+ if (colType === 'uuid')
307
+ serverImports.add('from uuid import UUID');
308
+ if (['date', 'datetime', 'timestamp', 'Timestamp'].includes(colType))
309
+ serverImports.add('from datetime import date, datetime');
310
+ if (['decimal', 'Money'].includes(colType))
311
+ serverImports.add('from decimal import Decimal');
312
+ if (colType === 'json')
313
+ serverImports.add('from typing import Any');
314
+ }
315
+ }
316
+ }
317
+ // ── Slice 4 follow-up — Python stdlib preamble for compact-form
318
+ // `Result<T, E>` / `Option<T>` references. The preamble's imports
319
+ // merge into the existing FastAPI imports; the body lines land
320
+ // between the imports and the first core artifact so generated fn
321
+ // signatures (`def parse_user(...) -> Result[User, ParseError]`)
322
+ // have the type aliases in scope.
323
+ const stdlibPreamble = buildPythonStdlibPreamble(root);
324
+ for (const imp of stdlibPreamble.imports) {
325
+ serverImports.add(imp);
326
+ }
327
+ // ── Generate main.py ──────────────────────────────────────────────────
328
+ const lines = [];
329
+ // Imports
330
+ for (const imp of [...serverImports].sort()) {
331
+ lines.push(imp);
332
+ }
333
+ lines.push('');
334
+ // Stdlib preamble — emitted before user-declared core nodes so any
335
+ // `def parse_user(...) -> Result[...]` annotation can resolve.
336
+ if (stdlibPreamble.lines.length > 0) {
337
+ lines.push('');
338
+ lines.push(...stdlibPreamble.lines);
339
+ }
340
+ // Core language nodes (models, types, etc.)
341
+ if (coreNodes.length > 0) {
342
+ lines.push('');
343
+ for (const node of coreNodes) {
344
+ const coreLines = generatePythonCoreNode(node, pythonCodegenOptions);
345
+ if (coreLines.length > 0) {
346
+ lines.push(...coreLines);
347
+ lines.push('');
348
+ }
349
+ }
350
+ }
351
+ // Implicit DB connection boilerplate (when models exist but no explicit database dependency)
352
+ if (coreTypes.has('model') && !hasExplicitDb) {
353
+ lines.push('# Database connection');
354
+ lines.push('DATABASE_URL = os.environ.get("DATABASE_URL", "sqlite+aiosqlite:///./app.db")');
355
+ lines.push('engine = create_async_engine(DATABASE_URL, echo=False)');
356
+ lines.push('async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)');
357
+ lines.push('');
358
+ lines.push('');
359
+ lines.push('async def get_db():');
360
+ lines.push(' async with async_session() as session:');
361
+ lines.push(' yield session');
362
+ lines.push('');
363
+ lines.push('');
364
+ lines.push('async def init_db():');
365
+ lines.push(' async with engine.begin() as conn:');
366
+ lines.push(' await conn.run_sync(SQLModel.metadata.create_all)');
367
+ lines.push('');
368
+ }
369
+ // App instantiation
370
+ lines.push(`app = FastAPI(title="${serverName}")`);
371
+ lines.push('');
372
+ // DB startup event
373
+ if (coreTypes.has('model') && !hasExplicitDb) {
374
+ lines.push('');
375
+ lines.push('@app.on_event("startup")');
376
+ lines.push('async def startup():');
377
+ lines.push(' await init_db()');
378
+ lines.push('');
379
+ }
380
+ // Request ID middleware (strict mode)
381
+ if (isStrict) {
382
+ lines.push('');
383
+ lines.push('@app.middleware("http")');
384
+ lines.push('async def add_request_id(request, call_next):');
385
+ lines.push(' request_id = str(uuid4())');
386
+ lines.push(' request.state.request_id = request_id');
387
+ lines.push(' response = await call_next(request)');
388
+ lines.push(' response.headers["X-Request-ID"] = request_id');
389
+ lines.push(' return response');
390
+ lines.push('');
391
+ }
392
+ // Middleware
393
+ for (const mLine of middlewareLines) {
394
+ lines.push(mLine);
395
+ }
396
+ if (middlewareLines.length > 0) {
397
+ lines.push('');
398
+ }
399
+ // Health check — before user routes so it can't be shadowed by catch-all
400
+ if (isStrict && !hasHealthRoute) {
401
+ lines.push('@app.get("/health")');
402
+ lines.push('async def health_check():');
403
+ lines.push(' return {"status": "ok"}');
404
+ lines.push('');
405
+ }
406
+ // Router includes
407
+ for (const route of routeArtifacts) {
408
+ lines.push(`app.include_router(${route.routerName})`);
409
+ }
410
+ if (routeArtifacts.length > 0) {
411
+ lines.push('');
412
+ }
413
+ // WebSocket route decorators
414
+ for (const ws of wsArtifacts) {
415
+ lines.push(`app.websocket("${ws.wsPath}")(${ws.funcName})`);
416
+ }
417
+ if (wsArtifacts.length > 0) {
418
+ lines.push('');
419
+ }
420
+ // Error handlers
421
+ if (isStrict) {
422
+ lines.push('');
423
+ lines.push('@app.exception_handler(Exception)');
424
+ lines.push('async def global_exception_handler(request, exc):');
425
+ lines.push(' logging.exception("Unhandled exception")');
426
+ lines.push(' return JSONResponse(status_code=500, content={"error": "Internal Server Error"})');
427
+ }
428
+ else {
429
+ lines.push('');
430
+ lines.push('@app.exception_handler(Exception)');
431
+ lines.push('async def global_exception_handler(request, exc):');
432
+ lines.push(' return JSONResponse(status_code=500, content={"error": str(exc)})');
433
+ }
434
+ lines.push('');
435
+ lines.push('');
436
+ lines.push('if __name__ == "__main__":');
437
+ if (uvicornNeedsImportString) {
438
+ if (sourceModulePath && sourcePackageDepth > 0) {
439
+ lines.push(` app_dir = str(Path(__file__).resolve().parents[${sourcePackageDepth}])`);
440
+ lines.push(' if app_dir not in sys.path:');
441
+ lines.push(' sys.path.insert(0, app_dir)');
442
+ lines.push(` uvicorn_app = "${sourceModulePath}:app"`);
443
+ }
444
+ else {
445
+ lines.push(' script_dir = str(Path(__file__).resolve().parent)');
446
+ lines.push(' if script_dir not in sys.path:');
447
+ lines.push(' sys.path.insert(0, script_dir)');
448
+ lines.push(' uvicorn_app = f"{Path(__file__).stem}:app"');
449
+ lines.push(' app_dir = script_dir');
450
+ }
451
+ }
452
+ const uvicornTarget = uvicornNeedsImportString ? 'uvicorn_app' : 'app';
453
+ const uvicornOpts = [uvicornTarget, `host=os.environ.get("HOST", "${uvicornHost}")`, `port=${port}`];
454
+ if (uvicornReload)
455
+ uvicornOpts.push('reload=True');
456
+ if (uvicornWorkers && uvicornWorkers > 1)
457
+ uvicornOpts.push(`workers=${uvicornWorkers}`);
458
+ if (uvicornNeedsImportString) {
459
+ uvicornOpts.push(sourceModulePath && sourcePackageDepth > 0 ? 'app_dir=app_dir' : 'app_dir=script_dir');
460
+ }
461
+ lines.push(` uvicorn.run(${uvicornOpts.join(', ')})`);
462
+ // ── Assemble result ────────────────────────────────────────────────────
463
+ sourceMap.unshift({
464
+ irLine: serverNode.loc?.line || root.loc?.line || 0,
465
+ irCol: serverNode.loc?.col || root.loc?.col || 1,
466
+ outLine: 1,
467
+ outCol: 1,
468
+ });
469
+ // Alembic migration scaffolding when models exist
470
+ const alembicArtifacts = [];
471
+ if (coreTypes.has('model')) {
472
+ alembicArtifacts.push({
473
+ path: 'alembic.ini',
474
+ content: [
475
+ '# Generated by KERN. Run migrations:',
476
+ '# alembic revision --autogenerate -m "init"',
477
+ '# alembic upgrade head',
478
+ '',
479
+ '[alembic]',
480
+ 'script_location = alembic',
481
+ 'sqlalchemy.url = sqlite:///./app.db',
482
+ ].join('\n'),
483
+ type: 'config',
484
+ });
485
+ alembicArtifacts.push({
486
+ path: 'alembic/env.py',
487
+ content: [
488
+ `import importlib`,
489
+ `import sys`,
490
+ `from logging.config import fileConfig`,
491
+ `from pathlib import Path`,
492
+ `from sqlalchemy import engine_from_config, pool`,
493
+ `from alembic import context`,
494
+ `from sqlmodel import SQLModel`,
495
+ ``,
496
+ `# Import models so metadata is populated`,
497
+ `app_dir = Path(__file__).resolve().parents[1]`,
498
+ `if str(app_dir) not in sys.path:`,
499
+ ` sys.path.insert(0, str(app_dir))`,
500
+ `model_modules = ${JSON.stringify(alembicEntryModules)}`,
501
+ `for module_path in sorted(app_dir.glob("*.py")):`,
502
+ ` if module_path.name == "__init__.py":`,
503
+ ` continue`,
504
+ ` try:`,
505
+ ` with module_path.open(encoding="utf-8") as module_file:`,
506
+ ` header = [next(module_file, "") for _ in range(10)]`,
507
+ ` except (OSError, UnicodeDecodeError):`,
508
+ ` continue`,
509
+ ` if any(${JSON.stringify(KERN_GENERATED_HEADER_MARKER)} in line.lower() for line in header):`,
510
+ ` module_name = module_path.stem`,
511
+ ` if module_name not in model_modules:`,
512
+ ` model_modules.append(module_name)`,
513
+ `for module_name in model_modules:`,
514
+ ` importlib.import_module(module_name)`,
515
+ ``,
516
+ `config = context.config`,
517
+ `if config.config_file_name is not None:`,
518
+ ` fileConfig(config.config_file_name)`,
519
+ ``,
520
+ `target_metadata = SQLModel.metadata`,
521
+ ``,
522
+ ``,
523
+ `def run_migrations_offline():`,
524
+ ` url = config.get_main_option("sqlalchemy.url")`,
525
+ ` context.configure(url=url, target_metadata=target_metadata, literal_binds=True)`,
526
+ ` with context.begin_transaction():`,
527
+ ` context.run_migrations()`,
528
+ ``,
529
+ ``,
530
+ `def run_migrations_online():`,
531
+ ` connectable = engine_from_config(`,
532
+ ` config.get_section(config.config_ini_section, {}),`,
533
+ ` prefix="sqlalchemy.",`,
534
+ ` poolclass=pool.NullPool,`,
535
+ ` )`,
536
+ ` with connectable.connect() as connection:`,
537
+ ` context.configure(connection=connection, target_metadata=target_metadata)`,
538
+ ` with context.begin_transaction():`,
539
+ ` context.run_migrations()`,
540
+ ``,
541
+ ``,
542
+ `if context.is_offline_mode():`,
543
+ ` run_migrations_offline()`,
544
+ `else:`,
545
+ ` run_migrations_online()`,
546
+ ].join('\n'),
547
+ type: 'config',
548
+ });
549
+ }
550
+ const packageArtifacts = [
551
+ ...(routeArtifacts.length > 0
552
+ ? [{ path: 'routes/__init__.py', content: '# Generated route package marker.', type: 'lib' }]
553
+ : []),
554
+ ...(wsArtifacts.length > 0
555
+ ? [{ path: 'ws/__init__.py', content: '# Generated websocket package marker.', type: 'lib' }]
556
+ : []),
557
+ ...(middlewareArtifacts.size > 0
558
+ ? [{ path: 'middleware/__init__.py', content: '# Generated middleware package marker.', type: 'lib' }]
559
+ : []),
560
+ ];
561
+ const artifacts = [
562
+ ...routeArtifacts.map((r) => r.artifact),
563
+ ...wsArtifacts.map((w) => w.artifact),
564
+ ...[...middlewareArtifacts.values()].map((m) => m.artifact),
565
+ ...(authArtifact ? [authArtifact] : []),
566
+ ...alembicArtifacts,
567
+ ...packageArtifacts,
568
+ ];
569
+ const output = lines.join('\n');
570
+ const irText = serializeIR(root);
571
+ const allText = [output, ...artifacts.map((a) => a.content)].join('\n');
572
+ const irTokenCount = countTokens(irText);
573
+ const tsTokenCount = countTokens(allText);
574
+ const tokenReduction = Math.round((1 - irTokenCount / tsTokenCount) * 100);
575
+ return {
576
+ code: output,
577
+ sourceMap,
578
+ irTokenCount,
579
+ tsTokenCount,
580
+ tokenReduction,
581
+ artifacts,
582
+ diagnostics: buildDiagnostics(root, accounted, 'fastapi'),
583
+ };
584
+ }
585
+ function usesFunctionTypeSyntax(node) {
586
+ const typeBearingProps = new Set(['alias', 'type', 'params', 'returns']);
587
+ for (const [key, value] of Object.entries(node.props ?? {})) {
588
+ if (typeBearingProps.has(key) && typeof value === 'string' && value.includes('=>'))
589
+ return true;
590
+ }
591
+ return (node.children ?? []).some(usesFunctionTypeSyntax);
592
+ }
593
+ //# sourceMappingURL=transpiler-fastapi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transpiler-fastapi.js","sourceRoot":"","sources":["../src/transpiler-fastapi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,aAAa,EACb,QAAQ,EACR,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,MAAM,4BAA4B,GAAG,oBAAoB,CAAC;AAW1D,SAAS,wBAAwB,CAAC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AAK,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IAClG,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * TypeScript type strings → Python type strings
3
+ */
4
+ /**
5
+ * Convert a TypeScript type string to a Python type string.
6
+ *
7
+ * Handles: primitives, arrays (T[]), Record<K,V>, Promise<T>, union types,
8
+ * string literal unions ("a"|"b"), T | null → T | None, generics.
9
+ */
10
+ export declare function mapTsTypeToPython(tsType: string): string;
11
+ /** Convert a camelCase or PascalCase identifier to snake_case. */
12
+ export declare function toSnakeCase(name: string): string;
13
+ /** Convert a name to SCREAMING_SNAKE_CASE. */
14
+ export declare function toScreamingSnake(name: string): string;