@azure-tools/rlc-common 1.0.0-beta.1 → 1.0.0-beta.10

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.
Files changed (135) hide show
  1. package/.eslintrc.json +23 -0
  2. package/.prettierignore +1 -0
  3. package/.prettierrc +7 -0
  4. package/.rush/temp/package-deps_build.json +33 -25
  5. package/.rush/temp/shrinkwrap-deps.json +84 -9
  6. package/CHANGELOG.md +52 -1
  7. package/CONTRIBUTING.md +29 -0
  8. package/README.md +3 -0
  9. package/dist/buildClient.js +89 -19
  10. package/dist/buildClient.js.map +1 -1
  11. package/dist/buildClientDefinitions.js.map +1 -1
  12. package/dist/buildIndexFile.js +18 -0
  13. package/dist/buildIndexFile.js.map +1 -1
  14. package/dist/buildIsUnexpectedHelper.js +52 -51
  15. package/dist/buildIsUnexpectedHelper.js.map +1 -1
  16. package/dist/buildMethodShortcuts.js +1 -1
  17. package/dist/buildMethodShortcuts.js.map +1 -1
  18. package/dist/buildObjectTypes.js +47 -11
  19. package/dist/buildObjectTypes.js.map +1 -1
  20. package/dist/buildParameterTypes.js +31 -3
  21. package/dist/buildParameterTypes.js.map +1 -1
  22. package/dist/buildResponseTypes.js +19 -6
  23. package/dist/buildResponseTypes.js.map +1 -1
  24. package/dist/buildSchemaType.js +22 -1
  25. package/dist/buildSchemaType.js.map +1 -1
  26. package/dist/buildSerializeHelper.js +35 -0
  27. package/dist/buildSerializeHelper.js.map +1 -0
  28. package/dist/buildTopLevelIndexFile.js +6 -3
  29. package/dist/buildTopLevelIndexFile.js.map +1 -1
  30. package/dist/helpers/nameConstructors.js +2 -2
  31. package/dist/helpers/nameConstructors.js.map +1 -1
  32. package/dist/helpers/nameUtils.js +1 -1
  33. package/dist/helpers/nameUtils.js.map +1 -1
  34. package/dist/helpers/operationHelpers.js +23 -3
  35. package/dist/helpers/operationHelpers.js.map +1 -1
  36. package/dist/helpers/pathUtils.js +13 -0
  37. package/dist/helpers/pathUtils.js.map +1 -0
  38. package/dist/helpers/shortcutMethods.js +1 -1
  39. package/dist/helpers/shortcutMethods.js.map +1 -1
  40. package/dist/index.js +1 -0
  41. package/dist/index.js.map +1 -1
  42. package/dist/interfaces.js.map +1 -1
  43. package/dist/metadata/buildPackageFile.js +70 -28
  44. package/dist/metadata/buildPackageFile.js.map +1 -1
  45. package/dist/metadata/buildReadmeFile.js +3 -3
  46. package/dist/package.json +1 -1
  47. package/dist/static/paginateContent.js +1 -1
  48. package/dist/static/pollingContent.js +26 -6
  49. package/dist/static/pollingContent.js.map +1 -1
  50. package/dist/static/serializeHelper.js +30 -0
  51. package/dist/static/serializeHelper.js.map +1 -0
  52. package/dist/test/template.js +1 -2
  53. package/dist/test/template.js.map +1 -1
  54. package/dist-esm/buildClient.js +88 -18
  55. package/dist-esm/buildClient.js.map +1 -1
  56. package/dist-esm/buildClientDefinitions.js +1 -1
  57. package/dist-esm/buildClientDefinitions.js.map +1 -1
  58. package/dist-esm/buildIndexFile.js +19 -1
  59. package/dist-esm/buildIndexFile.js.map +1 -1
  60. package/dist-esm/buildIsUnexpectedHelper.js +52 -51
  61. package/dist-esm/buildIsUnexpectedHelper.js.map +1 -1
  62. package/dist-esm/buildMethodShortcuts.js +1 -1
  63. package/dist-esm/buildMethodShortcuts.js.map +1 -1
  64. package/dist-esm/buildObjectTypes.js +47 -8
  65. package/dist-esm/buildObjectTypes.js.map +1 -1
  66. package/dist-esm/buildParameterTypes.js +35 -2
  67. package/dist-esm/buildParameterTypes.js.map +1 -1
  68. package/dist-esm/buildResponseTypes.js +19 -6
  69. package/dist-esm/buildResponseTypes.js.map +1 -1
  70. package/dist-esm/buildSchemaType.js +23 -2
  71. package/dist-esm/buildSchemaType.js.map +1 -1
  72. package/dist-esm/buildSerializeHelper.js +31 -0
  73. package/dist-esm/buildSerializeHelper.js.map +1 -0
  74. package/dist-esm/buildTopLevelIndexFile.js +6 -3
  75. package/dist-esm/buildTopLevelIndexFile.js.map +1 -1
  76. package/dist-esm/helpers/nameConstructors.js +2 -2
  77. package/dist-esm/helpers/nameConstructors.js.map +1 -1
  78. package/dist-esm/helpers/nameUtils.js +1 -1
  79. package/dist-esm/helpers/nameUtils.js.map +1 -1
  80. package/dist-esm/helpers/operationHelpers.js +15 -3
  81. package/dist-esm/helpers/operationHelpers.js.map +1 -1
  82. package/dist-esm/helpers/pathUtils.js +9 -0
  83. package/dist-esm/helpers/pathUtils.js.map +1 -0
  84. package/dist-esm/helpers/shortcutMethods.js +1 -1
  85. package/dist-esm/helpers/shortcutMethods.js.map +1 -1
  86. package/dist-esm/index.js +1 -0
  87. package/dist-esm/index.js.map +1 -1
  88. package/dist-esm/interfaces.js.map +1 -1
  89. package/dist-esm/metadata/buildPackageFile.js +70 -28
  90. package/dist-esm/metadata/buildPackageFile.js.map +1 -1
  91. package/dist-esm/metadata/buildReadmeFile.js +3 -3
  92. package/dist-esm/package.json +1 -1
  93. package/dist-esm/static/paginateContent.js +1 -1
  94. package/dist-esm/static/pollingContent.js +26 -6
  95. package/dist-esm/static/pollingContent.js.map +1 -1
  96. package/dist-esm/static/serializeHelper.js +27 -0
  97. package/dist-esm/static/serializeHelper.js.map +1 -0
  98. package/dist-esm/test/template.js +1 -2
  99. package/dist-esm/test/template.js.map +1 -1
  100. package/package.json +10 -4
  101. package/src/buildClient.ts +121 -19
  102. package/src/buildClientDefinitions.ts +6 -2
  103. package/src/buildIndexFile.ts +28 -0
  104. package/src/buildIsUnexpectedHelper.ts +52 -52
  105. package/src/buildMethodShortcuts.ts +1 -1
  106. package/src/buildObjectTypes.ts +66 -10
  107. package/src/buildParameterTypes.ts +45 -3
  108. package/src/buildResponseTypes.ts +23 -6
  109. package/src/buildSchemaType.ts +24 -1
  110. package/src/buildSerializeHelper.ts +42 -0
  111. package/src/buildTopLevelIndexFile.ts +9 -3
  112. package/src/helpers/nameConstructors.ts +2 -2
  113. package/src/helpers/nameUtils.ts +1 -1
  114. package/src/helpers/operationHelpers.ts +19 -3
  115. package/src/helpers/pathUtils.ts +9 -0
  116. package/src/helpers/schemaHelpers.ts +1 -1
  117. package/src/helpers/shortcutMethods.ts +1 -1
  118. package/src/index.ts +1 -0
  119. package/src/interfaces.ts +16 -1
  120. package/src/metadata/buildPackageFile.ts +94 -31
  121. package/src/metadata/buildReadmeFile.ts +3 -3
  122. package/src/static/paginateContent.ts +1 -1
  123. package/src/static/pollingContent.ts +26 -6
  124. package/src/static/serializeHelper.ts +29 -0
  125. package/src/test/template.ts +1 -2
  126. package/types/buildObjectTypes.d.ts +2 -1
  127. package/types/buildParameterTypes.d.ts +9 -1
  128. package/types/buildSerializeHelper.d.ts +5 -0
  129. package/types/helpers/operationHelpers.d.ts +4 -0
  130. package/types/helpers/pathUtils.d.ts +1 -0
  131. package/types/index.d.ts +1 -0
  132. package/types/interfaces.d.ts +15 -1
  133. package/types/static/pollingContent.d.ts +1 -1
  134. package/types/static/serializeHelper.d.ts +4 -0
  135. package/types/test/template.d.ts +1 -1
