UNPKG

@autorest/powershell

Version:
451 lines 29.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.tweakSdkModelPlugin = void 0; /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ const codemodel_1 = require("@autorest/codemodel"); const codegen_1 = require("@azure-tools/codegen"); const model_state_1 = require("../utils/model-state"); const http_definitions_1 = require("../utils/http-definitions"); const linq_1 = require("@azure-tools/linq"); const schema_1 = require("../utils/schema"); const code_namer_1 = require("../utils/code-namer"); async function tweakModel(state) { var _a; const model = state.model; addUsings(model); tweakSchema(model); model.globalParameters = (_a = model.globalParameters) !== null && _a !== void 0 ? _a : []; addAzureProperties(model.globalParameters); tweakGlobalParameter(model.globalParameters); await tweakOperation(state); addClientRequiredConstructorParametersDeclaration(model); return model; } function splitStringWithExclusion(input, delimiter) { const result = []; let temp = ''; let insideBracket = 0; for (let i = 0; i < input.length; i++) { if (input[i] === '<') { insideBracket++; temp += input[i]; } else if (input[i] === '>') { insideBracket--; temp += input[i]; } else if (input[i] === delimiter && insideBracket === 0) { result.push(temp.trim()); temp = ''; } else { temp += input[i]; } } if (temp !== '') { result.push(temp.trim()); } return result; } function addClientRequiredConstructorParametersDeclaration(model) { var _a; const declarations = []; for (const parameter of (0, linq_1.values)(model.globalParameters)) { if (parameter.language.default.name === '$host') { // skip $host continue; } if (parameter.required && parameter.readOnly) { declarations.push(`${(_a = parameter.schema.language.csharp) === null || _a === void 0 ? void 0 : _a.fullname} ${parameter.language.default.name.substring(0, 1).toLowerCase() + parameter.language.default.name.substring(1)}`); } } model.language.default.requiredConstructorParametersDeclaration = declarations.join(', '); } function tweakSchema(model) { var _a; for (const obj of (0, linq_1.values)(model.schemas.objects)) { const optionalParameters = Array(); const requiredParameters = Array(); const optionalParametersWithoutReadOnly = Array(); const requiredParametersWithoutReadOnly = Array(); for (const property of (0, linq_1.values)(obj.properties)) { property.language.csharp = { name: property.language.default.name.substring(0, 1).toUpperCase() + property.language.default.name.substring(1), formattedPropertySummary: (property.readOnly ? 'Gets ' : 'Gets or sets ') + property.language.default.description.substring(0, 1).toLowerCase() + property.language.default.description.substring(1) }; } const publicProperties = obj.extensions && obj.extensions['x-ms-azure-resource'] ? (0, schema_1.getAllPublicVirtualPropertiesForSdkWithoutInherited)(obj.language.default.virtualProperties) : (0, schema_1.getAllPublicVirtualPropertiesForSdk)(obj.language.default.virtualProperties); for (const virtualProperty of publicProperties) { if (virtualProperty.name.toLowerCase() === obj.language.default.name.toLowerCase()) { // If the name is same as class name, will add 'Property' suffix virtualProperty.name = virtualProperty.name + 'Property'; } if (virtualProperty.required && (virtualProperty.property.schema.type === codemodel_1.SchemaType.SealedChoice && virtualProperty.property.schema.choices.length === 1) || (virtualProperty.property.schema.type === codemodel_1.SchemaType.Choice && virtualProperty.property.schema.choices.length === 1)) { // For choice or seal choice with only one value and required, will not be handled as constant continue; } let type = ((_a = virtualProperty.property.schema.language.csharp) === null || _a === void 0 ? void 0 : _a.fullname) || ''; type = ((0, schema_1.valueType)(virtualProperty.property.schema.type) || (virtualProperty.property.schema.type === codemodel_1.SchemaType.SealedChoice && (virtualProperty.property.schema.choiceType.type !== codemodel_1.SchemaType.String || (virtualProperty.property.schema.extensions && !virtualProperty.property.schema.extensions['x-ms-model-as-string'])))) && !virtualProperty.required && virtualProperty.property.nullable != false ? `${type}?` : type; const CamelName = (0, codegen_1.camelCase)(virtualProperty.name); virtualProperty.required ? requiredParameters.push(`${type} ${CamelName}`) : optionalParameters.push(`${type} ${CamelName} = default(${type})`); if (!virtualProperty.readOnly) { virtualProperty.required ? requiredParametersWithoutReadOnly.push(`${type} ${CamelName}`) : optionalParametersWithoutReadOnly.push(`${type} ${CamelName} = default(${type})`); } } if (obj.parents && (obj.parents.immediate.length === 1 && !(obj.extensions && obj.extensions['x-ms-azure-resource']))) { // If there is only one direct parent parameter and extension x-ms-azure-resource is not set, will implement it as base class let baseConstructorParametersCall = Array(); const baseRequiredParameters = Array(); const baseOptionalParameters = Array(); const combinedProperties = (0, schema_1.getAllPublicVirtualPropertiesForSdk)(obj.parents.immediate[0].language.default.virtualProperties); for (const virtualProperty of (0, linq_1.values)(combinedProperties)) { if (virtualProperty.required) { baseRequiredParameters.push(virtualProperty.name); } else { baseOptionalParameters.push(virtualProperty.name); } } baseConstructorParametersCall = [...baseRequiredParameters, ...baseOptionalParameters].map((p) => (0, codegen_1.camelCase)(p) || ''); if (baseConstructorParametersCall.length > 0) { obj.language.default.baseConstructorCall = `base(${baseConstructorParametersCall.join(', ')})`; } } obj.language.default.constructorParametersDeclaration = [...requiredParameters, ...optionalParameters].join(', '); obj.language.default.constructorParametersDeclarationWithoutReadOnly = [...requiredParametersWithoutReadOnly, ...optionalParametersWithoutReadOnly].join(', '); } } function addUsings(model) { model.usings = [ 'Microsoft.Rest.Azure' ]; if (model.schemas.objects || model.schemas.sealedChoices) { model.usings.push('Models'); } } function addMethodParameterDeclaration(operation, state) { var _a; if ((_a = operation.language.default.pageable) === null || _a === void 0 ? void 0 : _a.nextPageOperation) { addPageableMethodParameterDeclaration(operation); } else { addNormalMethodParameterDeclaration(operation, state); } } function typePostfix(schema, nullable = true) { return ((0, schema_1.valueType)(schema.type) || (schema.type === codemodel_1.SchemaType.SealedChoice && (schema.choiceType.type !== codemodel_1.SchemaType.String || (schema.extensions && !schema.extensions['x-ms-model-as-string'])))) && nullable ? '?' : ''; } function addNormalMethodParameterDeclaration(operation, state) { let declarations = []; const optionalDeclarations = []; const requiredDeclarations = []; const requiredArgs = []; const optionalArgs = []; const args = []; let bodyParameters = []; if (operation.requests && operation.requests.length > 0) { bodyParameters = (operation.requests[0].parameters || []).filter(p => { var _a; return ((_a = p.protocol.http) === null || _a === void 0 ? void 0 : _a.in) === codemodel_1.ParameterLocation.Body; }); } (operation.parameters || []).filter(p => { var _a; return p.implementation != 'Client' && ((_a = p.protocol.http) === null || _a === void 0 ? void 0 : _a.in) !== 'complexHeader' && !(p.extensions && p.extensions['x-ms-parameter-grouping']) && !(p.required && p.schema.type === codemodel_1.SchemaType.Choice && p.schema.choices.length === 1) && !(p.required && p.schema.type === codemodel_1.SchemaType.SealedChoice && p.schema.choices.length === 1); }).forEach(function (parameter) { var _a, _b; let type = ((_a = parameter.schema.language.csharp) === null || _a === void 0 ? void 0 : _a.fullname) || ((_b = parameter.schema.language.csharp) === null || _b === void 0 ? void 0 : _b.name) || ''; if (parameter.extensions && parameter.extensions['x-ms-odata']) { type = `Microsoft.Rest.Azure.OData.ODataQuery<${type}>`; } const postfix = typePostfix(parameter.schema, parameter.nullable != false); if (!(parameter.required && parameter.schema.type === codemodel_1.SchemaType.Constant)) { // skip required const parameter parameter.required ? requiredDeclarations.push(`${type} ${parameter.language.default.name}`) : optionalDeclarations.push(`${type}${postfix} ${parameter.language.default.name} = default(${type}${postfix})`); parameter.required ? requiredArgs.push(parameter.language.default.name) : optionalArgs.push(parameter.language.default.name); } }); bodyParameters.filter(p => !(p.extensions && p.extensions['x-ms-parameter-grouping']) && !(p.required && p.schema.type === codemodel_1.SchemaType.Choice && p.schema.choices.length === 1) && !(p.required && p.schema.type === codemodel_1.SchemaType.SealedChoice && p.schema.choices.length === 1)).forEach(function (parameter) { if (parameter.extensions && parameter.extensions['x-ms-client-flatten']) { const constructorParametersDeclarationWithoutReadOnly = parameter.schema.language.default.constructorParametersDeclarationWithoutReadOnly; splitStringWithExclusion(constructorParametersDeclarationWithoutReadOnly, ',').forEach(function (p) { requiredDeclarations.push(p); requiredArgs.push(splitStringWithExclusion(p, ' ')[1]); }); } else { let type = parameter.schema.language.csharp && parameter.schema.language.csharp.fullname && parameter.schema.language.csharp.fullname != '<INVALID_FULLNAME>' ? parameter.schema.language.csharp.fullname : parameter.schema.language.default.name; if (parameter.schema.type === codemodel_1.SchemaType.Binary) { //as response or request body, binary is always stream, otherwise it is string type = 'System.IO.Stream'; } const postfix = typePostfix(parameter.schema, parameter.nullable != false); parameter.required ? requiredDeclarations.push(`${type} ${parameter.language.default.name}`) : optionalDeclarations.push(`${type}${postfix} ${parameter.language.default.name} = default(${type}${postfix})`); parameter.required ? requiredArgs.push(parameter.language.default.name) : optionalArgs.push(parameter.language.default.name); } }); declarations = [...requiredDeclarations, ...optionalDeclarations]; operation.language.default.syncMethodParameterDeclaration = declarations.join(', '); declarations.push('System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)'); operation.language.default.asyncMethodParameterDeclaration = declarations.join(', '); declarations.pop(); declarations.push('System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> customHeaders = null'); operation.language.default.syncMethodParameterDeclarationWithCustomHeader = declarations.join(', '); declarations.push('System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)'); operation.language.default.asyncMethodParameterDeclarationWithCustomHeader = declarations.join(', '); args.push(...requiredArgs, ...optionalArgs); operation.language.default.syncMethodInvocationArgs = args.join(', '); const argsWithCustomerHeaders = [...args]; args.push('null'); args.push('cancellationToken'); argsWithCustomerHeaders.push('customHeaders'); argsWithCustomerHeaders.push('cancellationToken'); operation.language.default.asyncMethodInvocationArgs = args.join(', '); operation.language.default.asyncMethodInvocationArgsWithCustomerHeaders = argsWithCustomerHeaders.join(', '); } function addPageableMethodParameterDeclaration(operation) { const optionalDeclarations = []; const requiredDeclarations = []; const requiredArgs = []; const optionalArgs = []; const headerParameters = (operation.parameters || []).filter(p => { var _a, _b; return p.implementation != 'Client' && !(p.extensions && p.extensions['x-ms-parameter-grouping']) && !(p.required && p.schema.type === codemodel_1.SchemaType.Choice && p.schema.choices.length === 1) && !(p.required && p.schema.type === codemodel_1.SchemaType.SealedChoice && p.schema.choices.length === 1) && (((_a = p.protocol.http) === null || _a === void 0 ? void 0 : _a.in) === codemodel_1.ParameterLocation.Header || ((_b = p.protocol.http) === null || _b === void 0 ? void 0 : _b.in) === 'complexHeader'); }); headerParameters.forEach(function (parameter) { var _a, _b; let type = ((_a = parameter.schema.language.csharp) === null || _a === void 0 ? void 0 : _a.fullname) || ((_b = parameter.schema.language.csharp) === null || _b === void 0 ? void 0 : _b.name) || ''; if (parameter.extensions && parameter.extensions['x-ms-odata']) { type = `Microsoft.Rest.Azure.OData.ODataQuery<${type}>`; } const postfix = typePostfix(parameter.schema, parameter.nullable != false); if (!(parameter.required && parameter.schema.type === codemodel_1.SchemaType.Constant)) { // skip required const parameter parameter.required ? requiredDeclarations.push(`${type} ${parameter.language.default.name}`) : optionalDeclarations.push(`${type}${postfix} ${parameter.language.default.name} = default(${type}${postfix})`); parameter.required ? requiredArgs.push(parameter.language.default.name) : optionalArgs.push(parameter.language.default.name); } }); const pageableMethodDeclarations = ['string nextPageLink', ...requiredDeclarations, ...optionalDeclarations]; operation.language.default.syncMethodParameterDeclaration = pageableMethodDeclarations.join(', '); pageableMethodDeclarations.push('System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)'); operation.language.default.asyncMethodParameterDeclaration = pageableMethodDeclarations.join(', '); pageableMethodDeclarations.pop(); pageableMethodDeclarations.push('System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> customHeaders = null'); operation.language.default.syncMethodParameterDeclarationWithCustomHeader = pageableMethodDeclarations.join(', '); pageableMethodDeclarations.push('System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)'); operation.language.default.asyncMethodParameterDeclarationWithCustomHeader = pageableMethodDeclarations.join(', '); const pageableMethodArgs = ['nextPageLink', ...requiredArgs, ...optionalArgs]; operation.language.default.syncMethodInvocationArgs = pageableMethodArgs.join(', '); const pageableMethodArgsWithCustomerHeaders = [...pageableMethodArgs]; pageableMethodArgs.push('null'); pageableMethodArgs.push('cancellationToken'); operation.language.default.asyncMethodInvocationArgs = pageableMethodArgs.join(', '); pageableMethodArgsWithCustomerHeaders.push('customHeaders'); pageableMethodArgsWithCustomerHeaders.push('cancellationToken'); operation.language.default.asyncMethodInvocationArgsWithCustomerHeaders = pageableMethodArgsWithCustomerHeaders.join(', '); } function tweakGlobalParameter(globalParameters) { if (!globalParameters) { return; } globalParameters.forEach(function (parameter) { if (parameter.language.default.name === 'apiVersion') { // change apiVersion to ApiVersion since the track 1 SDK expects it. parameter.language.default.name = 'ApiVersion'; if (parameter.schema.apiVersions) { parameter.clientDefaultValue = parameter.schema.apiVersions[0]; } } }); } async function tweakOperation(state) { var _a, _b, _c, _d, _e; for (const operationGroup of state.model.operationGroups) { if ((0, code_namer_1.isReserved)(operationGroup.$key)) { operationGroup.$key = (0, codegen_1.pascalCase)(`${operationGroup.$key}Model`); operationGroup.language.default.name = operationGroup.$key; } for (const operation of operationGroup.operations) { let initializeResponseBody = ''; operation.language.default.returnTypeHeader = {}; operation.language.default.returnTypeHeader.name = ''; if (operation.responses) { const schemas = new Set(); let respCountWithBody = 0; let binaryResponse = false; // sometimes, it will generate a binary response with no schema let specialBinaryResponse = 0; operation.responses.forEach(function (resp) { if (resp.schema) { schemas.add(resp.schema); if ((resp.schema).type === codemodel_1.SchemaType.Binary) { binaryResponse = true; } } else if (resp.binary) { binaryResponse = true; specialBinaryResponse = 1; } }); respCountWithBody = schemas.size + specialBinaryResponse; const isHead = operation.requests && ((_a = operation.requests[0].protocol.http) === null || _a === void 0 ? void 0 : _a.method) === 'head'; if (isHead) { const succeedCode = (_b = operation.responses.filter(r => { var _a; return ((_a = r.protocol.http) === null || _a === void 0 ? void 0 : _a.statusCodes[0]).startsWith('2'); })[0].protocol.http) === null || _b === void 0 ? void 0 : _b.statusCodes[0]; initializeResponseBody = `_result.Body = (_statusCode == System.Net.HttpStatusCode.${http_definitions_1.StatusCodes[succeedCode]});`; } const responses = operation.responses.filter(r => r.schema); const hasHeaderResponse = operation.responses.some(r => r.protocol.http.headers); const headerSchema = (0, codegen_1.pascalCase)(operationGroup.$key + ((_c = operation.language.default.original) !== null && _c !== void 0 ? _c : operation.language.default.name) + 'Headers'); operation.language.default.returnTypeHeader.name = hasHeaderResponse ? headerSchema : ''; let headerPostfix = hasHeaderResponse ? `,${headerSchema}` : ''; if (respCountWithBody === 0) { const statusCodes = new Array(); operation.responses.forEach(resp => { var _a; return statusCodes.push((_a = resp.protocol.http) === null || _a === void 0 ? void 0 : _a.statusCodes[0]); }); if (isHead && ((_d = operation.responses) === null || _d === void 0 ? void 0 : _d.length) === 2 && statusCodes.includes('404') && !hasHeaderResponse) { operation.language.default.responseType = 'Microsoft.Rest.Azure.AzureOperationResponse<bool>'; operation.language.default.returnType = 'bool'; } else { headerPostfix = hasHeaderResponse ? (isHead ? `AzureOperationResponse<bool,${headerSchema}>` : `AzureOperationHeaderResponse<${headerSchema}>`) : 'AzureOperationResponse'; operation.language.default.responseType = `Microsoft.Rest.Azure.${headerPostfix}`; operation.language.default.returnType = hasHeaderResponse ? (isHead ? 'bool' : headerSchema) : 'void'; } } else if (respCountWithBody === 1) { const respSchema = binaryResponse ? undefined : responses[0].schema; if (operation.language.default.pageable) { const responseType = respSchema.language.default.virtualProperties.owned.find((p) => p.name === (0, codegen_1.pascalCase)(operation.language.default.pageable.itemName)).property.schema.elementType.language.csharp.fullname; if (responseType) { if (hasHeaderResponse) { operation.language.default.responseType = `Microsoft.Rest.Azure.AzureOperationResponse<${operation.language.default.pageable.ipageType}<${responseType}>${headerPostfix}>`; } else { operation.language.default.responseType = `Microsoft.Rest.Azure.AzureOperationResponse<${operation.language.default.pageable.ipageType}<${responseType}>>`; } } else { operation.language.default.responseType = 'Microsoft.Rest.Azure.AzureOperationResponse'; } // Mark response as pageable if (respSchema.language.default.pagable == undefined) { respSchema.language.default.pagable = true; } operation.language.default.returnType = `${operation.language.default.pageable.ipageType}<${responseType}>`; operation.language.default.deserializeType = `${operation.language.default.pageable.pageType}<${responseType}>`; } else { if (respSchema) { respSchema.language.default.pagable = false; } const postfix = !!respSchema && ((0, schema_1.valueType)(respSchema.type) || (respSchema.type === codemodel_1.SchemaType.SealedChoice && respSchema.extensions && !respSchema.extensions['x-ms-model-as-string']) || (respSchema.type === codemodel_1.SchemaType.Choice && (0, schema_1.valueType)(respSchema.choiceType.type)) || (respSchema.type === codemodel_1.SchemaType.SealedChoice && respSchema.extensions && (0, schema_1.valueType)(respSchema.choiceType.type))) ? '?' : ''; const fullname = binaryResponse ? 'System.IO.Stream' : ((respSchema.type === codemodel_1.SchemaType.Choice || (respSchema.type === codemodel_1.SchemaType.SealedChoice && ((0, schema_1.valueType)(respSchema.choiceType.type) || (respSchema.extensions && respSchema.extensions['x-ms-model-as-string'])))) ? (_e = respSchema.choiceType.language.csharp) === null || _e === void 0 ? void 0 : _e.fullname : respSchema.language.csharp.fullname); operation.language.default.responseType = `Microsoft.Rest.Azure.AzureOperationResponse<${fullname}${postfix}${headerPostfix}>`; operation.language.default.returnType = `${fullname}${postfix}`; } } else { operation.language.default.responseType = `Microsoft.Rest.Azure.AzureOperationResponse<object${headerPostfix}>`; operation.language.default.returnType = 'object'; } } else { operation.language.default.responseType = 'Microsoft.Rest.Azure.AzureOperationResponse'; operation.language.default.returnType = 'void'; } operation.language.default.initializeResponseBody = initializeResponseBody; addMethodParameterDeclaration(operation, state); setFailureStatusCodePredicate(operation); } } } function setFailureStatusCodePredicate(operation) { var _a; const failureStatusCodePredicate = Array(); for (const resp of (0, linq_1.values)(operation.responses)) { const status = (_a = resp.protocol.http) === null || _a === void 0 ? void 0 : _a.statusCodes[0]; failureStatusCodePredicate.push(`(int)_statusCode != ${status}`); } if (failureStatusCodePredicate.length > 0) { operation.language.default.failureStatusCodePredicate = failureStatusCodePredicate.join(' && '); } else { operation.language.default.failureStatusCodePredicate = '!_httpResponse.IsSuccessStatusCode'; } } function addAzureProperties(globalParameters) { const primitiveTypeMap = new Map([ ['integer', 'int'], ['number', 'double'], ['boolean', 'bool'], ['string', 'string'] ]); // To align with track 1 SDK, move API version to the beginning if (globalParameters.length > 0 && globalParameters[globalParameters.length - 1].language.default.name === 'apiVersion') { const apiVersion = globalParameters.pop(); if (apiVersion) { apiVersion.clientDefaultValue = apiVersion.schema.value.value; apiVersion.language.default.description = 'The API version to use for this operation.'; globalParameters.unshift(apiVersion); } } const credential = new codemodel_1.Parameter('Credentials', 'Credentials needed for the client to connect to Azure.', new codemodel_1.Schema('credentials', 'credentials', codemodel_1.SchemaType.Object)); credential.language.default.serializedName = 'credentials'; credential.required = true; // Todo: Will need to add readOnly in the class Parameter credential.readOnly = true; credential.schema.language.csharp = { ...credential.schema.language.default, fullname: 'Microsoft.Rest.ServiceClientCredentials' }; globalParameters.unshift(credential); const acceptLanguage = new codemodel_1.Parameter('AcceptLanguage', 'The preferred language for the response.', new codemodel_1.Schema('accept-language', 'accept-language', codemodel_1.SchemaType.String)); acceptLanguage.language.default.serializedName = 'accept-language'; acceptLanguage.schema.language.csharp = { ...acceptLanguage.schema.language.default, fullname: primitiveTypeMap.get(acceptLanguage.schema.type) }; acceptLanguage.clientDefaultValue = 'en-US'; globalParameters.push(acceptLanguage); const longRunningOperationRetryTimeout = new codemodel_1.Parameter('LongRunningOperationRetryTimeout', 'The retry timeout in seconds for Long Running Operations. Default\n /// value is 30.', new codemodel_1.Schema('longRunningOperationRetryTimeout', 'longRunningOperationRetryTimeout', codemodel_1.SchemaType.Integer)); longRunningOperationRetryTimeout.language.default.serializedName = 'longRunningOperationRetryTimeout'; longRunningOperationRetryTimeout.schema.language.csharp = { ...longRunningOperationRetryTimeout.schema.language.default, fullname: primitiveTypeMap.get(longRunningOperationRetryTimeout.schema.type) }; longRunningOperationRetryTimeout.clientDefaultValue = 30; globalParameters.push(longRunningOperationRetryTimeout); const generateClientRequestId = new codemodel_1.Parameter('GenerateClientRequestId', 'Whether a unique x-ms-client-request-id should be generated. When \n /// set to true a unique x-ms-client-request-id value is generated and \n /// included in each request. Default is true.', new codemodel_1.Schema('generateClientRequestId', 'generateClientRequestId', codemodel_1.SchemaType.Boolean)); generateClientRequestId.language.default.serializedName = 'generateClientRequestId'; generateClientRequestId.schema.language.csharp = { ...generateClientRequestId.schema.language.default, fullname: primitiveTypeMap.get(generateClientRequestId.schema.type) }; generateClientRequestId.clientDefaultValue = true; globalParameters.push(generateClientRequestId); } async function tweakSdkModelPlugin(service) { const state = await new model_state_1.ModelState(service).init(); const debug = await service.getValue('debug') || false; try { service.writeFile({ filename: 'sdk-code-model-v4-tweaksdk.yaml', content: (0, codegen_1.serialize)(await tweakModel(state)), sourceMap: undefined, artifactType: 'code-model-v4' }); } catch (E) { if (debug && E instanceof Error) { console.error(`${__filename} - FAILURE ${JSON.stringify(E)} ${E.stack} `); } throw E; } } exports.tweakSdkModelPlugin = tweakSdkModelPlugin; //# sourceMappingURL=sdk-tweak-model.js.map