@azure-tools/typespec-ts 0.55.0-dev.11 → 0.55.0-dev.12
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.
- package/CHANGELOG.md +9 -0
- package/dist/src/framework/hooks/sdk-types.d.ts +3 -2
- package/dist/src/framework/hooks/sdk-types.d.ts.map +1 -1
- package/dist/src/framework/hooks/sdk-types.js +3 -2
- package/dist/src/framework/hooks/sdk-types.js.map +1 -1
- package/dist/src/modular/build-classical-client.js +2 -2
- package/dist/src/modular/build-classical-client.js.map +1 -1
- package/dist/src/modular/emit-models.d.ts.map +1 -1
- package/dist/src/modular/emit-models.js +19 -5
- package/dist/src/modular/emit-models.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/framework/hooks/sdk-types.ts +3 -2
- package/src/modular/build-classical-client.ts +2 -2
- package/src/modular/emit-models.ts +20 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure-tools/typespec-ts",
|
|
3
|
-
"version": "0.55.0-dev.
|
|
3
|
+
"version": "0.55.0-dev.12",
|
|
4
4
|
"description": "An experimental TypeSpec emitter for TypeScript",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@azure-tools/typespec-autorest": "^0.69.1 || >=0.70.0-dev <0.70.0",
|
|
27
27
|
"@azure-tools/typespec-azure-core": "^0.69.0 || >=0.70.0-dev <0.70.0",
|
|
28
28
|
"@azure-tools/typespec-azure-resource-manager": "^0.69.1 || >=0.70.0-dev <0.70.0",
|
|
29
|
-
"@azure-tools/typespec-client-generator-core": "^0.69.
|
|
29
|
+
"@azure-tools/typespec-client-generator-core": "^0.69.1 || >=0.70.0-dev <0.70.0",
|
|
30
30
|
"@azure/abort-controller": "^2.1.2",
|
|
31
31
|
"@azure/core-auth": "^1.6.0",
|
|
32
32
|
"@azure/core-lro": "^3.1.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@azure-tools/typespec-azure-core": "^0.69.0 || >=0.70.0-dev <0.70.0",
|
|
56
|
-
"@azure-tools/typespec-client-generator-core": "^0.69.
|
|
56
|
+
"@azure-tools/typespec-client-generator-core": "^0.69.1 || >=0.70.0-dev <0.70.0",
|
|
57
57
|
"@typespec/compiler": "^1.13.0",
|
|
58
58
|
"@typespec/http": "^1.13.0",
|
|
59
59
|
"@typespec/rest": "^0.83.0 || >=0.84.0-dev <0.84.0",
|
|
@@ -23,10 +23,11 @@ export const flattenPropertyModelMap: Map<SdkModelPropertyType, SdkModelType> =
|
|
|
23
23
|
SdkModelType
|
|
24
24
|
>();
|
|
25
25
|
/**
|
|
26
|
-
* Set of paged result models that
|
|
26
|
+
* Set of paged result models that should keep their public name (no "_" prefix).
|
|
27
|
+
* This includes models used as non-paging method responses or as model properties.
|
|
27
28
|
* Precomputed during visitPackageTypes for O(1) lookups in normalizeModelName.
|
|
28
29
|
*/
|
|
29
|
-
export const
|
|
30
|
+
export const pagedModelsKeptPublic = new Set<SdkType>();
|
|
30
31
|
|
|
31
32
|
export interface SdkTypeContext {
|
|
32
33
|
operations: Map<Type, SdkServiceMethod<SdkHttpOperation>>;
|
|
@@ -290,8 +290,8 @@ function buildClientOperationGroups(
|
|
|
290
290
|
} else {
|
|
291
291
|
// The `rawGroupName` is used to any places where we need normalized name twice so we need to keep the raw as PascalCase.
|
|
292
292
|
const rawGroupName = normalizeName(prefixes[0] ?? "", NameType.Interface);
|
|
293
|
-
const operationName = `_get${
|
|
294
|
-
const propertyType = `${
|
|
293
|
+
const operationName = `_get${rawGroupName}Operations`;
|
|
294
|
+
const propertyType = `${rawGroupName}Operations`;
|
|
295
295
|
// The `groupName` is used to any places where we don't need normalized name again
|
|
296
296
|
const groupName = normalizeName(rawGroupName, NameType.Property);
|
|
297
297
|
const existProperty = clientClass.getProperties().filter((p) => {
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
emitQueue,
|
|
45
45
|
flattenPropertyModelMap,
|
|
46
46
|
getAllOperationsFromClient,
|
|
47
|
-
|
|
47
|
+
pagedModelsKeptPublic,
|
|
48
48
|
} from "../framework/hooks/sdk-types.js";
|
|
49
49
|
import { refkey } from "../framework/refkey.js";
|
|
50
50
|
import { reportDiagnostic } from "../lib.js";
|
|
@@ -841,8 +841,7 @@ export function normalizeModelName(
|
|
|
841
841
|
}
|
|
842
842
|
const namespacePrefix = context.rlcOptions?.enableModelNamespace ? segments.join("") : "";
|
|
843
843
|
const internalModelPrefix =
|
|
844
|
-
(isPagedResultModel(context, type) && !
|
|
845
|
-
type.isGeneratedName
|
|
844
|
+
(isPagedResultModel(context, type) && !pagedModelsKeptPublic.has(type)) || type.isGeneratedName
|
|
846
845
|
? "_"
|
|
847
846
|
: "";
|
|
848
847
|
return `${internalModelPrefix}${normalizeName(namespacePrefix + type.name, nameType, true)}${unionSuffix}`;
|
|
@@ -932,7 +931,7 @@ export function visitPackageTypes(context: SdkContext) {
|
|
|
932
931
|
const { sdkPackage } = context;
|
|
933
932
|
emitQueue.clear();
|
|
934
933
|
flattenPropertyModelMap.clear();
|
|
935
|
-
|
|
934
|
+
pagedModelsKeptPublic.clear();
|
|
936
935
|
// Add all models in the package to the emit queue
|
|
937
936
|
for (const model of sdkPackage.models) {
|
|
938
937
|
visitType(context, model);
|
|
@@ -1015,7 +1014,19 @@ function trackPagedModelInNonPagingMethod(
|
|
|
1015
1014
|
if (method.kind !== "basic" && method.kind !== "lro") return;
|
|
1016
1015
|
const respType = method.response.type;
|
|
1017
1016
|
if (respType && isPagedResultModel(context, respType)) {
|
|
1018
|
-
|
|
1017
|
+
pagedModelsKeptPublic.add(respType);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* If a paged result model is used as a model property type, mark it so that
|
|
1023
|
+
* normalizeModelName keeps it public (no "_" prefix).
|
|
1024
|
+
*/
|
|
1025
|
+
function trackPagedModelUsedAsProperty(context: SdkContext, type: SdkType): void {
|
|
1026
|
+
// Unwrap array types to check the element type
|
|
1027
|
+
const resolved = type.kind === "array" ? type.valueType : type;
|
|
1028
|
+
if (resolved && isPagedResultModel(context, resolved)) {
|
|
1029
|
+
pagedModelsKeptPublic.add(resolved);
|
|
1019
1030
|
}
|
|
1020
1031
|
}
|
|
1021
1032
|
|
|
@@ -1044,6 +1055,10 @@ function visitType(context: SdkContext, type: SdkType | undefined) {
|
|
|
1044
1055
|
if (property.flatten && property.type.kind === "model") {
|
|
1045
1056
|
flattenPropertyModelMap.set(property, type);
|
|
1046
1057
|
}
|
|
1058
|
+
// If a paged result model is used as a model property (not as a paging
|
|
1059
|
+
// operation response), it must stay public (no "_" prefix) because users
|
|
1060
|
+
// interact with it directly through the property.
|
|
1061
|
+
trackPagedModelUsedAsProperty(context, property.type);
|
|
1047
1062
|
}
|
|
1048
1063
|
if (type.discriminatedSubtypes) {
|
|
1049
1064
|
for (const subType of Object.values(type.discriminatedSubtypes)) {
|