@azure-tools/typespec-powershell
Version:
An experimental TypeSpec emitter for PowerShell codegen
71 lines (70 loc) • 3.5 kB
TypeScript
import { Model, ModelProperty, Type, Service, Program } from "@typespec/compiler";
import { SdkContext } from "@azure-tools/typespec-client-generator-core";
import { Schema, ObjectSchema, StringSchema, NumberSchema, ConstantSchema } from "@autorest/codemodel";
import { HttpOperation } from "@typespec/http";
export declare const BINARY_TYPE_UNION = "string | Uint8Array | ReadableStream<Uint8Array> | NodeJS.ReadableStream";
export declare const BINARY_AND_FILE_TYPE_UNION: string;
export declare const ANY_SCHEMA = "any_schema";
export declare enum SchemaContext {
/** Schema is used as an input to an operation. */
Input = "input",
/** Schema is used as an output from an operation. */
Output = "output",
/** Schema is used as an exception from an operation. */
Exception = "exception"
}
export declare enum KnownMediaType {
Json = "json",
Xml = "xml",
Form = "form",
Binary = "binary",
MultipartFormData = "multipart/form-data",
Text = "text",
Unknown = "unknown"
}
export interface GetSchemaOptions {
usage?: SchemaContext[];
needRef?: boolean;
relevantProperty?: ModelProperty;
mediaTypes?: KnownMediaType[];
isRequestBody?: boolean;
isParentRequestBody?: boolean;
}
export declare let stringSchemaForEnum: StringSchema | undefined;
export declare let numberSchemaForEnum: NumberSchema | undefined;
export declare let constantSchemaForApiVersion: ConstantSchema | undefined;
export declare const schemaCache: Map<string | Type, Schema>;
export declare const modelSet: Set<Type>;
export declare const delayedModelSet: Set<Type>;
export declare function getSchemaForApiVersion(dpgContext: SdkContext, typeInput: Type): ConstantSchema<Schema>;
export declare function getSchemaForType(dpgContext: SdkContext, typeInput: Type, options?: GetSchemaOptions): any;
export declare function getEffectiveModelFromType(program: Program, type: Type): Type;
export declare function includeDerivedModel(model: Model, needRef?: boolean): boolean;
export declare function getTypeName(schema: Schema, usage?: string[]): string;
export declare function getSerializeTypeName(program: Program, schema: Schema, usage?: string[]): string;
export declare function getImportedModelName(schema: Schema, usage?: string[]): string[];
export declare function getFormattedPropertyDoc(program: Program, type: ModelProperty | Type, schemaType: any, sperator?: string): string | undefined;
export declare function getBodyType(program: Program, route: HttpOperation): Type | undefined;
export declare function getDefaultService(program: Program): Service | undefined;
/**
* Get the default api-version both from versioned and service decorator
* TODO: remember to switch to TCGC once the fix is done
* @param program
* @param dpgContext
* @returns default api-version value
*/
export declare function getEnrichedDefaultApiVersion(program: Program, dpgContext: SdkContext): string | undefined;
export declare function trimUsage(model: any): any;
export declare function isAzureCoreErrorType(t?: Type): boolean;
export declare function isAnonymousObjectSchema(schema: Schema): boolean;
export declare function isAnonymousModelType(type: Type): boolean;
/**
* Get the inline signiture of the model
* @param schema object schema detail
* @param options other optional parameters
* @returns
*/
export declare function getModelInlineSigniture(schema: ObjectSchema, options?: {
importedModels?: Set<string>;
usage?: string[];
}): string;