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 36 lines 1.0 kB view raw
1import type { AnalysisContext, Node, NodeName, Ref } from '@hey-api/codegen-core'; 2import { ref } from '@hey-api/codegen-core'; 3 4import type { py } from '../../py-compiler'; 5import type { PyDsl } from '../base'; 6import type { BaseCtor, MixinCtor } from './types'; 7 8export type ValueExpr = NodeName | PyDsl<py.Expression>; 9 10export interface ValueMethods extends Node { 11 $value(): py.Expression | undefined; 12 /** Sets the initializer expression (e.g., `= expr`). */ 13 assign(expr: ValueExpr): this; 14} 15 16export function ValueMixin<T extends py.Node, TBase extends BaseCtor<T>>(Base: TBase) { 17 abstract class Value extends Base { 18 protected value?: Ref<ValueExpr>; 19 20 override analyze(ctx: AnalysisContext): void { 21 super.analyze(ctx); 22 ctx.analyze(this.value); 23 } 24 25 protected assign(expr: ValueExpr): this { 26 this.value = ref(expr); 27 return this; 28 } 29 30 protected $value(): py.Expression | undefined { 31 return this.$node(this.value); 32 } 33 } 34 35 return Value as unknown as MixinCtor<TBase, ValueMethods>; 36}