fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at feat/use-query-options 52 lines 1.5 kB view raw
1import type { AnalysisContext } from '@hey-api/codegen-core'; 2 3import { py } from '../../py-compiler'; 4import { PyDsl } from '../base'; 5 6type ImportName = { alias?: string; name: string }; 7 8const Mixed = PyDsl<py.ImportStatement>; 9 10export class ImportPyDsl extends Mixed { 11 readonly '~dsl' = 'ImportPyDsl'; 12 13 protected isFrom: boolean = true; 14 protected module: string = ''; 15 protected names?: ReadonlyArray<ImportName>; 16 17 constructor(module: string); 18 constructor(module: string, isFrom: boolean); 19 constructor(module: string, names: ReadonlyArray<ImportName>, isFrom: boolean); 20 constructor( 21 module: string, 22 namesOrIsFrom?: ReadonlyArray<ImportName> | boolean, 23 isFrom?: boolean, 24 ) { 25 super(); 26 this.module = module; 27 if (typeof namesOrIsFrom === 'boolean') { 28 this.isFrom = namesOrIsFrom; 29 } else if (Array.isArray(namesOrIsFrom)) { 30 this.names = namesOrIsFrom; 31 this.isFrom = isFrom ?? true; 32 } else { 33 this.isFrom = true; 34 } 35 } 36 37 static from(module: string, names?: ReadonlyArray<ImportName>): ImportPyDsl { 38 return names ? new ImportPyDsl(module, names, true) : new ImportPyDsl(module, true); 39 } 40 41 static direct(module: string): ImportPyDsl { 42 return new ImportPyDsl(module, false); 43 } 44 45 override analyze(_ctx: AnalysisContext): void { 46 super.analyze(_ctx); 47 } 48 49 override toAst() { 50 return py.factory.createImportStatement(this.module, this.names, this.isFrom); 51 } 52}