@azure-tools/typespec-ts 0.13.4 → 0.14.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.
- package/CHANGELOG.md +9 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +88 -41
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +2 -1
- package/dist/src/lib.js.map +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts +2 -1
- package/dist/src/modular/buildClassicalClient.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +70 -43
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClientContext.d.ts +2 -1
- package/dist/src/modular/buildClientContext.d.ts.map +1 -1
- package/dist/src/modular/buildClientContext.js +55 -23
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildCodeModel.d.ts +2 -1
- package/dist/src/modular/buildCodeModel.d.ts.map +1 -1
- package/dist/src/modular/buildCodeModel.js +55 -27
- package/dist/src/modular/buildCodeModel.js.map +1 -1
- package/dist/src/modular/buildOperations.d.ts +2 -1
- package/dist/src/modular/buildOperations.d.ts.map +1 -1
- package/dist/src/modular/buildOperations.js +65 -23
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildProjectFiles.d.ts.map +1 -1
- package/dist/src/modular/buildProjectFiles.js +24 -4
- package/dist/src/modular/buildProjectFiles.js.map +1 -1
- package/dist/src/modular/buildRootIndex.d.ts +3 -2
- package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
- package/dist/src/modular/buildRootIndex.js +31 -50
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/buildSubpathIndex.d.ts +3 -0
- package/dist/src/modular/buildSubpathIndex.d.ts.map +1 -0
- package/dist/src/modular/{buildApiIndex.js → buildSubpathIndex.js} +4 -4
- package/dist/src/modular/buildSubpathIndex.js.map +1 -0
- package/dist/src/modular/emitModels.d.ts +1 -1
- package/dist/src/modular/emitModels.d.ts.map +1 -1
- package/dist/src/modular/emitModels.js +3 -2
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +2 -1
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.js +2 -1
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts +3 -3
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +60 -30
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/modularCodeModel.d.ts +3 -1
- package/dist/src/modular/modularCodeModel.d.ts.map +1 -1
- package/dist/src/transform/transform.d.ts +4 -1
- package/dist/src/transform/transform.d.ts.map +1 -1
- package/dist/src/transform/transform.js +8 -7
- package/dist/src/transform/transform.js.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts +1 -2
- package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.js +4 -3
- package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.js +2 -1
- package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
- package/dist/src/transform/transformParameters.d.ts +3 -3
- package/dist/src/transform/transformParameters.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.js +35 -34
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformPaths.d.ts +3 -2
- package/dist/src/transform/transformPaths.d.ts.map +1 -1
- package/dist/src/transform/transformPaths.js +11 -10
- package/dist/src/transform/transformPaths.js.map +1 -1
- package/dist/src/transform/transformResponses.d.ts +3 -3
- package/dist/src/transform/transformResponses.d.ts.map +1 -1
- package/dist/src/transform/transformResponses.js +19 -18
- package/dist/src/transform/transformResponses.js.map +1 -1
- package/dist/src/transform/transformSchemas.d.ts +3 -2
- package/dist/src/transform/transformSchemas.d.ts.map +1 -1
- package/dist/src/transform/transformSchemas.js +3 -2
- package/dist/src/transform/transformSchemas.js.map +1 -1
- package/dist/src/transform/transfromRLCOptions.d.ts +2 -2
- package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
- package/dist/src/transform/transfromRLCOptions.js +11 -3
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/clientUtils.d.ts +1 -0
- package/dist/src/utils/clientUtils.d.ts.map +1 -1
- package/dist/src/utils/clientUtils.js +3 -0
- package/dist/src/utils/clientUtils.js.map +1 -1
- package/dist/src/utils/modelUtils.d.ts +3 -3
- package/dist/src/utils/modelUtils.d.ts.map +1 -1
- package/dist/src/utils/modelUtils.js +78 -48
- package/dist/src/utils/modelUtils.js.map +1 -1
- package/dist/src/utils/operationUtil.d.ts +5 -3
- package/dist/src/utils/operationUtil.d.ts.map +1 -1
- package/dist/src/utils/operationUtil.js +24 -7
- package/dist/src/utils/operationUtil.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/src/index.ts +133 -43
- package/src/lib.ts +2 -1
- package/src/modular/buildClassicalClient.ts +97 -43
- package/src/modular/buildClientContext.ts +67 -25
- package/src/modular/buildCodeModel.ts +95 -24
- package/src/modular/buildOperations.ts +91 -25
- package/src/modular/buildProjectFiles.ts +29 -5
- package/src/modular/buildRootIndex.ts +63 -59
- package/src/modular/{buildApiIndex.ts → buildSubpathIndex.ts} +10 -3
- package/src/modular/emitModels.ts +6 -2
- package/src/modular/helpers/clientHelpers.ts +5 -1
- package/src/modular/helpers/namingHelpers.ts +2 -1
- package/src/modular/helpers/operationHelpers.ts +88 -35
- package/src/modular/modularCodeModel.ts +3 -1
- package/src/transform/transform.ts +9 -21
- package/src/transform/transformApiVersionInfo.ts +1 -3
- package/src/transform/transformHelperFunctionDetails.ts +1 -1
- package/src/transform/transformParameters.ts +27 -63
- package/src/transform/transformPaths.ts +17 -25
- package/src/transform/transformResponses.ts +23 -29
- package/src/transform/transformSchemas.ts +7 -4
- package/src/transform/transfromRLCOptions.ts +17 -5
- package/src/utils/clientUtils.ts +4 -0
- package/src/utils/modelUtils.ts +67 -74
- package/src/utils/operationUtil.ts +43 -11
- package/dist/src/modular/buildApiIndex.d.ts +0 -3
- package/dist/src/modular/buildApiIndex.d.ts.map +0 -1
- package/dist/src/modular/buildApiIndex.js.map +0 -1
- package/dist/src/modular/buildSharedTypes.d.ts +0 -6
- package/dist/src/modular/buildSharedTypes.d.ts.map +0 -1
- package/dist/src/modular/buildSharedTypes.js +0 -31
- package/dist/src/modular/buildSharedTypes.js.map +0 -1
- package/src/modular/buildSharedTypes.ts +0 -38
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Project, SourceFile } from "ts-morph";
|
|
2
2
|
import { getType } from "./helpers/typeHelpers.js";
|
|
3
3
|
import { ModularCodeModel, Type } from "./modularCodeModel.js";
|
|
4
|
+
import * as path from "path";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* This function creates the file containing all the models defined in TypeSpec
|
|
@@ -8,9 +9,12 @@ import { ModularCodeModel, Type } from "./modularCodeModel.js";
|
|
|
8
9
|
export function buildModels(
|
|
9
10
|
codeModel: ModularCodeModel,
|
|
10
11
|
project: Project,
|
|
11
|
-
srcPath: string = "src"
|
|
12
|
+
srcPath: string = "src",
|
|
13
|
+
subfolder: string = ""
|
|
12
14
|
): SourceFile {
|
|
13
|
-
const modelsFile = project.createSourceFile(
|
|
15
|
+
const modelsFile = project.createSourceFile(
|
|
16
|
+
path.join(`${srcPath}/src/`, subfolder, `models/models.ts`)
|
|
17
|
+
);
|
|
14
18
|
|
|
15
19
|
// We are generating both models and enums here
|
|
16
20
|
const coreClientTypes = new Set<string>();
|
|
@@ -14,7 +14,11 @@ export function getClientParameters(
|
|
|
14
14
|
|
|
15
15
|
const params: OptionalKind<ParameterDeclarationStructure>[] = [
|
|
16
16
|
...parameters
|
|
17
|
-
.filter(
|
|
17
|
+
.filter(
|
|
18
|
+
(p) =>
|
|
19
|
+
p.type.type !== "constant" &&
|
|
20
|
+
(p.clientDefaultValue === null || p.clientDefaultValue === undefined)
|
|
21
|
+
)
|
|
18
22
|
.map<OptionalKind<ParameterDeclarationStructure>>((p) => {
|
|
19
23
|
return {
|
|
20
24
|
name: p.clientName,
|
|
@@ -38,6 +38,7 @@ export function getOperationName(
|
|
|
38
38
|
export function isReservedName(name: string, nameType: NameType): boolean {
|
|
39
39
|
return ReservedModelNames.some(
|
|
40
40
|
(reservedName) =>
|
|
41
|
-
reservedName.name === name
|
|
41
|
+
reservedName.name === name.toLowerCase() &&
|
|
42
|
+
reservedName.reservedFor.includes(nameType)
|
|
42
43
|
);
|
|
43
44
|
}
|
|
@@ -12,24 +12,41 @@ import {
|
|
|
12
12
|
Type
|
|
13
13
|
} from "../modularCodeModel.js";
|
|
14
14
|
import { buildType } from "./typeHelpers.js";
|
|
15
|
+
import {
|
|
16
|
+
NameType,
|
|
17
|
+
OperationResponse,
|
|
18
|
+
getResponseBaseName,
|
|
19
|
+
getResponseTypeName,
|
|
20
|
+
normalizeName
|
|
21
|
+
} from "@azure-tools/rlc-common";
|
|
15
22
|
import { getOperationName } from "./namingHelpers.js";
|
|
16
23
|
import { getFixmeForMultilineDocs } from "./fixmeHelpers.js";
|
|
17
24
|
|
|
18
|
-
function getRLCResponseType(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
function getRLCResponseType(rlcResponse?: OperationResponse) {
|
|
26
|
+
if (!rlcResponse?.responses) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
return rlcResponse?.responses
|
|
30
|
+
.map((resp) => {
|
|
31
|
+
const baseResponseName = getResponseBaseName(
|
|
32
|
+
rlcResponse.operationGroup,
|
|
33
|
+
rlcResponse.operationName,
|
|
34
|
+
resp.statusCode
|
|
35
|
+
);
|
|
36
|
+
// Get the information to build the Response Interface
|
|
37
|
+
return resp.predefinedName ?? getResponseTypeName(baseResponseName);
|
|
38
|
+
})
|
|
39
|
+
.join(" | ");
|
|
27
40
|
}
|
|
28
41
|
|
|
29
42
|
export function getSendPrivateFunction(
|
|
30
|
-
operation: Operation
|
|
43
|
+
operation: Operation,
|
|
44
|
+
clientType: string
|
|
31
45
|
): OptionalKind<FunctionDeclarationStructure> {
|
|
32
|
-
|
|
46
|
+
if (operation.name === "uploadTestFile") {
|
|
47
|
+
operation;
|
|
48
|
+
}
|
|
49
|
+
const parameters = getOperationSignatureParameters(operation, clientType);
|
|
33
50
|
const { name } = getOperationName(operation);
|
|
34
51
|
|
|
35
52
|
const functionStatement: OptionalKind<FunctionDeclarationStructure> = {
|
|
@@ -37,7 +54,7 @@ export function getSendPrivateFunction(
|
|
|
37
54
|
isExported: true,
|
|
38
55
|
name: `_${name}Send`,
|
|
39
56
|
parameters,
|
|
40
|
-
returnType: `StreamableMethod<${getRLCResponseType(operation)}>`
|
|
57
|
+
returnType: `StreamableMethod<${getRLCResponseType(operation.rlcResponse)}>`
|
|
41
58
|
};
|
|
42
59
|
|
|
43
60
|
const operationPath = operation.url;
|
|
@@ -47,7 +64,7 @@ export function getSendPrivateFunction(
|
|
|
47
64
|
statements.push(
|
|
48
65
|
`return context.path("${operationPath}", ${getPathParameters(
|
|
49
66
|
operation
|
|
50
|
-
)}).${operationMethod}({
|
|
67
|
+
)}).${operationMethod}({...operationOptionsToRequestParameters(options), ${getRequestParameters(
|
|
51
68
|
operation
|
|
52
69
|
)}});`
|
|
53
70
|
);
|
|
@@ -59,22 +76,35 @@ export function getSendPrivateFunction(
|
|
|
59
76
|
}
|
|
60
77
|
|
|
61
78
|
export function getDeserializePrivateFunction(
|
|
62
|
-
operation: Operation
|
|
79
|
+
operation: Operation,
|
|
80
|
+
needSubClient: boolean,
|
|
81
|
+
needUnexpectedHelper: boolean
|
|
63
82
|
): OptionalKind<FunctionDeclarationStructure> {
|
|
64
83
|
const { name } = getOperationName(operation);
|
|
65
84
|
|
|
66
|
-
|
|
85
|
+
let parameters: OptionalKind<ParameterDeclarationStructure>[] = [
|
|
67
86
|
{
|
|
68
87
|
name: "result",
|
|
69
|
-
type: getRLCResponseType(operation)
|
|
88
|
+
type: getRLCResponseType(operation.rlcResponse)
|
|
70
89
|
}
|
|
71
90
|
];
|
|
72
91
|
|
|
73
92
|
// TODO: Support operation overloads
|
|
74
93
|
const response = operation.responses[0]!;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
94
|
+
let returnType;
|
|
95
|
+
if (response?.type?.type) {
|
|
96
|
+
returnType = buildType(response.type.name, response.type);
|
|
97
|
+
} else {
|
|
98
|
+
if (!needUnexpectedHelper) {
|
|
99
|
+
parameters = [
|
|
100
|
+
{
|
|
101
|
+
name: "_result",
|
|
102
|
+
type: getRLCResponseType(operation.rlcResponse)
|
|
103
|
+
}
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
returnType = { name: "", type: "void" };
|
|
107
|
+
}
|
|
78
108
|
|
|
79
109
|
const functionStatement: OptionalKind<FunctionDeclarationStructure> = {
|
|
80
110
|
isAsync: true,
|
|
@@ -84,7 +114,13 @@ export function getDeserializePrivateFunction(
|
|
|
84
114
|
returnType: `Promise<${returnType.type}>`
|
|
85
115
|
};
|
|
86
116
|
const statements: string[] = [];
|
|
87
|
-
|
|
117
|
+
if (needUnexpectedHelper) {
|
|
118
|
+
statements.push(
|
|
119
|
+
`if(${needSubClient ? "UnexpectedHelper." : ""}isUnexpected(result)){`,
|
|
120
|
+
"throw result.body",
|
|
121
|
+
"}"
|
|
122
|
+
);
|
|
123
|
+
}
|
|
88
124
|
|
|
89
125
|
if (response?.type?.type === "any") {
|
|
90
126
|
statements.push(`return result.body`);
|
|
@@ -110,7 +146,8 @@ export function getDeserializePrivateFunction(
|
|
|
110
146
|
}
|
|
111
147
|
|
|
112
148
|
function getOperationSignatureParameters(
|
|
113
|
-
operation: Operation
|
|
149
|
+
operation: Operation,
|
|
150
|
+
clientType: string
|
|
114
151
|
): OptionalKind<ParameterDeclarationStructure>[] {
|
|
115
152
|
const optionsType = getOperationOptionsName(operation);
|
|
116
153
|
const parameters: Map<
|
|
@@ -129,6 +166,14 @@ function getOperationSignatureParameters(
|
|
|
129
166
|
bodyArray.clientName,
|
|
130
167
|
buildType(bodyArray.clientName, bodyArray.type)
|
|
131
168
|
);
|
|
169
|
+
} else if (operation.bodyParameter?.type.type === "byte-array") {
|
|
170
|
+
parameters.set(
|
|
171
|
+
operation.bodyParameter.clientName,
|
|
172
|
+
buildType(
|
|
173
|
+
operation.bodyParameter.clientName,
|
|
174
|
+
operation.bodyParameter.type
|
|
175
|
+
)
|
|
176
|
+
);
|
|
132
177
|
}
|
|
133
178
|
|
|
134
179
|
operation.parameters
|
|
@@ -145,7 +190,7 @@ function getOperationSignatureParameters(
|
|
|
145
190
|
});
|
|
146
191
|
|
|
147
192
|
// Add context as the first parameter
|
|
148
|
-
const contextParam = { name: "context", type:
|
|
193
|
+
const contextParam = { name: "context", type: clientType };
|
|
149
194
|
|
|
150
195
|
// Add the options parameter
|
|
151
196
|
const optionsParam = {
|
|
@@ -163,11 +208,12 @@ function getOperationSignatureParameters(
|
|
|
163
208
|
* This operation builds and returns the function declaration for an operation.
|
|
164
209
|
*/
|
|
165
210
|
export function getOperationFunction(
|
|
166
|
-
operation: Operation
|
|
211
|
+
operation: Operation,
|
|
212
|
+
clientType: string
|
|
167
213
|
): OptionalKind<FunctionDeclarationStructure> {
|
|
168
214
|
// Extract required parameters
|
|
169
215
|
const parameters: OptionalKind<ParameterDeclarationStructure>[] =
|
|
170
|
-
getOperationSignatureParameters(operation);
|
|
216
|
+
getOperationSignatureParameters(operation, clientType);
|
|
171
217
|
|
|
172
218
|
// TODO: Support operation overloads
|
|
173
219
|
const response = operation.responses[0]!;
|
|
@@ -180,7 +226,7 @@ export function getOperationFunction(
|
|
|
180
226
|
docs: [operation.description, ...getFixmeForMultilineDocs(fixme)],
|
|
181
227
|
isAsync: true,
|
|
182
228
|
isExported: true,
|
|
183
|
-
name: name,
|
|
229
|
+
name: normalizeName(operation.name, NameType.Operation, true),
|
|
184
230
|
parameters,
|
|
185
231
|
returnType: `Promise<${returnType.type}>`
|
|
186
232
|
};
|
|
@@ -241,11 +287,11 @@ function getRequestParameters(operation: Operation): string {
|
|
|
241
287
|
paramStr = `${getContentTypeValue(contentTypeParameter)},`;
|
|
242
288
|
}
|
|
243
289
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
290
|
+
if (parametersImplementation.header.length) {
|
|
291
|
+
paramStr = `${paramStr}\nheaders: {${
|
|
292
|
+
parametersImplementation.header.join(",\n") + ","
|
|
293
|
+
},`;
|
|
294
|
+
}
|
|
249
295
|
|
|
250
296
|
if (parametersImplementation.query.length) {
|
|
251
297
|
paramStr = `${paramStr}\nqueryParameters: {${parametersImplementation.query.join(
|
|
@@ -280,6 +326,10 @@ function buildBodyParameter(bodyParameter: BodyParameter | undefined) {
|
|
|
280
326
|
return `\nbody: ${bodyParameter.clientName},`;
|
|
281
327
|
}
|
|
282
328
|
|
|
329
|
+
if (bodyParameter.type.type === "byte-array") {
|
|
330
|
+
return `\nbody: ${bodyParameter.clientName},`;
|
|
331
|
+
}
|
|
332
|
+
|
|
283
333
|
return "";
|
|
284
334
|
}
|
|
285
335
|
|
|
@@ -324,7 +374,7 @@ function getContentTypeValue(param: Parameter | Property) {
|
|
|
324
374
|
}
|
|
325
375
|
|
|
326
376
|
if (defaultValue) {
|
|
327
|
-
return `contentType:
|
|
377
|
+
return `contentType: options.${param.clientName} as any ?? "${defaultValue}"`;
|
|
328
378
|
} else {
|
|
329
379
|
return `contentType: options.${param.clientName}`;
|
|
330
380
|
}
|
|
@@ -424,18 +474,19 @@ function getPathParameters(operation: Operation) {
|
|
|
424
474
|
for (const param of operation.parameters) {
|
|
425
475
|
if (param.location === "path") {
|
|
426
476
|
if (!param.optional) {
|
|
427
|
-
pathParams
|
|
477
|
+
pathParams += `${pathParams !== "" ? "," : ""} ${param.clientName}`;
|
|
428
478
|
continue;
|
|
429
479
|
}
|
|
430
480
|
|
|
431
481
|
const defaultValue = getDefaultValue(param);
|
|
432
482
|
|
|
433
|
-
pathParams
|
|
483
|
+
pathParams += `${pathParams !== "" ? "," : ""} options.${
|
|
484
|
+
param.clientName
|
|
485
|
+
}`;
|
|
434
486
|
|
|
435
487
|
if (defaultValue) {
|
|
436
|
-
pathParams
|
|
488
|
+
pathParams += ` ?? "${defaultValue}"`;
|
|
437
489
|
}
|
|
438
|
-
pathParams = `${pathParams},`;
|
|
439
490
|
}
|
|
440
491
|
}
|
|
441
492
|
|
|
@@ -511,6 +562,8 @@ function deserializeResponseValue(type: Type, restValue: string): string {
|
|
|
511
562
|
switch (type.type) {
|
|
512
563
|
case "datetime":
|
|
513
564
|
return `new Date(${restValue} ?? "")`;
|
|
565
|
+
case "byte-array":
|
|
566
|
+
return `Buffer.from(${restValue} ?? "")`;
|
|
514
567
|
case "list":
|
|
515
568
|
if (type.elementType?.type === "model") {
|
|
516
569
|
return `(${restValue} ?? []).map(p => ({${getResponseMapping(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RLCOptions } from "@azure-tools/rlc-common";
|
|
1
|
+
import { OperationResponse, RLCOptions } from "@azure-tools/rlc-common";
|
|
2
2
|
|
|
3
3
|
export interface ModularCodeModel {
|
|
4
4
|
options: RLCOptions;
|
|
@@ -95,6 +95,7 @@ export interface Client {
|
|
|
95
95
|
operationGroups: OperationGroup[];
|
|
96
96
|
url: string;
|
|
97
97
|
apiVersions: any[];
|
|
98
|
+
rlcClientName: string;
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
export type ParameterLocation =
|
|
@@ -151,4 +152,5 @@ export interface Operation {
|
|
|
151
152
|
itemName?: string;
|
|
152
153
|
continuationTokenName?: string;
|
|
153
154
|
addedOn?: string;
|
|
155
|
+
rlcResponse?: OperationResponse;
|
|
154
156
|
}
|
|
@@ -38,19 +38,23 @@ import { transformRLCOptions } from "./transfromRLCOptions.js";
|
|
|
38
38
|
import { transformApiVersionInfo } from "./transformApiVersionInfo.js";
|
|
39
39
|
import { getClientLroOverload } from "../utils/operationUtil.js";
|
|
40
40
|
|
|
41
|
+
export interface RLCSdkContext extends SdkContext {
|
|
42
|
+
options?: RLCOptions;
|
|
43
|
+
}
|
|
44
|
+
|
|
41
45
|
export async function transformRLCModel(
|
|
42
46
|
program: Program,
|
|
43
47
|
emitterOptions: RLCOptions,
|
|
44
48
|
client: SdkClient,
|
|
45
49
|
emitterOutputDir: string,
|
|
46
|
-
dpgContext:
|
|
50
|
+
dpgContext: RLCSdkContext
|
|
47
51
|
): Promise<RLCModel> {
|
|
48
52
|
const options: RLCOptions = transformRLCOptions(
|
|
49
|
-
program,
|
|
50
53
|
emitterOptions,
|
|
51
54
|
emitterOutputDir,
|
|
52
55
|
dpgContext
|
|
53
56
|
);
|
|
57
|
+
dpgContext.options = options;
|
|
54
58
|
const srcPath = join(
|
|
55
59
|
emitterOutputDir ?? "",
|
|
56
60
|
"src",
|
|
@@ -74,31 +78,20 @@ export async function transformRLCModel(
|
|
|
74
78
|
const schemas: Schema[] = transformSchemas(program, client, dpgContext);
|
|
75
79
|
|
|
76
80
|
const responses: OperationResponse[] = transformToResponseTypes(
|
|
77
|
-
program,
|
|
78
81
|
importSet,
|
|
79
82
|
client,
|
|
80
83
|
dpgContext
|
|
81
84
|
);
|
|
82
85
|
const parameters: OperationParameter[] = transformToParameterTypes(
|
|
83
|
-
program,
|
|
84
86
|
importSet,
|
|
85
87
|
client,
|
|
86
88
|
dpgContext
|
|
87
89
|
);
|
|
88
|
-
const helperDetails = transformHelperFunctionDetails(
|
|
89
|
-
program,
|
|
90
|
-
client,
|
|
91
|
-
dpgContext
|
|
92
|
-
);
|
|
90
|
+
const helperDetails = transformHelperFunctionDetails(client, dpgContext);
|
|
93
91
|
// Enrich client-level annotation detail
|
|
94
92
|
helperDetails.clientLroOverload = getClientLroOverload(paths);
|
|
95
93
|
const urlInfo = transformUrlInfo(program, dpgContext);
|
|
96
|
-
const apiVersionInfo = transformApiVersionInfo(
|
|
97
|
-
client,
|
|
98
|
-
program,
|
|
99
|
-
dpgContext,
|
|
100
|
-
urlInfo
|
|
101
|
-
);
|
|
94
|
+
const apiVersionInfo = transformApiVersionInfo(client, dpgContext, urlInfo);
|
|
102
95
|
return {
|
|
103
96
|
srcPath,
|
|
104
97
|
libraryName,
|
|
@@ -137,7 +130,6 @@ export function transformUrlInfo(
|
|
|
137
130
|
}
|
|
138
131
|
|
|
139
132
|
const schema = getSchemaForType(
|
|
140
|
-
program,
|
|
141
133
|
dpgContext,
|
|
142
134
|
type,
|
|
143
135
|
[SchemaContext.Exception, SchemaContext.Input],
|
|
@@ -151,11 +143,7 @@ export function transformUrlInfo(
|
|
|
151
143
|
(getDoc(program, property) &&
|
|
152
144
|
getFormattedPropertyDoc(program, property, schema, " ")) ??
|
|
153
145
|
getFormattedPropertyDoc(program, type, schema, " " /* sperator*/),
|
|
154
|
-
value: predictDefaultValue(
|
|
155
|
-
program,
|
|
156
|
-
dpgContext,
|
|
157
|
-
host?.[0]?.parameters.get(key)
|
|
158
|
-
)
|
|
146
|
+
value: predictDefaultValue(dpgContext, host?.[0]?.parameters.get(key))
|
|
159
147
|
});
|
|
160
148
|
}
|
|
161
149
|
}
|
|
@@ -22,10 +22,10 @@ import {
|
|
|
22
22
|
|
|
23
23
|
export function transformApiVersionInfo(
|
|
24
24
|
client: SdkClient,
|
|
25
|
-
program: Program,
|
|
26
25
|
dpgContext: SdkContext,
|
|
27
26
|
urlInfo?: UrlInfo
|
|
28
27
|
): ApiVersionInfo | undefined {
|
|
28
|
+
const program = dpgContext.program;
|
|
29
29
|
const queryVersionDetail = getOperationQueryApiVersion(
|
|
30
30
|
client,
|
|
31
31
|
program,
|
|
@@ -77,7 +77,6 @@ function getOperationQueryApiVersion(
|
|
|
77
77
|
);
|
|
78
78
|
params.map((p) => {
|
|
79
79
|
const type = getSchemaForType(
|
|
80
|
-
program,
|
|
81
80
|
dpgContext,
|
|
82
81
|
p.param.type,
|
|
83
82
|
[SchemaContext.Exception, SchemaContext.Input],
|
|
@@ -104,7 +103,6 @@ function getOperationQueryApiVersion(
|
|
|
104
103
|
);
|
|
105
104
|
params.map((p) => {
|
|
106
105
|
const type = getSchemaForType(
|
|
107
|
-
program,
|
|
108
106
|
dpgContext,
|
|
109
107
|
p.param.type,
|
|
110
108
|
[SchemaContext.Exception, SchemaContext.Input],
|
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
import { getSpecialSerializeInfo } from "./transformParameters.js";
|
|
17
17
|
|
|
18
18
|
export function transformHelperFunctionDetails(
|
|
19
|
-
program: Program,
|
|
20
19
|
client: SdkClient,
|
|
21
20
|
dpgContext: SdkContext
|
|
22
21
|
): HelperFunctionDetails {
|
|
22
|
+
const program = dpgContext.program;
|
|
23
23
|
// Extract paged metadata from Azure.Core.Page
|
|
24
24
|
const annotationDetails = {
|
|
25
25
|
hasLongRunning: hasPollingOperations(program, client, dpgContext)
|