@azure-tools/rlc-common 1.0.0-beta.1
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 +45 -0
- package/.rush/temp/shrinkwrap-deps.json +72 -0
- package/CHANGELOG.md +3 -0
- package/dist/buildClient.js +198 -0
- package/dist/buildClient.js.map +1 -0
- package/dist/buildClientDefinitions.js +160 -0
- package/dist/buildClientDefinitions.js.map +1 -0
- package/dist/buildIndexFile.js +150 -0
- package/dist/buildIndexFile.js.map +1 -0
- package/dist/buildIsUnexpectedHelper.js +219 -0
- package/dist/buildIsUnexpectedHelper.js.map +1 -0
- package/dist/buildMethodShortcuts.js +50 -0
- package/dist/buildMethodShortcuts.js.map +1 -0
- package/dist/buildObjectTypes.js +250 -0
- package/dist/buildObjectTypes.js.map +1 -0
- package/dist/buildPaginateHelper.js +30 -0
- package/dist/buildPaginateHelper.js.map +1 -0
- package/dist/buildParameterTypes.js +287 -0
- package/dist/buildParameterTypes.js.map +1 -0
- package/dist/buildPollingHelper.js +21 -0
- package/dist/buildPollingHelper.js.map +1 -0
- package/dist/buildResponseTypes.js +122 -0
- package/dist/buildResponseTypes.js.map +1 -0
- package/dist/buildSchemaType.js +44 -0
- package/dist/buildSchemaType.js.map +1 -0
- package/dist/buildTopLevelIndexFile.js +45 -0
- package/dist/buildTopLevelIndexFile.js.map +1 -0
- package/dist/helpers/nameConstructors.js +41 -0
- package/dist/helpers/nameConstructors.js.map +1 -0
- package/dist/helpers/nameUtils.js +196 -0
- package/dist/helpers/nameUtils.js.map +1 -0
- package/dist/helpers/operationHelpers.js +83 -0
- package/dist/helpers/operationHelpers.js.map +1 -0
- package/dist/helpers/schemaHelpers.js +27 -0
- package/dist/helpers/schemaHelpers.js.map +1 -0
- package/dist/helpers/shortcutMethods.js +46 -0
- package/dist/helpers/shortcutMethods.js.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces.js +18 -0
- package/dist/interfaces.js.map +1 -0
- package/dist/metadata/buildApiExtractorConfig.js +56 -0
- package/dist/metadata/buildApiExtractorConfig.js.map +1 -0
- package/dist/metadata/buildESLintConfig.js +33 -0
- package/dist/metadata/buildESLintConfig.js.map +1 -0
- package/dist/metadata/buildLicenseFile.js +41 -0
- package/dist/metadata/buildLicenseFile.js.map +1 -0
- package/dist/metadata/buildPackageFile.js +232 -0
- package/dist/metadata/buildPackageFile.js.map +1 -0
- package/dist/metadata/buildReadmeFile.js +170 -0
- package/dist/metadata/buildReadmeFile.js.map +1 -0
- package/dist/metadata/buildRollupConfig.js +144 -0
- package/dist/metadata/buildRollupConfig.js.map +1 -0
- package/dist/metadata/buildTsConfig.js +72 -0
- package/dist/metadata/buildTsConfig.js.map +1 -0
- package/dist/package.json +1 -0
- package/dist/static/paginateContent.js +214 -0
- package/dist/static/paginateContent.js.map +1 -0
- package/dist/static/pollingContent.js +78 -0
- package/dist/static/pollingContent.js.map +1 -0
- package/dist/test/buildEnvFile.js +31 -0
- package/dist/test/buildEnvFile.js.map +1 -0
- package/dist/test/buildKarmaConfig.js +19 -0
- package/dist/test/buildKarmaConfig.js.map +1 -0
- package/dist/test/buildRecordedClient.js +22 -0
- package/dist/test/buildRecordedClient.js.map +1 -0
- package/dist/test/buildSampleTest.js +19 -0
- package/dist/test/buildSampleTest.js.map +1 -0
- package/dist/test/template.js +192 -0
- package/dist/test/template.js.map +1 -0
- package/dist-esm/buildClient.js +191 -0
- package/dist-esm/buildClient.js.map +1 -0
- package/dist-esm/buildClientDefinitions.js +155 -0
- package/dist-esm/buildClientDefinitions.js.map +1 -0
- package/dist-esm/buildIndexFile.js +145 -0
- package/dist-esm/buildIndexFile.js.map +1 -0
- package/dist-esm/buildIsUnexpectedHelper.js +215 -0
- package/dist-esm/buildIsUnexpectedHelper.js.map +1 -0
- package/dist-esm/buildMethodShortcuts.js +46 -0
- package/dist-esm/buildMethodShortcuts.js.map +1 -0
- package/dist-esm/buildObjectTypes.js +249 -0
- package/dist-esm/buildObjectTypes.js.map +1 -0
- package/dist-esm/buildPaginateHelper.js +26 -0
- package/dist-esm/buildPaginateHelper.js.map +1 -0
- package/dist-esm/buildParameterTypes.js +288 -0
- package/dist-esm/buildParameterTypes.js.map +1 -0
- package/dist-esm/buildPollingHelper.js +17 -0
- package/dist-esm/buildPollingHelper.js.map +1 -0
- package/dist-esm/buildResponseTypes.js +127 -0
- package/dist-esm/buildResponseTypes.js.map +1 -0
- package/dist-esm/buildSchemaType.js +39 -0
- package/dist-esm/buildSchemaType.js.map +1 -0
- package/dist-esm/buildTopLevelIndexFile.js +41 -0
- package/dist-esm/buildTopLevelIndexFile.js.map +1 -0
- package/dist-esm/helpers/nameConstructors.js +34 -0
- package/dist-esm/helpers/nameConstructors.js.map +1 -0
- package/dist-esm/helpers/nameUtils.js +187 -0
- package/dist-esm/helpers/nameUtils.js.map +1 -0
- package/dist-esm/helpers/operationHelpers.js +72 -0
- package/dist-esm/helpers/operationHelpers.js.map +1 -0
- package/dist-esm/helpers/schemaHelpers.js +21 -0
- package/dist-esm/helpers/schemaHelpers.js.map +1 -0
- package/dist-esm/helpers/shortcutMethods.js +42 -0
- package/dist-esm/helpers/shortcutMethods.js.map +1 -0
- package/dist-esm/index.js +28 -0
- package/dist-esm/index.js.map +1 -0
- package/dist-esm/interfaces.js +15 -0
- package/dist-esm/interfaces.js.map +1 -0
- package/dist-esm/metadata/buildApiExtractorConfig.js +51 -0
- package/dist-esm/metadata/buildApiExtractorConfig.js.map +1 -0
- package/dist-esm/metadata/buildESLintConfig.js +28 -0
- package/dist-esm/metadata/buildESLintConfig.js.map +1 -0
- package/dist-esm/metadata/buildLicenseFile.js +36 -0
- package/dist-esm/metadata/buildLicenseFile.js.map +1 -0
- package/dist-esm/metadata/buildPackageFile.js +234 -0
- package/dist-esm/metadata/buildPackageFile.js.map +1 -0
- package/dist-esm/metadata/buildReadmeFile.js +167 -0
- package/dist-esm/metadata/buildReadmeFile.js.map +1 -0
- package/dist-esm/metadata/buildRollupConfig.js +139 -0
- package/dist-esm/metadata/buildRollupConfig.js.map +1 -0
- package/dist-esm/metadata/buildTsConfig.js +67 -0
- package/dist-esm/metadata/buildTsConfig.js.map +1 -0
- package/dist-esm/package.json +1 -0
- package/dist-esm/static/paginateContent.js +211 -0
- package/dist-esm/static/paginateContent.js.map +1 -0
- package/dist-esm/static/pollingContent.js +75 -0
- package/dist-esm/static/pollingContent.js.map +1 -0
- package/dist-esm/test/buildEnvFile.js +24 -0
- package/dist-esm/test/buildEnvFile.js.map +1 -0
- package/dist-esm/test/buildKarmaConfig.js +14 -0
- package/dist-esm/test/buildKarmaConfig.js.map +1 -0
- package/dist-esm/test/buildRecordedClient.js +17 -0
- package/dist-esm/test/buildRecordedClient.js.map +1 -0
- package/dist-esm/test/buildSampleTest.js +14 -0
- package/dist-esm/test/buildSampleTest.js.map +1 -0
- package/dist-esm/test/template.js +189 -0
- package/dist-esm/test/template.js.map +1 -0
- package/package.json +40 -0
- package/publishPackage.js +11 -0
- package/rlc-common.build.log +2 -0
- package/src/buildClient.ts +251 -0
- package/src/buildClientDefinitions.ts +231 -0
- package/src/buildIndexFile.ts +172 -0
- package/src/buildIsUnexpectedHelper.ts +240 -0
- package/src/buildMethodShortcuts.ts +75 -0
- package/src/buildObjectTypes.ts +393 -0
- package/src/buildPaginateHelper.ts +33 -0
- package/src/buildParameterTypes.ts +435 -0
- package/src/buildPollingHelper.ts +18 -0
- package/src/buildResponseTypes.ts +169 -0
- package/src/buildSchemaType.ts +56 -0
- package/src/buildTopLevelIndexFile.ts +46 -0
- package/src/helpers/nameConstructors.ts +93 -0
- package/src/helpers/nameUtils.ts +227 -0
- package/src/helpers/operationHelpers.ts +103 -0
- package/src/helpers/schemaHelpers.ts +25 -0
- package/src/helpers/shortcutMethods.ts +60 -0
- package/src/index.ts +28 -0
- package/src/interfaces.ts +212 -0
- package/src/metadata/buildApiExtractorConfig.ts +59 -0
- package/src/metadata/buildESLintConfig.ts +34 -0
- package/src/metadata/buildLicenseFile.ts +39 -0
- package/src/metadata/buildPackageFile.ts +271 -0
- package/src/metadata/buildReadmeFile.ts +231 -0
- package/src/metadata/buildRollupConfig.ts +147 -0
- package/src/metadata/buildTsConfig.ts +79 -0
- package/src/static/paginateContent.ts +210 -0
- package/src/static/pollingContent.ts +74 -0
- package/src/test/buildEnvFile.ts +26 -0
- package/src/test/buildKarmaConfig.ts +15 -0
- package/src/test/buildRecordedClient.ts +18 -0
- package/src/test/buildSampleTest.ts +15 -0
- package/src/test/template.ts +192 -0
- package/tsconfig-cjs.json +9 -0
- package/tsconfig-common.json +13 -0
- package/tsconfig.json +13 -0
- package/types/buildClient.d.ts +2 -0
- package/types/buildClientDefinitions.d.ts +5 -0
- package/types/buildIndexFile.d.ts +5 -0
- package/types/buildIsUnexpectedHelper.d.ts +5 -0
- package/types/buildMethodShortcuts.d.ts +4 -0
- package/types/buildObjectTypes.d.ts +14 -0
- package/types/buildPaginateHelper.d.ts +5 -0
- package/types/buildParameterTypes.d.ts +5 -0
- package/types/buildPollingHelper.d.ts +5 -0
- package/types/buildResponseTypes.d.ts +5 -0
- package/types/buildSchemaType.d.ts +19 -0
- package/types/buildTopLevelIndexFile.d.ts +5 -0
- package/types/helpers/nameConstructors.d.ts +28 -0
- package/types/helpers/nameUtils.d.ts +25 -0
- package/types/helpers/operationHelpers.d.ts +9 -0
- package/types/helpers/schemaHelpers.d.ts +4 -0
- package/types/helpers/shortcutMethods.d.ts +3 -0
- package/types/index.d.ts +25 -0
- package/types/interfaces.d.ts +186 -0
- package/types/metadata/buildApiExtractorConfig.d.ts +5 -0
- package/types/metadata/buildESLintConfig.d.ts +5 -0
- package/types/metadata/buildLicenseFile.d.ts +5 -0
- package/types/metadata/buildPackageFile.d.ts +5 -0
- package/types/metadata/buildReadmeFile.d.ts +5 -0
- package/types/metadata/buildRollupConfig.d.ts +5 -0
- package/types/metadata/buildTsConfig.d.ts +5 -0
- package/types/static/paginateContent.d.ts +1 -0
- package/types/static/pollingContent.d.ts +1 -0
- package/types/test/buildEnvFile.d.ts +9 -0
- package/types/test/buildKarmaConfig.d.ts +5 -0
- package/types/test/buildRecordedClient.d.ts +5 -0
- package/types/test/buildSampleTest.d.ts +5 -0
- package/types/test/template.d.ts +5 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pollingContent = void 0;
|
|
4
|
+
exports.pollingContent = `
|
|
5
|
+
import { Client, HttpResponse } from "@azure-rest/core-client";
|
|
6
|
+
import {
|
|
7
|
+
LongRunningOperation,
|
|
8
|
+
LroEngine,
|
|
9
|
+
LroEngineOptions,
|
|
10
|
+
LroResponse,
|
|
11
|
+
PollerLike,
|
|
12
|
+
PollOperationState
|
|
13
|
+
} from "@azure/core-lro";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Helper function that builds a Poller object to help polling a long running operation.
|
|
17
|
+
* @param client - Client to use for sending the request to get additional pages.
|
|
18
|
+
* @param initialResponse - The initial response.
|
|
19
|
+
* @param options - Options to set a resume state or custom polling interval.
|
|
20
|
+
* @returns - A poller object to poll for operation state updates and eventually get the final response.
|
|
21
|
+
*/
|
|
22
|
+
export function getLongRunningPoller<TResult extends HttpResponse>(
|
|
23
|
+
client: Client,
|
|
24
|
+
initialResponse: TResult,
|
|
25
|
+
options: LroEngineOptions<TResult, PollOperationState<TResult>> = {}
|
|
26
|
+
): PollerLike<PollOperationState<TResult>, TResult> {
|
|
27
|
+
const poller: LongRunningOperation<TResult> = {
|
|
28
|
+
requestMethod: initialResponse.request.method,
|
|
29
|
+
requestPath: initialResponse.request.url,
|
|
30
|
+
sendInitialRequest: async () => {
|
|
31
|
+
// In the case of Rest Clients we are building the LRO poller object from a response that's the reason
|
|
32
|
+
// we are not triggering the initial request here, just extracting the information from the
|
|
33
|
+
// response we were provided.
|
|
34
|
+
return getLroResponse(initialResponse);
|
|
35
|
+
},
|
|
36
|
+
sendPollRequest: async path => {
|
|
37
|
+
// This is the callback that is going to be called to poll the service
|
|
38
|
+
// to get the latest status. We use the client provided and the polling path
|
|
39
|
+
// which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
|
|
40
|
+
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
41
|
+
const response = await client
|
|
42
|
+
.pathUnchecked(path ?? initialResponse.request.url)
|
|
43
|
+
.get();
|
|
44
|
+
const lroResponse = getLroResponse(response as TResult);
|
|
45
|
+
lroResponse.rawResponse.headers["x-ms-original-url"] =
|
|
46
|
+
initialResponse.request.url;
|
|
47
|
+
return lroResponse;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return new LroEngine(poller, options);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Converts a Rest Client response to a response that the LRO engine knows about
|
|
56
|
+
* @param response - a rest client http response
|
|
57
|
+
* @returns - An LRO response that the LRO engine can work with
|
|
58
|
+
*/
|
|
59
|
+
function getLroResponse<TResult extends HttpResponse>(
|
|
60
|
+
response: TResult
|
|
61
|
+
): LroResponse<TResult> {
|
|
62
|
+
if (Number.isNaN(response.status)) {
|
|
63
|
+
throw new TypeError(
|
|
64
|
+
\`Status code of the response is not a number. Value: \${response.status}\`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
flatResponse: response,
|
|
70
|
+
rawResponse: {
|
|
71
|
+
...response,
|
|
72
|
+
statusCode: Number.parseInt(response.status),
|
|
73
|
+
body: response.body
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
//# sourceMappingURL=pollingContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pollingContent.js","sourceRoot":"","sources":["../../src/static/pollingContent.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyE7B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildEnvBrowserFile = exports.buildEnvFile = void 0;
|
|
4
|
+
// @ts-ignore: to fix the handlebars issue
|
|
5
|
+
const handlebars_1 = require("handlebars");
|
|
6
|
+
const template_js_1 = require("./template.js");
|
|
7
|
+
function buildEnvFile(model) {
|
|
8
|
+
var _a;
|
|
9
|
+
const generateTest = Boolean((_a = model.options) === null || _a === void 0 ? void 0 : _a.generateTest);
|
|
10
|
+
if (!generateTest) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
path: "test/public/utils/env.ts",
|
|
15
|
+
content: handlebars_1.default.compile(template_js_1.envContent, { noEscape: true })({})
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.buildEnvFile = buildEnvFile;
|
|
19
|
+
function buildEnvBrowserFile(model) {
|
|
20
|
+
var _a;
|
|
21
|
+
const generateTest = Boolean((_a = model.options) === null || _a === void 0 ? void 0 : _a.generateTest);
|
|
22
|
+
if (!generateTest) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
path: "test/public/utils/env.browser.ts",
|
|
27
|
+
content: handlebars_1.default.compile("", { noEscape: true })({})
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.buildEnvBrowserFile = buildEnvBrowserFile;
|
|
31
|
+
//# sourceMappingURL=buildEnvFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildEnvFile.js","sourceRoot":"","sources":["../../src/test/buildEnvFile.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,2CAA6B;AAC7B,+CAA2C;AAG3C,SAAgB,YAAY,CAAC,KAAe;;IAC1C,MAAM,YAAY,GAAG,OAAO,CAAC,MAAA,KAAK,CAAC,OAAO,0CAAE,YAAY,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO;KACR;IACD,OAAO;QACL,IAAI,EAAE,0BAA0B;QAChC,OAAO,EAAE,oBAAG,CAAC,OAAO,CAAC,wBAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC;AATD,oCASC;AAED,SAAgB,mBAAmB,CAAC,KAAe;;IACjD,MAAM,YAAY,GAAG,OAAO,CAAC,MAAA,KAAK,CAAC,OAAO,0CAAE,YAAY,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO;KACR;IACD,OAAO;QACL,IAAI,EAAE,kCAAkC;QACxC,OAAO,EAAE,oBAAG,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;KACjD,CAAC;AACJ,CAAC;AATD,kDASC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildKarmaConfigFile = void 0;
|
|
4
|
+
// @ts-ignore: to fix the handlebars issue
|
|
5
|
+
const handlebars_1 = require("handlebars");
|
|
6
|
+
const template_js_1 = require("./template.js");
|
|
7
|
+
function buildKarmaConfigFile(model) {
|
|
8
|
+
var _a;
|
|
9
|
+
const generateTest = Boolean((_a = model.options) === null || _a === void 0 ? void 0 : _a.generateTest);
|
|
10
|
+
if (!generateTest) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
path: "karma.conf.js",
|
|
15
|
+
content: handlebars_1.default.compile(template_js_1.karmaConfig, { noEscape: true })({})
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.buildKarmaConfigFile = buildKarmaConfigFile;
|
|
19
|
+
//# sourceMappingURL=buildKarmaConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildKarmaConfig.js","sourceRoot":"","sources":["../../src/test/buildKarmaConfig.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,2CAA6B;AAE7B,+CAA4C;AAE5C,SAAgB,oBAAoB,CAAC,KAAe;;IAClD,MAAM,YAAY,GAAG,OAAO,CAAC,MAAA,KAAK,CAAC,OAAO,0CAAE,YAAY,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO;KACR;IACD,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,oBAAG,CAAC,OAAO,CAAC,yBAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;KAC1D,CAAC;AACJ,CAAC;AATD,oDASC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildRecordedClientFile = void 0;
|
|
4
|
+
// @ts-ignore: to fix the handlebars issue
|
|
5
|
+
const handlebars_1 = require("handlebars");
|
|
6
|
+
const template_js_1 = require("./template.js");
|
|
7
|
+
function buildRecordedClientFile(model) {
|
|
8
|
+
var _a;
|
|
9
|
+
const generateTest = Boolean((_a = model.options) === null || _a === void 0 ? void 0 : _a.generateTest);
|
|
10
|
+
if (!generateTest) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const recordedClientFileContents = handlebars_1.default.compile(template_js_1.recordedClientContent, {
|
|
14
|
+
noEscape: true
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
path: "test/public/utils/recordedClient.ts",
|
|
18
|
+
content: recordedClientFileContents({})
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.buildRecordedClientFile = buildRecordedClientFile;
|
|
22
|
+
//# sourceMappingURL=buildRecordedClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildRecordedClient.js","sourceRoot":"","sources":["../../src/test/buildRecordedClient.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,2CAA6B;AAE7B,+CAAsD;AAEtD,SAAgB,uBAAuB,CAAC,KAAe;;IACrD,MAAM,YAAY,GAAG,OAAO,CAAC,MAAA,KAAK,CAAC,OAAO,0CAAE,YAAY,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO;KACR;IACD,MAAM,0BAA0B,GAAG,oBAAG,CAAC,OAAO,CAAC,mCAAqB,EAAE;QACpE,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IACH,OAAO;QACL,IAAI,EAAE,qCAAqC;QAC3C,OAAO,EAAE,0BAA0B,CAAC,EAAE,CAAC;KACxC,CAAC;AACJ,CAAC;AAZD,0DAYC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildSampleTest = void 0;
|
|
4
|
+
// @ts-ignore: to fix the handlebars issue
|
|
5
|
+
const handlebars_1 = require("handlebars");
|
|
6
|
+
const template_js_1 = require("./template.js");
|
|
7
|
+
function buildSampleTest(model) {
|
|
8
|
+
var _a;
|
|
9
|
+
const generateTest = Boolean((_a = model.options) === null || _a === void 0 ? void 0 : _a.generateTest);
|
|
10
|
+
if (!generateTest) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
path: "test/public/sampleTest.spec.ts",
|
|
15
|
+
content: handlebars_1.default.compile(template_js_1.sampleTestContent, { noEscape: true })({})
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.buildSampleTest = buildSampleTest;
|
|
19
|
+
//# sourceMappingURL=buildSampleTest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSampleTest.js","sourceRoot":"","sources":["../../src/test/buildSampleTest.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,2CAA6B;AAC7B,+CAAkD;AAGlD,SAAgB,eAAe,CAAC,KAAe;;IAC7C,MAAM,YAAY,GAAG,OAAO,CAAC,MAAA,KAAK,CAAC,OAAO,0CAAE,YAAY,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO;KACR;IACD,OAAO;QACL,IAAI,EAAE,gCAAgC;QACtC,OAAO,EAAE,oBAAG,CAAC,OAAO,CAAC,+BAAiB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;KAChE,CAAC;AACJ,CAAC;AATD,0CASC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sampleTestContent = exports.recordedClientContent = exports.karmaConfig = exports.envBrowserContent = exports.envContent = void 0;
|
|
4
|
+
exports.envContent = `
|
|
5
|
+
import * as dotenv from "dotenv";
|
|
6
|
+
|
|
7
|
+
dotenv.config();
|
|
8
|
+
`;
|
|
9
|
+
exports.envBrowserContent = `
|
|
10
|
+
import * as dotenv from "dotenv";
|
|
11
|
+
|
|
12
|
+
dotenv.config();
|
|
13
|
+
`;
|
|
14
|
+
exports.karmaConfig = `
|
|
15
|
+
// https://github.com/karma-runner/karma-chrome-launcher
|
|
16
|
+
process.env.CHROME_BIN = require("puppeteer").executablePath();
|
|
17
|
+
require("dotenv").config();
|
|
18
|
+
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
|
|
19
|
+
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
|
|
20
|
+
|
|
21
|
+
module.exports = function (config) {
|
|
22
|
+
config.set({
|
|
23
|
+
// base path that will be used to resolve all patterns (eg. files, exclude)
|
|
24
|
+
basePath: "./",
|
|
25
|
+
|
|
26
|
+
// frameworks to use
|
|
27
|
+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
|
28
|
+
frameworks: ["source-map-support", "mocha"],
|
|
29
|
+
|
|
30
|
+
plugins: [
|
|
31
|
+
"karma-mocha",
|
|
32
|
+
"karma-mocha-reporter",
|
|
33
|
+
"karma-chrome-launcher",
|
|
34
|
+
"karma-edge-launcher",
|
|
35
|
+
"karma-firefox-launcher",
|
|
36
|
+
"karma-ie-launcher",
|
|
37
|
+
"karma-env-preprocessor",
|
|
38
|
+
"karma-coverage",
|
|
39
|
+
"karma-sourcemap-loader",
|
|
40
|
+
"karma-junit-reporter",
|
|
41
|
+
"karma-source-map-support",
|
|
42
|
+
],
|
|
43
|
+
|
|
44
|
+
// list of files / patterns to load in the browser
|
|
45
|
+
files: [
|
|
46
|
+
"dist-test/index.browser.js",
|
|
47
|
+
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true },
|
|
48
|
+
],
|
|
49
|
+
|
|
50
|
+
// list of files / patterns to exclude
|
|
51
|
+
exclude: [],
|
|
52
|
+
|
|
53
|
+
// preprocess matching files before serving them to the browser
|
|
54
|
+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
|
55
|
+
preprocessors: {
|
|
56
|
+
"**/*.js": ["sourcemap", "env"],
|
|
57
|
+
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
|
|
58
|
+
// Preprocess source file to calculate code coverage, however this will make source file unreadable
|
|
59
|
+
// "dist-test/index.js": ["coverage"]
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
envPreprocessor: [
|
|
63
|
+
"TEST_MODE",
|
|
64
|
+
"ENDPOINT",
|
|
65
|
+
"AZURE_CLIENT_SECRET",
|
|
66
|
+
"AZURE_CLIENT_ID",
|
|
67
|
+
"AZURE_TENANT_ID",
|
|
68
|
+
"SUBSCRIPTION_ID",
|
|
69
|
+
],
|
|
70
|
+
|
|
71
|
+
// test results reporter to use
|
|
72
|
+
// possible values: 'dots', 'progress'
|
|
73
|
+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
|
74
|
+
reporters: ["mocha", "coverage", "junit"],
|
|
75
|
+
|
|
76
|
+
coverageReporter: {
|
|
77
|
+
// specify a common output directory
|
|
78
|
+
dir: "coverage-browser/",
|
|
79
|
+
reporters: [
|
|
80
|
+
{ type: "json", subdir: ".", file: "coverage.json" },
|
|
81
|
+
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
|
|
82
|
+
{ type: "html", subdir: "html" },
|
|
83
|
+
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" },
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
junitReporter: {
|
|
88
|
+
outputDir: "", // results will be saved as $outputDir/$browserName.xml
|
|
89
|
+
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
|
|
90
|
+
suite: "", // suite will become the package name attribute in xml testsuite element
|
|
91
|
+
useBrowserName: false, // add browser name to report and classes names
|
|
92
|
+
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
|
|
93
|
+
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
|
|
94
|
+
properties: {}, // key value pair of properties to add to the <properties> section of the report
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
// web server port
|
|
98
|
+
port: 9876,
|
|
99
|
+
|
|
100
|
+
// enable / disable colors in the output (reporters and logs)
|
|
101
|
+
colors: true,
|
|
102
|
+
|
|
103
|
+
// level of logging
|
|
104
|
+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
|
105
|
+
logLevel: config.LOG_INFO,
|
|
106
|
+
|
|
107
|
+
// enable / disable watching file and executing tests whenever any file changes
|
|
108
|
+
autoWatch: false,
|
|
109
|
+
|
|
110
|
+
// --no-sandbox allows our tests to run in Linux without having to change the system.
|
|
111
|
+
// --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.
|
|
112
|
+
browsers: ["ChromeHeadlessNoSandbox"],
|
|
113
|
+
customLaunchers: {
|
|
114
|
+
ChromeHeadlessNoSandbox: {
|
|
115
|
+
base: "ChromeHeadless",
|
|
116
|
+
flags: ["--no-sandbox", "--disable-web-security"],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
// Continuous Integration mode
|
|
121
|
+
// if true, Karma captures browsers, runs the tests and exits
|
|
122
|
+
singleRun: false,
|
|
123
|
+
|
|
124
|
+
// Concurrency level
|
|
125
|
+
// how many browser should be started simultaneous
|
|
126
|
+
concurrency: 1,
|
|
127
|
+
|
|
128
|
+
browserNoActivityTimeout: 60000000,
|
|
129
|
+
browserDisconnectTimeout: 10000,
|
|
130
|
+
browserDisconnectTolerance: 3,
|
|
131
|
+
|
|
132
|
+
client: {
|
|
133
|
+
mocha: {
|
|
134
|
+
// change Karma's debug.html to the mocha web reporter
|
|
135
|
+
reporter: "html",
|
|
136
|
+
timeout: "600000",
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
`;
|
|
142
|
+
exports.recordedClientContent = `
|
|
143
|
+
import { Context } from "mocha";
|
|
144
|
+
import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";
|
|
145
|
+
import "./env";
|
|
146
|
+
|
|
147
|
+
const envSetupForPlayback: Record<string, string> = {
|
|
148
|
+
ENDPOINT: "https://endpoint",
|
|
149
|
+
AZURE_CLIENT_ID: "azure_client_id",
|
|
150
|
+
AZURE_CLIENT_SECRET: "azure_client_secret",
|
|
151
|
+
AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
|
|
152
|
+
SUBSCRIPTION_ID: "azure_subscription_id"
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const recorderEnvSetup: RecorderStartOptions = {
|
|
156
|
+
envSetupForPlayback
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* creates the recorder and reads the environment variables from the \`.env\` file.
|
|
161
|
+
* Should be called first in the test suite to make sure environment variables are
|
|
162
|
+
* read before they are being used.
|
|
163
|
+
*/
|
|
164
|
+
export async function createRecorder(context: Context): Promise<Recorder> {
|
|
165
|
+
const recorder = new Recorder(context.currentTest);
|
|
166
|
+
await recorder.start(recorderEnvSetup);
|
|
167
|
+
return recorder;
|
|
168
|
+
}
|
|
169
|
+
`;
|
|
170
|
+
exports.sampleTestContent = `
|
|
171
|
+
import { Recorder } from "@azure-tools/test-recorder";
|
|
172
|
+
import { assert } from "chai";
|
|
173
|
+
import { createRecorder } from "./utils/recordedClient";
|
|
174
|
+
import { Context } from "mocha";
|
|
175
|
+
|
|
176
|
+
describe("My test", () => {
|
|
177
|
+
let recorder: Recorder;
|
|
178
|
+
|
|
179
|
+
beforeEach(async function(this: Context) {
|
|
180
|
+
recorder = await createRecorder(this);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
afterEach(async function() {
|
|
184
|
+
await recorder.stop();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("sample test", async function() {
|
|
188
|
+
assert.equal(1, 1);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
`;
|
|
192
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/test/template.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;;;;CAIzB,CAAC;AAEW,QAAA,iBAAiB,GAAG;;;;CAIhC,CAAC;AAEW,QAAA,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+H1B,CAAC;AAEW,QAAA,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BpC,CAAC;AAEW,QAAA,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;CAqBhC,CAAC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { Project, StructureKind, VariableDeclarationKind } from "ts-morph";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
import { NameType, normalizeName } from "./helpers/nameUtils.js";
|
|
6
|
+
import { isConstantSchema } from "./helpers/schemaHelpers.js";
|
|
7
|
+
import { buildMethodShortcutImplementation } from "./buildMethodShortcuts.js";
|
|
8
|
+
export function buildClient(model) {
|
|
9
|
+
const name = normalizeName(model.libraryName, NameType.File);
|
|
10
|
+
const { srcPath } = model;
|
|
11
|
+
const project = new Project();
|
|
12
|
+
const filePath = path.join(srcPath, `${name}.ts`);
|
|
13
|
+
const clientFile = project.createSourceFile(filePath, undefined, {
|
|
14
|
+
overwrite: true
|
|
15
|
+
});
|
|
16
|
+
// Get all paths
|
|
17
|
+
const clientName = model.libraryName;
|
|
18
|
+
const urlParameters = model?.urlInfo?.urlParameters;
|
|
19
|
+
if (!model.options) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const { multiClient, batch } = model.options;
|
|
23
|
+
const { addCredentials, credentialScopes, credentialKeyHeaderName } = model.options;
|
|
24
|
+
const credentialTypes = credentialScopes && credentialScopes.length > 0 ? ["TokenCredential"] : [];
|
|
25
|
+
if (credentialKeyHeaderName) {
|
|
26
|
+
credentialTypes.push("KeyCredential");
|
|
27
|
+
}
|
|
28
|
+
const commonClientParams = [
|
|
29
|
+
...(urlParameters ?? []),
|
|
30
|
+
...(addCredentials === false ||
|
|
31
|
+
!isSecurityInfoDefined(credentialScopes, credentialKeyHeaderName)
|
|
32
|
+
? []
|
|
33
|
+
: [{ name: "credentials", type: credentialTypes.join(" | ") }])
|
|
34
|
+
];
|
|
35
|
+
const clientInterfaceName = clientName.endsWith("Client")
|
|
36
|
+
? `${clientName}`
|
|
37
|
+
: `${clientName}Client`;
|
|
38
|
+
const functionStatement = {
|
|
39
|
+
isExported: true,
|
|
40
|
+
name: `createClient`,
|
|
41
|
+
parameters: [
|
|
42
|
+
...commonClientParams,
|
|
43
|
+
{ name: "options", type: "ClientOptions = {}" }
|
|
44
|
+
],
|
|
45
|
+
docs: [
|
|
46
|
+
{
|
|
47
|
+
description: `Initialize a new instance of the class ${clientInterfaceName} class. \n` +
|
|
48
|
+
commonClientParams
|
|
49
|
+
.map((param) => {
|
|
50
|
+
return `@param ${param.name} type: ${param.type} ${param.description ?? ""}`;
|
|
51
|
+
})
|
|
52
|
+
.join("\n")
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
returnType: clientInterfaceName,
|
|
56
|
+
isDefaultExport: false,
|
|
57
|
+
statements: getClientFactoryBody(model, clientInterfaceName)
|
|
58
|
+
};
|
|
59
|
+
if (!multiClient || !batch || batch.length === 1) {
|
|
60
|
+
functionStatement.isDefaultExport = true;
|
|
61
|
+
}
|
|
62
|
+
clientFile.addFunction(functionStatement);
|
|
63
|
+
clientFile.addImportDeclarations([
|
|
64
|
+
{
|
|
65
|
+
namedImports: ["getClient", "ClientOptions"],
|
|
66
|
+
moduleSpecifier: "@azure-rest/core-client"
|
|
67
|
+
}
|
|
68
|
+
]);
|
|
69
|
+
if (addCredentials &&
|
|
70
|
+
isSecurityInfoDefined(credentialScopes, credentialKeyHeaderName)) {
|
|
71
|
+
clientFile.addImportDeclarations([
|
|
72
|
+
{
|
|
73
|
+
namedImports: credentialTypes,
|
|
74
|
+
moduleSpecifier: "@azure/core-auth"
|
|
75
|
+
}
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
clientFile.addImportDeclarations([
|
|
79
|
+
{
|
|
80
|
+
namedImports: [`${clientInterfaceName}`],
|
|
81
|
+
moduleSpecifier: "./clientDefinitions"
|
|
82
|
+
}
|
|
83
|
+
]);
|
|
84
|
+
return { path: filePath, content: clientFile.getFullText() };
|
|
85
|
+
}
|
|
86
|
+
function isSecurityInfoDefined(credentialScopes, credentialKeyHeaderName) {
|
|
87
|
+
return ((credentialScopes && credentialScopes.length > 0) || credentialKeyHeaderName);
|
|
88
|
+
}
|
|
89
|
+
function getClientFactoryBody(model, clientTypeName) {
|
|
90
|
+
if (!model.options || !model.options.packageDetails || !model.urlInfo) {
|
|
91
|
+
return "";
|
|
92
|
+
}
|
|
93
|
+
const { includeShortcuts, packageDetails } = model.options;
|
|
94
|
+
let clientPackageName = packageDetails.nameWithoutScope ?? "";
|
|
95
|
+
const packageVersion = packageDetails.version;
|
|
96
|
+
const { endpoint, urlParameters } = model.urlInfo;
|
|
97
|
+
let baseUrl;
|
|
98
|
+
if (urlParameters && endpoint) {
|
|
99
|
+
let parsedEndpoint = endpoint;
|
|
100
|
+
urlParameters.forEach((urlParameter) => {
|
|
101
|
+
parsedEndpoint = parsedEndpoint.replace(`{${urlParameter.name}}`, `\${${urlParameter.name}}`);
|
|
102
|
+
});
|
|
103
|
+
baseUrl = `options.baseUrl ?? \`${parsedEndpoint}\``;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
baseUrl = `options.baseUrl ?? "${endpoint}"`;
|
|
107
|
+
}
|
|
108
|
+
const apiVersion = getApiVersion(model);
|
|
109
|
+
let apiVersionStatement = "";
|
|
110
|
+
if (apiVersion) {
|
|
111
|
+
apiVersionStatement = `options.apiVersion = options.apiVersion ?? "${apiVersion}"`;
|
|
112
|
+
}
|
|
113
|
+
if (!clientPackageName.endsWith("-rest")) {
|
|
114
|
+
clientPackageName = clientPackageName + "-rest";
|
|
115
|
+
}
|
|
116
|
+
const userAgentInfoStatement = "const userAgentInfo = `azsdk-js-" +
|
|
117
|
+
clientPackageName +
|
|
118
|
+
"/" +
|
|
119
|
+
packageVersion +
|
|
120
|
+
"`;";
|
|
121
|
+
const userAgentPrefix = "options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`: `${userAgentInfo}`;";
|
|
122
|
+
const userAgentStatement = {
|
|
123
|
+
kind: StructureKind.VariableStatement,
|
|
124
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
125
|
+
declarations: [{ name: "userAgentPrefix", initializer: userAgentPrefix }]
|
|
126
|
+
};
|
|
127
|
+
const userAgentOptionsStatement = `options = {
|
|
128
|
+
...options,
|
|
129
|
+
userAgentOptions: {
|
|
130
|
+
userAgentPrefix
|
|
131
|
+
}
|
|
132
|
+
}`;
|
|
133
|
+
const baseUrlStatement = {
|
|
134
|
+
kind: StructureKind.VariableStatement,
|
|
135
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
136
|
+
declarations: [{ name: "baseUrl", initializer: baseUrl }]
|
|
137
|
+
};
|
|
138
|
+
const { credentialScopes, credentialKeyHeaderName } = model.options;
|
|
139
|
+
const scopesString = credentialScopes && credentialScopes.length
|
|
140
|
+
? credentialScopes.map((cs) => `"${cs}"`).join(", ")
|
|
141
|
+
: "";
|
|
142
|
+
const scopes = scopesString ? `scopes: [${scopesString}],` : "";
|
|
143
|
+
const apiKeyHeaderName = credentialKeyHeaderName
|
|
144
|
+
? `apiKeyHeaderName: "${credentialKeyHeaderName}",`
|
|
145
|
+
: "";
|
|
146
|
+
const credentials = scopes || apiKeyHeaderName
|
|
147
|
+
? `options = {
|
|
148
|
+
...options,
|
|
149
|
+
credentials: {
|
|
150
|
+
${scopes}
|
|
151
|
+
${apiKeyHeaderName}
|
|
152
|
+
},
|
|
153
|
+
}`
|
|
154
|
+
: "";
|
|
155
|
+
const getClient = `const client = getClient(
|
|
156
|
+
baseUrl, ${credentials ? "credentials," : ""} options
|
|
157
|
+
) as ${clientTypeName};
|
|
158
|
+
`;
|
|
159
|
+
let returnStatement = `return client;`;
|
|
160
|
+
if (includeShortcuts) {
|
|
161
|
+
const shortcutImplementations = buildMethodShortcutImplementation(model.paths);
|
|
162
|
+
const shortcutBody = Object.keys(shortcutImplementations).map((key) => {
|
|
163
|
+
// If the operation group has an empty name, it means its operations are client
|
|
164
|
+
// level operations so we need to spread the definitions. Otherwise they are
|
|
165
|
+
// within an operation group so we add them as key: value
|
|
166
|
+
return `${key && key !== "client" ? `"${key}":` : "..."} {${shortcutImplementations[key].join()}}`;
|
|
167
|
+
});
|
|
168
|
+
returnStatement = `return { ...client, ${shortcutBody.join()} };`;
|
|
169
|
+
}
|
|
170
|
+
return [
|
|
171
|
+
baseUrlStatement,
|
|
172
|
+
apiVersionStatement,
|
|
173
|
+
credentials,
|
|
174
|
+
userAgentInfoStatement,
|
|
175
|
+
userAgentStatement,
|
|
176
|
+
userAgentOptionsStatement,
|
|
177
|
+
getClient,
|
|
178
|
+
returnStatement
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
function getApiVersion(model) {
|
|
182
|
+
if (!model.apiVersionParam) {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
if (model.apiVersionParam &&
|
|
186
|
+
isConstantSchema(model.apiVersionParam)) {
|
|
187
|
+
return model.apiVersionParam.default;
|
|
188
|
+
}
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=buildClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildClient.js","sourceRoot":"","sources":["../src/buildClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,OAAO,EAEP,aAAa,EACb,uBAAuB,EAGxB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAG9E,MAAM,UAAU,WAAW,CAAC,KAAe;IACzC,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,WAAW,EAAE,QAAQ,CAAC,IAAI,CA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