@@ -1,5 +1,6 @@
1
1
  export const pollingContent = `
2
2
  import { Client, HttpResponse } from "@azure-rest/core-client";
3
+ {{#if useLegacyLro}}
3
4
  import {
4
5
  LongRunningOperation,
5
6
  LroEngine,
@@ -8,7 +9,16 @@ import {
8
9
  PollerLike,
9
10
  PollOperationState
10
11
  } from "@azure/core-lro";
11
-
12
+ {{else}}
13
+ import {
14
+ CreateHttpPollerOptions,
15
+ LongRunningOperation,
16
+ LroResponse,
17
+ OperationState,
18
+ SimplePollerLike,
19
+ createHttpPoller
20
+ } from "@azure/core-lro";
21
+ {{/if}}
12
22
  /**
13
23
  * Helper function that builds a Poller object to help polling a long running operation.
14
24
  * @param client - Client to use for sending the request to get additional pages.
@@ -16,12 +26,17 @@ import {
16
26
  * @param options - Options to set a resume state or custom polling interval.
17
27
  * @returns - A poller object to poll for operation state updates and eventually get the final response.
18
28
  */
19
- export function getLongRunningPoller<TResult extends HttpResponse>(
29
+ export {{#unless useLegacyLro}}async {{/unless}}function getLongRunningPoller<TResult extends HttpResponse>(
20
30
  client: Client,
21
31
  initialResponse: TResult,
32
+ {{#if useLegacyLro}}
22
33
  options: LroEngineOptions<TResult, PollOperationState<TResult>> = {}
23
- ): PollerLike<PollOperationState<TResult>, TResult> {
24
- const poller: LongRunningOperation<TResult> = {
34
+ ): PollerLike<PollOperationState<TResult>, TResult> {
35
+ {{else}}
36
+ options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {}
37
+ ): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {
38
+ {{/if}}
39
+ const poller: LongRunningOperation<TResult> = {
25
40
  requestMethod: initialResponse.request.method,
26
41
  requestPath: initialResponse.request.url,
27
42
  sendInitialRequest: async () => {
@@ -45,13 +60,18 @@ export function getLongRunningPoller<TResult extends HttpResponse>(
45
60
  }
46
61
  };
47
62
 
63
+ {{#if useLegacyLro}}
48
64
  return new LroEngine(poller, options);
65
+ {{else}}
66
+ options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;
67
+ return await createHttpPoller(poller, options);
68
+ {{/if}}
49
69
  }
50
70
 
51
71
  /**
52
- * Converts a Rest Client response to a response that the LRO engine knows about
72
+ * Converts a Rest Client response to a response that the LRO implementation understands
53
73
  * @param response - a rest client http response
54
- * @returns - An LRO response that the LRO engine can work with
74
+ * @returns - An LRO response that the LRO implementation understands
55
75
  */
56
76
  function getLroResponse<TResult extends HttpResponse>(
57
77
  response: TResult
@@ -0,0 +1,29 @@
1
+ export const buildMultiCollectionContent = `
2
+ export function buildMultiCollection(
3
+ queryParameters: string[],
4
+ parameterName: string
5
+ ) {
6
+ return queryParameters
7
+ .map((item, index) => {
8
+ if (index === 0) {
9
+ return item;
10
+ }
11
+ return \`\${parameterName}=\${item}\`;
12
+ })
13
+ .join("&");
14
+ }`;
15
+
16
+ export const buildPipeCollectionContent = `
17
+ export function buildPipeCollection(queryParameters: string[]): string {
18
+ return queryParameters.join("|");
19
+ }`;
20
+
21
+ export const buildSsvCollectionContent = `
22
+ export function buildSsvCollection(queryParameters: string[]): string {
23
+ return queryParameters.join(" ");
24
+ }`;
25
+
26
+ export const buildTsvCollectionContent = `
27
+ export function buildTsvCollection(queryParameters: string[]) {
28
+ return queryParameters.join("\\t");
29
+ }`;
@@ -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",
@@ -65,6 +63,7 @@ module.exports = function (config) {
65
63
  "AZURE_CLIENT_ID",
66
64
  "AZURE_TENANT_ID",
67
65
  "SUBSCRIPTION_ID",
66
+ "RECORDINGS_RELATIVE_PATH",
68
67
  ],
69
68
 
70
69
  // test results reporter to use
@@ -4,6 +4,7 @@ import { Parameter, Property, RLCModel, SchemaContext } from "./interfaces.js";
4
4
  * Generates interfaces for ObjectSchemas
5
5
  */
6
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[];
7
8
  export declare function buildPolymorphicAliases(model: RLCModel, schemaUsage: SchemaContext[]): TypeAliasDeclarationStructure[];
8
9
  /**
9
10
  * Builds a Typescript property or parameter signature
@@ -11,4 +12,4 @@ export declare function buildPolymorphicAliases(model: RLCModel, schemaUsage: Sc
11
12
  * @param importedModels - Set to track the models that need to be imported
12
13
  * @returns a PropertySignatureStructure for the property.
13
14
  */
14
- export declare function getPropertySignature(property: Property | Parameter, schemaUsage: SchemaContext[], importedModels?: Set<string>): PropertySignatureStructure;
15
+ export declare function getPropertySignature(property: Property | Parameter, schemaUsage: SchemaContext[], importedModels: Set<string>): PropertySignatureStructure;
@@ -1,5 +1,13 @@
1
- import { RLCModel } from "./interfaces.js";
1
+ import { ParameterMetadatas, RLCModel } from "./interfaces.js";
2
2
  export declare function buildParameterTypes(model: RLCModel): {
3
3
  path: string;
4
4
  content: string;
5
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,5 @@
1
+ import { RLCModel } from "./interfaces.js";
2
+ export declare function buildSerializeHelper(model: RLCModel): {
3
+ path: string;
4
+ content: any;
5
+ } | undefined;
@@ -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
@@ -23,3 +23,4 @@ export * from "./metadata/buildRollupConfig.js";
23
23
  export * from "./metadata/buildTsConfig.js";
24
24
  export * from "./metadata/buildESLintConfig.js";
25
25
  export * from "./metadata/buildLicenseFile.js";
26
+ export * from "./buildSerializeHelper.js";
@@ -4,21 +4,30 @@ export interface RLCModel {
4
4
  paths: Paths;
5
5
  options?: RLCOptions;
6
6
  schemas: Schema[];
7
- apiVersionParam?: Parameter;
7
+ apiVersionInQueryParam?: Parameter;
8
8
  parameters?: OperationParameter[];
9
9
  responses?: OperationResponse[];
10
10
  importSet?: Map<ImportKind, Set<string>>;
11
11
  annotations?: AnnotationDetails;
12
12
  urlInfo?: UrlInfo;
13
13
  }
14
+ export interface PathTemplateApiVersion {
15
+ value: string;
16
+ templateName: string;
17
+ }
14
18
  export interface UrlInfo {
15
19
  endpoint?: string;
16
20
  urlParameters?: PathParameter[];
21
+ pathTemplateApiVersion?: PathTemplateApiVersion;
17
22
  }
18
23
  export interface AnnotationDetails {
19
24
  hasPaging?: boolean;
20
25
  hasLongRunning?: boolean;
21
26
  pageDetails?: PagingDetails;
27
+ hasMultiCollection?: boolean;
28
+ hasPipeCollection?: boolean;
29
+ hasSsvCollection?: boolean;
30
+ hasTsvCollection?: boolean;
22
31
  }
23
32
  export interface PagingDetails {
24
33
  itemNames: string[];
@@ -54,6 +63,7 @@ export declare type PathParameter = {
54
63
  name: string;
55
64
  type: string;
56
65
  description?: string;
66
+ value?: string | number | boolean;
57
67
  };
58
68
  export interface OperationAnnotations {
59
69
  isLongRunning?: boolean;
@@ -78,6 +88,7 @@ export interface RLCOptions {
78
88
  productDocLink?: string;
79
89
  serviceInfo?: ServiceInfo;
80
90
  azureArm?: boolean;
91
+ sourceFrom?: "Cadl" | "Swagger";
81
92
  }
82
93
  export interface ServiceInfo {
83
94
  title?: string;
@@ -113,6 +124,9 @@ export interface Schema {
113
124
  default?: any;
114
125
  readOnly?: boolean;
115
126
  usage?: SchemaContext[];
127
+ alias?: string;
128
+ outputAlias?: string;
129
+ fromCore?: boolean;
116
130
  }
117
131
  export interface ObjectSchema extends Schema {
118
132
  properties?: Record<string, Schema>;
@@ -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 engine knows about\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO engine can work with\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";
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}";
@@ -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-edge-launcher\",\n \"karma-firefox-launcher\",\n \"karma-ie-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 ],\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";
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";