import { AutorestExtensionHost , Session , startSession } from "@autorest/extension-base" ; import { CodeModel , codeModelSchema } from "@autorest/codemodel" ; import { extractAutorestOptions } from "./utils/autorestOptions" ; import { PackageDetails } from "./models/packageDetails" ; import { TracingInfo } from "./models/clientDetails" ; export interface AutorestOptions { restLevelClient ? : boolean ; rlcShortcut ? : boolean ; azureArm ? : boolean ; addCredentials ? : boolean ; credentialKeyHeaderName ? : string ; credentialScopes ? : string [ ] ; srcPath : string ; outputPath ? : string ; title ? : string ; packageDetails : PackageDetails ; licenseHeader : boolean ; tracingInfo ? : TracingInfo ; generateMetadata ? : boolean ; useCoreV2 ? : boolean ; hideClients ? : boolean ; ignoreNullableOnOptional ? : boolean ; allowInsecureConnection ? : boolean ; disablePagingAsyncIterators ? : boolean ; skipEnumValidation ? : boolean ; azureOutputDirectory ? : string ; headAsBoolean ? : boolean ; isTestPackage ? : boolean ; generateTest ? : boolean ; batch ? : [ string , any ] [ ] ; generateSample ? : boolean ; } let host ; let session ; let options ; export async function initializeSession ( autorestHost ) { host = autorestHost ; session = await startSession < CodeModel > ( host , codeModelSchema ) ; options = await extractAutorestOptions ( ) ; } export function getSession ( ) { if ( ! session ) { throw new Error ( "Session has not been initialized, make sure to call initializeSession early in the plugin startup" ) ; } return session ; } export function getHost ( ) { if ( ! host ) { throw new Error ( "Host has not been initialized, make sure to call initializeSession early in the plugin startup" ) ; } return host ; } export function getAutorestOptions ( ) { if ( ! options ) { throw new Error ( "Options have not been initialized, make sure to call initializeSession early in the plugin startup" ) ; } return options ; }