UNPKG

@autorest/go

Version:
169 lines 7.85 kB
import * as go from '../../codemodel.go/src/index.js'; import { ImportManager } from './imports.js'; export declare const commentLength = 120; export declare const dateFormat = "2006-01-02"; export declare const datetimeRFC3339Format = "time.RFC3339Nano"; export declare const datetimeRFC1123Format = "time.RFC1123"; export declare const timeRFC3339Format = "15:04:05.999999999Z07:00"; export declare const doNotEditRegex: RegExp; /** * returns the common source-file preamble (license comment, package name etc) * * @param codeModel the code model being emitted * @param doNotEdit when false the 'DO NOT EDIT' clause is omitted * @param packageName overrides the package name in the code model * @returns the source file preamble */ export declare function contentPreamble(codeModel: go.CodeModel, doNotEdit?: boolean, packageName?: string): string; export declare function sortAscending(a: string, b: string): number; /** * returns the parameter's type definition with a possible '*' prefix * * @param param the parameter for which to emit the type definition * @param pkgName optional package name in which the type resides * @returns the parameter type definition text */ export declare function formatParameterTypeName(param: go.ClientOptionsType | go.ClientParameter | go.ParameterGroup, pkgName?: string): string; export declare function sortParametersByRequired(a: go.ClientParameter | go.ParameterGroup, b: go.ClientParameter | go.ParameterGroup): number; /** * sort client parameters based on the API design guidelines. * the params array is sorted in place and returned to the caller. * * @param params the client parameters to sort * @param type the Go code model type * @returns the provided array after it's been sorted */ export declare function sortClientParameters(params: Array<go.ClientParameter>, type: go.CodeModelType): Array<go.ClientParameter>; export declare function getCreateRequestParametersSig(method: go.MethodType | go.NextPageMethod): string; export declare function getCreateRequestParameters(method: go.MethodType): string; export declare function getMethodParameters(method: go.MethodType | go.NextPageMethod, paramsFilter?: (p: Array<go.MethodParameter>) => Array<go.MethodParameter>): Array<go.MethodParameter | go.ParameterGroup>; export declare function getParamName(param: go.MethodParameter): string; export declare function formatBytesEncoding(enc: go.BytesEncoding): string; export declare function formatParamValue(param: go.MethodParameter, imports: ImportManager): string; export declare function getDelimiterForCollectionFormat(cf: go.CollectionFormat): string; export declare function formatValue(paramName: string, type: go.WireType, imports: ImportManager, defef?: boolean): string; export declare function formatLiteralValue(value: go.Literal, withCast: boolean): string; export declare function hasSchemaResponse(method: go.MethodType): boolean; export declare function getResultFieldName(method: go.MethodType): string; export declare function formatStatusCodes(statusCodes: Array<number>): string; export declare function formatStatusCode(statusCode: number): string; export declare function formatCommentAsBulletItem(prefix: string, docs: go.Docs): string; export declare function formatDocCommentWithPrefix(prefix: string, docs: go.Docs): string; export declare function formatDocComment(docs: go.Docs): string; export declare function getParentImport(codeModel: go.CodeModel): string; export declare function getBitSizeForNumber(intSize: 'float32' | 'float64' | 'int8' | 'int16' | 'int32' | 'int64'): string; export declare function recursiveUnwrapMapSlice(item: go.WireType): go.WireType; /** * returns a * character when byValue is false * * @param byValue indicates if the type is passed by value * @returns a * or the empty string */ export declare function star(byValue: boolean): string; /** * returns the zero-value expression for the specific parameter * * @param param the param for which to create a zero value * @returns the zero-value expression */ export declare function zeroValue(param: go.MethodParameter): string; export type SerDeFormat = 'JSON' | 'XML'; export declare function getSerDeFormat(model: go.Model | go.PolymorphicModel, codeModel: go.CodeModel): SerDeFormat; export declare function getAllClientParameters(codeModel: go.CodeModel): Array<go.ClientParameter>; export declare function getCommonClientParameters(codeModel: go.CodeModel): Array<go.ClientParameter>; /** * groups method parameters based on their kind. * note that the body param kinds are mutually exclusive. */ export interface MethodParamGroups { /** the body parameter if applicable */ bodyParam?: go.BodyParameter; /** encoded query params. can be empty */ encodedQueryParams: Array<go.QueryParameter>; /** form body params. can be empty */ formBodyParams: Array<go.FormBodyParameter>; /** head params. can be empty */ headerParams: Array<go.HeaderParameter>; /** multipart-form body params. can be empty */ multipartBodyParams: Array<go.MultipartFormBodyParameter>; /** path params. can be empty */ pathParams: Array<go.PathParameter>; /** partial body params. can be empty */ partialBodyParams: Array<go.PartialBodyParameter>; /** unencoded query params. can be empty */ unencodedQueryParams: Array<go.QueryParameter>; } /** * enumerates method parameters and returns them based on kinds * * @param method the method containing the parameters to group * @returns the groups of parameters */ export declare function getMethodParamGroups(method: go.MethodType | go.NextPageMethod): MethodParamGroups; /** helper for managing indentation levels */ export declare class indentation { private level; constructor(level?: number); /** * returns spaces for the current indentation level * * @returns a string with the current indentation level */ get(): string; /** * increments the indentation level * * @returns this indentation instance */ push(): indentation; /** * decrements the indentation level * * @returns this indentation instance */ pop(): indentation; } /** the if condition in an if block */ export interface ifBlock { /** the condition in the if block */ condition: string; /** the body of the if block */ body: (indent: indentation) => string; } /** the else condition in an if/else block */ export interface elseBlock { /** the body of the else block */ body: (indent: indentation) => string; } /** * constructs an if block (can expand to include else if as necessary) * * @param indent the current indentation helper in scope * @param ifBlock the if block definition * @param elseBlock optional else block definition * @returns the text for the if block */ export declare function buildIfBlock(indent: indentation, ifBlock: ifBlock, elseBlock?: elseBlock): string; /** * constructs an "if err != nil { return something }" block * * @param indent the current indentation helper in scope * @param errVar the name of the error variable used in the condition * @param returns the value(s) to return from the control block * @returns the text for the error check block */ export declare function buildErrCheck(indent: indentation, errVar: string, returns: string): string; /** * splits a token credential scope into the audience and scope. * e.g. "https://monitor.azure.com/.default" is split into * - audience: https://monitor.azure.com * - scope: /.default * @param scope */ export declare function splitScope(scope: string): { audience: string; scope: string; }; /** returns true if the specified method is internal */ export declare function isMethodInternal(method: go.MethodType): boolean; //# sourceMappingURL=helpers.d.ts.map