@azure-tools/typespec-java 0.37.4 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,31 @@
1
1
  import { SdkClientType, SdkHttpOperation } from "@azure-tools/typespec-client-generator-core";
2
2
  import { Program } from "@typespec/compiler";
3
3
  import { Version } from "@typespec/versioning";
4
+ /**
5
+ * Sentinel values that describe a client that not have consistent api-versions.
6
+ * Reason is either the service is not versioned, or the client aggregates multiple services of different api-versions.
7
+ */
8
+ export declare enum InconsistentVersions {
9
+ /**
10
+ * The client is not versioned.
11
+ */
12
+ NotVersioned = 0,
13
+ /**
14
+ * The client contains multiple services which may have the same set or different set of api-versions.
15
+ */
16
+ MixedVersions = 1
17
+ }
4
18
  /**
5
19
  * Gets the array of api-version on the TypeSpec service that contains this SDK client.
6
- * `undefined` if the service is not versioned.
20
+ * Returns {@link InconsistentVersions.NotVersioned} when the service is not versioned and
21
+ * {@link InconsistentVersions.MixedVersions} when the client aggregates multiple services
22
+ * that disagree on api-version.
7
23
  *
8
24
  * @param program the program
9
25
  * @param client the SDK client
10
- * @returns the array of api-version on the TypeSpec service that contains this SDK client
26
+ * @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.
11
27
  */
12
- export declare function getServiceApiVersions(program: Program, client: SdkClientType<SdkHttpOperation>): Version[] | undefined;
28
+ export declare function getServiceApiVersions(program: Program, client: SdkClientType<SdkHttpOperation>): Version[] | InconsistentVersions;
13
29
  /**
14
30
  * Filter api-versions for "ServiceVersion".
15
31
  * TODO(xiaofei) pending TCGC design: https://github.com/Azure/typespec-azure/issues/965
@@ -1 +1 @@
1
- {"version":3,"file":"versioning-utils.d.ts","sourceRoot":"","sources":["../../src/versioning-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC9F,OAAO,EAAa,OAAO,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AO,EAChB,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,QAAQ,EAAE,OAAO,EAAE,EACnB,cAAc,GAAE,OAAc,GAC7B,OAAO,EAAE,CAQX;AAMD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAa1D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAuChF"}
@@ -1,20 +1,51 @@
1
1
  import { isPreviewVersion } from "@azure-tools/typespec-azure-core";
2
2
  import { findVersionedNamespace, getVersions } from "@typespec/versioning";
3
+ /**
4
+ * Sentinel values that describe a client that not have consistent api-versions.
5
+ * Reason is either the service is not versioned, or the client aggregates multiple services of different api-versions.
6
+ */
7
+ export var InconsistentVersions;
8
+ (function (InconsistentVersions) {
9
+ /**
10
+ * The client is not versioned.
11
+ */
12
+ InconsistentVersions[InconsistentVersions["NotVersioned"] = 0] = "NotVersioned";
13
+ /**
14
+ * The client contains multiple services which may have the same set or different set of api-versions.
15
+ */
16
+ InconsistentVersions[InconsistentVersions["MixedVersions"] = 1] = "MixedVersions";
17
+ })(InconsistentVersions || (InconsistentVersions = {}));
3
18
  /**
4
19
  * Gets the array of api-version on the TypeSpec service that contains this SDK client.
5
- * `undefined` if the service is not versioned.
20
+ * Returns {@link InconsistentVersions.NotVersioned} when the service is not versioned and
21
+ * {@link InconsistentVersions.MixedVersions} when the client aggregates multiple services
22
+ * that disagree on api-version.
6
23
  *
7
24
  * @param program the program
8
25
  * @param client the SDK client
9
- * @returns the array of api-version on the TypeSpec service that contains this SDK client
26
+ * @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.
10
27
  */
11
28
  export function getServiceApiVersions(program, client) {
12
- // TODO: use client.apiVersions after TCGC supports multiple service
13
- // Also, this function lacks the logic of the handling of added/removed on the Namespace/Interface of the SDK client.
29
+ // TODO: use client.apiVersions
14
30
  let apiVersions;
15
- const versionedNamespace = findVersionedNamespace(program, client.__raw.service);
16
- if (versionedNamespace) {
17
- apiVersions = getVersions(program, versionedNamespace)[1]?.getVersions();
31
+ // TCGC 0.63+ supports multiple api-version in a single client
32
+ if (Array.isArray(client.__raw.service)) {
33
+ // here, we treat a versioned client with multiple service as client of mixed versions
34
+ apiVersions = isSdkClientVersioned(client)
35
+ ? InconsistentVersions.MixedVersions
36
+ : InconsistentVersions.NotVersioned;
37
+ }
38
+ else {
39
+ const serviceNamespace = client.__raw.service;
40
+ const versionedNamespace = findVersionedNamespace(program, serviceNamespace);
41
+ if (versionedNamespace) {
42
+ apiVersions =
43
+ getVersions(program, versionedNamespace)[1]?.getVersions() ??
44
+ InconsistentVersions.NotVersioned;
45
+ }
46
+ else {
47
+ apiVersions = InconsistentVersions.NotVersioned;
48
+ }
18
49
  }
19
50
  return apiVersions;
20
51
  }
@@ -107,4 +138,8 @@ export function isVersionEarlierThan(version, compareTo) {
107
138
  // Versions are identical
108
139
  return false;
109
140
  }
141
+ function isSdkClientVersioned(client) {
142
+ // on TCGC, the difference of versioned client and not versioned client is on the existence of "apiVersion" parameter in clientInitialization
143
+ return client.clientInitialization.parameters.some((p) => p.name === "apiVersion");
144
+ }
110
145
  //# sourceMappingURL=versioning-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"versioning-utils.js","sourceRoot":"","sources":["../../src/versioning-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAW,MAAM,sBAAsB,CAAC;AAEpF;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAgB,EAChB,MAAuC;IAEvC,oEAAoE;IACpE,qHAAqH;IACrH,IAAI,WAAkC,CAAC;I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