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 298 lines 9.3 kB view raw
1import type { IR, Plugin, SchemaVisitorContext, SchemaWithType, Walker } from '@hey-api/shared'; 2 3import type { DollarPyDsl } from '../../py-dsl'; 4import type { PydanticField, PydanticFinal, PydanticResult, PydanticType } from './shared/types'; 5import type { PydanticPlugin } from './types'; 6 7export type PydanticResolvers = Plugin.Resolvers<{ 8 /** 9 * Resolver for array schemas. 10 * 11 * Allows customization of how array types are rendered. 12 * 13 * Returning `undefined` will execute the default resolver logic. 14 */ 15 array?: (ctx: ArrayResolverContext) => PydanticType | undefined; 16 /** 17 * Resolver for boolean schemas. 18 * 19 * Allows customization of how boolean types are rendered. 20 * 21 * Returning `undefined` will execute the default resolver logic. 22 */ 23 boolean?: (ctx: BooleanResolverContext) => PydanticType | undefined; 24 /** 25 * Resolver for enum schemas. 26 * 27 * Allows customization of how enum types are rendered. 28 * 29 * Returning `undefined` will execute the default resolver logic. 30 */ 31 enum?: (ctx: EnumResolverContext) => PydanticType | undefined; 32 /** 33 * Resolver for intersection schemas. 34 * 35 * Allows customization of how intersection types are rendered. 36 * 37 * Returning `undefined` will execute the default resolver logic. 38 */ 39 intersection?: (ctx: IntersectionResolverContext) => PydanticType | undefined; 40 /** 41 * Resolver for never schemas. 42 * 43 * Allows customization of how never types are rendered. 44 * 45 * Returning `undefined` will execute the default resolver logic. 46 */ 47 never?: (ctx: NeverResolverContext) => PydanticType | undefined; 48 /** 49 * Resolver for null schemas. 50 * 51 * Allows customization of how null types are rendered. 52 * 53 * Returning `undefined` will execute the default resolver logic. 54 */ 55 null?: (ctx: NullResolverContext) => PydanticType | undefined; 56 /** 57 * Resolver for number schemas. 58 * 59 * Allows customization of how number types are rendered. 60 * 61 * Returning `undefined` will execute the default resolver logic. 62 */ 63 number?: (ctx: NumberResolverContext) => PydanticType | undefined; 64 /** 65 * Resolver for object schemas. 66 * 67 * Allows customization of how object types are rendered. 68 * 69 * Returning `undefined` will execute the default resolver logic. 70 */ 71 object?: ( 72 ctx: ObjectResolverContext, 73 ) => (PydanticType & { fields?: Array<PydanticField> }) | undefined; 74 /** 75 * Resolver for string schemas. 76 * 77 * Allows customization of how string types are rendered. 78 * 79 * Returning `undefined` will execute the default resolver logic. 80 */ 81 string?: (ctx: StringResolverContext) => PydanticType | undefined; 82 /** 83 * Resolver for tuple schemas. 84 * 85 * Allows customization of how tuple types are rendered. 86 * 87 * Returning `undefined` will execute the default resolver logic. 88 */ 89 tuple?: (ctx: TupleResolverContext) => PydanticType | undefined; 90 /** 91 * Resolver for undefined schemas. 92 * 93 * Allows customization of how undefined types are rendered. 94 * 95 * Returning `undefined` will execute the default resolver logic. 96 */ 97 undefined?: (ctx: UndefinedResolverContext) => PydanticType | undefined; 98 /** 99 * Resolver for union schemas. 100 * 101 * Allows customization of how union types are rendered. 102 * 103 * Returning `undefined` will execute the default resolver logic. 104 */ 105 union?: (ctx: UnionResolverContext) => PydanticType | undefined; 106 /** 107 * Resolver for unknown schemas. 108 * 109 * Allows customization of how unknown types are rendered. 110 * 111 * Returning `undefined` will execute the default resolver logic. 112 */ 113 unknown?: (ctx: UnknownResolverContext) => PydanticType | undefined; 114 /** 115 * Resolver for void schemas. 116 * 117 * Allows customization of how void types are rendered. 118 * 119 * Returning `undefined` will execute the default resolver logic. 120 */ 121 void?: (ctx: VoidResolverContext) => PydanticType | undefined; 122}>; 123 124interface BaseContext extends DollarPyDsl { 125 /** The plugin instance. */ 126 plugin: PydanticPlugin['Instance']; 127} 128 129export interface ArrayResolverContext extends BaseContext { 130 applyModifiers: (result: PydanticResult, opts?: { optional?: boolean }) => PydanticFinal; 131 childResults: Array<PydanticResult>; 132 /** 133 * Nodes used to build different parts of the result. 134 */ 135 nodes: { 136 base: (ctx: ArrayResolverContext) => PydanticType; 137 maxLength: (ctx: ArrayResolverContext) => PydanticType | undefined; 138 minLength: (ctx: ArrayResolverContext) => PydanticType | undefined; 139 }; 140 schema: SchemaWithType<'array'>; 141 walk: Walker<PydanticResult, PydanticPlugin['Instance']>; 142 walkerCtx: SchemaVisitorContext<PydanticPlugin['Instance']>; 143} 144 145export interface BooleanResolverContext extends BaseContext { 146 /** 147 * Nodes used to build different parts of the result. 148 */ 149 nodes: { 150 base: (ctx: BooleanResolverContext) => PydanticType; 151 const: (ctx: BooleanResolverContext) => PydanticType | undefined; 152 }; 153 schema: SchemaWithType<'boolean'>; 154} 155 156export interface EnumResolverContext extends BaseContext { 157 /** 158 * Nodes used to build different parts of the result. 159 */ 160 nodes: { 161 base: (ctx: EnumResolverContext) => PydanticType; 162 items: (ctx: EnumResolverContext) => { 163 enumMembers: Required<PydanticFinal>['enumMembers']; 164 isNullable: boolean; 165 }; 166 }; 167 schema: SchemaWithType<'enum'>; 168} 169 170export interface IntersectionResolverContext extends BaseContext { 171 applyModifiers: (result: PydanticResult, opts?: { optional?: boolean }) => PydanticFinal; 172 childResults: Array<PydanticResult>; 173 /** 174 * Nodes used to build different parts of the result. 175 */ 176 nodes: { 177 base: (ctx: IntersectionResolverContext) => PydanticType; 178 }; 179 parentSchema: IR.SchemaObject; 180 schema: IR.SchemaObject; 181} 182 183export interface NeverResolverContext extends BaseContext { 184 /** 185 * Nodes used to build different parts of the result. 186 */ 187 nodes: { 188 base: (ctx: NeverResolverContext) => PydanticType; 189 }; 190 schema: SchemaWithType<'never'>; 191} 192 193export interface NullResolverContext extends BaseContext { 194 /** 195 * Nodes used to build different parts of the result. 196 */ 197 nodes: { 198 base: (ctx: NullResolverContext) => PydanticType; 199 }; 200 schema: SchemaWithType<'null'>; 201} 202 203export interface NumberResolverContext extends BaseContext { 204 /** 205 * Nodes used to build different parts of the result. 206 */ 207 nodes: { 208 base: (ctx: NumberResolverContext) => PydanticType; 209 const: (ctx: NumberResolverContext) => PydanticType | undefined; 210 }; 211 schema: SchemaWithType<'integer' | 'number'>; 212} 213 214export interface ObjectResolverContext extends BaseContext { 215 _childResults: Array<PydanticResult>; 216 applyModifiers: (result: PydanticResult, opts: { optional?: boolean }) => PydanticFinal; 217 /** 218 * Nodes used to build different parts of the result. 219 */ 220 nodes: { 221 additionalProperties: (ctx: ObjectResolverContext) => PydanticType | null | undefined; 222 base: (ctx: ObjectResolverContext) => PydanticType & { fields?: Array<PydanticField> }; 223 fields: (ctx: ObjectResolverContext) => Array<PydanticField>; 224 }; 225 schema: SchemaWithType<'object'>; 226 walk: Walker<PydanticResult, PydanticPlugin['Instance']>; 227 walkerCtx: SchemaVisitorContext<PydanticPlugin['Instance']>; 228} 229 230export interface StringResolverContext extends BaseContext { 231 /** 232 * Nodes used to build different parts of the result. 233 */ 234 nodes: { 235 base: (ctx: StringResolverContext) => PydanticType; 236 const: (ctx: StringResolverContext) => PydanticType | undefined; 237 }; 238 schema: SchemaWithType<'string'>; 239} 240 241export interface TupleResolverContext extends BaseContext { 242 applyModifiers: (result: PydanticResult, opts?: { optional?: boolean }) => PydanticFinal; 243 childResults: Array<PydanticResult>; 244 /** 245 * Nodes used to build different parts of the result. 246 */ 247 nodes: { 248 base: (ctx: TupleResolverContext) => PydanticType; 249 const: (ctx: TupleResolverContext) => PydanticType | undefined; 250 }; 251 schema: SchemaWithType<'tuple'>; 252 walk: Walker<PydanticResult, PydanticPlugin['Instance']>; 253 walkerCtx: SchemaVisitorContext<PydanticPlugin['Instance']>; 254} 255 256export interface UndefinedResolverContext extends BaseContext { 257 /** 258 * Nodes used to build different parts of the result. 259 */ 260 nodes: { 261 base: (ctx: UndefinedResolverContext) => PydanticType; 262 }; 263 schema: SchemaWithType<'undefined'>; 264} 265 266export interface UnionResolverContext extends BaseContext { 267 applyModifiers: (result: PydanticResult, opts?: { optional?: boolean }) => PydanticFinal; 268 childResults: Array<PydanticResult>; 269 /** 270 * Nodes used to build different parts of the result. 271 */ 272 nodes: { 273 base: (ctx: UnionResolverContext) => PydanticType; 274 }; 275 parentSchema: IR.SchemaObject; 276 schema: IR.SchemaObject; 277 schemas: ReadonlyArray<IR.SchemaObject>; 278} 279 280export interface UnknownResolverContext extends BaseContext { 281 /** 282 * Nodes used to build different parts of the result. 283 */ 284 nodes: { 285 base: (ctx: UnknownResolverContext) => PydanticType; 286 }; 287 schema: SchemaWithType<'unknown'>; 288} 289 290export interface VoidResolverContext extends BaseContext { 291 /** 292 * Nodes used to build different parts of the result. 293 */ 294 nodes: { 295 base: (ctx: VoidResolverContext) => PydanticType; 296 }; 297 schema: SchemaWithType<'void'>; 298}