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 44 lines 1.2 kB view raw
1import type { AnalysisContext, NodeName, Ref } from '@hey-api/codegen-core'; 2import { ref } from '@hey-api/codegen-core'; 3 4import { py } from '../../py-compiler'; 5import type { MaybePyDsl } from '../base'; 6import { PyDsl } from '../base'; 7import { LayoutMixin } from '../mixins/layout'; 8 9export type TupleElement = NodeName | MaybePyDsl<py.Expression>; 10 11const Mixed = LayoutMixin(PyDsl<py.TupleExpression>); 12 13export class TuplePyDsl extends Mixed { 14 readonly '~dsl' = 'TuplePyDsl'; 15 16 protected _elements: Array<Ref<TupleElement>> = []; 17 18 constructor(...elements: Array<TupleElement>) { 19 super(); 20 this._elements = elements.map((element) => ref(element)); 21 } 22 23 override analyze(ctx: AnalysisContext): void { 24 super.analyze(ctx); 25 for (const el of this._elements) { 26 ctx.analyze(el); 27 } 28 } 29 30 element(expr: TupleElement): this { 31 this._elements.push(ref(expr)); 32 return this; 33 } 34 35 elements(...exprs: ReadonlyArray<TupleElement>): this { 36 this._elements.push(...exprs.map((expr) => ref(expr))); 37 return this; 38 } 39 40 override toAst() { 41 const astElements = this._elements.map((el) => this.$node(el)); 42 return py.factory.createTupleExpression(astElements); 43 } 44}