@azure-tools/rlc-common 1.0.0-beta.8 → 1.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +15 -12
- package/.rush/temp/shrinkwrap-deps.json +13 -13
- package/CHANGELOG.md +7 -0
- package/dist/buildClient.js +22 -11
- package/dist/buildClient.js.map +1 -1
- package/dist/buildIndexFile.js +18 -0
- package/dist/buildIndexFile.js.map +1 -1
- package/dist/buildSerializeHelper.js +35 -0
- package/dist/buildSerializeHelper.js.map +1 -0
- package/dist/buildTopLevelIndexFile.js +2 -1
- package/dist/buildTopLevelIndexFile.js.map +1 -1
- package/dist/helpers/operationHelpers.js +21 -1
- package/dist/helpers/operationHelpers.js.map +1 -1
- package/dist/helpers/pathUtils.js +12 -0
- package/dist/helpers/pathUtils.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/metadata/buildPackageFile.js +43 -16
- package/dist/metadata/buildPackageFile.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/static/pollingContent.js +26 -6
- package/dist/static/pollingContent.js.map +1 -1
- package/dist/static/serializeHelper.js +30 -0
- package/dist/static/serializeHelper.js.map +1 -0
- package/dist/test/template.js +0 -2
- package/dist/test/template.js.map +1 -1
- package/dist-esm/buildClient.js +22 -11
- package/dist-esm/buildClient.js.map +1 -1
- package/dist-esm/buildIndexFile.js +19 -1
- package/dist-esm/buildIndexFile.js.map +1 -1
- package/dist-esm/buildSerializeHelper.js +31 -0
- package/dist-esm/buildSerializeHelper.js.map +1 -0
- package/dist-esm/buildTopLevelIndexFile.js +2 -1
- package/dist-esm/buildTopLevelIndexFile.js.map +1 -1
- package/dist-esm/helpers/operationHelpers.js +12 -0
- package/dist-esm/helpers/operationHelpers.js.map +1 -1
- package/dist-esm/helpers/pathUtils.js +8 -0
- package/dist-esm/helpers/pathUtils.js.map +1 -0
- package/dist-esm/index.js +1 -0
- package/dist-esm/index.js.map +1 -1
- package/dist-esm/interfaces.js.map +1 -1
- package/dist-esm/metadata/buildPackageFile.js +43 -16
- package/dist-esm/metadata/buildPackageFile.js.map +1 -1
- package/dist-esm/package.json +1 -1
- package/dist-esm/static/pollingContent.js +26 -6
- package/dist-esm/static/pollingContent.js.map +1 -1
- package/dist-esm/static/serializeHelper.js +27 -0
- package/dist-esm/static/serializeHelper.js.map +1 -0
- package/dist-esm/test/template.js +0 -2
- package/dist-esm/test/template.js.map +1 -1
- package/package.json +1 -1
- package/src/buildClient.ts +23 -12
- package/src/buildIndexFile.ts +28 -0
- package/src/buildSerializeHelper.ts +42 -0
- package/src/buildTopLevelIndexFile.ts +6 -2
- package/src/helpers/operationHelpers.ts +16 -0
- package/src/helpers/pathUtils.ts +7 -0
- package/src/index.ts +1 -0
- package/src/interfaces.ts +5 -0
- package/src/metadata/buildPackageFile.ts +52 -16
- package/src/static/pollingContent.ts +26 -6
- package/src/static/serializeHelper.ts +29 -0
- package/src/test/template.ts +0 -2
- package/types/buildSerializeHelper.d.ts +5 -0
- package/types/helpers/operationHelpers.d.ts +4 -0
- package/types/helpers/pathUtils.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/interfaces.d.ts +5 -0
- package/types/static/pollingContent.d.ts +1 -1
- package/types/static/serializeHelper.d.ts +4 -0
- package/types/test/template.d.ts +1 -1
package/src/test/template.ts
CHANGED
|
@@ -30,9 +30,7 @@ module.exports = function (config) {
|
|
|
30
30
|
"karma-mocha",
|
|
31
31
|
"karma-mocha-reporter",
|
|
32
32
|
"karma-chrome-launcher",
|
|
33
|
-
"karma-edge-launcher",
|
|
34
33
|
"karma-firefox-launcher",
|
|
35
|
-
"karma-ie-launcher",
|
|
36
34
|
"karma-env-preprocessor",
|
|
37
35
|
"karma-coverage",
|
|
38
36
|
"karma-sourcemap-loader",
|
|
@@ -4,6 +4,10 @@ export declare function buildMethodDefinitions(methods: Methods, pathParams?: Pa
|
|
|
4
4
|
export declare function getPathParamDefinitions(pathParams: PathParameter[]): OptionalKind<ParameterDeclarationStructure>[];
|
|
5
5
|
export declare function hasPagingOperations(model: RLCModel): boolean;
|
|
6
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;
|
|
7
11
|
export declare function hasUnexpectedHelper(model: RLCModel): boolean;
|
|
8
12
|
export declare function hasInputModels(model: RLCModel): boolean;
|
|
9
13
|
export declare function hasOutputModels(model: RLCModel): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getRelativePartFromSrcPath(srcPath: string): string;
|
package/types/index.d.ts
CHANGED
package/types/interfaces.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ export interface AnnotationDetails {
|
|
|
24
24
|
hasPaging?: boolean;
|
|
25
25
|
hasLongRunning?: boolean;
|
|
26
26
|
pageDetails?: PagingDetails;
|
|
27
|
+
hasMultiCollection?: boolean;
|
|
28
|
+
hasPipeCollection?: boolean;
|
|
29
|
+
hasSsvCollection?: boolean;
|
|
30
|
+
hasTsvCollection?: boolean;
|
|
27
31
|
}
|
|
28
32
|
export interface PagingDetails {
|
|
29
33
|
itemNames: string[];
|
|
@@ -84,6 +88,7 @@ export interface RLCOptions {
|
|
|
84
88
|
productDocLink?: string;
|
|
85
89
|
serviceInfo?: ServiceInfo;
|
|
86
90
|
azureArm?: boolean;
|
|
91
|
+
sourceFrom?: "Cadl" | "Swagger";
|
|
87
92
|
}
|
|
88
93
|
export interface ServiceInfo {
|
|
89
94
|
title?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const pollingContent = "\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport {\n LongRunningOperation,\n LroEngine,\n LroEngineOptions,\n LroResponse,\n PollerLike,\n PollOperationState\n} from \"@azure/core-lro\";\n\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\nexport function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n options: LroEngineOptions<TResult, PollOperationState<TResult>> = {}\n): PollerLike<PollOperationState<TResult>, TResult> {\n const poller: LongRunningOperation<TResult> = {\n requestMethod: initialResponse.request.method,\n requestPath: initialResponse.request.url,\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async path => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n const response = await client\n .pathUnchecked(path ?? initialResponse.request.url)\n .get();\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] =\n initialResponse.request.url;\n return lroResponse;\n }\n };\n\n return new LroEngine(poller, options);\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO
|
|
1
|
+
export declare const pollingContent = "\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\n{{#if useLegacyLro}}\nimport {\n LongRunningOperation,\n LroEngine,\n LroEngineOptions,\n LroResponse,\n PollerLike,\n PollOperationState\n} from \"@azure/core-lro\";\n{{else}}\nimport {\n CreateHttpPollerOptions,\n LongRunningOperation,\n LroResponse,\n OperationState,\n SimplePollerLike,\n createHttpPoller\n} from \"@azure/core-lro\";\n{{/if}}\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\nexport {{#unless useLegacyLro}}async {{/unless}}function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n {{#if useLegacyLro}}\n options: LroEngineOptions<TResult, PollOperationState<TResult>> = {}\n ): PollerLike<PollOperationState<TResult>, TResult> {\n {{else}}\n options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {}\n ): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {\n {{/if}} \n const poller: LongRunningOperation<TResult> = {\n requestMethod: initialResponse.request.method,\n requestPath: initialResponse.request.url,\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async path => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n const response = await client\n .pathUnchecked(path ?? initialResponse.request.url)\n .get();\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] =\n initialResponse.request.url;\n return lroResponse;\n }\n };\n\n {{#if useLegacyLro}}\n return new LroEngine(poller, options);\n {{else}}\n options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;\n return await createHttpPoller(poller, options);\n {{/if}}\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO implementation understands\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO implementation understands\n */\nfunction getLroResponse<TResult extends HttpResponse>(\n response: TResult\n): LroResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(\n `Status code of the response is not a number. Value: ${response.status}`\n );\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body\n }\n };\n}\n";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const buildMultiCollectionContent = "\nexport function buildMultiCollection(\n queryParameters: string[],\n parameterName: string\n) {\n return queryParameters\n .map((item, index) => {\n if (index === 0) {\n return item;\n }\n return `${parameterName}=${item}`;\n })\n .join(\"&\");\n}";
|
|
2
|
+
export declare const buildPipeCollectionContent = "\nexport function buildPipeCollection(queryParameters: string[]): string {\n return queryParameters.join(\"|\");\n}";
|
|
3
|
+
export declare const buildSsvCollectionContent = "\nexport function buildSsvCollection(queryParameters: string[]): string {\n return queryParameters.join(\" \");\n}";
|
|
4
|
+
export declare const buildTsvCollectionContent = "\nexport function buildTsvCollection(queryParameters: string[]) {\n return queryParameters.join(\"\\t\");\n}";
|
package/types/test/template.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const envContent = "\nimport * as dotenv from \"dotenv\";\n\ndotenv.config();\n";
|
|
2
2
|
export declare const envBrowserContent = "\nimport * as dotenv from \"dotenv\";\n\ndotenv.config();\n";
|
|
3
|
-
export declare const karmaConfig = "\n// https://github.com/karma-runner/karma-chrome-launcher\nprocess.env.CHROME_BIN = require(\"puppeteer\").executablePath();\nrequire(\"dotenv\").config();\nconst { relativeRecordingsPath } = require(\"@azure-tools/test-recorder\");\nprocess.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();\n\nmodule.exports = function (config) {\n config.set({\n // base path that will be used to resolve all patterns (eg. files, exclude)\n basePath: \"./\",\n\n // frameworks to use\n // available frameworks: https://npmjs.org/browse/keyword/karma-adapter\n frameworks: [\"source-map-support\", \"mocha\"],\n\n plugins: [\n \"karma-mocha\",\n \"karma-mocha-reporter\",\n \"karma-chrome-launcher\",\n \"karma-
|
|
3
|
+
export declare const karmaConfig = "\n// https://github.com/karma-runner/karma-chrome-launcher\nprocess.env.CHROME_BIN = require(\"puppeteer\").executablePath();\nrequire(\"dotenv\").config();\nconst { relativeRecordingsPath } = require(\"@azure-tools/test-recorder\");\nprocess.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();\n\nmodule.exports = function (config) {\n config.set({\n // base path that will be used to resolve all patterns (eg. files, exclude)\n basePath: \"./\",\n\n // frameworks to use\n // available frameworks: https://npmjs.org/browse/keyword/karma-adapter\n frameworks: [\"source-map-support\", \"mocha\"],\n\n plugins: [\n \"karma-mocha\",\n \"karma-mocha-reporter\",\n \"karma-chrome-launcher\",\n \"karma-firefox-launcher\",\n \"karma-env-preprocessor\",\n \"karma-coverage\",\n \"karma-sourcemap-loader\",\n \"karma-junit-reporter\",\n \"karma-source-map-support\",\n ],\n\n // list of files / patterns to load in the browser\n files: [\n \"dist-test/index.browser.js\",\n { pattern: \"dist-test/index.browser.js.map\", type: \"html\", included: false, served: true },\n ],\n\n // list of files / patterns to exclude\n exclude: [],\n\n // preprocess matching files before serving them to the browser\n // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor\n preprocessors: {\n \"**/*.js\": [\"sourcemap\", \"env\"],\n // IMPORTANT: COMMENT following line if you want to debug in your browsers!!\n // Preprocess source file to calculate code coverage, however this will make source file unreadable\n // \"dist-test/index.js\": [\"coverage\"]\n },\n\n envPreprocessor: [\n \"TEST_MODE\",\n \"ENDPOINT\",\n \"AZURE_CLIENT_SECRET\",\n \"AZURE_CLIENT_ID\",\n \"AZURE_TENANT_ID\",\n \"SUBSCRIPTION_ID\",\n \"RECORDINGS_RELATIVE_PATH\",\n ],\n\n // test results reporter to use\n // possible values: 'dots', 'progress'\n // available reporters: https://npmjs.org/browse/keyword/karma-reporter\n reporters: [\"mocha\", \"coverage\", \"junit\"],\n\n coverageReporter: {\n // specify a common output directory\n dir: \"coverage-browser/\",\n reporters: [\n { type: \"json\", subdir: \".\", file: \"coverage.json\" },\n { type: \"lcovonly\", subdir: \".\", file: \"lcov.info\" },\n { type: \"html\", subdir: \"html\" },\n { type: \"cobertura\", subdir: \".\", file: \"cobertura-coverage.xml\" },\n ],\n },\n\n junitReporter: {\n outputDir: \"\", // results will be saved as $outputDir/$browserName.xml\n outputFile: \"test-results.browser.xml\", // if included, results will be saved as $outputDir/$browserName/$outputFile\n suite: \"\", // suite will become the package name attribute in xml testsuite element\n useBrowserName: false, // add browser name to report and classes names\n nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element\n classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element\n properties: {}, // key value pair of properties to add to the <properties> section of the report\n },\n\n // web server port\n port: 9876,\n\n // enable / disable colors in the output (reporters and logs)\n colors: true,\n\n // level of logging\n // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG\n logLevel: config.LOG_INFO,\n\n // enable / disable watching file and executing tests whenever any file changes\n autoWatch: false,\n\n // --no-sandbox allows our tests to run in Linux without having to change the system.\n // --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.\n browsers: [\"ChromeHeadlessNoSandbox\"],\n customLaunchers: {\n ChromeHeadlessNoSandbox: {\n base: \"ChromeHeadless\",\n flags: [\"--no-sandbox\", \"--disable-web-security\"],\n },\n },\n\n // Continuous Integration mode\n // if true, Karma captures browsers, runs the tests and exits\n singleRun: false,\n\n // Concurrency level\n // how many browser should be started simultaneous\n concurrency: 1,\n\n browserNoActivityTimeout: 60000000,\n browserDisconnectTimeout: 10000,\n browserDisconnectTolerance: 3,\n\n client: {\n mocha: {\n // change Karma's debug.html to the mocha web reporter\n reporter: \"html\",\n timeout: \"600000\",\n },\n },\n });\n};\n";
|
|
4
4
|
export declare const recordedClientContent = "\nimport { Context } from \"mocha\";\nimport { Recorder, RecorderStartOptions } from \"@azure-tools/test-recorder\";\nimport \"./env\";\n\nconst envSetupForPlayback: Record<string, string> = {\n ENDPOINT: \"https://endpoint\",\n AZURE_CLIENT_ID: \"azure_client_id\",\n AZURE_CLIENT_SECRET: \"azure_client_secret\",\n AZURE_TENANT_ID: \"88888888-8888-8888-8888-888888888888\",\n SUBSCRIPTION_ID: \"azure_subscription_id\"\n};\n\nconst recorderEnvSetup: RecorderStartOptions = {\n envSetupForPlayback\n};\n\n/**\n* creates the recorder and reads the environment variables from the `.env` file.\n* Should be called first in the test suite to make sure environment variables are\n* read before they are being used.\n*/\nexport async function createRecorder(context: Context): Promise<Recorder> {\n const recorder = new Recorder(context.currentTest);\n await recorder.start(recorderEnvSetup);\n return recorder;\n}\n";
|
|
5
5
|
export declare const sampleTestContent = "\nimport { Recorder } from \"@azure-tools/test-recorder\";\nimport { assert } from \"chai\";\nimport { createRecorder } from \"./utils/recordedClient\";\nimport { Context } from \"mocha\";\n\ndescribe(\"My test\", () => {\n let recorder: Recorder;\n\n beforeEach(async function(this: Context) {\n recorder = await createRecorder(this);\n });\n\n afterEach(async function() {\n await recorder.stop();\n });\n\n it(\"sample test\", async function() {\n assert.equal(1, 1);\n });\n});\n";
|