@autorest/typescript 6.0.0-beta.14 → 6.0.0-beta.17
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 +13 -0
- package/README.md +41 -5
- package/dist/src/autorestSession.d.ts +12 -4
- package/dist/src/autorestSession.d.ts.map +1 -1
- package/dist/src/autorestSession.js +3 -9
- package/dist/src/autorestSession.js.map +1 -1
- package/dist/src/conflictResolver.d.ts.map +1 -1
- package/dist/src/conflictResolver.js.map +1 -1
- package/dist/src/generators/clientFileGenerator.d.ts.map +1 -1
- package/dist/src/generators/clientFileGenerator.js +181 -31
- package/dist/src/generators/clientFileGenerator.js.map +1 -1
- package/dist/src/generators/indexGenerator.d.ts.map +1 -1
- package/dist/src/generators/indexGenerator.js +70 -9
- package/dist/src/generators/indexGenerator.js.map +1 -1
- package/dist/src/generators/modelsGenerator.d.ts.map +1 -1
- package/dist/src/generators/modelsGenerator.js +20 -2
- package/dist/src/generators/modelsGenerator.js.map +1 -1
- package/dist/src/generators/operationGenerator.d.ts.map +1 -1
- package/dist/src/generators/operationGenerator.js +10 -8
- package/dist/src/generators/operationGenerator.js.map +1 -1
- package/dist/src/generators/samples/sampleEnv.hbs +4 -0
- package/dist/src/generators/samples/sampleEnvGenerator.d.ts +3 -0
- package/dist/src/generators/samples/sampleEnvGenerator.d.ts.map +1 -0
- package/dist/src/generators/samples/sampleEnvGenerator.js +17 -0
- package/dist/src/generators/samples/sampleEnvGenerator.js.map +1 -0
- package/dist/src/generators/samples/sampleGenerator.d.ts +13 -0
- package/dist/src/generators/samples/sampleGenerator.d.ts.map +1 -0
- package/dist/src/generators/samples/sampleGenerator.js +43 -0
- package/dist/src/generators/samples/sampleGenerator.js.map +1 -0
- package/dist/src/generators/static/apiExtractorConfig.js +2 -2
- package/dist/src/generators/static/apiExtractorConfig.js.map +1 -1
- package/dist/src/generators/static/esLintConfigGenerator.d.ts +3 -0
- package/dist/src/generators/static/esLintConfigGenerator.d.ts.map +1 -0
- package/dist/src/generators/static/esLintConfigGenerator.js +26 -0
- package/dist/src/generators/static/esLintConfigGenerator.js.map +1 -0
- package/dist/src/generators/static/{README.md.hbs → hlcREADME.md.hbs} +23 -0
- package/dist/src/generators/static/karma.conf.js.hbs +141 -0
- package/dist/src/generators/static/karmaConfigFileGenerator.d.ts +3 -0
- package/dist/src/generators/static/karmaConfigFileGenerator.d.ts.map +1 -0
- package/dist/src/generators/static/karmaConfigFileGenerator.js +23 -0
- package/dist/src/generators/static/karmaConfigFileGenerator.js.map +1 -0
- package/dist/src/generators/static/packageFileGenerator.d.ts.map +1 -1
- package/dist/src/generators/static/packageFileGenerator.js +174 -48
- package/dist/src/generators/static/packageFileGenerator.js.map +1 -1
- package/dist/src/generators/static/readmeFileGenerator.d.ts +2 -2
- package/dist/src/generators/static/readmeFileGenerator.d.ts.map +1 -1
- package/dist/src/generators/static/readmeFileGenerator.js +35 -17
- package/dist/src/generators/static/readmeFileGenerator.js.map +1 -1
- package/dist/src/generators/static/rlcREADME.md.hbs +71 -0
- package/dist/src/generators/static/rollupConfigFileGenerator.d.ts.map +1 -1
- package/dist/src/generators/static/rollupConfigFileGenerator.js +12 -71
- package/dist/src/generators/static/rollupConfigFileGenerator.js.map +1 -1
- package/dist/src/generators/static/samples.ts.hbs +49 -0
- package/dist/src/generators/static/tsConfigFileGenerator.d.ts.map +1 -1
- package/dist/src/generators/static/tsConfigFileGenerator.js +40 -18
- package/dist/src/generators/static/tsConfigFileGenerator.js.map +1 -1
- package/dist/src/generators/test/envBrowserFileGenerator.d.ts +3 -0
- package/dist/src/generators/test/envBrowserFileGenerator.d.ts.map +1 -0
- package/dist/src/generators/test/envBrowserFileGenerator.js +15 -0
- package/dist/src/generators/test/envBrowserFileGenerator.js.map +1 -0
- package/dist/src/generators/test/envFileGenerator.d.ts +3 -0
- package/dist/src/generators/test/envFileGenerator.d.ts.map +1 -0
- package/dist/src/generators/test/envFileGenerator.js +23 -0
- package/dist/src/generators/test/envFileGenerator.js.map +1 -0
- package/dist/src/generators/test/recordedClientFileGenerator.d.ts +3 -0
- package/dist/src/generators/test/recordedClientFileGenerator.d.ts.map +1 -0
- package/dist/src/generators/test/recordedClientFileGenerator.js +23 -0
- package/dist/src/generators/test/recordedClientFileGenerator.js.map +1 -0
- package/dist/src/generators/test/rlcEnv.ts.hbs +3 -0
- package/dist/src/generators/test/rlcRecordedClient.ts.hbs +35 -0
- package/dist/src/generators/test/rlcSampleTest.spec.ts.hbs +19 -0
- package/dist/src/generators/{static → test}/sampleTest.ts.hbs +0 -0
- package/dist/src/generators/test/sampleTestGenerator.d.ts.map +1 -1
- package/dist/src/generators/test/sampleTestGenerator.js +23 -7
- package/dist/src/generators/test/sampleTestGenerator.js.map +1 -1
- package/dist/src/generators/utils/pagingOperations.d.ts +5 -0
- package/dist/src/generators/utils/pagingOperations.d.ts.map +1 -1
- package/dist/src/generators/utils/pagingOperations.js +2 -1
- package/dist/src/generators/utils/pagingOperations.js.map +1 -1
- package/dist/src/main.d.ts +2 -2
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +3 -3
- package/dist/src/main.js.map +1 -1
- package/dist/src/models/clientDetails.d.ts +7 -0
- package/dist/src/models/clientDetails.d.ts.map +1 -1
- package/dist/src/models/modelDetails.d.ts +2 -2
- package/dist/src/models/modelDetails.d.ts.map +1 -1
- package/dist/src/models/operationDetails.d.ts +1 -0
- package/dist/src/models/operationDetails.d.ts.map +1 -1
- package/dist/src/models/sampleDetails.d.ts +22 -0
- package/dist/src/models/sampleDetails.d.ts.map +1 -0
- package/dist/src/models/sampleDetails.js +3 -0
- package/dist/src/models/sampleDetails.js.map +1 -0
- package/dist/src/restLevelClient/generateClient.d.ts +1 -1
- package/dist/src/restLevelClient/generateClient.d.ts.map +1 -1
- package/dist/src/restLevelClient/generateClient.js +81 -163
- package/dist/src/restLevelClient/generateClient.js.map +1 -1
- package/dist/src/restLevelClient/generateClientDefinition.d.ts +6 -0
- package/dist/src/restLevelClient/generateClientDefinition.d.ts.map +1 -0
- package/dist/src/restLevelClient/generateClientDefinition.js +231 -0
- package/dist/src/restLevelClient/generateClientDefinition.js.map +1 -0
- package/dist/src/restLevelClient/generateMethodShortcuts.d.ts +8 -0
- package/dist/src/restLevelClient/generateMethodShortcuts.d.ts.map +1 -0
- package/dist/src/restLevelClient/generateMethodShortcuts.js +70 -0
- package/dist/src/restLevelClient/generateMethodShortcuts.js.map +1 -0
- package/dist/src/restLevelClient/generateObjectTypes.d.ts.map +1 -1
- package/dist/src/restLevelClient/generateObjectTypes.js.map +1 -1
- package/dist/src/restLevelClient/generatePagingHelper.d.ts.map +1 -1
- package/dist/src/restLevelClient/generatePagingHelper.js +2 -1
- package/dist/src/restLevelClient/generatePagingHelper.js.map +1 -1
- package/dist/src/restLevelClient/generateParameterTypes.d.ts.map +1 -1
- package/dist/src/restLevelClient/generateParameterTypes.js +186 -36
- package/dist/src/restLevelClient/generateParameterTypes.js.map +1 -1
- package/dist/src/restLevelClient/generatePollingHelper.d.ts.map +1 -1
- package/dist/src/restLevelClient/generatePollingHelper.js +3 -1
- package/dist/src/restLevelClient/generatePollingHelper.js.map +1 -1
- package/dist/src/restLevelClient/generateResponseTypes.d.ts.map +1 -1
- package/dist/src/restLevelClient/generateResponseTypes.js +13 -7
- package/dist/src/restLevelClient/generateResponseTypes.js.map +1 -1
- package/dist/src/restLevelClient/generateRestLevel.d.ts.map +1 -1
- package/dist/src/restLevelClient/generateRestLevel.js +26 -4
- package/dist/src/restLevelClient/generateRestLevel.js.map +1 -1
- package/dist/src/restLevelClient/generateSchemaTypes.d.ts.map +1 -1
- package/dist/src/restLevelClient/generateSchemaTypes.js +5 -2
- package/dist/src/restLevelClient/generateSchemaTypes.js.map +1 -1
- package/dist/src/restLevelClient/generateTopLevelIndexFile.d.ts +4 -0
- package/dist/src/restLevelClient/generateTopLevelIndexFile.d.ts.map +1 -0
- package/dist/src/restLevelClient/generateTopLevelIndexFile.js +41 -0
- package/dist/src/restLevelClient/generateTopLevelIndexFile.js.map +1 -0
- package/dist/src/restLevelClient/helpers/operationHelpers.d.ts +10 -0
- package/dist/src/restLevelClient/helpers/operationHelpers.d.ts.map +1 -0
- package/dist/src/restLevelClient/helpers/operationHelpers.js +64 -0
- package/dist/src/restLevelClient/helpers/operationHelpers.js.map +1 -0
- package/dist/src/restLevelClient/interfaces.d.ts +24 -0
- package/dist/src/restLevelClient/interfaces.d.ts.map +1 -0
- package/dist/src/restLevelClient/interfaces.js +3 -0
- package/dist/src/restLevelClient/interfaces.js.map +1 -0
- package/dist/src/restLevelClient/operationHelpers.d.ts.map +1 -1
- package/dist/src/restLevelClient/operationHelpers.js +4 -1
- package/dist/src/restLevelClient/operationHelpers.js.map +1 -1
- package/dist/src/restLevelClient/schemaHelpers.d.ts.map +1 -1
- package/dist/src/restLevelClient/schemaHelpers.js +4 -1
- package/dist/src/restLevelClient/schemaHelpers.js.map +1 -1
- package/dist/src/transforms/operationTransforms.d.ts.map +1 -1
- package/dist/src/transforms/operationTransforms.js +1 -0
- package/dist/src/transforms/operationTransforms.js.map +1 -1
- package/dist/src/transforms/samplesTransforms.d.ts +7 -0
- package/dist/src/transforms/samplesTransforms.d.ts.map +1 -0
- package/dist/src/transforms/samplesTransforms.js +283 -0
- package/dist/src/transforms/samplesTransforms.js.map +1 -0
- package/dist/src/transforms/transforms.d.ts +1 -2
- package/dist/src/transforms/transforms.d.ts.map +1 -1
- package/dist/src/transforms/transforms.js +4 -3
- package/dist/src/transforms/transforms.js.map +1 -1
- package/dist/src/typescriptGenerator.d.ts +2 -2
- package/dist/src/typescriptGenerator.d.ts.map +1 -1
- package/dist/src/typescriptGenerator.js +19 -8
- package/dist/src/typescriptGenerator.js.map +1 -1
- package/dist/src/utils/autorestOptions.d.ts +2 -2
- package/dist/src/utils/autorestOptions.d.ts.map +1 -1
- package/dist/src/utils/autorestOptions.js +107 -30
- package/dist/src/utils/autorestOptions.js.map +1 -1
- package/dist/src/utils/nameUtils.d.ts +6 -2
- package/dist/src/utils/nameUtils.d.ts.map +1 -1
- package/dist/src/utils/nameUtils.js +9 -5
- package/dist/src/utils/nameUtils.js.map +1 -1
- package/dist/src/utils/schemaHelpers.js +8 -3
- package/dist/src/utils/schemaHelpers.js.map +1 -1
- package/package.json +16 -10
- package/src/autorestSession.ts +20 -16
- package/src/conflictResolver.ts +0 -1
- package/src/generators/clientFileGenerator.ts +264 -33
- package/src/generators/indexGenerator.ts +78 -9
- package/src/generators/modelsGenerator.ts +21 -1
- package/src/generators/operationGenerator.ts +11 -9
- package/src/generators/samples/sampleEnv.hbs +4 -0
- package/src/generators/samples/sampleEnvGenerator.ts +14 -0
- package/src/generators/samples/sampleGenerator.ts +50 -0
- package/src/generators/static/apiExtractorConfig.ts +2 -2
- package/src/generators/static/esLintConfigGenerator.ts +24 -0
- package/src/generators/static/{README.md.hbs → hlcREADME.md.hbs} +23 -0
- package/src/generators/static/karma.conf.js.hbs +141 -0
- package/src/generators/static/karmaConfigFileGenerator.ts +20 -0
- package/src/generators/static/packageFileGenerator.ts +187 -48
- package/src/generators/static/readmeFileGenerator.ts +64 -35
- package/src/generators/static/rlcREADME.md.hbs +71 -0
- package/src/generators/static/rollupConfigFileGenerator.ts +13 -71
- package/src/generators/static/samples.ts.hbs +49 -0
- package/src/generators/static/tsConfigFileGenerator.ts +47 -20
- package/src/generators/test/envBrowserFileGenerator.ts +14 -0
- package/src/generators/test/envFileGenerator.ts +22 -0
- package/src/generators/test/recordedClientFileGenerator.ts +22 -0
- package/src/generators/test/rlcEnv.ts.hbs +3 -0
- package/src/generators/test/rlcRecordedClient.ts.hbs +35 -0
- package/src/generators/test/rlcSampleTest.spec.ts.hbs +19 -0
- package/src/generators/{static → test}/sampleTest.ts.hbs +0 -0
- package/src/generators/test/sampleTestGenerator.ts +23 -8
- package/src/generators/utils/pagingOperations.ts +1 -1
- package/src/main.ts +8 -5
- package/src/models/clientDetails.ts +8 -0
- package/src/models/modelDetails.ts +2 -2
- package/src/models/operationDetails.ts +1 -0
- package/src/models/sampleDetails.ts +22 -0
- package/src/restLevelClient/generateClient.ts +99 -250
- package/src/restLevelClient/generateClientDefinition.ts +343 -0
- package/src/restLevelClient/generateMethodShortcuts.ts +121 -0
- package/src/restLevelClient/generateObjectTypes.ts +1 -3
- package/src/restLevelClient/generatePagingHelper.ts +3 -2
- package/src/restLevelClient/generateParameterTypes.ts +295 -70
- package/src/restLevelClient/generatePollingHelper.ts +3 -3
- package/src/restLevelClient/generateResponseTypes.ts +13 -7
- package/src/restLevelClient/generateRestLevel.ts +32 -7
- package/src/restLevelClient/generateSchemaTypes.ts +5 -3
- package/src/restLevelClient/generateTopLevelIndexFile.ts +41 -0
- package/src/restLevelClient/helpers/operationHelpers.ts +93 -0
- package/src/restLevelClient/interfaces.ts +26 -0
- package/src/restLevelClient/operationHelpers.ts +8 -2
- package/src/restLevelClient/schemaHelpers.ts +4 -2
- package/src/transforms/operationTransforms.ts +1 -0
- package/src/transforms/samplesTransforms.ts +300 -0
- package/src/transforms/transforms.ts +6 -6
- package/src/typescriptGenerator.ts +20 -11
- package/src/utils/autorestOptions.ts +170 -59
- package/src/utils/nameUtils.ts +16 -8
- package/src/utils/schemaHelpers.ts +2 -2
- package/dist/src/generators/clientContextFileGenerator.d.ts +0 -5
- package/dist/src/generators/clientContextFileGenerator.d.ts.map +0 -1
- package/dist/src/generators/clientContextFileGenerator.js +0 -263
- package/dist/src/generators/clientContextFileGenerator.js.map +0 -1
- package/dist/src/restLevelClient/helpers/getOperationParameters.d.ts +0 -6
- package/dist/src/restLevelClient/helpers/getOperationParameters.d.ts.map +0 -1
- package/dist/src/restLevelClient/helpers/getOperationParameters.js +0 -29
- package/dist/src/restLevelClient/helpers/getOperationParameters.js.map +0 -1
- package/src/generators/clientContextFileGenerator.ts +0 -405
- package/src/restLevelClient/helpers/getOperationParameters.ts +0 -34
package/src/autorestSession.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AutorestExtensionHost,
|
|
3
|
+
Session,
|
|
4
|
+
startSession
|
|
5
|
+
} from "@autorest/extension-base";
|
|
2
6
|
import { CodeModel, codeModelSchema } from "@autorest/codemodel";
|
|
3
7
|
import { extractAutorestOptions } from "./utils/autorestOptions";
|
|
4
8
|
import { PackageDetails } from "./models/packageDetails";
|
|
5
|
-
import { TracingInfo } from "./models/clientDetails";
|
|
9
|
+
import { DependencyInfo, TracingInfo } from "./models/clientDetails";
|
|
6
10
|
|
|
7
11
|
export interface AutorestOptions {
|
|
8
12
|
restLevelClient?: boolean;
|
|
13
|
+
rlcShortcut?: boolean;
|
|
9
14
|
azureArm?: boolean;
|
|
10
15
|
addCredentials?: boolean;
|
|
11
16
|
credentialKeyHeaderName?: string;
|
|
@@ -27,24 +32,23 @@ export interface AutorestOptions {
|
|
|
27
32
|
headAsBoolean?: boolean;
|
|
28
33
|
isTestPackage?: boolean;
|
|
29
34
|
generateTest?: boolean;
|
|
35
|
+
batch?: [string, any][];
|
|
36
|
+
multiClient?: boolean;
|
|
37
|
+
generateSample?: boolean;
|
|
38
|
+
azureSdkForJs?: boolean;
|
|
39
|
+
productDocLink?: string;
|
|
40
|
+
coreHttpCompatMode?: boolean;
|
|
41
|
+
dependencyInfo?: DependencyInfo;
|
|
30
42
|
}
|
|
31
43
|
|
|
32
|
-
let host:
|
|
44
|
+
let host: AutorestExtensionHost;
|
|
33
45
|
let session: Session<CodeModel>;
|
|
34
46
|
let options: AutorestOptions;
|
|
35
47
|
|
|
36
|
-
export async function initializeSession(autorestHost:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!session) {
|
|
42
|
-
session = await startSession<CodeModel>(host, undefined, codeModelSchema);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!options) {
|
|
46
|
-
options = await extractAutorestOptions();
|
|
47
|
-
}
|
|
48
|
+
export async function initializeSession(autorestHost: AutorestExtensionHost) {
|
|
49
|
+
host = autorestHost;
|
|
50
|
+
session = await startSession<CodeModel>(host, codeModelSchema);
|
|
51
|
+
options = await extractAutorestOptions();
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
export function getSession(): Session<CodeModel> {
|
|
@@ -57,7 +61,7 @@ export function getSession(): Session<CodeModel> {
|
|
|
57
61
|
return session;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
export function getHost():
|
|
64
|
+
export function getHost(): AutorestExtensionHost {
|
|
61
65
|
if (!host) {
|
|
62
66
|
throw new Error(
|
|
63
67
|
"Host has not been initialized, make sure to call initializeSession early in the plugin startup"
|
package/src/conflictResolver.ts
CHANGED
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
Project,
|
|
6
6
|
PropertyDeclarationStructure,
|
|
7
7
|
ClassDeclaration,
|
|
8
|
-
SourceFile
|
|
8
|
+
SourceFile,
|
|
9
|
+
CodeBlockWriter
|
|
9
10
|
} from "ts-morph";
|
|
10
11
|
import { ClientDetails } from "../models/clientDetails";
|
|
11
12
|
import {
|
|
@@ -25,6 +26,9 @@ import { getAllModelsNames } from "./utils/responseTypeUtils";
|
|
|
25
26
|
import { addTracingOperationImports } from "./utils/tracingUtils";
|
|
26
27
|
import { addPagingEsNextRef, addPagingImports } from "./utils/pagingOperations";
|
|
27
28
|
import { getAutorestOptions } from "../autorestSession";
|
|
29
|
+
import { ParameterDetails } from "../models/parameterDetails";
|
|
30
|
+
import { EndpointDetails } from "../transforms/urlTransforms";
|
|
31
|
+
import { PackageDetails } from "../models/packageDetails";
|
|
28
32
|
|
|
29
33
|
type OperationDeclarationDetails = { name: string; typeName: string };
|
|
30
34
|
|
|
@@ -33,9 +37,10 @@ export function generateClient(clientDetails: ClientDetails, project: Project) {
|
|
|
33
37
|
useCoreV2,
|
|
34
38
|
hideClients,
|
|
35
39
|
srcPath,
|
|
36
|
-
addCredentials
|
|
40
|
+
addCredentials,
|
|
41
|
+
packageDetails,
|
|
42
|
+
coreHttpCompatMode
|
|
37
43
|
} = getAutorestOptions();
|
|
38
|
-
const clientContextClassName = `${clientDetails.className}Context`;
|
|
39
44
|
const hasMappers = !!clientDetails.mappers.length;
|
|
40
45
|
|
|
41
46
|
// Check if there are any client level operations
|
|
@@ -72,36 +77,43 @@ export function generateClient(clientDetails: ClientDetails, project: Project) {
|
|
|
72
77
|
}
|
|
73
78
|
);
|
|
74
79
|
|
|
80
|
+
!useCoreV2 && writePackageInfo(clientFile, packageDetails);
|
|
81
|
+
|
|
75
82
|
const flattenedInlineOperations = inlineOperations.reduce<OperationDetails[]>(
|
|
76
83
|
(acc, curr) => (acc = [...acc, ...curr.operations]),
|
|
77
84
|
[]
|
|
78
85
|
);
|
|
79
86
|
|
|
87
|
+
if (!useCoreV2) {
|
|
88
|
+
clientFile.addImportDeclaration({
|
|
89
|
+
namespaceImport: "coreHttp",
|
|
90
|
+
moduleSpecifier: "@azure/core-http"
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
clientFile.addImportDeclaration({
|
|
94
|
+
namespaceImport: "coreClient",
|
|
95
|
+
moduleSpecifier: "@azure/core-client"
|
|
96
|
+
});
|
|
97
|
+
clientFile.addImportDeclaration({
|
|
98
|
+
namespaceImport: "coreHttpCompat",
|
|
99
|
+
moduleSpecifier: "@azure/core-http-compat"
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
80
103
|
if (hasCredentials || hasInlineOperations || !hasClientOptionalParams) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
});
|
|
91
|
-
clientFile.addImportDeclaration({
|
|
92
|
-
namespaceImport: "coreRestPipeline",
|
|
93
|
-
moduleSpecifier: "@azure/core-rest-pipeline"
|
|
94
|
-
});
|
|
104
|
+
clientFile.addImportDeclaration({
|
|
105
|
+
namespaceImport: "coreRestPipeline",
|
|
106
|
+
moduleSpecifier: "@azure/core-rest-pipeline"
|
|
107
|
+
});
|
|
108
|
+
clientFile.addImportDeclaration({
|
|
109
|
+
namespaceImport: "coreTracing",
|
|
110
|
+
moduleSpecifier: "@azure/core-tracing"
|
|
111
|
+
});
|
|
112
|
+
if (hasCredentials) {
|
|
95
113
|
clientFile.addImportDeclaration({
|
|
96
|
-
namespaceImport: "
|
|
97
|
-
moduleSpecifier: "@azure/core-
|
|
114
|
+
namespaceImport: "coreAuth",
|
|
115
|
+
moduleSpecifier: "@azure/core-auth"
|
|
98
116
|
});
|
|
99
|
-
if (hasCredentials) {
|
|
100
|
-
clientFile.addImportDeclaration({
|
|
101
|
-
namespaceImport: "coreAuth",
|
|
102
|
-
moduleSpecifier: "@azure/core-auth"
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
117
|
}
|
|
106
118
|
}
|
|
107
119
|
|
|
@@ -163,14 +175,13 @@ export function generateClient(clientDetails: ClientDetails, project: Project) {
|
|
|
163
175
|
});
|
|
164
176
|
}
|
|
165
177
|
|
|
166
|
-
clientFile.addImportDeclaration({
|
|
167
|
-
namedImports: [clientContextClassName],
|
|
168
|
-
moduleSpecifier: `./${clientDetails.sourceFileName}Context`
|
|
169
|
-
});
|
|
170
|
-
|
|
171
178
|
const clientClass = clientFile.addClass({
|
|
172
179
|
name: clientDetails.className,
|
|
173
|
-
extends:
|
|
180
|
+
extends: !useCoreV2
|
|
181
|
+
? "coreHttp.ServiceClient"
|
|
182
|
+
: coreHttpCompatMode
|
|
183
|
+
? "coreHttpCompat.ExtendedServiceClient"
|
|
184
|
+
: "coreClient.ServiceClient",
|
|
174
185
|
isExported: true
|
|
175
186
|
});
|
|
176
187
|
|
|
@@ -185,7 +196,10 @@ export function generateClient(clientDetails: ClientDetails, project: Project) {
|
|
|
185
196
|
}
|
|
186
197
|
|
|
187
198
|
const importedModels = new Set<string>();
|
|
188
|
-
|
|
199
|
+
const clientParams = clientDetails.parameters.filter(
|
|
200
|
+
param => param.implementationLocation === ImplementationLocation.Client
|
|
201
|
+
);
|
|
202
|
+
writeClassProperties(clientClass, clientParams, importedModels);
|
|
189
203
|
writeConstructor(clientDetails, clientClass, importedModels);
|
|
190
204
|
writeClientOperations(
|
|
191
205
|
clientFile,
|
|
@@ -206,6 +220,26 @@ export function generateClient(clientDetails: ClientDetails, project: Project) {
|
|
|
206
220
|
clientFile.fixUnusedIdentifiers();
|
|
207
221
|
}
|
|
208
222
|
|
|
223
|
+
function writeClassProperties(
|
|
224
|
+
clientClass: ClassDeclaration,
|
|
225
|
+
clientParams: ParameterDetails[],
|
|
226
|
+
importedModels: Set<string>
|
|
227
|
+
) {
|
|
228
|
+
const params = clientParams.filter(p => !p.isSynthetic);
|
|
229
|
+
params.forEach(({ typeDetails }) =>
|
|
230
|
+
typeDetails.usedModels.forEach(model => importedModels.add(model))
|
|
231
|
+
);
|
|
232
|
+
clientClass.addProperties(
|
|
233
|
+
params.map(param => {
|
|
234
|
+
return {
|
|
235
|
+
name: param.name,
|
|
236
|
+
type: param.typeDetails.typeName,
|
|
237
|
+
hasQuestionToken: !param.required
|
|
238
|
+
} as PropertyDeclarationStructure;
|
|
239
|
+
})
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
209
243
|
export function checkForNameCollisions(
|
|
210
244
|
importedOperations: OperationGroupDetails[],
|
|
211
245
|
inlineOperations: OperationGroupDetails[]
|
|
@@ -285,8 +319,57 @@ function writeConstructor(
|
|
|
285
319
|
]
|
|
286
320
|
});
|
|
287
321
|
|
|
322
|
+
const { useCoreV2 } = getAutorestOptions();
|
|
323
|
+
const hasLro = clientDetails.operationGroups.some(og =>
|
|
324
|
+
og.operations.some(o => o.isLro)
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
const clientParams = clientDetails.parameters.filter(
|
|
328
|
+
param => param.implementationLocation === ImplementationLocation.Client
|
|
329
|
+
);
|
|
330
|
+
const addBlankLine = true;
|
|
331
|
+
const requiredParameters = getRequiredParamAssignments(requiredParams);
|
|
332
|
+
const constantParameters = getConstantClientParamAssignments(clientParams);
|
|
333
|
+
|
|
334
|
+
const writeStatement = (content: string, shouldAddBlankLine = false) => (
|
|
335
|
+
writer: CodeBlockWriter
|
|
336
|
+
) => {
|
|
337
|
+
if (content) {
|
|
338
|
+
writer.writeLine(content);
|
|
339
|
+
shouldAddBlankLine && writer.blankLine();
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const writeStatements = (lines: string[], shouldAddBlankLine = false) => (
|
|
344
|
+
writer: CodeBlockWriter
|
|
345
|
+
) => {
|
|
346
|
+
lines.forEach(line => writer.writeLine(line));
|
|
347
|
+
shouldAddBlankLine && writer.blankLine();
|
|
348
|
+
};
|
|
349
|
+
|
|
288
350
|
clientConstructor.addStatements([
|
|
289
|
-
|
|
351
|
+
writeStatements(getRequiredParamChecks(requiredParams), addBlankLine),
|
|
352
|
+
writeStatement(
|
|
353
|
+
writeDefaultOptions(
|
|
354
|
+
clientParams.some(p => p.name === "credentials"),
|
|
355
|
+
hasLro,
|
|
356
|
+
clientDetails
|
|
357
|
+
)
|
|
358
|
+
)
|
|
359
|
+
]);
|
|
360
|
+
|
|
361
|
+
!useCoreV2 &&
|
|
362
|
+
clientConstructor.addStatements([
|
|
363
|
+
writeStatement(getEndpointStatement(clientDetails.endpoint), addBlankLine)
|
|
364
|
+
]);
|
|
365
|
+
|
|
366
|
+
clientConstructor.addStatements([
|
|
367
|
+
requiredParameters.length ? "// Parameter assignments" : "",
|
|
368
|
+
writeStatements(getRequiredParamAssignments(requiredParams), addBlankLine),
|
|
369
|
+
constantParameters.length
|
|
370
|
+
? "// Assigning values to Constant parameters"
|
|
371
|
+
: "",
|
|
372
|
+
writeStatements(constantParameters, addBlankLine)
|
|
290
373
|
]);
|
|
291
374
|
|
|
292
375
|
const operationDeclarationDetails: OperationDeclarationDetails[] = getOperationGroupsDeclarationDetails(
|
|
@@ -362,3 +445,151 @@ function writeClientOperations(
|
|
|
362
445
|
})
|
|
363
446
|
);
|
|
364
447
|
}
|
|
448
|
+
|
|
449
|
+
function getRequiredParamChecks(requiredParameters: ParameterDetails[]) {
|
|
450
|
+
return requiredParameters.map(
|
|
451
|
+
({ name }) => `if(${name} === undefined) {
|
|
452
|
+
throw new Error("'${name}' cannot be null");
|
|
453
|
+
}`
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function getCredentialScopesValue(credentialScopes?: string | string[]) {
|
|
458
|
+
if (Array.isArray(credentialScopes)) {
|
|
459
|
+
return `[${credentialScopes.map(scope => `"${scope}"`).join()}]`;
|
|
460
|
+
} else if (typeof credentialScopes === "string") {
|
|
461
|
+
return `"${credentialScopes}"`;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return credentialScopes;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function getTrack2DefaultContent(addScopes: string, hasCredentials: boolean) {
|
|
468
|
+
return `// Initializing default values for options
|
|
469
|
+
if (!options) {
|
|
470
|
+
options = {};
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const defaultUserAgent = \`azsdk-js-\${packageName.replace(/@.*\\//,"")}/\${packageVersion} \${coreHttp.getDefaultUserAgentValue()}\`;
|
|
474
|
+
|
|
475
|
+
${addScopes}
|
|
476
|
+
|
|
477
|
+
super(${hasCredentials ? "credentials" : `undefined`}, {
|
|
478
|
+
...options,
|
|
479
|
+
userAgent: options.userAgent
|
|
480
|
+
? \`\${options.userAgent} \${defaultUserAgent}\`
|
|
481
|
+
: \`\${defaultUserAgent}\`
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
this.requestContentType = "application/json; charset=utf-8";
|
|
485
|
+
|
|
486
|
+
`;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function getTrack1DefaultContent(
|
|
490
|
+
addScopes: string,
|
|
491
|
+
defaults: string,
|
|
492
|
+
packageDetails: PackageDetails,
|
|
493
|
+
clientDetails: ClientDetails
|
|
494
|
+
) {
|
|
495
|
+
return `// Initializing default values for options
|
|
496
|
+
if (!options) {
|
|
497
|
+
options = {};
|
|
498
|
+
}
|
|
499
|
+
${defaults}
|
|
500
|
+
|
|
501
|
+
const packageDetails = \`azsdk-js-${packageDetails.name.replace(
|
|
502
|
+
/@.*\//,
|
|
503
|
+
""
|
|
504
|
+
)}/${packageDetails.version}\`;
|
|
505
|
+
const userAgentPrefix =
|
|
506
|
+
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
507
|
+
? \`\${options.userAgentOptions.userAgentPrefix} \${packageDetails}\`
|
|
508
|
+
: \`\${packageDetails}\`;
|
|
509
|
+
|
|
510
|
+
${addScopes}
|
|
511
|
+
const optionsWithDefaults = {
|
|
512
|
+
...defaults,
|
|
513
|
+
...options,
|
|
514
|
+
userAgentOptions: {
|
|
515
|
+
userAgentPrefix
|
|
516
|
+
},
|
|
517
|
+
baseUri: ${getEndpoint(clientDetails.endpoint)}
|
|
518
|
+
};
|
|
519
|
+
super(optionsWithDefaults);
|
|
520
|
+
`;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function writeDefaultOptions(
|
|
524
|
+
hasCredentials: boolean,
|
|
525
|
+
hasLro: boolean,
|
|
526
|
+
clientDetails: ClientDetails
|
|
527
|
+
) {
|
|
528
|
+
const { useCoreV2, credentialScopes, packageDetails } = getAutorestOptions();
|
|
529
|
+
|
|
530
|
+
const credentialScopesValues = getCredentialScopesValue(credentialScopes);
|
|
531
|
+
const addScopes = credentialScopes
|
|
532
|
+
? `if(!options.credentialScopes) {
|
|
533
|
+
options.credentialScopes = ${credentialScopesValues}
|
|
534
|
+
}`
|
|
535
|
+
: "";
|
|
536
|
+
|
|
537
|
+
const defaults = !hasCredentials
|
|
538
|
+
? `const defaults: ${clientDetails.className}OptionalParams = {
|
|
539
|
+
requestContentType: "application/json; charset=utf-8"
|
|
540
|
+
};`
|
|
541
|
+
: `const defaults: ${clientDetails.className}OptionalParams = {
|
|
542
|
+
requestContentType: "application/json; charset=utf-8",
|
|
543
|
+
credential: credentials
|
|
544
|
+
};`;
|
|
545
|
+
|
|
546
|
+
return !useCoreV2
|
|
547
|
+
? getTrack2DefaultContent(addScopes, hasCredentials)
|
|
548
|
+
: getTrack1DefaultContent(
|
|
549
|
+
addScopes,
|
|
550
|
+
defaults,
|
|
551
|
+
packageDetails,
|
|
552
|
+
clientDetails
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function getEndpointStatement({ endpoint }: EndpointDetails) {
|
|
557
|
+
return `this.baseUri = options.endpoint ?? ${
|
|
558
|
+
endpoint ? `"${endpoint}"` : `""`
|
|
559
|
+
};`;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function getEndpoint({ endpoint }: EndpointDetails) {
|
|
563
|
+
return `options.endpoint ?? options.baseUri ?? ${
|
|
564
|
+
endpoint ? `"${endpoint}"` : `""`
|
|
565
|
+
}`;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
function getRequiredParamAssignments(requiredParameters: ParameterDetails[]) {
|
|
569
|
+
const disallowedClientParameters = ["credentials"];
|
|
570
|
+
return requiredParameters
|
|
571
|
+
.filter(({ name }) => !disallowedClientParameters.includes(name))
|
|
572
|
+
.map(({ name }) => `this.${name} = ${name};`);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
function getConstantClientParamAssignments(
|
|
576
|
+
clientParameters: ParameterDetails[]
|
|
577
|
+
) {
|
|
578
|
+
return clientParameters
|
|
579
|
+
.filter(p => !!p.defaultValue || p.schemaType === SchemaType.Constant)
|
|
580
|
+
.map(
|
|
581
|
+
({ name, defaultValue }) =>
|
|
582
|
+
`this.${name} = options.${name} || ${defaultValue}`
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function writePackageInfo(
|
|
587
|
+
sourceFile: SourceFile,
|
|
588
|
+
packageDetails: PackageDetails
|
|
589
|
+
) {
|
|
590
|
+
sourceFile.addStatements([
|
|
591
|
+
`\n\n`,
|
|
592
|
+
`const packageName = "${packageDetails.name || ""}";`,
|
|
593
|
+
`const packageVersion = "${packageDetails.version || ""}";`
|
|
594
|
+
]);
|
|
595
|
+
}
|
|
@@ -12,7 +12,7 @@ export function generateIndexFile(
|
|
|
12
12
|
project: Project,
|
|
13
13
|
clientDetails?: ClientDetails
|
|
14
14
|
) {
|
|
15
|
-
const { restLevelClient, srcPath } = getAutorestOptions();
|
|
15
|
+
const { restLevelClient, srcPath, multiClient, batch } = getAutorestOptions();
|
|
16
16
|
const indexFile = project.createSourceFile(`${srcPath}/index.ts`, undefined, {
|
|
17
17
|
overwrite: true
|
|
18
18
|
});
|
|
@@ -24,30 +24,103 @@ export function generateIndexFile(
|
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
26
|
generateHLCIndex(clientDetails, indexFile);
|
|
27
|
-
} else {
|
|
27
|
+
} else if (!multiClient || !batch || batch?.length === 1) {
|
|
28
|
+
// if we are generate single client package for RLC
|
|
28
29
|
generateRLCIndex(indexFile);
|
|
30
|
+
} else {
|
|
31
|
+
generateRLCIndexForMultiClient(indexFile);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// to generate a index.ts for each single module inside the multi client RLC package
|
|
36
|
+
function generateRLCIndexForMultiClient(file: SourceFile) {
|
|
37
|
+
const { model } = getSession();
|
|
38
|
+
const clientName = model.language.default.name;
|
|
39
|
+
const createClientFuncName = `${clientName}`;
|
|
40
|
+
const moduleName = normalizeName(clientName, NameType.File);
|
|
41
|
+
|
|
42
|
+
file.addImportDeclaration({
|
|
43
|
+
namespaceImport: "Parameters",
|
|
44
|
+
moduleSpecifier: "./parameters"
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
file.addImportDeclaration({
|
|
48
|
+
namespaceImport: "Responses",
|
|
49
|
+
moduleSpecifier: "./responses"
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
file.addImportDeclaration({
|
|
53
|
+
namespaceImport: "Client",
|
|
54
|
+
moduleSpecifier: "./clientDefinitions"
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const exports = ['Parameters', 'Responses', 'Client'];
|
|
58
|
+
if (hasInputModels(model)) {
|
|
59
|
+
file.addImportDeclaration({
|
|
60
|
+
namespaceImport: "Models",
|
|
61
|
+
moduleSpecifier: "./models",
|
|
62
|
+
});
|
|
63
|
+
exports.push("Models");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (hasOutputModels(model)) {
|
|
67
|
+
file.addImportDeclaration({
|
|
68
|
+
namespaceImport: "OutputModels",
|
|
69
|
+
moduleSpecifier: "./outputModels",
|
|
70
|
+
});
|
|
71
|
+
exports.push("OutputModels");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (hasPagingOperations(model)) {
|
|
75
|
+
file.addImportDeclaration({
|
|
76
|
+
namespaceImport: "PaginateHelper",
|
|
77
|
+
moduleSpecifier: './paginateHelper',
|
|
78
|
+
});
|
|
79
|
+
exports.push("PaginateHelper");
|
|
29
80
|
}
|
|
81
|
+
|
|
82
|
+
if (hasPollingOperations(model)) {
|
|
83
|
+
file.addImportDeclaration({
|
|
84
|
+
namespaceImport: 'PollingHelper',
|
|
85
|
+
moduleSpecifier: './pollingHelper',
|
|
86
|
+
})
|
|
87
|
+
exports.push("PollingHelper");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
file.addExportDeclarations([
|
|
91
|
+
{
|
|
92
|
+
moduleSpecifier: `./${moduleName}`,
|
|
93
|
+
namedExports: [createClientFuncName],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
namedExports: [...exports]
|
|
97
|
+
}
|
|
98
|
+
]);
|
|
30
99
|
}
|
|
31
100
|
|
|
32
101
|
function generateRLCIndex(file: SourceFile) {
|
|
33
102
|
const { model } = getSession();
|
|
34
103
|
const clientName = model.language.default.name;
|
|
104
|
+
const createClientFuncName = `${clientName}`;
|
|
35
105
|
const moduleName = normalizeName(clientName, NameType.File);
|
|
36
106
|
|
|
37
107
|
file.addImportDeclaration({
|
|
38
108
|
moduleSpecifier: `./${moduleName}`,
|
|
39
|
-
defaultImport:
|
|
109
|
+
defaultImport: createClientFuncName
|
|
40
110
|
});
|
|
41
111
|
|
|
42
112
|
file.addExportDeclarations([
|
|
43
113
|
{
|
|
44
|
-
moduleSpecifier: `./${moduleName}
|
|
114
|
+
moduleSpecifier: `./${moduleName}`,
|
|
45
115
|
},
|
|
46
116
|
{
|
|
47
117
|
moduleSpecifier: "./parameters"
|
|
48
118
|
},
|
|
49
119
|
{
|
|
50
120
|
moduleSpecifier: "./responses"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
moduleSpecifier: "./clientDefinitions"
|
|
51
124
|
}
|
|
52
125
|
]);
|
|
53
126
|
|
|
@@ -84,7 +157,7 @@ function generateRLCIndex(file: SourceFile) {
|
|
|
84
157
|
}
|
|
85
158
|
|
|
86
159
|
file.addExportAssignment({
|
|
87
|
-
expression:
|
|
160
|
+
expression: createClientFuncName,
|
|
88
161
|
isExportEquals: false
|
|
89
162
|
});
|
|
90
163
|
}
|
|
@@ -102,10 +175,6 @@ function generateHLCIndex(clientDetails: ClientDetails, file: SourceFile) {
|
|
|
102
175
|
{
|
|
103
176
|
moduleSpecifier: `./${clientDetails.sourceFileName}`,
|
|
104
177
|
namedExports: [clientDetails.className]
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
moduleSpecifier: `./${clientDetails.sourceFileName}Context`,
|
|
108
|
-
namedExports: [`${clientDetails.className}Context`]
|
|
109
178
|
}
|
|
110
179
|
]);
|
|
111
180
|
|
|
@@ -69,6 +69,10 @@ export function generateModels(clientDetails: ClientDetails, project: Project) {
|
|
|
69
69
|
namespaceImport: "coreRestPipeline",
|
|
70
70
|
moduleSpecifier: "@azure/core-rest-pipeline"
|
|
71
71
|
});
|
|
72
|
+
modelsIndexFile.addImportDeclaration({
|
|
73
|
+
namespaceImport: "coreHttpCompat",
|
|
74
|
+
moduleSpecifier: "@azure/core-http-compat"
|
|
75
|
+
});
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
writeUniontypes(clientDetails, modelsIndexFile);
|
|
@@ -77,13 +81,21 @@ export function generateModels(clientDetails: ClientDetails, project: Project) {
|
|
|
77
81
|
writeOperationModels(clientDetails, modelsIndexFile);
|
|
78
82
|
writeClientModels(clientDetails, modelsIndexFile);
|
|
79
83
|
modelsIndexFile.fixUnusedIdentifiers();
|
|
84
|
+
const allTypes = modelsIndexFile.getTypeAliases();
|
|
85
|
+
clientDetails.allTypes = allTypes
|
|
86
|
+
.filter(item => {
|
|
87
|
+
return item.isExported();
|
|
88
|
+
})
|
|
89
|
+
.map(item => {
|
|
90
|
+
return item.getName();
|
|
91
|
+
});
|
|
80
92
|
}
|
|
81
93
|
|
|
82
94
|
const writeClientModels = (
|
|
83
95
|
clientDetails: ClientDetails,
|
|
84
96
|
modelsIndexFile: SourceFile
|
|
85
97
|
) => {
|
|
86
|
-
const { useCoreV2 } = getAutorestOptions();
|
|
98
|
+
const { useCoreV2, coreHttpCompatMode } = getAutorestOptions();
|
|
87
99
|
let clientOptionalParams = clientDetails.parameters.filter(
|
|
88
100
|
p =>
|
|
89
101
|
(!p.required || p.defaultValue) &&
|
|
@@ -97,6 +109,8 @@ const writeClientModels = (
|
|
|
97
109
|
{
|
|
98
110
|
baseClass: !useCoreV2
|
|
99
111
|
? "coreHttp.ServiceClientOptions"
|
|
112
|
+
: coreHttpCompatMode
|
|
113
|
+
? "coreHttpCompat.ExtendedServiceClientOptions"
|
|
100
114
|
: "coreClient.ServiceClientOptions"
|
|
101
115
|
}
|
|
102
116
|
);
|
|
@@ -771,6 +785,12 @@ function getPropertyTypeName(
|
|
|
771
785
|
ignoreNullableOnOptional: boolean
|
|
772
786
|
) {
|
|
773
787
|
if (property.isConstant) {
|
|
788
|
+
if (
|
|
789
|
+
property.type === SchemaType.Number ||
|
|
790
|
+
property.type === SchemaType.Boolean
|
|
791
|
+
) {
|
|
792
|
+
return `${property.defaultValue}`;
|
|
793
|
+
}
|
|
774
794
|
return `"${getStringForValue(
|
|
775
795
|
property.defaultValue,
|
|
776
796
|
property.type,
|
|
@@ -475,7 +475,7 @@ function addClass(
|
|
|
475
475
|
name: "client",
|
|
476
476
|
isReadonly: true,
|
|
477
477
|
scope: Scope.Private,
|
|
478
|
-
type: `${clientDetails.className}
|
|
478
|
+
type: `${clientDetails.className}`
|
|
479
479
|
});
|
|
480
480
|
const constructorDefinition = operationGroupClass.addConstructor({
|
|
481
481
|
docs: [
|
|
@@ -487,7 +487,7 @@ function addClass(
|
|
|
487
487
|
{
|
|
488
488
|
name: "client",
|
|
489
489
|
hasQuestionToken: false,
|
|
490
|
-
type: `${clientDetails.className}
|
|
490
|
+
type: `${clientDetails.className}`
|
|
491
491
|
}
|
|
492
492
|
]
|
|
493
493
|
});
|
|
@@ -979,11 +979,13 @@ function writeLroOperationBody(
|
|
|
979
979
|
sendOperationStatement,
|
|
980
980
|
`const lro = new LroImpl(sendOperation,${operationParamsName},
|
|
981
981
|
${operationSpecName})`,
|
|
982
|
-
`
|
|
982
|
+
`const poller = new LroEngine(lro,{ resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs${
|
|
983
983
|
lroResourceLocationConfig
|
|
984
984
|
? `, lroResourceLocationConfig: "${lroResourceLocationConfig.toLowerCase()}"`
|
|
985
985
|
: ""
|
|
986
|
-
} })
|
|
986
|
+
} });`,
|
|
987
|
+
'await poller.poll();',
|
|
988
|
+
'return poller;'
|
|
987
989
|
]);
|
|
988
990
|
|
|
989
991
|
methodDeclaration.setReturnType(
|
|
@@ -1319,16 +1321,16 @@ function addImports(
|
|
|
1319
1321
|
});
|
|
1320
1322
|
}
|
|
1321
1323
|
|
|
1322
|
-
const
|
|
1324
|
+
const clientClassName = `${className}`;
|
|
1323
1325
|
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
+
const clientFileName = normalizeName(
|
|
1327
|
+
clientClassName,
|
|
1326
1328
|
NameType.File
|
|
1327
1329
|
);
|
|
1328
1330
|
|
|
1329
1331
|
operationGroupFile.addImportDeclaration({
|
|
1330
|
-
namedImports: [`${
|
|
1331
|
-
moduleSpecifier: `../${
|
|
1332
|
+
namedImports: [`${clientClassName}`],
|
|
1333
|
+
moduleSpecifier: `../${clientFileName}`
|
|
1332
1334
|
});
|
|
1333
1335
|
|
|
1334
1336
|
if (hasLroOperation(operationGroupDetails)) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as hbs from 'handlebars';
|
|
4
|
+
import { Project } from 'ts-morph';
|
|
5
|
+
|
|
6
|
+
export function generateSampleEnv(project: Project) {
|
|
7
|
+
const file = fs.readFileSync(path.join(__dirname, "sampleEnv.hbs"), {
|
|
8
|
+
encoding: "utf-8"
|
|
9
|
+
});
|
|
10
|
+
const readmeFileContents = hbs.compile(file, { noEscape: true });
|
|
11
|
+
project.createSourceFile("sample.env", readmeFileContents({}), {
|
|
12
|
+
overwrite: true
|
|
13
|
+
});
|
|
14
|
+
}
|