@azure-tools/rlc-common 1.0.0-beta.7 → 1.0.0-beta.9
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/.rush/temp/package-deps_build.json +15 -12
- package/.rush/temp/shrinkwrap-deps.json +13 -13
- package/CHANGELOG.md +14 -2
- package/dist/buildClient.js +45 -13
- package/dist/buildClient.js.map +1 -1
- package/dist/buildIndexFile.js +18 -0
- package/dist/buildIndexFile.js.map +1 -1
- package/dist/buildSerializeHelper.js +35 -0
- package/dist/buildSerializeHelper.js.map +1 -0
- package/dist/buildTopLevelIndexFile.js +2 -1
- package/dist/buildTopLevelIndexFile.js.map +1 -1
- package/dist/helpers/operationHelpers.js +22 -2
- package/dist/helpers/operationHelpers.js.map +1 -1
- package/dist/helpers/pathUtils.js +12 -0
- package/dist/helpers/pathUtils.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/metadata/buildPackageFile.js +44 -17
- package/dist/metadata/buildPackageFile.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/static/pollingContent.js +26 -6
- package/dist/static/pollingContent.js.map +1 -1
- package/dist/static/serializeHelper.js +30 -0
- package/dist/static/serializeHelper.js.map +1 -0
- package/dist/test/template.js +0 -2
- package/dist/test/template.js.map +1 -1
- package/dist-esm/buildClient.js +45 -13
- package/dist-esm/buildClient.js.map +1 -1
- package/dist-esm/buildIndexFile.js +19 -1
- package/dist-esm/buildIndexFile.js.map +1 -1
- package/dist-esm/buildSerializeHelper.js +31 -0
- package/dist-esm/buildSerializeHelper.js.map +1 -0
- package/dist-esm/buildTopLevelIndexFile.js +2 -1
- package/dist-esm/buildTopLevelIndexFile.js.map +1 -1
- package/dist-esm/helpers/operationHelpers.js +14 -2
- package/dist-esm/helpers/operationHelpers.js.map +1 -1
- package/dist-esm/helpers/pathUtils.js +8 -0
- package/dist-esm/helpers/pathUtils.js.map +1 -0
- package/dist-esm/index.js +1 -0
- package/dist-esm/index.js.map +1 -1
- package/dist-esm/interfaces.js.map +1 -1
- package/dist-esm/metadata/buildPackageFile.js +44 -17
- package/dist-esm/metadata/buildPackageFile.js.map +1 -1
- package/dist-esm/package.json +1 -1
- package/dist-esm/static/pollingContent.js +26 -6
- package/dist-esm/static/pollingContent.js.map +1 -1
- package/dist-esm/static/serializeHelper.js +27 -0
- package/dist-esm/static/serializeHelper.js.map +1 -0
- package/dist-esm/test/template.js +0 -2
- package/dist-esm/test/template.js.map +1 -1
- package/package.json +1 -1
- package/src/buildClient.ts +53 -14
- package/src/buildIndexFile.ts +28 -0
- package/src/buildSerializeHelper.ts +42 -0
- package/src/buildTopLevelIndexFile.ts +6 -2
- package/src/helpers/operationHelpers.ts +18 -2
- package/src/helpers/pathUtils.ts +7 -0
- package/src/index.ts +1 -0
- package/src/interfaces.ts +5 -0
- package/src/metadata/buildPackageFile.ts +53 -17
- package/src/static/pollingContent.ts +26 -6
- package/src/static/serializeHelper.ts +29 -0
- package/src/test/template.ts +0 -2
- package/types/buildSerializeHelper.d.ts +5 -0
- package/types/helpers/operationHelpers.d.ts +4 -0
- package/types/helpers/pathUtils.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/interfaces.d.ts +5 -0
- package/types/static/pollingContent.d.ts +1 -1
- package/types/static/serializeHelper.d.ts +4 -0
- package/types/test/template.d.ts +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../../src/helpers/pathUtils.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,UAAU,0BAA0B,CAAC,OAAe;IACxD,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IACrE,OAAO,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC;QACjC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;QAC3B,CAAC,CAAC,YAAY,CAAC;AACnB,CAAC"}
|
package/dist-esm/index.js
CHANGED
|
@@ -25,4 +25,5 @@ export * from "./metadata/buildRollupConfig.js";
|
|
|
25
25
|
export * from "./metadata/buildTsConfig.js";
|
|
26
26
|
export * from "./metadata/buildESLintConfig.js";
|
|
27
27
|
export * from "./metadata/buildLicenseFile.js";
|
|
28
|
+
export * from "./buildSerializeHelper.js";
|
|
28
29
|
//# sourceMappingURL=index.js.map
|
package/dist-esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uCAAuC,CAAC;AACtD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uCAAuC,CAAC;AACtD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAmHA,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,+DAAc,CAAA;IACd,+DAAc,CAAA;AAChB,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB;AAMD,MAAM,CAAN,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,kDAAkD;IAClD,gCAAe,CAAA;IACf,qDAAqD;IACrD,kCAAiB,CAAA;IACjB,wDAAwD;IACxD,wCAAuB,CAAA;AACzB,CAAC,EAPW,aAAa,KAAb,aAAa,QAOxB"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { Project } from "ts-morph";
|
|
4
|
+
import { NameType, normalizeName } from "../helpers/nameUtils.js";
|
|
4
5
|
import { hasPagingOperations, hasPollingOperations } from "../helpers/operationHelpers.js";
|
|
6
|
+
import { getRelativePartFromSrcPath } from "../helpers/pathUtils.js";
|
|
5
7
|
let hasPaging = false;
|
|
6
8
|
let hasLRO = false;
|
|
9
|
+
let clientFilePaths = [];
|
|
7
10
|
export function buildPackageFile(model, hasSamplesGenerated = false) {
|
|
8
11
|
const generateMetadata = Boolean(model.options?.generateMetadata);
|
|
9
12
|
if (!generateMetadata) {
|
|
@@ -32,14 +35,21 @@ function restLevelPackage(model, hasSamplesGenerated) {
|
|
|
32
35
|
if (!model.options || !model.options.packageDetails) {
|
|
33
36
|
return;
|
|
34
37
|
}
|
|
35
|
-
|
|
38
|
+
clientFilePaths.push(getClientFilePath(model));
|
|
39
|
+
hasPaging = hasPaging || hasPagingOperations(model);
|
|
40
|
+
hasLRO = hasLRO || hasPollingOperations(model);
|
|
41
|
+
const { packageDetails, generateTest, generateSample, azureOutputDirectory, azureSdkForJs, isCadlTest, sourceFrom, multiClient, batch } = model.options;
|
|
42
|
+
if (multiClient &&
|
|
43
|
+
batch &&
|
|
44
|
+
batch.length > 1 &&
|
|
45
|
+
clientFilePaths.length < batch.length) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
36
48
|
const clientPackageName = packageDetails.name;
|
|
37
49
|
let apiRefUrlQueryParameter = "";
|
|
38
50
|
if (packageDetails.version.includes("beta")) {
|
|
39
51
|
apiRefUrlQueryParameter = "?view=azure-node-preview";
|
|
40
52
|
}
|
|
41
|
-
hasPaging = hasPaging || hasPagingOperations(model);
|
|
42
|
-
hasLRO = hasLRO || hasPollingOperations(model);
|
|
43
53
|
const packageInfo = {
|
|
44
54
|
name: `${packageDetails.name}`,
|
|
45
55
|
"sdk-type": "client",
|
|
@@ -79,7 +89,9 @@ function restLevelPackage(model, hasSamplesGenerated) {
|
|
|
79
89
|
"execute:samples": "echo skipped",
|
|
80
90
|
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
|
|
81
91
|
format: `prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore "src/**/*.ts" "*.{js,json}" ${appendPathWhenFormat(generateTest, generateSample)}`,
|
|
82
|
-
"generate:client":
|
|
92
|
+
"generate:client": sourceFrom === "Swagger"
|
|
93
|
+
? "autorest --typescript swagger/README.md && npm run format"
|
|
94
|
+
: "echo skipped",
|
|
83
95
|
"integration-test:browser": "echo skipped",
|
|
84
96
|
"integration-test:node": "echo skipped",
|
|
85
97
|
"integration-test": "echo skipped",
|
|
@@ -105,17 +117,18 @@ function restLevelPackage(model, hasSamplesGenerated) {
|
|
|
105
117
|
"@azure/core-paging": "^1.2.0"
|
|
106
118
|
}),
|
|
107
119
|
...(hasLRO && {
|
|
108
|
-
"@azure/core-lro": "^2.
|
|
120
|
+
"@azure/core-lro": "^2.5.0",
|
|
121
|
+
"@azure/abort-controller": "^1.0.0"
|
|
109
122
|
})
|
|
110
123
|
},
|
|
111
124
|
devDependencies: {
|
|
112
125
|
"@microsoft/api-extractor": "^7.31.1",
|
|
113
126
|
autorest: "latest",
|
|
114
127
|
"@types/node": "^14.0.0",
|
|
115
|
-
dotenv: "^
|
|
128
|
+
dotenv: "^16.0.0",
|
|
116
129
|
eslint: "^8.0.0",
|
|
117
|
-
mkdirp: "^1.
|
|
118
|
-
prettier: "2.
|
|
130
|
+
mkdirp: "^2.1.2",
|
|
131
|
+
prettier: "^2.5.1",
|
|
119
132
|
rimraf: "^3.0.0",
|
|
120
133
|
"source-map-support": "^0.5.9",
|
|
121
134
|
typescript: "~4.8.0"
|
|
@@ -126,13 +139,21 @@ function restLevelPackage(model, hasSamplesGenerated) {
|
|
|
126
139
|
}
|
|
127
140
|
if (azureSdkForJs) {
|
|
128
141
|
packageInfo["//metadata"] = {
|
|
129
|
-
constantPaths: [
|
|
130
|
-
{
|
|
131
|
-
path: "swagger/README.md",
|
|
132
|
-
prefix: "package-version"
|
|
133
|
-
}
|
|
134
|
-
]
|
|
142
|
+
constantPaths: []
|
|
135
143
|
};
|
|
144
|
+
clientFilePaths.forEach((path) => {
|
|
145
|
+
packageInfo["//metadata"].constantPaths.push({
|
|
146
|
+
path,
|
|
147
|
+
prefix: "userAgentInfo"
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
// Only generate this from Swagger spec
|
|
151
|
+
if (sourceFrom === "Swagger") {
|
|
152
|
+
packageInfo["//metadata"].constantPaths.push({
|
|
153
|
+
path: "swagger/README.md",
|
|
154
|
+
prefix: "package-version"
|
|
155
|
+
});
|
|
156
|
+
}
|
|
136
157
|
packageInfo.scripts["build"] =
|
|
137
158
|
"npm run clean && tsc -p . && dev-tool run bundle && mkdirp ./review && api-extractor run --local";
|
|
138
159
|
packageInfo.scripts["build:debug"] =
|
|
@@ -171,17 +192,15 @@ function restLevelPackage(model, hasSamplesGenerated) {
|
|
|
171
192
|
packageInfo.devDependencies["cross-env"] = "^7.0.2";
|
|
172
193
|
packageInfo.devDependencies["karma-chrome-launcher"] = "^3.0.0";
|
|
173
194
|
packageInfo.devDependencies["karma-coverage"] = "^2.0.0";
|
|
174
|
-
packageInfo.devDependencies["karma-edge-launcher"] = "^0.4.2";
|
|
175
195
|
packageInfo.devDependencies["karma-env-preprocessor"] = "^0.1.1";
|
|
176
196
|
packageInfo.devDependencies["karma-firefox-launcher"] = "^1.1.0";
|
|
177
|
-
packageInfo.devDependencies["karma-ie-launcher"] = "^1.0.0";
|
|
178
197
|
packageInfo.devDependencies["karma-junit-reporter"] = "^2.0.1";
|
|
179
198
|
packageInfo.devDependencies["karma-mocha-reporter"] = "^2.2.5";
|
|
180
199
|
packageInfo.devDependencies["karma-mocha"] = "^2.0.1";
|
|
181
200
|
packageInfo.devDependencies["karma-source-map-support"] = "~1.4.0";
|
|
182
201
|
packageInfo.devDependencies["karma-sourcemap-loader"] = "^0.3.8";
|
|
183
202
|
packageInfo.devDependencies["karma"] = "^6.2.0";
|
|
184
|
-
packageInfo.devDependencies["nyc"] = "^
|
|
203
|
+
packageInfo.devDependencies["nyc"] = "^15.0.0";
|
|
185
204
|
packageInfo.devDependencies["source-map-support"] = "^0.5.9";
|
|
186
205
|
packageInfo.scripts["test"] =
|
|
187
206
|
"npm run clean && npm run build:test && npm run unit-test";
|
|
@@ -246,4 +265,12 @@ function appendPathWhenFormat(generateTest, generateSample) {
|
|
|
246
265
|
function appednPathWhenLint(generateTest) {
|
|
247
266
|
return generateTest ? "test" : "";
|
|
248
267
|
}
|
|
268
|
+
function getClientFilePath(model) {
|
|
269
|
+
const { srcPath } = model;
|
|
270
|
+
const sdkReletivePart = getRelativePartFromSrcPath(srcPath);
|
|
271
|
+
const clientFilename = normalizeName(model.libraryName, NameType.File);
|
|
272
|
+
return sdkReletivePart
|
|
273
|
+
? `src/${sdkReletivePart}/${clientFilename}.ts`
|
|
274
|
+
: `src/${clientFilename}.ts`;
|
|
275
|
+
}
|
|
249
276
|
//# sourceMappingURL=buildPackageFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPackageFile.js","sourceRoot":"","sources":["../../src/metadata/buildPackageFile.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"buildPackageFile.js","sourceRoot":"","sources":["../../src/metadata/buildPackageFile.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,gC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jB,WAAW,CAAC,OAAO,CAAC,iBAAiB,CAAC;gBACpC,kCAAkC,CAAC;SACtC;KACF;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,oBAAoB,CAC3B,YAAsB,EACtB,cAAwB;IAExB,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,YAAY,EAAE;QAChB,IAAI,GAAG,IAAI,GAAG,iBAAiB,CAAC;KACjC;IACD,IAAI,cAAc,EAAE;QAClB,IAAI,GAAG,IAAI,GAAG,wBAAwB,CAAC;KACxC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,kBAAkB,CAAC,YAAsB;IAChD,OAAO,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AACpC,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAe;IACxC,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1B,MAAM,eAAe,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,cAAc,GAAG,aAAa,CAAC,KAAK,CAAC,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvE,OAAO,eAAe;QACpB,CAAC,CAAC,OAAO,eAAe,IAAI,cAAc,KAAK;QAC/C,CAAC,CAAC,OAAO,cAAc,KAAK,CAAC;AACjC,CAAC"}
|
package/dist-esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@azure-tools/rlc-common","version":"1.0.0-beta.
|
|
1
|
+
{"name":"@azure-tools/rlc-common","version":"1.0.0-beta.9","description":"","type":"module","main":"dist/index.js","module":"dist-esm/index.js","exports":{".":{"types":"./types/index.d.ts","require":"./dist/index.js","import":"./dist-esm/index.js"}},"types":"./types/index.d.ts","scripts":{"lint":"eslint src --ext .ts --max-warnings=0","lint:fix":"eslint src --fix --ext .ts","format":"npm run -s prettier -- --write","check-format":"npm run prettier -- --check","prettier":"prettier --config ./.prettierrc src/**/*.ts","build":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node publishPackage.js","build:cjs":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig-cjs.json && node publishPackage.js","build:esm":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig.json && node publishPackage.js","test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":"","license":"ISC","dependencies":{"ts-morph":"^15.1.0","lodash":"^4.17.21","handlebars":"^4.7.7"},"devDependencies":{"@types/node":"^18.0.0","eslint":"^8.9.0","prettier":"~2.7.1","typescript":"~4.8.0","rimraf":"^3.0.2","@types/lodash":"^4.14.182","fs-extra":"^10.0.0","@types/fs-extra":"^8.1.0","ts-node":"^10.7.0"}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const pollingContent = `
|
|
2
2
|
import { Client, HttpResponse } from "@azure-rest/core-client";
|
|
3
|
+
{{#if useLegacyLro}}
|
|
3
4
|
import {
|
|
4
5
|
LongRunningOperation,
|
|
5
6
|
LroEngine,
|
|
@@ -8,7 +9,16 @@ import {
|
|
|
8
9
|
PollerLike,
|
|
9
10
|
PollOperationState
|
|
10
11
|
} from "@azure/core-lro";
|
|
11
|
-
|
|
12
|
+
{{else}}
|
|
13
|
+
import {
|
|
14
|
+
CreateHttpPollerOptions,
|
|
15
|
+
LongRunningOperation,
|
|
16
|
+
LroResponse,
|
|
17
|
+
OperationState,
|
|
18
|
+
SimplePollerLike,
|
|
19
|
+
createHttpPoller
|
|
20
|
+
} from "@azure/core-lro";
|
|
21
|
+
{{/if}}
|
|
12
22
|
/**
|
|
13
23
|
* Helper function that builds a Poller object to help polling a long running operation.
|
|
14
24
|
* @param client - Client to use for sending the request to get additional pages.
|
|
@@ -16,12 +26,17 @@ import {
|
|
|
16
26
|
* @param options - Options to set a resume state or custom polling interval.
|
|
17
27
|
* @returns - A poller object to poll for operation state updates and eventually get the final response.
|
|
18
28
|
*/
|
|
19
|
-
export function getLongRunningPoller<TResult extends HttpResponse>(
|
|
29
|
+
export {{#unless useLegacyLro}}async {{/unless}}function getLongRunningPoller<TResult extends HttpResponse>(
|
|
20
30
|
client: Client,
|
|
21
31
|
initialResponse: TResult,
|
|
32
|
+
{{#if useLegacyLro}}
|
|
22
33
|
options: LroEngineOptions<TResult, PollOperationState<TResult>> = {}
|
|
23
|
-
): PollerLike<PollOperationState<TResult>, TResult> {
|
|
24
|
-
|
|
34
|
+
): PollerLike<PollOperationState<TResult>, TResult> {
|
|
35
|
+
{{else}}
|
|
36
|
+
options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {}
|
|
37
|
+
): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {
|
|
38
|
+
{{/if}}
|
|
39
|
+
const poller: LongRunningOperation<TResult> = {
|
|
25
40
|
requestMethod: initialResponse.request.method,
|
|
26
41
|
requestPath: initialResponse.request.url,
|
|
27
42
|
sendInitialRequest: async () => {
|
|
@@ -45,13 +60,18 @@ export function getLongRunningPoller<TResult extends HttpResponse>(
|
|
|
45
60
|
}
|
|
46
61
|
};
|
|
47
62
|
|
|
63
|
+
{{#if useLegacyLro}}
|
|
48
64
|
return new LroEngine(poller, options);
|
|
65
|
+
{{else}}
|
|
66
|
+
options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;
|
|
67
|
+
return await createHttpPoller(poller, options);
|
|
68
|
+
{{/if}}
|
|
49
69
|
}
|
|
50
70
|
|
|
51
71
|
/**
|
|
52
|
-
* Converts a Rest Client response to a response that the LRO
|
|
72
|
+
* Converts a Rest Client response to a response that the LRO implementation understands
|
|
53
73
|
* @param response - a rest client http response
|
|
54
|
-
* @returns - An LRO response that the LRO
|
|
74
|
+
* @returns - An LRO response that the LRO implementation understands
|
|
55
75
|
*/
|
|
56
76
|
function getLroResponse<TResult extends HttpResponse>(
|
|
57
77
|
response: TResult
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pollingContent.js","sourceRoot":"","sources":["../../src/static/pollingContent.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG
|
|
1
|
+
{"version":3,"file":"pollingContent.js","sourceRoot":"","sources":["../../src/static/pollingContent.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6F7B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const buildMultiCollectionContent = `
|
|
2
|
+
export function buildMultiCollection(
|
|
3
|
+
queryParameters: string[],
|
|
4
|
+
parameterName: string
|
|
5
|
+
) {
|
|
6
|
+
return queryParameters
|
|
7
|
+
.map((item, index) => {
|
|
8
|
+
if (index === 0) {
|
|
9
|
+
return item;
|
|
10
|
+
}
|
|
11
|
+
return \`\${parameterName}=\${item}\`;
|
|
12
|
+
})
|
|
13
|
+
.join("&");
|
|
14
|
+
}`;
|
|
15
|
+
export const buildPipeCollectionContent = `
|
|
16
|
+
export function buildPipeCollection(queryParameters: string[]): string {
|
|
17
|
+
return queryParameters.join("|");
|
|
18
|
+
}`;
|
|
19
|
+
export const buildSsvCollectionContent = `
|
|
20
|
+
export function buildSsvCollection(queryParameters: string[]): string {
|
|
21
|
+
return queryParameters.join(" ");
|
|
22
|
+
}`;
|
|
23
|
+
export const buildTsvCollectionContent = `
|
|
24
|
+
export function buildTsvCollection(queryParameters: string[]) {
|
|
25
|
+
return queryParameters.join("\\t");
|
|
26
|
+
}`;
|
|
27
|
+
//# sourceMappingURL=serializeHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeHelper.js","sourceRoot":"","sources":["../../src/static/serializeHelper.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,2BAA2B,GAAG;;;;;;;;;;;;;EAazC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;EAGxC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;EAGvC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;EAGvC,CAAC"}
|
|
@@ -28,9 +28,7 @@ module.exports = function (config) {
|
|
|
28
28
|
"karma-mocha",
|
|
29
29
|
"karma-mocha-reporter",
|
|
30
30
|
"karma-chrome-launcher",
|
|
31
|
-
"karma-edge-launcher",
|
|
32
31
|
"karma-firefox-launcher",
|
|
33
|
-
"karma-ie-launcher",
|
|
34
32
|
"karma-env-preprocessor",
|
|
35
33
|
"karma-coverage",
|
|
36
34
|
"karma-sourcemap-loader",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/test/template.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;;;;CAIzB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;CAIhC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/test/template.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;;;;CAIzB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;CAIhC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8H1B,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BpC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;CAqBhC,CAAC"}
|
package/package.json
CHANGED
package/src/buildClient.ts
CHANGED
|
@@ -56,6 +56,7 @@ export function buildClient(model: RLCModel): File | undefined {
|
|
|
56
56
|
? `${clientName}`
|
|
57
57
|
: `${clientName}Client`;
|
|
58
58
|
|
|
59
|
+
normalizeUrlInfo(model);
|
|
59
60
|
const urlParameters = model?.urlInfo?.urlParameters?.filter(
|
|
60
61
|
// Do not include parameters with constant values in the signature, these should go in the options bag
|
|
61
62
|
(p) => p.value === undefined
|
|
@@ -93,27 +94,38 @@ export function buildClient(model: RLCModel): File | undefined {
|
|
|
93
94
|
...(addCredentials === false ||
|
|
94
95
|
!isSecurityInfoDefined(credentialScopes, credentialKeyHeaderName)
|
|
95
96
|
? []
|
|
96
|
-
: [
|
|
97
|
+
: [
|
|
98
|
+
{
|
|
99
|
+
name: "credentials",
|
|
100
|
+
type: credentialTypes.join(" | "),
|
|
101
|
+
description: `uniquely identify client credential`
|
|
102
|
+
}
|
|
103
|
+
])
|
|
97
104
|
];
|
|
98
105
|
|
|
106
|
+
const allClientParams = [
|
|
107
|
+
...commonClientParams,
|
|
108
|
+
{
|
|
109
|
+
name: "options",
|
|
110
|
+
type: `${clientOptionsInterface?.name ?? "ClientOptions"} = {}`,
|
|
111
|
+
description: "the parameter for all optional parameters"
|
|
112
|
+
}
|
|
113
|
+
];
|
|
99
114
|
const functionStatement = {
|
|
100
115
|
isExported: true,
|
|
101
116
|
name: `createClient`,
|
|
102
|
-
parameters:
|
|
103
|
-
...commonClientParams,
|
|
104
|
-
{
|
|
105
|
-
name: "options",
|
|
106
|
-
type: `${clientOptionsInterface?.name ?? "ClientOptions"} = {}`
|
|
107
|
-
}
|
|
108
|
-
],
|
|
117
|
+
parameters: allClientParams,
|
|
109
118
|
docs: [
|
|
110
119
|
{
|
|
111
120
|
description:
|
|
112
|
-
`Initialize a new instance of
|
|
113
|
-
|
|
121
|
+
`Initialize a new instance of \`${clientInterfaceName}\` \n` +
|
|
122
|
+
allClientParams
|
|
114
123
|
.map((param) => {
|
|
115
|
-
return `@param ${param.name} type: ${param.type
|
|
116
|
-
|
|
124
|
+
return `@param ${param.name} type: ${param.type
|
|
125
|
+
.split("=")[0]
|
|
126
|
+
.split(" ")
|
|
127
|
+
.join("")}, ${
|
|
128
|
+
param.description ?? "The parameter " + param.name
|
|
117
129
|
}`;
|
|
118
130
|
})
|
|
119
131
|
.join("\n")
|
|
@@ -204,7 +216,7 @@ function getClientFactoryBody(
|
|
|
204
216
|
baseUrl = `options.baseUrl ?? "${endpoint}"`;
|
|
205
217
|
}
|
|
206
218
|
|
|
207
|
-
const apiVersion =
|
|
219
|
+
const apiVersion = getApiVersionInQueryParam(model);
|
|
208
220
|
let apiVersionStatement: string = "";
|
|
209
221
|
if (apiVersion) {
|
|
210
222
|
apiVersionStatement = `options.apiVersion = options.apiVersion ?? "${apiVersion}"`;
|
|
@@ -298,7 +310,7 @@ function getClientFactoryBody(
|
|
|
298
310
|
];
|
|
299
311
|
}
|
|
300
312
|
|
|
301
|
-
function
|
|
313
|
+
function getApiVersionInQueryParam(model: RLCModel): string | undefined {
|
|
302
314
|
if (!model.apiVersionInQueryParam) {
|
|
303
315
|
return undefined;
|
|
304
316
|
}
|
|
@@ -312,3 +324,30 @@ function getApiVersion(model: RLCModel): string | undefined {
|
|
|
312
324
|
|
|
313
325
|
return undefined;
|
|
314
326
|
}
|
|
327
|
+
|
|
328
|
+
function normalizeUrlInfo(model: RLCModel) {
|
|
329
|
+
if (
|
|
330
|
+
!model ||
|
|
331
|
+
!model.urlInfo ||
|
|
332
|
+
!model.urlInfo.endpoint ||
|
|
333
|
+
!model.urlInfo.urlParameters ||
|
|
334
|
+
model.urlInfo.urlParameters.length === 0
|
|
335
|
+
) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
let parsedEndpoint = model.urlInfo.endpoint;
|
|
340
|
+
const urlParameters = model.urlInfo.urlParameters;
|
|
341
|
+
urlParameters.forEach((urlParameter) => {
|
|
342
|
+
const name = urlParameter.name;
|
|
343
|
+
const normalizedName = normalizeName(name, NameType.Parameter);
|
|
344
|
+
if (name !== normalizedName) {
|
|
345
|
+
urlParameter.name = normalizedName;
|
|
346
|
+
parsedEndpoint = parsedEndpoint.replace(
|
|
347
|
+
`{${name}}`,
|
|
348
|
+
`{${normalizedName}}`
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
model.urlInfo.endpoint = parsedEndpoint;
|
|
353
|
+
}
|
package/src/buildIndexFile.ts
CHANGED
|
@@ -5,9 +5,13 @@ import { Project, SourceFile } from "ts-morph";
|
|
|
5
5
|
import { NameType, normalizeName } from "./helpers/nameUtils.js";
|
|
6
6
|
import {
|
|
7
7
|
hasInputModels,
|
|
8
|
+
hasMultiCollection,
|
|
8
9
|
hasOutputModels,
|
|
9
10
|
hasPagingOperations,
|
|
11
|
+
hasPipeCollection,
|
|
10
12
|
hasPollingOperations,
|
|
13
|
+
hasSsvCollection,
|
|
14
|
+
hasTsvCollection,
|
|
11
15
|
hasUnexpectedHelper
|
|
12
16
|
} from "./helpers/operationHelpers.js";
|
|
13
17
|
import { RLCModel } from "./interfaces.js";
|
|
@@ -89,6 +93,19 @@ function generateRLCIndexForMultiClient(file: SourceFile, model: RLCModel) {
|
|
|
89
93
|
exports.push("PollingHelper");
|
|
90
94
|
}
|
|
91
95
|
|
|
96
|
+
if (
|
|
97
|
+
hasMultiCollection(model) ||
|
|
98
|
+
hasSsvCollection(model) ||
|
|
99
|
+
hasPipeCollection(model) ||
|
|
100
|
+
hasTsvCollection(model)
|
|
101
|
+
) {
|
|
102
|
+
file.addImportDeclaration({
|
|
103
|
+
namespaceImport: "SerializeHelper",
|
|
104
|
+
moduleSpecifier: "./serializeHelper"
|
|
105
|
+
});
|
|
106
|
+
exports.push("SerializeHelper");
|
|
107
|
+
}
|
|
108
|
+
|
|
92
109
|
file.addExportDeclarations([
|
|
93
110
|
{
|
|
94
111
|
moduleSpecifier: `./${moduleName}`,
|
|
@@ -165,6 +182,17 @@ function generateRLCIndex(file: SourceFile, model: RLCModel) {
|
|
|
165
182
|
]);
|
|
166
183
|
}
|
|
167
184
|
|
|
185
|
+
if (
|
|
186
|
+
hasMultiCollection(model) ||
|
|
187
|
+
hasSsvCollection(model) ||
|
|
188
|
+
hasPipeCollection(model) ||
|
|
189
|
+
hasTsvCollection(model)
|
|
190
|
+
) {
|
|
191
|
+
file.addExportDeclarations([{
|
|
192
|
+
moduleSpecifier: "./serializeHelper"
|
|
193
|
+
}]);
|
|
194
|
+
}
|
|
195
|
+
|
|
168
196
|
file.addExportAssignment({
|
|
169
197
|
expression: createClientFuncName,
|
|
170
198
|
isExportEquals: false
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RLCModel } from "./interfaces.js";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
// @ts-ignore: to fix the handlebars issue
|
|
4
|
+
import hbs from "handlebars";
|
|
5
|
+
import {
|
|
6
|
+
hasMultiCollection,
|
|
7
|
+
hasPipeCollection,
|
|
8
|
+
hasSsvCollection,
|
|
9
|
+
hasTsvCollection
|
|
10
|
+
} from "./helpers/operationHelpers.js";
|
|
11
|
+
import {
|
|
12
|
+
buildMultiCollectionContent,
|
|
13
|
+
buildPipeCollectionContent,
|
|
14
|
+
buildSsvCollectionContent,
|
|
15
|
+
buildTsvCollectionContent
|
|
16
|
+
} from "./static/serializeHelper.js";
|
|
17
|
+
|
|
18
|
+
export function buildSerializeHelper(model: RLCModel) {
|
|
19
|
+
let serializeHelperContent = "";
|
|
20
|
+
if (hasMultiCollection(model)) {
|
|
21
|
+
serializeHelperContent += "\n" + buildMultiCollectionContent;
|
|
22
|
+
}
|
|
23
|
+
if (hasPipeCollection(model)) {
|
|
24
|
+
serializeHelperContent += "\n" + buildPipeCollectionContent;
|
|
25
|
+
}
|
|
26
|
+
if (hasSsvCollection(model)) {
|
|
27
|
+
serializeHelperContent += "\n" + buildSsvCollectionContent;
|
|
28
|
+
}
|
|
29
|
+
if (hasTsvCollection(model)) {
|
|
30
|
+
serializeHelperContent += "\n" + buildTsvCollectionContent;
|
|
31
|
+
}
|
|
32
|
+
if (serializeHelperContent !== "") {
|
|
33
|
+
const readmeFileContents = hbs.compile(serializeHelperContent, {
|
|
34
|
+
noEscape: true
|
|
35
|
+
});
|
|
36
|
+
const { srcPath } = model;
|
|
37
|
+
return {
|
|
38
|
+
path: path.join(srcPath, "serializeHelper.ts"),
|
|
39
|
+
content: readmeFileContents({})
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -5,6 +5,7 @@ import { NameType, normalizeName } from "./helpers/nameUtils.js";
|
|
|
5
5
|
import { RLCModel } from "./interfaces.js";
|
|
6
6
|
import { Project } from "ts-morph";
|
|
7
7
|
import * as path from "path";
|
|
8
|
+
import { getRelativePartFromSrcPath } from "./helpers/pathUtils.js";
|
|
8
9
|
|
|
9
10
|
const batchOutputFolder: [string, string, string][] = [];
|
|
10
11
|
|
|
@@ -18,7 +19,7 @@ export function buildTopLevelIndex(model: RLCModel) {
|
|
|
18
19
|
if (srcPath) {
|
|
19
20
|
const clientName = model.libraryName;
|
|
20
21
|
const moduleName = normalizeName(clientName, NameType.File);
|
|
21
|
-
const relativePath = "
|
|
22
|
+
const relativePath = "./" + getRelativePartFromSrcPath(srcPath);
|
|
22
23
|
batchOutputFolder.push([relativePath, clientName, moduleName]);
|
|
23
24
|
}
|
|
24
25
|
if (
|
|
@@ -42,7 +43,10 @@ export function buildTopLevelIndex(model: RLCModel) {
|
|
|
42
43
|
namedExports: [...allModules]
|
|
43
44
|
});
|
|
44
45
|
const content = indexFile.getFullText();
|
|
45
|
-
const filePath = path.join(
|
|
46
|
+
const filePath = path.join(
|
|
47
|
+
srcPath.substring(0, srcPath.indexOf("/src/") + 5),
|
|
48
|
+
`index.ts`
|
|
49
|
+
);
|
|
46
50
|
return { path: filePath, content };
|
|
47
51
|
}
|
|
48
52
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
RLCModel,
|
|
14
14
|
SchemaContext
|
|
15
15
|
} from "../interfaces.js";
|
|
16
|
-
import { pascalCase } from "./nameUtils.js";
|
|
16
|
+
import { NameType, normalizeName, pascalCase } from "./nameUtils.js";
|
|
17
17
|
import { isObjectSchema } from "./schemaHelpers.js";
|
|
18
18
|
|
|
19
19
|
export function buildMethodDefinitions(
|
|
@@ -52,7 +52,7 @@ export function getPathParamDefinitions(
|
|
|
52
52
|
): OptionalKind<ParameterDeclarationStructure>[] {
|
|
53
53
|
return pathParams.map(({ name, type, description }) => {
|
|
54
54
|
return {
|
|
55
|
-
name,
|
|
55
|
+
name: normalizeName(name, NameType.Parameter),
|
|
56
56
|
type,
|
|
57
57
|
description
|
|
58
58
|
};
|
|
@@ -67,6 +67,22 @@ export function hasPollingOperations(model: RLCModel) {
|
|
|
67
67
|
return Boolean(model.annotations?.hasLongRunning);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
export function hasMultiCollection(model: RLCModel) {
|
|
71
|
+
return Boolean(model.annotations?.hasMultiCollection);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function hasPipeCollection(model: RLCModel) {
|
|
75
|
+
return Boolean(model.annotations?.hasPipeCollection);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function hasSsvCollection(model: RLCModel) {
|
|
79
|
+
return Boolean(model.annotations?.hasSsvCollection);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function hasTsvCollection(model: RLCModel) {
|
|
83
|
+
return Boolean(model.annotations?.hasTsvCollection);
|
|
84
|
+
}
|
|
85
|
+
|
|
70
86
|
export function hasUnexpectedHelper(model: RLCModel) {
|
|
71
87
|
const pathDictionary = model.paths;
|
|
72
88
|
for (const details of Object.values(pathDictionary)) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// FIXME https://github.com/Azure/autorest.typescript/issues/1720
|
|
2
|
+
export function getRelativePartFromSrcPath(srcPath: string) {
|
|
3
|
+
const relativePart = srcPath.substring(srcPath.indexOf("/src/") + 4);
|
|
4
|
+
return relativePart.startsWith("/")
|
|
5
|
+
? relativePart.substring(1)
|
|
6
|
+
: relativePart;
|
|
7
|
+
}
|
package/src/index.ts
CHANGED
package/src/interfaces.ts
CHANGED
|
@@ -28,6 +28,10 @@ export interface AnnotationDetails {
|
|
|
28
28
|
hasPaging?: boolean;
|
|
29
29
|
hasLongRunning?: boolean;
|
|
30
30
|
pageDetails?: PagingDetails;
|
|
31
|
+
hasMultiCollection?: boolean;
|
|
32
|
+
hasPipeCollection?: boolean;
|
|
33
|
+
hasSsvCollection?: boolean;
|
|
34
|
+
hasTsvCollection?: boolean;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
export interface PagingDetails {
|
|
@@ -96,6 +100,7 @@ export interface RLCOptions {
|
|
|
96
100
|
productDocLink?: string;
|
|
97
101
|
serviceInfo?: ServiceInfo;
|
|
98
102
|
azureArm?: boolean;
|
|
103
|
+
sourceFrom?: "Cadl" | "Swagger";
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
export interface ServiceInfo {
|