@azure-tools/rlc-common 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +23 -0
- package/.prettierignore +1 -0
- package/.prettierrc +7 -0
- package/.rush/temp/package-deps_build.json +53 -0
- package/.rush/temp/shrinkwrap-deps.json +147 -0
- package/CHANGELOG.md +61 -0
- package/CONTRIBUTING.md +30 -0
- package/README.md +3 -0
- package/dist/buildClient.js +268 -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 +170 -0
- package/dist/buildIndexFile.js.map +1 -0
- package/dist/buildIsUnexpectedHelper.js +220 -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 +286 -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 +315 -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 +135 -0
- package/dist/buildResponseTypes.js.map +1 -0
- package/dist/buildSchemaType.js +65 -0
- package/dist/buildSchemaType.js.map +1 -0
- package/dist/buildSerializeHelper.js +35 -0
- package/dist/buildSerializeHelper.js.map +1 -0
- package/dist/buildTopLevelIndexFile.js +48 -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 +103 -0
- package/dist/helpers/operationHelpers.js.map +1 -0
- package/dist/helpers/pathUtils.js +13 -0
- package/dist/helpers/pathUtils.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 +45 -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 +274 -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 +98 -0
- package/dist/static/pollingContent.js.map +1 -0
- package/dist/static/serializeHelper.js +30 -0
- package/dist/static/serializeHelper.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 +191 -0
- package/dist/test/template.js.map +1 -0
- package/dist-esm/buildClient.js +261 -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 +165 -0
- package/dist-esm/buildIndexFile.js.map +1 -0
- package/dist-esm/buildIsUnexpectedHelper.js +216 -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 +288 -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 +321 -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 +140 -0
- package/dist-esm/buildResponseTypes.js.map +1 -0
- package/dist-esm/buildSchemaType.js +60 -0
- package/dist-esm/buildSchemaType.js.map +1 -0
- package/dist-esm/buildSerializeHelper.js +31 -0
- package/dist-esm/buildSerializeHelper.js.map +1 -0
- package/dist-esm/buildTopLevelIndexFile.js +44 -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 +84 -0
- package/dist-esm/helpers/operationHelpers.js.map +1 -0
- package/dist-esm/helpers/pathUtils.js +9 -0
- package/dist-esm/helpers/pathUtils.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 +29 -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 +276 -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 +95 -0
- package/dist-esm/static/pollingContent.js.map +1 -0
- package/dist-esm/static/serializeHelper.js +27 -0
- package/dist-esm/static/serializeHelper.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 +188 -0
- package/dist-esm/test/template.js.map +1 -0
- package/package.json +46 -0
- package/publishPackage.js +11 -0
- package/rlc-common.build.log +2 -0
- package/src/buildClient.ts +353 -0
- package/src/buildClientDefinitions.ts +235 -0
- package/src/buildIndexFile.ts +202 -0
- package/src/buildIsUnexpectedHelper.ts +240 -0
- package/src/buildMethodShortcuts.ts +75 -0
- package/src/buildObjectTypes.ts +449 -0
- package/src/buildPaginateHelper.ts +33 -0
- package/src/buildParameterTypes.ts +477 -0
- package/src/buildPollingHelper.ts +18 -0
- package/src/buildResponseTypes.ts +186 -0
- package/src/buildSchemaType.ts +85 -0
- package/src/buildSerializeHelper.ts +42 -0
- package/src/buildTopLevelIndexFile.ts +52 -0
- package/src/helpers/nameConstructors.ts +93 -0
- package/src/helpers/nameUtils.ts +227 -0
- package/src/helpers/operationHelpers.ts +119 -0
- package/src/helpers/pathUtils.ts +9 -0
- package/src/helpers/schemaHelpers.ts +25 -0
- package/src/helpers/shortcutMethods.ts +60 -0
- package/src/index.ts +29 -0
- package/src/interfaces.ts +227 -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 +334 -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 +94 -0
- package/src/static/serializeHelper.ts +29 -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 +191 -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 +15 -0
- package/types/buildPaginateHelper.d.ts +5 -0
- package/types/buildParameterTypes.d.ts +13 -0
- package/types/buildPollingHelper.d.ts +5 -0
- package/types/buildResponseTypes.d.ts +5 -0
- package/types/buildSchemaType.d.ts +19 -0
- package/types/buildSerializeHelper.d.ts +5 -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 +13 -0
- package/types/helpers/pathUtils.d.ts +1 -0
- package/types/helpers/schemaHelpers.d.ts +4 -0
- package/types/helpers/shortcutMethods.d.ts +3 -0
- package/types/index.d.ts +26 -0
- package/types/interfaces.d.ts +200 -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/static/serializeHelper.d.ts +4 -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,191 @@
|
|
|
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-firefox-launcher",
|
|
35
|
+
"karma-env-preprocessor",
|
|
36
|
+
"karma-coverage",
|
|
37
|
+
"karma-sourcemap-loader",
|
|
38
|
+
"karma-junit-reporter",
|
|
39
|
+
"karma-source-map-support",
|
|
40
|
+
],
|
|
41
|
+
|
|
42
|
+
// list of files / patterns to load in the browser
|
|
43
|
+
files: [
|
|
44
|
+
"dist-test/index.browser.js",
|
|
45
|
+
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true },
|
|
46
|
+
],
|
|
47
|
+
|
|
48
|
+
// list of files / patterns to exclude
|
|
49
|
+
exclude: [],
|
|
50
|
+
|
|
51
|
+
// preprocess matching files before serving them to the browser
|
|
52
|
+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
|
53
|
+
preprocessors: {
|
|
54
|
+
"**/*.js": ["sourcemap", "env"],
|
|
55
|
+
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
|
|
56
|
+
// Preprocess source file to calculate code coverage, however this will make source file unreadable
|
|
57
|
+
// "dist-test/index.js": ["coverage"]
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
envPreprocessor: [
|
|
61
|
+
"TEST_MODE",
|
|
62
|
+
"ENDPOINT",
|
|
63
|
+
"AZURE_CLIENT_SECRET",
|
|
64
|
+
"AZURE_CLIENT_ID",
|
|
65
|
+
"AZURE_TENANT_ID",
|
|
66
|
+
"SUBSCRIPTION_ID",
|
|
67
|
+
"RECORDINGS_RELATIVE_PATH",
|
|
68
|
+
],
|
|
69
|
+
|
|
70
|
+
// test results reporter to use
|
|
71
|
+
// possible values: 'dots', 'progress'
|
|
72
|
+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
|
73
|
+
reporters: ["mocha", "coverage", "junit"],
|
|
74
|
+
|
|
75
|
+
coverageReporter: {
|
|
76
|
+
// specify a common output directory
|
|
77
|
+
dir: "coverage-browser/",
|
|
78
|
+
reporters: [
|
|
79
|
+
{ type: "json", subdir: ".", file: "coverage.json" },
|
|
80
|
+
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
|
|
81
|
+
{ type: "html", subdir: "html" },
|
|
82
|
+
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" },
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
junitReporter: {
|
|
87
|
+
outputDir: "", // results will be saved as $outputDir/$browserName.xml
|
|
88
|
+
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
|
|
89
|
+
suite: "", // suite will become the package name attribute in xml testsuite element
|
|
90
|
+
useBrowserName: false, // add browser name to report and classes names
|
|
91
|
+
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
|
|
92
|
+
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
|
|
93
|
+
properties: {}, // key value pair of properties to add to the <properties> section of the report
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
// web server port
|
|
97
|
+
port: 9876,
|
|
98
|
+
|
|
99
|
+
// enable / disable colors in the output (reporters and logs)
|
|
100
|
+
colors: true,
|
|
101
|
+
|
|
102
|
+
// level of logging
|
|
103
|
+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
|
104
|
+
logLevel: config.LOG_INFO,
|
|
105
|
+
|
|
106
|
+
// enable / disable watching file and executing tests whenever any file changes
|
|
107
|
+
autoWatch: false,
|
|
108
|
+
|
|
109
|
+
// --no-sandbox allows our tests to run in Linux without having to change the system.
|
|
110
|
+
// --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.
|
|
111
|
+
browsers: ["ChromeHeadlessNoSandbox"],
|
|
112
|
+
customLaunchers: {
|
|
113
|
+
ChromeHeadlessNoSandbox: {
|
|
114
|
+
base: "ChromeHeadless",
|
|
115
|
+
flags: ["--no-sandbox", "--disable-web-security"],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
// Continuous Integration mode
|
|
120
|
+
// if true, Karma captures browsers, runs the tests and exits
|
|
121
|
+
singleRun: false,
|
|
122
|
+
|
|
123
|
+
// Concurrency level
|
|
124
|
+
// how many browser should be started simultaneous
|
|
125
|
+
concurrency: 1,
|
|
126
|
+
|
|
127
|
+
browserNoActivityTimeout: 60000000,
|
|
128
|
+
browserDisconnectTimeout: 10000,
|
|
129
|
+
browserDisconnectTolerance: 3,
|
|
130
|
+
|
|
131
|
+
client: {
|
|
132
|
+
mocha: {
|
|
133
|
+
// change Karma's debug.html to the mocha web reporter
|
|
134
|
+
reporter: "html",
|
|
135
|
+
timeout: "600000",
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
`;
|
|
141
|
+
exports.recordedClientContent = `
|
|
142
|
+
import { Context } from "mocha";
|
|
143
|
+
import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";
|
|
144
|
+
import "./env";
|
|
145
|
+
|
|
146
|
+
const envSetupForPlayback: Record<string, string> = {
|
|
147
|
+
ENDPOINT: "https://endpoint",
|
|
148
|
+
AZURE_CLIENT_ID: "azure_client_id",
|
|
149
|
+
AZURE_CLIENT_SECRET: "azure_client_secret",
|
|
150
|
+
AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
|
|
151
|
+
SUBSCRIPTION_ID: "azure_subscription_id"
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const recorderEnvSetup: RecorderStartOptions = {
|
|
155
|
+
envSetupForPlayback
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* creates the recorder and reads the environment variables from the \`.env\` file.
|
|
160
|
+
* Should be called first in the test suite to make sure environment variables are
|
|
161
|
+
* read before they are being used.
|
|
162
|
+
*/
|
|
163
|
+
export async function createRecorder(context: Context): Promise<Recorder> {
|
|
164
|
+
const recorder = new Recorder(context.currentTest);
|
|
165
|
+
await recorder.start(recorderEnvSetup);
|
|
166
|
+
return recorder;
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
169
|
+
exports.sampleTestContent = `
|
|
170
|
+
import { Recorder } from "@azure-tools/test-recorder";
|
|
171
|
+
import { assert } from "chai";
|
|
172
|
+
import { createRecorder } from "./utils/recordedClient";
|
|
173
|
+
import { Context } from "mocha";
|
|
174
|
+
|
|
175
|
+
describe("My test", () => {
|
|
176
|
+
let recorder: Recorder;
|
|
177
|
+
|
|
178
|
+
beforeEach(async function(this: Context) {
|
|
179
|
+
recorder = await createRecorder(this);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
afterEach(async function() {
|
|
183
|
+
await recorder.stop();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("sample test", async function() {
|
|
187
|
+
assert.equal(1, 1);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
`;
|
|
191
|
+
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8H1B,CAAC;AAEW,QAAA,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BpC,CAAC;AAEW,QAAA,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;CAqBhC,CAAC"}
|
|
@@ -0,0 +1,261 @@
|
|
|
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
|
+
function getClientOptionsInterface(clientName, optionalUrlParameters) {
|
|
9
|
+
if (!optionalUrlParameters || optionalUrlParameters.length === 0) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const properties = optionalUrlParameters.map((param) => {
|
|
13
|
+
return {
|
|
14
|
+
name: param.name,
|
|
15
|
+
type: param.type,
|
|
16
|
+
hasQuestionToken: true
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
name: `${clientName}Options`,
|
|
21
|
+
extends: ["ClientOptions"],
|
|
22
|
+
isExported: true,
|
|
23
|
+
properties
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function buildClient(model) {
|
|
27
|
+
const name = normalizeName(model.libraryName, NameType.File);
|
|
28
|
+
const { srcPath } = model;
|
|
29
|
+
const project = new Project();
|
|
30
|
+
const filePath = path.join(srcPath, `${name}.ts`);
|
|
31
|
+
const clientFile = project.createSourceFile(filePath, undefined, {
|
|
32
|
+
overwrite: true
|
|
33
|
+
});
|
|
34
|
+
// Get all paths
|
|
35
|
+
const clientName = model.libraryName;
|
|
36
|
+
const clientInterfaceName = clientName.endsWith("Client")
|
|
37
|
+
? `${clientName}`
|
|
38
|
+
: `${clientName}Client`;
|
|
39
|
+
normalizeUrlInfo(model);
|
|
40
|
+
const urlParameters = model?.urlInfo?.urlParameters?.filter(
|
|
41
|
+
// Do not include parameters with constant values in the signature, these should go in the options bag
|
|
42
|
+
(p) => p.value === undefined);
|
|
43
|
+
const optionalUrlParameters = model?.urlInfo?.urlParameters?.filter(
|
|
44
|
+
// Do not include parameters with constant values in the signature, these should go in the options bag
|
|
45
|
+
(p) => Boolean(p.value));
|
|
46
|
+
const clientOptionsInterface = getClientOptionsInterface(clientInterfaceName, optionalUrlParameters);
|
|
47
|
+
if (clientOptionsInterface) {
|
|
48
|
+
clientFile.addInterface(clientOptionsInterface);
|
|
49
|
+
}
|
|
50
|
+
if (!model.options) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const { multiClient, batch } = model.options;
|
|
54
|
+
const { addCredentials, credentialScopes, credentialKeyHeaderName } = model.options;
|
|
55
|
+
const credentialTypes = credentialScopes && credentialScopes.length > 0 ? ["TokenCredential"] : [];
|
|
56
|
+
if (credentialKeyHeaderName) {
|
|
57
|
+
credentialTypes.push("KeyCredential");
|
|
58
|
+
}
|
|
59
|
+
const commonClientParams = [
|
|
60
|
+
...(urlParameters ?? []),
|
|
61
|
+
...(addCredentials === false ||
|
|
62
|
+
!isSecurityInfoDefined(credentialScopes, credentialKeyHeaderName)
|
|
63
|
+
? []
|
|
64
|
+
: [
|
|
65
|
+
{
|
|
66
|
+
name: "credentials",
|
|
67
|
+
type: credentialTypes.join(" | "),
|
|
68
|
+
description: `uniquely identify client credential`
|
|
69
|
+
}
|
|
70
|
+
])
|
|
71
|
+
];
|
|
72
|
+
const allClientParams = [
|
|
73
|
+
...commonClientParams,
|
|
74
|
+
{
|
|
75
|
+
name: "options",
|
|
76
|
+
type: `${clientOptionsInterface?.name ?? "ClientOptions"} = {}`,
|
|
77
|
+
description: "the parameter for all optional parameters"
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
const functionStatement = {
|
|
81
|
+
isExported: true,
|
|
82
|
+
name: `createClient`,
|
|
83
|
+
parameters: allClientParams,
|
|
84
|
+
docs: [
|
|
85
|
+
{
|
|
86
|
+
description: `Initialize a new instance of \`${clientInterfaceName}\` \n` +
|
|
87
|
+
allClientParams
|
|
88
|
+
.map((param) => {
|
|
89
|
+
return `@param ${param.name} type: ${param.type
|
|
90
|
+
.split("=")[0]
|
|
91
|
+
.split(" ")
|
|
92
|
+
.join("")}, ${param.description ?? "The parameter " + param.name}`;
|
|
93
|
+
})
|
|
94
|
+
.join("\n")
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
returnType: clientInterfaceName,
|
|
98
|
+
isDefaultExport: false,
|
|
99
|
+
statements: getClientFactoryBody(model, clientInterfaceName)
|
|
100
|
+
};
|
|
101
|
+
if (!multiClient || !batch || batch.length === 1) {
|
|
102
|
+
functionStatement.isDefaultExport = true;
|
|
103
|
+
}
|
|
104
|
+
clientFile.addFunction(functionStatement);
|
|
105
|
+
clientFile.addImportDeclarations([
|
|
106
|
+
{
|
|
107
|
+
namedImports: ["getClient", "ClientOptions"],
|
|
108
|
+
moduleSpecifier: "@azure-rest/core-client"
|
|
109
|
+
}
|
|
110
|
+
]);
|
|
111
|
+
if (addCredentials &&
|
|
112
|
+
isSecurityInfoDefined(credentialScopes, credentialKeyHeaderName)) {
|
|
113
|
+
clientFile.addImportDeclarations([
|
|
114
|
+
{
|
|
115
|
+
namedImports: credentialTypes,
|
|
116
|
+
moduleSpecifier: "@azure/core-auth"
|
|
117
|
+
}
|
|
118
|
+
]);
|
|
119
|
+
}
|
|
120
|
+
clientFile.addImportDeclarations([
|
|
121
|
+
{
|
|
122
|
+
namedImports: [`${clientInterfaceName}`],
|
|
123
|
+
moduleSpecifier: "./clientDefinitions"
|
|
124
|
+
}
|
|
125
|
+
]);
|
|
126
|
+
return { path: filePath, content: clientFile.getFullText() };
|
|
127
|
+
}
|
|
128
|
+
function isSecurityInfoDefined(credentialScopes, credentialKeyHeaderName) {
|
|
129
|
+
return ((credentialScopes && credentialScopes.length > 0) || credentialKeyHeaderName);
|
|
130
|
+
}
|
|
131
|
+
function getClientFactoryBody(model, clientTypeName) {
|
|
132
|
+
if (!model.options || !model.options.packageDetails || !model.urlInfo) {
|
|
133
|
+
return "";
|
|
134
|
+
}
|
|
135
|
+
const { includeShortcuts, packageDetails } = model.options;
|
|
136
|
+
let clientPackageName = packageDetails.nameWithoutScope ?? "";
|
|
137
|
+
const packageVersion = packageDetails.version;
|
|
138
|
+
const { endpoint, urlParameters } = model.urlInfo;
|
|
139
|
+
const optionalUrlParameters = [];
|
|
140
|
+
for (const param of urlParameters ?? []) {
|
|
141
|
+
if (param.value) {
|
|
142
|
+
const value = typeof param.value === "string" ? `"${param.value}"` : param.value;
|
|
143
|
+
optionalUrlParameters.push(`const ${param.name} = options.${param.name} ?? ${value}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
let baseUrl;
|
|
147
|
+
if (urlParameters && endpoint) {
|
|
148
|
+
let parsedEndpoint = endpoint;
|
|
149
|
+
urlParameters.forEach((urlParameter) => {
|
|
150
|
+
parsedEndpoint = parsedEndpoint.replace(`{${urlParameter.name}}`, `\${${urlParameter.name}}`);
|
|
151
|
+
});
|
|
152
|
+
baseUrl = `options.baseUrl ?? \`${parsedEndpoint}\``;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
baseUrl = `options.baseUrl ?? "${endpoint}"`;
|
|
156
|
+
}
|
|
157
|
+
const apiVersion = getApiVersionInQueryParam(model);
|
|
158
|
+
let apiVersionStatement = "";
|
|
159
|
+
if (apiVersion) {
|
|
160
|
+
apiVersionStatement = `options.apiVersion = options.apiVersion ?? "${apiVersion}"`;
|
|
161
|
+
}
|
|
162
|
+
if (!clientPackageName.endsWith("-rest")) {
|
|
163
|
+
clientPackageName = clientPackageName + "-rest";
|
|
164
|
+
}
|
|
165
|
+
const userAgentInfoStatement = "const userAgentInfo = `azsdk-js-" +
|
|
166
|
+
clientPackageName +
|
|
167
|
+
"/" +
|
|
168
|
+
packageVersion +
|
|
169
|
+
"`;";
|
|
170
|
+
const userAgentPrefix = "options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`: `${userAgentInfo}`;";
|
|
171
|
+
const userAgentStatement = {
|
|
172
|
+
kind: StructureKind.VariableStatement,
|
|
173
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
174
|
+
declarations: [{ name: "userAgentPrefix", initializer: userAgentPrefix }]
|
|
175
|
+
};
|
|
176
|
+
const userAgentOptionsStatement = `options = {
|
|
177
|
+
...options,
|
|
178
|
+
userAgentOptions: {
|
|
179
|
+
userAgentPrefix
|
|
180
|
+
}
|
|
181
|
+
}`;
|
|
182
|
+
const baseUrlStatement = {
|
|
183
|
+
kind: StructureKind.VariableStatement,
|
|
184
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
185
|
+
declarations: [{ name: "baseUrl", initializer: baseUrl }]
|
|
186
|
+
};
|
|
187
|
+
const { credentialScopes, credentialKeyHeaderName } = model.options;
|
|
188
|
+
const scopesString = credentialScopes && credentialScopes.length
|
|
189
|
+
? credentialScopes.map((cs) => `"${cs}"`).join(", ")
|
|
190
|
+
: "";
|
|
191
|
+
const scopes = scopesString ? `scopes: [${scopesString}],` : "";
|
|
192
|
+
const apiKeyHeaderName = credentialKeyHeaderName
|
|
193
|
+
? `apiKeyHeaderName: "${credentialKeyHeaderName}",`
|
|
194
|
+
: "";
|
|
195
|
+
const credentials = scopes || apiKeyHeaderName
|
|
196
|
+
? `options = {
|
|
197
|
+
...options,
|
|
198
|
+
credentials: {
|
|
199
|
+
${scopes}
|
|
200
|
+
${apiKeyHeaderName}
|
|
201
|
+
},
|
|
202
|
+
}`
|
|
203
|
+
: "";
|
|
204
|
+
const getClient = `const client = getClient(
|
|
205
|
+
baseUrl, ${credentials ? "credentials," : ""} options
|
|
206
|
+
) as ${clientTypeName};
|
|
207
|
+
`;
|
|
208
|
+
let returnStatement = `return client;`;
|
|
209
|
+
if (includeShortcuts) {
|
|
210
|
+
const shortcutImplementations = buildMethodShortcutImplementation(model.paths);
|
|
211
|
+
const shortcutBody = Object.keys(shortcutImplementations).map((key) => {
|
|
212
|
+
// If the operation group has an empty name, it means its operations are client
|
|
213
|
+
// level operations so we need to spread the definitions. Otherwise they are
|
|
214
|
+
// within an operation group so we add them as key: value
|
|
215
|
+
return `${key && key !== "client" ? `"${key}":` : "..."} {${shortcutImplementations[key].join()}}`;
|
|
216
|
+
});
|
|
217
|
+
returnStatement = `return { ...client, ${shortcutBody.join()} };`;
|
|
218
|
+
}
|
|
219
|
+
return [
|
|
220
|
+
...optionalUrlParameters,
|
|
221
|
+
baseUrlStatement,
|
|
222
|
+
apiVersionStatement,
|
|
223
|
+
credentials,
|
|
224
|
+
userAgentInfoStatement,
|
|
225
|
+
userAgentStatement,
|
|
226
|
+
userAgentOptionsStatement,
|
|
227
|
+
getClient,
|
|
228
|
+
returnStatement
|
|
229
|
+
];
|
|
230
|
+
}
|
|
231
|
+
function getApiVersionInQueryParam(model) {
|
|
232
|
+
if (!model.apiVersionInQueryParam) {
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
if (model.apiVersionInQueryParam &&
|
|
236
|
+
isConstantSchema(model.apiVersionInQueryParam)) {
|
|
237
|
+
return model.apiVersionInQueryParam.default;
|
|
238
|
+
}
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
function normalizeUrlInfo(model) {
|
|
242
|
+
if (!model ||
|
|
243
|
+
!model.urlInfo ||
|
|
244
|
+
!model.urlInfo.endpoint ||
|
|
245
|
+
!model.urlInfo.urlParameters ||
|
|
246
|
+
model.urlInfo.urlParameters.length === 0) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
let parsedEndpoint = model.urlInfo.endpoint;
|
|
250
|
+
const urlParameters = model.urlInfo.urlParameters;
|
|
251
|
+
urlParameters.forEach((urlParameter) => {
|
|
252
|
+
const name = urlParameter.name;
|
|
253
|
+
const normalizedName = normalizeName(name, NameType.Parameter);
|
|
254
|
+
if (name !== normalizedName) {
|
|
255
|
+
urlParameter.name = normalizedName;
|
|
256
|
+
parsedEndpoint = parsedEndpoint.replace(`{${name}}`, `{${normalizedName}}`);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
model.urlInfo.endpoint = parsedEndpoint;
|
|
260
|
+
}
|
|
261
|
+
//# 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,EAGL,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,SAAS,yBAAyB,CAChC,UAAkB,EAClB,qBAAuC;IAEvC,IAAI,CAAC,qBAAqB,IAAI,qBAAqB,CAAC,MAAM,KAAK,CAAC,EAAE;QAChE,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,UAAU,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACrD,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,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@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { Project, StructureKind, Writers } from "ts-morph";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
import { buildMethodDefinitions, getPathParamDefinitions } from "./helpers/operationHelpers.js";
|
|
6
|
+
import { generateMethodShortcuts } from "./helpers/shortcutMethods.js";
|
|
7
|
+
import { REST_CLIENT_RESERVED } from "./buildMethodShortcuts.js";
|
|
8
|
+
import { CasingConvention, NameType, normalizeName } from "./helpers/nameUtils.js";
|
|
9
|
+
import { pascalCase } from "./helpers/nameUtils.js";
|
|
10
|
+
export function buildClientDefinitions(model) {
|
|
11
|
+
const options = {
|
|
12
|
+
importedParameters: new Set(),
|
|
13
|
+
importedResponses: new Set(),
|
|
14
|
+
clientImports: new Set()
|
|
15
|
+
};
|
|
16
|
+
const project = new Project();
|
|
17
|
+
const srcPath = model.srcPath;
|
|
18
|
+
const filePath = path.join(srcPath, `clientDefinitions.ts`);
|
|
19
|
+
const clientDefinitionsFile = project.createSourceFile(filePath, undefined, {
|
|
20
|
+
overwrite: true
|
|
21
|
+
});
|
|
22
|
+
// Get all paths
|
|
23
|
+
const pathDictionary = model.paths;
|
|
24
|
+
let shortcuts = [];
|
|
25
|
+
// There may be operations without an operation group, those shortcut
|
|
26
|
+
// methods need to be handled differently.
|
|
27
|
+
let shortcutsInOperationGroup = [];
|
|
28
|
+
if (model.options?.includeShortcuts) {
|
|
29
|
+
shortcuts = generateMethodShortcuts(model.paths);
|
|
30
|
+
clientDefinitionsFile.addInterfaces(shortcuts);
|
|
31
|
+
shortcutsInOperationGroup = shortcuts
|
|
32
|
+
.filter((s) => s.name !== "ClientOperations")
|
|
33
|
+
.map((s) => getShortcutName(s.name));
|
|
34
|
+
}
|
|
35
|
+
clientDefinitionsFile.addInterface({
|
|
36
|
+
name: "Routes",
|
|
37
|
+
isExported: true,
|
|
38
|
+
callSignatures: getPathFirstRoutesInterfaceDefinition(pathDictionary, clientDefinitionsFile, options)
|
|
39
|
+
});
|
|
40
|
+
const clientName = model.libraryName;
|
|
41
|
+
const clientInterfaceName = clientName.endsWith("Client")
|
|
42
|
+
? `${clientName}`
|
|
43
|
+
: `${clientName}Client`;
|
|
44
|
+
clientDefinitionsFile.addTypeAlias({
|
|
45
|
+
isExported: true,
|
|
46
|
+
name: clientInterfaceName,
|
|
47
|
+
type: Writers.intersectionType("Client", Writers.objectType({
|
|
48
|
+
properties: [
|
|
49
|
+
{ name: "path", type: "Routes" },
|
|
50
|
+
...shortcutsInOperationGroup
|
|
51
|
+
]
|
|
52
|
+
}),
|
|
53
|
+
// If the length of shortcuts in operation group and all shortcutsInOperationGroup
|
|
54
|
+
// is the same, then we don't have any operations at the client level
|
|
55
|
+
// Otherwise we need to make the client interface name an union with the
|
|
56
|
+
// definition of all client level shortcut methods
|
|
57
|
+
...(shortcutsInOperationGroup.length !== shortcuts.length
|
|
58
|
+
? [`ClientOperations`]
|
|
59
|
+
: []))
|
|
60
|
+
});
|
|
61
|
+
if (options.importedParameters.size) {
|
|
62
|
+
clientDefinitionsFile.addImportDeclaration({
|
|
63
|
+
namedImports: [...options.importedParameters],
|
|
64
|
+
moduleSpecifier: "./parameters"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (options.importedResponses.size) {
|
|
68
|
+
clientDefinitionsFile.addImportDeclaration({
|
|
69
|
+
namedImports: [...options.importedResponses],
|
|
70
|
+
moduleSpecifier: "./responses"
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
options.clientImports.add("Client");
|
|
74
|
+
options.clientImports.add("StreamableMethod");
|
|
75
|
+
clientDefinitionsFile.addImportDeclarations([
|
|
76
|
+
{
|
|
77
|
+
namedImports: [...options.clientImports],
|
|
78
|
+
moduleSpecifier: "@azure-rest/core-client"
|
|
79
|
+
}
|
|
80
|
+
]);
|
|
81
|
+
return { path: filePath, content: clientDefinitionsFile.getFullText() };
|
|
82
|
+
}
|
|
83
|
+
function getPathFirstRoutesInterfaceDefinition(paths, sourcefile, options) {
|
|
84
|
+
const operationGroupCount = getOperationGroupCount(paths);
|
|
85
|
+
const signatures = [];
|
|
86
|
+
for (const key of Object.keys(paths)) {
|
|
87
|
+
for (const verb of Object.keys(paths[key].methods)) {
|
|
88
|
+
for (const method of paths[key].methods[verb]) {
|
|
89
|
+
options.importedParameters.add(method.optionsName);
|
|
90
|
+
method.returnType
|
|
91
|
+
.split(" | ")
|
|
92
|
+
.forEach((item) => options.importedResponses.add(item));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
generatePathFirstRouteMethodsDefinition(paths[key], operationGroupCount, sourcefile);
|
|
96
|
+
const pathParams = paths[key].pathParameters;
|
|
97
|
+
signatures.push({
|
|
98
|
+
docs: [
|
|
99
|
+
`Resource for '${key
|
|
100
|
+
.replace(/}/g, "\\}")
|
|
101
|
+
.replace(/{/g, "\\{")}' has methods for the following verbs: ${Object.keys(paths[key].methods).join(", ")}`
|
|
102
|
+
],
|
|
103
|
+
parameters: [
|
|
104
|
+
{ name: "path", type: `"${key}"` },
|
|
105
|
+
...getPathParamDefinitions(pathParams)
|
|
106
|
+
],
|
|
107
|
+
returnType: getOperationReturnTypeName(paths[key], getOperationGroupCount(paths)),
|
|
108
|
+
kind: StructureKind.CallSignature
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return signatures;
|
|
112
|
+
}
|
|
113
|
+
function getOperationGroupCount(paths) {
|
|
114
|
+
const operationGroups = Object.keys(paths)
|
|
115
|
+
.map((p) => paths[p].operationGroupName)
|
|
116
|
+
.filter((p) => p && p !== "Client");
|
|
117
|
+
const uniqueNames = new Set(operationGroups);
|
|
118
|
+
return uniqueNames.size;
|
|
119
|
+
}
|
|
120
|
+
function getOperationReturnTypeName({ operationGroupName, name }, operationGroupCount) {
|
|
121
|
+
if (operationGroupCount > 1 &&
|
|
122
|
+
operationGroupName &&
|
|
123
|
+
operationGroupName !== "Client") {
|
|
124
|
+
return `${pascalCase(operationGroupName)}${pascalCase(name)}`;
|
|
125
|
+
}
|
|
126
|
+
return pascalCase(name);
|
|
127
|
+
}
|
|
128
|
+
function generatePathFirstRouteMethodsDefinition(path, operationGroupCount, file) {
|
|
129
|
+
const methodDefinitions = buildMethodDefinitions(path.methods);
|
|
130
|
+
const interfaceDef = {
|
|
131
|
+
methods: methodDefinitions,
|
|
132
|
+
name: getOperationReturnTypeName(path, operationGroupCount),
|
|
133
|
+
isExported: true
|
|
134
|
+
};
|
|
135
|
+
file.addInterface(interfaceDef);
|
|
136
|
+
}
|
|
137
|
+
function getShortcutName(interfaceName) {
|
|
138
|
+
const endIndex = shouldKeepSuffix(interfaceName)
|
|
139
|
+
? undefined
|
|
140
|
+
: interfaceName.length - "Operations".length;
|
|
141
|
+
const clientProperty = normalizeName(interfaceName.substring(0, endIndex), NameType.OperationGroup, true, REST_CLIENT_RESERVED, CasingConvention.Camel);
|
|
142
|
+
return {
|
|
143
|
+
name: clientProperty,
|
|
144
|
+
type: interfaceName
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function shouldKeepSuffix(name) {
|
|
148
|
+
const reservedNames = [
|
|
149
|
+
"pipelineOperations",
|
|
150
|
+
"pathOperations",
|
|
151
|
+
"pathUncheckedOperations"
|
|
152
|
+
];
|
|
153
|
+
return reservedNames.some((r) => r.toLowerCase() === name.toLowerCase());
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=buildClientDefinitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildClientDefinitions.js","sourceRoot":"","sources":["../src/buildClientDefinitions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAIL,OAAO,EAEP,aAAa,EACb,OAAO,EACR,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,+BAA+B,CAAC;AAEvC,OA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