@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
|
+
export const envContent = `
|
|
2
|
+
import * as dotenv from "dotenv";
|
|
3
|
+
|
|
4
|
+
dotenv.config();
|
|
5
|
+
`;
|
|
6
|
+
|
|
7
|
+
export const envBrowserContent = `
|
|
8
|
+
import * as dotenv from "dotenv";
|
|
9
|
+
|
|
10
|
+
dotenv.config();
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const karmaConfig = `
|
|
14
|
+
// https://github.com/karma-runner/karma-chrome-launcher
|
|
15
|
+
process.env.CHROME_BIN = require("puppeteer").executablePath();
|
|
16
|
+
require("dotenv").config();
|
|
17
|
+
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
|
|
18
|
+
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
|
|
19
|
+
|
|
20
|
+
module.exports = function (config) {
|
|
21
|
+
config.set({
|
|
22
|
+
// base path that will be used to resolve all patterns (eg. files, exclude)
|
|
23
|
+
basePath: "./",
|
|
24
|
+
|
|
25
|
+
// frameworks to use
|
|
26
|
+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
|
27
|
+
frameworks: ["source-map-support", "mocha"],
|
|
28
|
+
|
|
29
|
+
plugins: [
|
|
30
|
+
"karma-mocha",
|
|
31
|
+
"karma-mocha-reporter",
|
|
32
|
+
"karma-chrome-launcher",
|
|
33
|
+
"karma-firefox-launcher",
|
|
34
|
+
"karma-env-preprocessor",
|
|
35
|
+
"karma-coverage",
|
|
36
|
+
"karma-sourcemap-loader",
|
|
37
|
+
"karma-junit-reporter",
|
|
38
|
+
"karma-source-map-support",
|
|
39
|
+
],
|
|
40
|
+
|
|
41
|
+
// list of files / patterns to load in the browser
|
|
42
|
+
files: [
|
|
43
|
+
"dist-test/index.browser.js",
|
|
44
|
+
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true },
|
|
45
|
+
],
|
|
46
|
+
|
|
47
|
+
// list of files / patterns to exclude
|
|
48
|
+
exclude: [],
|
|
49
|
+
|
|
50
|
+
// preprocess matching files before serving them to the browser
|
|
51
|
+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
|
52
|
+
preprocessors: {
|
|
53
|
+
"**/*.js": ["sourcemap", "env"],
|
|
54
|
+
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
|
|
55
|
+
// Preprocess source file to calculate code coverage, however this will make source file unreadable
|
|
56
|
+
// "dist-test/index.js": ["coverage"]
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
envPreprocessor: [
|
|
60
|
+
"TEST_MODE",
|
|
61
|
+
"ENDPOINT",
|
|
62
|
+
"AZURE_CLIENT_SECRET",
|
|
63
|
+
"AZURE_CLIENT_ID",
|
|
64
|
+
"AZURE_TENANT_ID",
|
|
65
|
+
"SUBSCRIPTION_ID",
|
|
66
|
+
"RECORDINGS_RELATIVE_PATH",
|
|
67
|
+
],
|
|
68
|
+
|
|
69
|
+
// test results reporter to use
|
|
70
|
+
// possible values: 'dots', 'progress'
|
|
71
|
+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
|
72
|
+
reporters: ["mocha", "coverage", "junit"],
|
|
73
|
+
|
|
74
|
+
coverageReporter: {
|
|
75
|
+
// specify a common output directory
|
|
76
|
+
dir: "coverage-browser/",
|
|
77
|
+
reporters: [
|
|
78
|
+
{ type: "json", subdir: ".", file: "coverage.json" },
|
|
79
|
+
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
|
|
80
|
+
{ type: "html", subdir: "html" },
|
|
81
|
+
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" },
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
junitReporter: {
|
|
86
|
+
outputDir: "", // results will be saved as $outputDir/$browserName.xml
|
|
87
|
+
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
|
|
88
|
+
suite: "", // suite will become the package name attribute in xml testsuite element
|
|
89
|
+
useBrowserName: false, // add browser name to report and classes names
|
|
90
|
+
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
|
|
91
|
+
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
|
|
92
|
+
properties: {}, // key value pair of properties to add to the <properties> section of the report
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
// web server port
|
|
96
|
+
port: 9876,
|
|
97
|
+
|
|
98
|
+
// enable / disable colors in the output (reporters and logs)
|
|
99
|
+
colors: true,
|
|
100
|
+
|
|
101
|
+
// level of logging
|
|
102
|
+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
|
103
|
+
logLevel: config.LOG_INFO,
|
|
104
|
+
|
|
105
|
+
// enable / disable watching file and executing tests whenever any file changes
|
|
106
|
+
autoWatch: false,
|
|
107
|
+
|
|
108
|
+
// --no-sandbox allows our tests to run in Linux without having to change the system.
|
|
109
|
+
// --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.
|
|
110
|
+
browsers: ["ChromeHeadlessNoSandbox"],
|
|
111
|
+
customLaunchers: {
|
|
112
|
+
ChromeHeadlessNoSandbox: {
|
|
113
|
+
base: "ChromeHeadless",
|
|
114
|
+
flags: ["--no-sandbox", "--disable-web-security"],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
// Continuous Integration mode
|
|
119
|
+
// if true, Karma captures browsers, runs the tests and exits
|
|
120
|
+
singleRun: false,
|
|
121
|
+
|
|
122
|
+
// Concurrency level
|
|
123
|
+
// how many browser should be started simultaneous
|
|
124
|
+
concurrency: 1,
|
|
125
|
+
|
|
126
|
+
browserNoActivityTimeout: 60000000,
|
|
127
|
+
browserDisconnectTimeout: 10000,
|
|
128
|
+
browserDisconnectTolerance: 3,
|
|
129
|
+
|
|
130
|
+
client: {
|
|
131
|
+
mocha: {
|
|
132
|
+
// change Karma's debug.html to the mocha web reporter
|
|
133
|
+
reporter: "html",
|
|
134
|
+
timeout: "600000",
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
`;
|
|
140
|
+
|
|
141
|
+
export const 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
|
+
|
|
170
|
+
export const 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
|
+
`;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"declaration": true,
|
|
4
|
+
"declarationDir": "./types",
|
|
5
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
6
|
+
/* Type Checking */
|
|
7
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
8
|
+
"skipLibCheck": true
|
|
9
|
+
},
|
|
10
|
+
"compileOnSave": false,
|
|
11
|
+
"exclude": ["node_modules", "dist"],
|
|
12
|
+
"include": ["src"]
|
|
13
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InterfaceDeclarationStructure, PropertySignatureStructure, TypeAliasDeclarationStructure } from "ts-morph";
|
|
2
|
+
import { Parameter, Property, RLCModel, SchemaContext } from "./interfaces.js";
|
|
3
|
+
/**
|
|
4
|
+
* Generates interfaces for ObjectSchemas
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildObjectInterfaces(model: RLCModel, importedModels: Set<string>, schemaUsage: SchemaContext[]): InterfaceDeclarationStructure[];
|
|
7
|
+
export declare function buildObjectAliases(model: RLCModel, importedModels: Set<string>, schemaUsage: SchemaContext[]): TypeAliasDeclarationStructure[];
|
|
8
|
+
export declare function buildPolymorphicAliases(model: RLCModel, schemaUsage: SchemaContext[]): TypeAliasDeclarationStructure[];
|
|
9
|
+
/**
|
|
10
|
+
* Builds a Typescript property or parameter signature
|
|
11
|
+
* @param property - Property or parameter to get the Typescript signature for
|
|
12
|
+
* @param importedModels - Set to track the models that need to be imported
|
|
13
|
+
* @returns a PropertySignatureStructure for the property.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getPropertySignature(property: Property | Parameter, schemaUsage: SchemaContext[], importedModels: Set<string>): PropertySignatureStructure;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ParameterMetadatas, RLCModel } from "./interfaces.js";
|
|
2
|
+
export declare function buildParameterTypes(model: RLCModel): {
|
|
3
|
+
path: string;
|
|
4
|
+
content: string;
|
|
5
|
+
} | undefined;
|
|
6
|
+
export declare function buildBodyTypeAlias(parameters: ParameterMetadatas): {
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
isExported: boolean;
|
|
10
|
+
docs?: {
|
|
11
|
+
description: string;
|
|
12
|
+
}[] | undefined;
|
|
13
|
+
} | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Project } from "ts-morph";
|
|
2
|
+
import { RLCModel, SchemaContext } from "./interfaces.js";
|
|
3
|
+
/**
|
|
4
|
+
* Generates types to represent schema definitions in the swagger
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildSchemaTypes(model: RLCModel): {
|
|
7
|
+
inputModelFile: {
|
|
8
|
+
path: string;
|
|
9
|
+
content: string;
|
|
10
|
+
} | undefined;
|
|
11
|
+
outputModelFile: {
|
|
12
|
+
path: string;
|
|
13
|
+
content: string;
|
|
14
|
+
} | undefined;
|
|
15
|
+
};
|
|
16
|
+
export declare function generateModelFiles(model: RLCModel, project: Project, filePath: string, schemaContext: SchemaContext[]): {
|
|
17
|
+
path: string;
|
|
18
|
+
content: string;
|
|
19
|
+
} | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the response type name by baseName or operatioName & statusCode
|
|
3
|
+
* @param baseResponseName
|
|
4
|
+
*/
|
|
5
|
+
export declare function getResponseTypeName(baseResponseName: string): string;
|
|
6
|
+
export declare function getResponseTypeName(operationGroup: string, operationName: string, statusCode: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* The prefix of all response types
|
|
9
|
+
* @param operationGroup operation group name e.g string_PutEmpty
|
|
10
|
+
* @param operationName operation name D e.g string_PutEmpty
|
|
11
|
+
* @param statusCode 2XX, 4XX, 5XX, default etc.
|
|
12
|
+
* @returns normolized base name e.g StringPutEmpty200
|
|
13
|
+
*/
|
|
14
|
+
export declare function getResponseBaseName(operationGroup: string, operationName: string, statusCode: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* The prefix of all parameter relevant types
|
|
17
|
+
* @param operationName is composed with operationGroup and operationID e.g string_PutEmpty
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare function getParameterBaseName(operationGroup: string, operationName: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Get the top-layer parameter name
|
|
23
|
+
* @param operationGroup operation group name
|
|
24
|
+
* @param operationName is composed with operationGroup and operationID e.g string_PutEmpty
|
|
25
|
+
* @returns top-layer parameter name e.g StringPutEmptParameters
|
|
26
|
+
*/
|
|
27
|
+
export declare function getParameterTypeName(baseName: string): string;
|
|
28
|
+
export declare function getParameterTypeName(operationGroup: string, operationName: string): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ReservedName {
|
|
2
|
+
name: string;
|
|
3
|
+
reservedFor: NameType[];
|
|
4
|
+
}
|
|
5
|
+
export declare enum NameType {
|
|
6
|
+
Class = 0,
|
|
7
|
+
File = 1,
|
|
8
|
+
Interface = 2,
|
|
9
|
+
Property = 3,
|
|
10
|
+
Parameter = 4,
|
|
11
|
+
Operation = 5,
|
|
12
|
+
OperationGroup = 6
|
|
13
|
+
}
|
|
14
|
+
export declare enum CasingConvention {
|
|
15
|
+
Pascal = 0,
|
|
16
|
+
Camel = 1
|
|
17
|
+
}
|
|
18
|
+
export declare function guardReservedNames(name: string, nameType: NameType, customReservedNames?: ReservedName[]): string;
|
|
19
|
+
export declare function normalizeName(name: string, nameType: NameType, shouldGuard?: boolean, customReservedNames?: ReservedName[], casingOverride?: CasingConvention): string;
|
|
20
|
+
export declare function getModelsName(title: string): string;
|
|
21
|
+
export declare function getMappersName(title: string): string;
|
|
22
|
+
export declare function pascalCase(str: string): string;
|
|
23
|
+
export declare function camelCase(str: string, options?: {
|
|
24
|
+
uppercaseThreshold?: number;
|
|
25
|
+
}): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MethodSignatureStructure, OptionalKind, ParameterDeclarationStructure } from "ts-morph";
|
|
2
|
+
import { Methods, PathParameter, RLCModel } from "../interfaces.js";
|
|
3
|
+
export declare function buildMethodDefinitions(methods: Methods, pathParams?: PathParameter[]): OptionalKind<MethodSignatureStructure>[];
|
|
4
|
+
export declare function getPathParamDefinitions(pathParams: PathParameter[]): OptionalKind<ParameterDeclarationStructure>[];
|
|
5
|
+
export declare function hasPagingOperations(model: RLCModel): boolean;
|
|
6
|
+
export declare function hasPollingOperations(model: RLCModel): boolean;
|
|
7
|
+
export declare function hasMultiCollection(model: RLCModel): boolean;
|
|
8
|
+
export declare function hasPipeCollection(model: RLCModel): boolean;
|
|
9
|
+
export declare function hasSsvCollection(model: RLCModel): boolean;
|
|
10
|
+
export declare function hasTsvCollection(model: RLCModel): boolean;
|
|
11
|
+
export declare function hasUnexpectedHelper(model: RLCModel): boolean;
|
|
12
|
+
export declare function hasInputModels(model: RLCModel): boolean;
|
|
13
|
+
export declare function hasOutputModels(model: RLCModel): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getRelativePartFromSrcPath(srcPath: string): string;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from "./interfaces.js";
|
|
2
|
+
export * from "./buildClientDefinitions.js";
|
|
3
|
+
export * from "./buildSchemaType.js";
|
|
4
|
+
export * from "./buildClient.js";
|
|
5
|
+
export * from "./helpers/nameConstructors.js";
|
|
6
|
+
export * from "./buildResponseTypes.js";
|
|
7
|
+
export * from "./helpers/shortcutMethods.js";
|
|
8
|
+
export * from "./helpers/nameUtils.js";
|
|
9
|
+
export * from "./buildParameterTypes.js";
|
|
10
|
+
export * from "./buildIsUnexpectedHelper.js";
|
|
11
|
+
export * from "./buildTopLevelIndexFile.js";
|
|
12
|
+
export * from "./buildIndexFile.js";
|
|
13
|
+
export * from "./buildPaginateHelper.js";
|
|
14
|
+
export * from "./buildPollingHelper.js";
|
|
15
|
+
export * from "./test/buildKarmaConfig.js";
|
|
16
|
+
export * from "./test/buildEnvFile.js";
|
|
17
|
+
export * from "./test/buildRecordedClient.js";
|
|
18
|
+
export * from "./test/buildSampleTest.js";
|
|
19
|
+
export * from "./metadata/buildReadmeFile.js";
|
|
20
|
+
export * from "./metadata/buildApiExtractorConfig.js";
|
|
21
|
+
export * from "./metadata/buildPackageFile.js";
|
|
22
|
+
export * from "./metadata/buildRollupConfig.js";
|
|
23
|
+
export * from "./metadata/buildTsConfig.js";
|
|
24
|
+
export * from "./metadata/buildESLintConfig.js";
|
|
25
|
+
export * from "./metadata/buildLicenseFile.js";
|
|
26
|
+
export * from "./buildSerializeHelper.js";
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
export interface RLCModel {
|
|
2
|
+
libraryName: string;
|
|
3
|
+
srcPath: string;
|
|
4
|
+
paths: Paths;
|
|
5
|
+
options?: RLCOptions;
|
|
6
|
+
schemas: Schema[];
|
|
7
|
+
apiVersionInQueryParam?: Parameter;
|
|
8
|
+
parameters?: OperationParameter[];
|
|
9
|
+
responses?: OperationResponse[];
|
|
10
|
+
importSet?: Map<ImportKind, Set<string>>;
|
|
11
|
+
annotations?: AnnotationDetails;
|
|
12
|
+
urlInfo?: UrlInfo;
|
|
13
|
+
}
|
|
14
|
+
export interface PathTemplateApiVersion {
|
|
15
|
+
value: string;
|
|
16
|
+
templateName: string;
|
|
17
|
+
}
|
|
18
|
+
export interface UrlInfo {
|
|
19
|
+
endpoint?: string;
|
|
20
|
+
urlParameters?: PathParameter[];
|
|
21
|
+
pathTemplateApiVersion?: PathTemplateApiVersion;
|
|
22
|
+
}
|
|
23
|
+
export interface AnnotationDetails {
|
|
24
|
+
hasPaging?: boolean;
|
|
25
|
+
hasLongRunning?: boolean;
|
|
26
|
+
pageDetails?: PagingDetails;
|
|
27
|
+
hasMultiCollection?: boolean;
|
|
28
|
+
hasPipeCollection?: boolean;
|
|
29
|
+
hasSsvCollection?: boolean;
|
|
30
|
+
hasTsvCollection?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface PagingDetails {
|
|
33
|
+
itemNames: string[];
|
|
34
|
+
nextLinkNames: string[];
|
|
35
|
+
isComplexPaging: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare type Methods = {
|
|
38
|
+
[key: string]: [OperationMethod];
|
|
39
|
+
};
|
|
40
|
+
export interface ResponseTypes {
|
|
41
|
+
success: string[];
|
|
42
|
+
error: string[];
|
|
43
|
+
}
|
|
44
|
+
export interface OperationMethod {
|
|
45
|
+
optionsName: string;
|
|
46
|
+
description: string;
|
|
47
|
+
hasOptionalOptions: boolean;
|
|
48
|
+
returnType: string;
|
|
49
|
+
successStatus: string[];
|
|
50
|
+
responseTypes: ResponseTypes;
|
|
51
|
+
operationName: string;
|
|
52
|
+
annotations?: OperationAnnotations;
|
|
53
|
+
}
|
|
54
|
+
export interface PathMetadata {
|
|
55
|
+
name: string;
|
|
56
|
+
pathParameters: PathParameter[];
|
|
57
|
+
methods: Methods;
|
|
58
|
+
operationGroupName: string;
|
|
59
|
+
description: string;
|
|
60
|
+
}
|
|
61
|
+
export declare type Paths = Record<string, PathMetadata>;
|
|
62
|
+
export declare type PathParameter = {
|
|
63
|
+
name: string;
|
|
64
|
+
type: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
value?: string | number | boolean;
|
|
67
|
+
};
|
|
68
|
+
export interface OperationAnnotations {
|
|
69
|
+
isLongRunning?: boolean;
|
|
70
|
+
isPageable?: boolean;
|
|
71
|
+
}
|
|
72
|
+
export interface RLCOptions {
|
|
73
|
+
includeShortcuts?: boolean;
|
|
74
|
+
multiClient?: boolean;
|
|
75
|
+
batch?: any[];
|
|
76
|
+
packageDetails?: PackageDetails;
|
|
77
|
+
addCredentials?: boolean;
|
|
78
|
+
credentialScopes?: string[];
|
|
79
|
+
credentialKeyHeaderName?: string;
|
|
80
|
+
generateMetadata?: boolean;
|
|
81
|
+
generateTest?: boolean;
|
|
82
|
+
generateSample?: boolean;
|
|
83
|
+
azureSdkForJs?: boolean;
|
|
84
|
+
azureOutputDirectory?: string;
|
|
85
|
+
isCadlTest?: boolean;
|
|
86
|
+
title?: string;
|
|
87
|
+
dependencyInfo?: DependencyInfo;
|
|
88
|
+
productDocLink?: string;
|
|
89
|
+
serviceInfo?: ServiceInfo;
|
|
90
|
+
azureArm?: boolean;
|
|
91
|
+
sourceFrom?: "Cadl" | "Swagger";
|
|
92
|
+
}
|
|
93
|
+
export interface ServiceInfo {
|
|
94
|
+
title?: string;
|
|
95
|
+
description?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface DependencyInfo {
|
|
98
|
+
link: string;
|
|
99
|
+
description: string;
|
|
100
|
+
}
|
|
101
|
+
export declare enum ImportKind {
|
|
102
|
+
ResponseOutput = 0,
|
|
103
|
+
ParameterInput = 1
|
|
104
|
+
}
|
|
105
|
+
export interface File {
|
|
106
|
+
path: string;
|
|
107
|
+
content: string;
|
|
108
|
+
}
|
|
109
|
+
export declare enum SchemaContext {
|
|
110
|
+
/** Schema is used as an input to an operation. */
|
|
111
|
+
Input = "input",
|
|
112
|
+
/** Schema is used as an output from an operation. */
|
|
113
|
+
Output = "output",
|
|
114
|
+
/** Schema is used as an exception from an operation. */
|
|
115
|
+
Exception = "exception"
|
|
116
|
+
}
|
|
117
|
+
export interface Schema {
|
|
118
|
+
name: string;
|
|
119
|
+
type: string;
|
|
120
|
+
typeName?: string;
|
|
121
|
+
outputTypeName?: string;
|
|
122
|
+
description?: string;
|
|
123
|
+
required?: boolean;
|
|
124
|
+
default?: any;
|
|
125
|
+
readOnly?: boolean;
|
|
126
|
+
usage?: SchemaContext[];
|
|
127
|
+
alias?: string;
|
|
128
|
+
outputAlias?: string;
|
|
129
|
+
fromCore?: boolean;
|
|
130
|
+
}
|
|
131
|
+
export interface ObjectSchema extends Schema {
|
|
132
|
+
properties?: Record<string, Schema>;
|
|
133
|
+
discriminatorValue?: string;
|
|
134
|
+
discriminator?: Schema;
|
|
135
|
+
isPolyParent?: boolean;
|
|
136
|
+
children?: {
|
|
137
|
+
all?: ObjectSchema[];
|
|
138
|
+
immediate?: ObjectSchema[];
|
|
139
|
+
};
|
|
140
|
+
parents?: {
|
|
141
|
+
all?: ObjectSchema[];
|
|
142
|
+
immediate?: ObjectSchema[];
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export interface DictionarySchema extends Schema {
|
|
146
|
+
valueTypeName?: string;
|
|
147
|
+
outputValueTypeName?: string;
|
|
148
|
+
}
|
|
149
|
+
export interface Property extends Schema {
|
|
150
|
+
}
|
|
151
|
+
export interface Parameter extends Schema {
|
|
152
|
+
}
|
|
153
|
+
export interface PackageDetails {
|
|
154
|
+
name: string;
|
|
155
|
+
scopeName?: string;
|
|
156
|
+
nameWithoutScope?: string;
|
|
157
|
+
description?: string;
|
|
158
|
+
version: string;
|
|
159
|
+
}
|
|
160
|
+
export interface OperationParameter {
|
|
161
|
+
operationGroup: string;
|
|
162
|
+
operationName: string;
|
|
163
|
+
/**
|
|
164
|
+
* An operation with multiple request parameters means that
|
|
165
|
+
* the operation can get different values for content-type and each value
|
|
166
|
+
* may have a different type associated to it.
|
|
167
|
+
*/
|
|
168
|
+
parameters: ParameterMetadatas[];
|
|
169
|
+
}
|
|
170
|
+
export interface ParameterMetadatas {
|
|
171
|
+
parameters?: ParameterMetadata[];
|
|
172
|
+
body?: ParameterBodyMetadata;
|
|
173
|
+
}
|
|
174
|
+
export interface ParameterBodyMetadata {
|
|
175
|
+
isPartialBody?: boolean;
|
|
176
|
+
body?: ParameterBodySchema[];
|
|
177
|
+
}
|
|
178
|
+
export declare type ParameterBodySchema = Schema;
|
|
179
|
+
export interface ParameterMetadata {
|
|
180
|
+
type: "query" | "path" | "header";
|
|
181
|
+
name: string;
|
|
182
|
+
param: Schema;
|
|
183
|
+
}
|
|
184
|
+
export interface OperationResponse {
|
|
185
|
+
operationGroup: string;
|
|
186
|
+
operationName: string;
|
|
187
|
+
responses: ResponseMetadata[];
|
|
188
|
+
}
|
|
189
|
+
export interface ResponseMetadata {
|
|
190
|
+
statusCode: string;
|
|
191
|
+
description?: string;
|
|
192
|
+
headers?: ResponseHeaderSchema[];
|
|
193
|
+
body?: ResponseBodySchema;
|
|
194
|
+
}
|
|
195
|
+
export declare type ResponseHeaderSchema = Schema;
|
|
196
|
+
export declare type ResponseBodySchema = Schema;
|
|
197
|
+
export declare type ContentBuilder = {
|
|
198
|
+
(model: RLCModel): File | undefined;
|
|
199
|
+
(model: RLCModel, hasSampleGenerated?: boolean): File | undefined;
|
|
200
|
+
};
|