@azure-tools/typespec-java
Version:
TypeSpec library for emitting Java client from the TypeSpec REST protocol binding
62 lines • 3.05 kB
TypeScript
import { SdkClientType, SdkHttpOperation } from "@azure-tools/typespec-client-generator-core";
import { Program } from "@typespec/compiler";
import { Version } from "@typespec/versioning";
/**
* Sentinel values that describe a client that not have consistent api-versions.
* Reason is either the service is not versioned, or the client aggregates multiple services of different api-versions.
*/
export declare enum InconsistentVersions {
/**
* The client is not versioned.
*/
NotVersioned = 0,
/**
* The client contains multiple services which may have the same set or different set of api-versions.
*/
MixedVersions = 1
}
/**
* Gets the array of api-version on the TypeSpec service that contains this SDK client.
* Returns {@link InconsistentVersions.NotVersioned} when the service is not versioned and
* {@link InconsistentVersions.MixedVersions} when the client aggregates multiple services
* that disagree on api-version.
*
* @param program the program
* @param client the SDK client
* @returns the array of api-version when there is only one service in the SDK client or an {@link InconsistentVersions} indicator when the SDK client is not versioned or has multiple versions.
*/
export declare function getServiceApiVersions(program: Program, client: SdkClientType<SdkHttpOperation>): Version[] | InconsistentVersions;
/**
* Filter api-versions for "ServiceVersion".
* TODO(xiaofei) pending TCGC design: https://github.com/Azure/typespec-azure/issues/965
* We still cannot move to TCGC, due to it only recognizes api-versions from 1 service.
*
* @param pinnedApiVersion the api-version to use as filter base
* @param versions api-versions to filter
* @param excludePreview whether to exclude preview api-versions when pinnedApiVersion is stable, default is `true`
* @returns filtered api-versions
*/
export declare function getFilteredApiVersions(program: Program, pinnedApiVersion: string | undefined, versions: Version[], excludePreview?: boolean): Version[];
export declare function isStableApiVersionString(version: string): boolean;
/**
* Checks whether a version follows the YYYY-MM-DD(-preview) format.
* The "-preview" suffix is optional.
*
* @param version the version string to validate
* @returns true if the version follows the YYYY-MM-DD(-preview) format, false otherwise
*/
export declare function isVersionedByDate(version: string): boolean;
/**
* Compares two date-based versions to determine if the first version is earlier than the second.
* Assumes both versions have already passed isVersionedByDate validation.
*
* Comparison logic:
* 1. Compare by date (YYYY-MM-DD) first
* 2. If dates are equal, stable version is considered later than preview version
*
* @param version the version to check
* @param compareTo the version to compare against
* @returns true if version is earlier than compareTo, false otherwise
*/
export declare function isVersionEarlierThan(version: string, compareTo: string): boolean;
//# sourceMappingURL=versioning-utils.d.ts.map