@azure-tools/typespec-ts 0.55.0-dev.8 → 0.55.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.
Files changed (192) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +1 -77
  3. package/dist/src/framework/hooks/sdk-types.d.ts +3 -2
  4. package/dist/src/framework/hooks/sdk-types.d.ts.map +1 -1
  5. package/dist/src/framework/hooks/sdk-types.js +3 -2
  6. package/dist/src/framework/hooks/sdk-types.js.map +1 -1
  7. package/dist/src/index.d.ts.map +1 -1
  8. package/dist/src/index.js +24 -80
  9. package/dist/src/index.js.map +1 -1
  10. package/dist/src/lib.d.ts +2 -12
  11. package/dist/src/lib.d.ts.map +1 -1
  12. package/dist/src/lib.js +0 -65
  13. package/dist/src/lib.js.map +1 -1
  14. package/dist/src/modular/build-classical-client.js +2 -2
  15. package/dist/src/modular/build-classical-client.js.map +1 -1
  16. package/dist/src/modular/emit-models.d.ts.map +1 -1
  17. package/dist/src/modular/emit-models.js +19 -5
  18. package/dist/src/modular/emit-models.js.map +1 -1
  19. package/dist/src/modular/emit-samples.js +92 -19
  20. package/dist/src/modular/emit-samples.js.map +1 -1
  21. package/dist/src/modular/serialization/serialize-utils.js +2 -2
  22. package/dist/src/modular/serialization/serialize-utils.js.map +1 -1
  23. package/dist/src/rlc-common/helpers/name-constructors.d.ts.map +1 -1
  24. package/dist/src/rlc-common/helpers/name-constructors.js +1 -7
  25. package/dist/src/rlc-common/helpers/name-constructors.js.map +1 -1
  26. package/dist/src/rlc-common/index.d.ts +0 -16
  27. package/dist/src/rlc-common/index.d.ts.map +1 -1
  28. package/dist/src/rlc-common/index.js +0 -16
  29. package/dist/src/rlc-common/index.js.map +1 -1
  30. package/dist/src/rlc-common/interfaces.d.ts +0 -10
  31. package/dist/src/rlc-common/interfaces.d.ts.map +1 -1
  32. package/dist/src/rlc-common/interfaces.js.map +1 -1
  33. package/dist/src/rlc-common/metadata/build-package-file.d.ts.map +1 -1
  34. package/dist/src/rlc-common/metadata/build-package-file.js +0 -12
  35. package/dist/src/rlc-common/metadata/build-package-file.js.map +1 -1
  36. package/dist/src/rlc-common/metadata/build-readme-file.d.ts.map +1 -1
  37. package/dist/src/rlc-common/metadata/build-readme-file.js +4 -89
  38. package/dist/src/rlc-common/metadata/build-readme-file.js.map +1 -1
  39. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts +0 -1
  40. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts.map +1 -1
  41. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js +2 -2
  42. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js.map +1 -1
  43. package/dist/src/rlc-common/metadata/package-json/package-common.d.ts +0 -1
  44. package/dist/src/rlc-common/metadata/package-json/package-common.d.ts.map +1 -1
  45. package/dist/src/rlc-common/metadata/package-json/package-common.js.map +1 -1
  46. package/dist/src/rlc-common/test/build-snippets.d.ts.map +1 -1
  47. package/dist/src/rlc-common/test/build-snippets.js +0 -1
  48. package/dist/src/rlc-common/test/build-snippets.js.map +1 -1
  49. package/dist/src/rlc-common/test/template.d.ts +1 -1
  50. package/dist/src/rlc-common/test/template.d.ts.map +1 -1
  51. package/dist/src/rlc-common/test/template.js +0 -4
  52. package/dist/src/rlc-common/test/template.js.map +1 -1
  53. package/dist/src/transform/transform-schemas.js +1 -1
  54. package/dist/src/transform/transform-schemas.js.map +1 -1
  55. package/dist/src/transform/transform.d.ts.map +1 -1
  56. package/dist/src/transform/transform.js +5 -11
  57. package/dist/src/transform/transform.js.map +1 -1
  58. package/dist/src/transform/transfrom-rlc-options.d.ts +2 -2
  59. package/dist/src/transform/transfrom-rlc-options.d.ts.map +1 -1
  60. package/dist/src/transform/transfrom-rlc-options.js +19 -39
  61. package/dist/src/transform/transfrom-rlc-options.js.map +1 -1
  62. package/dist/src/utils/client-utils.d.ts +1 -1
  63. package/dist/src/utils/client-utils.d.ts.map +1 -1
  64. package/dist/src/utils/client-utils.js +4 -5
  65. package/dist/src/utils/client-utils.js.map +1 -1
  66. package/dist/src/utils/emit-util.d.ts +0 -1
  67. package/dist/src/utils/emit-util.d.ts.map +1 -1
  68. package/dist/src/utils/emit-util.js +0 -13
  69. package/dist/src/utils/emit-util.js.map +1 -1
  70. package/dist/src/utils/model-utils.d.ts +1 -1
  71. package/dist/src/utils/model-utils.d.ts.map +1 -1
  72. package/dist/src/utils/model-utils.js +4 -11
  73. package/dist/src/utils/model-utils.js.map +1 -1
  74. package/dist/tsconfig.tsbuildinfo +1 -1
  75. package/package.json +40 -44
  76. package/src/framework/hooks/sdk-types.ts +3 -2
  77. package/src/index.ts +27 -105
  78. package/src/lib.ts +1 -77
  79. package/src/modular/build-classical-client.ts +2 -2
  80. package/src/modular/emit-models.ts +20 -5
  81. package/src/modular/emit-samples.ts +119 -38
  82. package/src/modular/serialization/serialize-utils.ts +2 -2
  83. package/src/rlc-common/helpers/name-constructors.ts +1 -8
  84. package/src/rlc-common/index.ts +0 -16
  85. package/src/rlc-common/interfaces.ts +0 -11
  86. package/src/rlc-common/metadata/build-package-file.ts +0 -13
  87. package/src/rlc-common/metadata/build-readme-file.ts +4 -99
  88. package/src/rlc-common/metadata/package-json/build-azure-monorepo-package.ts +2 -3
  89. package/src/rlc-common/metadata/package-json/package-common.ts +0 -1
  90. package/src/rlc-common/test/build-snippets.ts +0 -1
  91. package/src/rlc-common/test/template.ts +0 -4
  92. package/src/transform/transform-schemas.ts +1 -1
  93. package/src/transform/transform.ts +4 -14
  94. package/src/transform/transfrom-rlc-options.ts +19 -63
  95. package/src/utils/client-utils.ts +4 -5
  96. package/src/utils/emit-util.ts +1 -14
  97. package/src/utils/model-utils.ts +4 -17
  98. package/dist/src/rlc-common/build-client-definitions.d.ts +0 -6
  99. package/dist/src/rlc-common/build-client-definitions.d.ts.map +0 -1
  100. package/dist/src/rlc-common/build-client-definitions.js +0 -157
  101. package/dist/src/rlc-common/build-client-definitions.js.map +0 -1
  102. package/dist/src/rlc-common/build-client.d.ts +0 -9
  103. package/dist/src/rlc-common/build-client.d.ts.map +0 -1
  104. package/dist/src/rlc-common/build-client.js +0 -375
  105. package/dist/src/rlc-common/build-client.js.map +0 -1
  106. package/dist/src/rlc-common/build-index-file.d.ts +0 -6
  107. package/dist/src/rlc-common/build-index-file.d.ts.map +0 -1
  108. package/dist/src/rlc-common/build-index-file.js +0 -180
  109. package/dist/src/rlc-common/build-index-file.js.map +0 -1
  110. package/dist/src/rlc-common/build-is-unexpected-helper.d.ts +0 -6
  111. package/dist/src/rlc-common/build-is-unexpected-helper.d.ts.map +0 -1
  112. package/dist/src/rlc-common/build-is-unexpected-helper.js +0 -219
  113. package/dist/src/rlc-common/build-is-unexpected-helper.js.map +0 -1
  114. package/dist/src/rlc-common/build-logger.d.ts +0 -6
  115. package/dist/src/rlc-common/build-logger.d.ts.map +0 -1
  116. package/dist/src/rlc-common/build-logger.js +0 -23
  117. package/dist/src/rlc-common/build-logger.js.map +0 -1
  118. package/dist/src/rlc-common/build-method-shortcuts.d.ts +0 -5
  119. package/dist/src/rlc-common/build-method-shortcuts.d.ts.map +0 -1
  120. package/dist/src/rlc-common/build-method-shortcuts.js +0 -54
  121. package/dist/src/rlc-common/build-method-shortcuts.js.map +0 -1
  122. package/dist/src/rlc-common/build-object-types.d.ts +0 -29
  123. package/dist/src/rlc-common/build-object-types.d.ts.map +0 -1
  124. package/dist/src/rlc-common/build-object-types.js +0 -410
  125. package/dist/src/rlc-common/build-object-types.js.map +0 -1
  126. package/dist/src/rlc-common/build-paginate-helper.d.ts +0 -6
  127. package/dist/src/rlc-common/build-paginate-helper.d.ts.map +0 -1
  128. package/dist/src/rlc-common/build-paginate-helper.js +0 -27
  129. package/dist/src/rlc-common/build-paginate-helper.js.map +0 -1
  130. package/dist/src/rlc-common/build-parameter-types.d.ts +0 -14
  131. package/dist/src/rlc-common/build-parameter-types.d.ts.map +0 -1
  132. package/dist/src/rlc-common/build-parameter-types.js +0 -338
  133. package/dist/src/rlc-common/build-parameter-types.js.map +0 -1
  134. package/dist/src/rlc-common/build-polling-helper.d.ts +0 -6
  135. package/dist/src/rlc-common/build-polling-helper.d.ts.map +0 -1
  136. package/dist/src/rlc-common/build-polling-helper.js +0 -59
  137. package/dist/src/rlc-common/build-polling-helper.js.map +0 -1
  138. package/dist/src/rlc-common/build-response-types.d.ts +0 -6
  139. package/dist/src/rlc-common/build-response-types.d.ts.map +0 -1
  140. package/dist/src/rlc-common/build-response-types.js +0 -140
  141. package/dist/src/rlc-common/build-response-types.js.map +0 -1
  142. package/dist/src/rlc-common/build-samples.d.ts +0 -3
  143. package/dist/src/rlc-common/build-samples.d.ts.map +0 -1
  144. package/dist/src/rlc-common/build-samples.js +0 -30
  145. package/dist/src/rlc-common/build-samples.js.map +0 -1
  146. package/dist/src/rlc-common/build-schema-type.d.ts +0 -20
  147. package/dist/src/rlc-common/build-schema-type.d.ts.map +0 -1
  148. package/dist/src/rlc-common/build-schema-type.js +0 -64
  149. package/dist/src/rlc-common/build-schema-type.js.map +0 -1
  150. package/dist/src/rlc-common/build-serialize-helper.d.ts +0 -6
  151. package/dist/src/rlc-common/build-serialize-helper.d.ts.map +0 -1
  152. package/dist/src/rlc-common/build-serialize-helper.js +0 -36
  153. package/dist/src/rlc-common/build-serialize-helper.js.map +0 -1
  154. package/dist/src/rlc-common/build-top-level-index-file.d.ts +0 -6
  155. package/dist/src/rlc-common/build-top-level-index-file.d.ts.map +0 -1
  156. package/dist/src/rlc-common/build-top-level-index-file.js +0 -44
  157. package/dist/src/rlc-common/build-top-level-index-file.js.map +0 -1
  158. package/dist/src/rlc-common/helpers/path-utils.d.ts +0 -2
  159. package/dist/src/rlc-common/helpers/path-utils.d.ts.map +0 -1
  160. package/dist/src/rlc-common/helpers/path-utils.js +0 -9
  161. package/dist/src/rlc-common/helpers/path-utils.js.map +0 -1
  162. package/dist/src/rlc-common/helpers/shortcut-methods.d.ts +0 -4
  163. package/dist/src/rlc-common/helpers/shortcut-methods.d.ts.map +0 -1
  164. package/dist/src/rlc-common/helpers/shortcut-methods.js +0 -49
  165. package/dist/src/rlc-common/helpers/shortcut-methods.js.map +0 -1
  166. package/dist/src/rlc-common/helpers/value-generation-util.d.ts +0 -12
  167. package/dist/src/rlc-common/helpers/value-generation-util.d.ts.map +0 -1
  168. package/dist/src/rlc-common/helpers/value-generation-util.js +0 -161
  169. package/dist/src/rlc-common/helpers/value-generation-util.js.map +0 -1
  170. package/dist/src/rlc-common/transform-sample-groups.d.ts +0 -9
  171. package/dist/src/rlc-common/transform-sample-groups.d.ts.map +0 -1
  172. package/dist/src/rlc-common/transform-sample-groups.js +0 -298
  173. package/dist/src/rlc-common/transform-sample-groups.js.map +0 -1
  174. package/src/rlc-common/build-client-definitions.ts +0 -226
  175. package/src/rlc-common/build-client.ts +0 -463
  176. package/src/rlc-common/build-index-file.ts +0 -220
  177. package/src/rlc-common/build-is-unexpected-helper.ts +0 -241
  178. package/src/rlc-common/build-logger.ts +0 -29
  179. package/src/rlc-common/build-method-shortcuts.ts +0 -71
  180. package/src/rlc-common/build-object-types.ts +0 -591
  181. package/src/rlc-common/build-paginate-helper.ts +0 -31
  182. package/src/rlc-common/build-parameter-types.ts +0 -460
  183. package/src/rlc-common/build-polling-helper.ts +0 -80
  184. package/src/rlc-common/build-response-types.ts +0 -170
  185. package/src/rlc-common/build-samples.ts +0 -32
  186. package/src/rlc-common/build-schema-type.ts +0 -79
  187. package/src/rlc-common/build-serialize-helper.ts +0 -49
  188. package/src/rlc-common/build-top-level-index-file.ts +0 -51
  189. package/src/rlc-common/helpers/path-utils.ts +0 -8
  190. package/src/rlc-common/helpers/shortcut-methods.ts +0 -58
  191. package/src/rlc-common/helpers/value-generation-util.ts +0 -234
  192. package/src/rlc-common/transform-sample-groups.ts +0 -383
@@ -1,20 +0,0 @@
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;
20
- //# sourceMappingURL=build-schema-type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-schema-type.d.ts","sourceRoot":"","sources":["../../../src/rlc-common/build-schema-type.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAOnC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1D;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ;;;;;;;;;EAW/C;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,aAAa,EAAE;;;cA6C/B"}
@@ -1,64 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import { joinPaths } from "@typespec/compiler";
4
- import { Project } from "ts-morph";
5
- import { buildObjectAliases, buildObjectInterfaces, buildPolymorphicAliases, } from "./build-object-types.js";
6
- import { getImportSpecifier } from "./helpers/imports-util.js";
7
- import { SchemaContext } from "./interfaces.js";
8
- /**
9
- * Generates types to represent schema definitions in the swagger
10
- */
11
- export function buildSchemaTypes(model) {
12
- const { srcPath } = model;
13
- const project = new Project({ useInMemoryFileSystem: true });
14
- let filePath = joinPaths(srcPath, `models.ts`);
15
- const inputModelFile = generateModelFiles(model, project, filePath, [SchemaContext.Input]);
16
- filePath = joinPaths(srcPath, `outputModels.ts`);
17
- const outputModelFile = generateModelFiles(model, project, filePath, [
18
- SchemaContext.Output,
19
- SchemaContext.Exception,
20
- ]);
21
- return { inputModelFile, outputModelFile };
22
- }
23
- export function generateModelFiles(model, project, filePath, schemaContext) {
24
- // Track models that need to be imported
25
- const importedModels = new Set();
26
- const objectsDefinitions = buildObjectInterfaces(model, importedModels, schemaContext);
27
- const objectTypeAliases = buildPolymorphicAliases(model, schemaContext);
28
- const objectAliases = buildObjectAliases(model, importedModels, schemaContext);
29
- if (objectTypeAliases.length || objectsDefinitions.length || objectAliases.length) {
30
- const modelsFile = project.createSourceFile(filePath, undefined, {
31
- overwrite: true,
32
- });
33
- modelsFile.addInterfaces(objectsDefinitions);
34
- modelsFile.addTypeAliases(objectTypeAliases);
35
- modelsFile.addTypeAliases(objectAliases);
36
- if (importedModels.size > 0) {
37
- modelsFile.addImportDeclarations([
38
- {
39
- isTypeOnly: true,
40
- namedImports: [...Array.from(importedModels || [])],
41
- moduleSpecifier: getImportSpecifier("restClient", model.importInfo.runtimeImports),
42
- },
43
- ]);
44
- }
45
- // Add NodeReadableStream import if binary types are used in models.
46
- // platform-types.ts is generated directly under src/ (no static-helpers/
47
- // subdirectory) to match the RLC design where all output lives in src/.
48
- // The platform-types static helper resolves NodeReadableStream to
49
- // NodeJS.ReadableStream on Node and `never` on browser/react-native, so the
50
- // union arm drops out naturally in non-Node builds.
51
- if (modelsFile.getFullText().includes("NodeReadableStream")) {
52
- modelsFile.addImportDeclarations([
53
- {
54
- isTypeOnly: true,
55
- namedImports: ["NodeReadableStream"],
56
- moduleSpecifier: "#platform/platform-types",
57
- },
58
- ]);
59
- }
60
- return { path: filePath, content: modelsFile.getFullText() };
61
- }
62
- return undefined;
63
- }
64
- //# sourceMappingURL=build-schema-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-schema-type.js","sourceRoot":"","sources":["../../../src/rlc-common/build-schema-type.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,UA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path: string;
4
- content: string;
5
- } | undefined;
6
- //# sourceMappingURL=build-serialize-helper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-serialize-helper.d.ts","sourceRoot":"","sources":["../../../src/rlc-common/build-serialize-helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAmB3C,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,QAAQ;;;cA4BnD"}
@@ -1,36 +0,0 @@
1
- import { joinPaths } from "@typespec/compiler";
2
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
- // @ts-ignore: to fix the handlebars issue
4
- import hbs from "handlebars";
5
- import { hasCsvCollection, hasMultiCollection, hasPipeCollection, hasSsvCollection, hasTsvCollection, } from "./helpers/operation-helpers.js";
6
- import { buildCsvCollectionContent, buildMultiCollectionContent, buildPipeCollectionContent, buildSsvCollectionContent, buildTsvCollectionContent, } from "./static/serialize-helper.js";
7
- export function buildSerializeHelper(model) {
8
- let serializeHelperContent = "";
9
- if (hasMultiCollection(model)) {
10
- serializeHelperContent += "\n" + buildMultiCollectionContent;
11
- }
12
- if (hasPipeCollection(model)) {
13
- serializeHelperContent += "\n" + buildPipeCollectionContent;
14
- }
15
- if (hasSsvCollection(model)) {
16
- serializeHelperContent += "\n" + buildSsvCollectionContent;
17
- }
18
- if (hasTsvCollection(model)) {
19
- serializeHelperContent += "\n" + buildTsvCollectionContent;
20
- }
21
- if (hasCsvCollection(model)) {
22
- serializeHelperContent += "\n" + buildCsvCollectionContent;
23
- }
24
- if (serializeHelperContent !== "") {
25
- const readmeFileContents = hbs.compile(serializeHelperContent, {
26
- noEscape: true,
27
- });
28
- const { srcPath } = model;
29
- return {
30
- path: joinPaths(srcPath, "serializeHelper.ts"),
31
- content: readmeFileContents({}),
32
- };
33
- }
34
- return undefined;
35
- }
36
- //# sourceMappingURL=build-serialize-helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-serialize-helper.js","sourceRo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,OAAO;YACL,IAAI,EAAE,SAAS,CAAC,OAAO,EAAE,oBAAoB,CAAC;YAC9C,OAAO,EAAE,kBAAkB,CAAC,EAAE,CAAC;SAChC,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1,6 +0,0 @@
1
- import { RLCModel } from "./interfaces.js";
2
- export declare function buildTopLevelIndex(model: RLCModel): {
3
- path: string;
4
- content: string;
5
- } | undefined;
6
- //# sourceMappingURL=build-top-level-index-file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-top-level-index-file.d.ts","sourceRoot":"","sources":["../../../src/rlc-common/build-top-level-index-file.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ;;;cAuCjD"}
@@ -1,44 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import { joinPaths } from "@typespec/compiler";
4
- import { Project } from "ts-morph";
5
- import { NameType, normalizeName } from "./helpers/name-utils.js";
6
- import { getRelativePartFromSrcPath } from "./helpers/path-utils.js";
7
- const batchOutputFolder = [];
8
- export function buildTopLevelIndex(model) {
9
- if (!model.options) {
10
- return undefined;
11
- }
12
- const project = new Project({ useInMemoryFileSystem: true });
13
- const { srcPath } = model;
14
- const { multiClient } = model.options;
15
- const batch = model.options.batch;
16
- if (srcPath) {
17
- const clientName = model.libraryName;
18
- const moduleName = normalizeName(clientName, NameType.File);
19
- const relativePath = "./" + getRelativePartFromSrcPath(srcPath, model.options.isModularLibrary);
20
- batchOutputFolder.push([relativePath, clientName, moduleName]);
21
- }
22
- if (multiClient && batch && batch.length > 1 && batchOutputFolder.length === batch.length) {
23
- const indexFile = project.createSourceFile("index.ts", undefined, {
24
- overwrite: true,
25
- });
26
- const allModules = [];
27
- batchOutputFolder.forEach((item) => {
28
- indexFile.addImportDeclaration({
29
- isTypeOnly: true,
30
- namespaceImport: item[1],
31
- moduleSpecifier: `${item[0]}/index.js`,
32
- });
33
- allModules.push(item[1]);
34
- });
35
- indexFile.addExportDeclaration({
36
- namedExports: [...allModules],
37
- });
38
- const content = indexFile.getFullText();
39
- const filePath = joinPaths(srcPath.substring(0, srcPath.lastIndexOf("src") + 4), model.options.isModularLibrary ? "rest" : "", `index.ts`);
40
- return { path: filePath, content };
41
- }
42
- return undefined;
43
- }
44
- //# sourceMappingURL=build-top-level-index-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-top-level-index-file.js","sourceRoot":"","sources":["../../../src/rlc-common/build-top-level-index-file.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAGrE,MAAM,iBAAiB,GAA+B,EAAE,CAAC;AAEzD,MAAM,UAAU,kBAAkB,CAAC,KAAe;IAChD,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1B,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC;IACtC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;IAClC,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC;QACrC,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAA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,EAAE,OAAO,EAAE,CAAC;IACrC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function getRelativePartFromSrcPath(srcPath: string, isModularLibrary?: boolean): string;
2
- //# sourceMappingURL=path-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../../../src/rlc-common/helpers/path-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,GAAE,OAAe,UAO5F"}
@@ -1,9 +0,0 @@
1
- export function getRelativePartFromSrcPath(srcPath, isModularLibrary = false) {
2
- const sep = "/";
3
- let relativePart = srcPath.substring(srcPath.indexOf(sep + "src") + 4);
4
- if (isModularLibrary) {
5
- relativePart = relativePart.substring(srcPath.indexOf(sep + "rest"), +5);
6
- }
7
- return relativePart.startsWith(sep) ? relativePart.substring(1) : relativePart;
8
- }
9
- //# sourceMappingURL=path-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../../../../src/rlc-common/helpers/path-utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,0BAA0B,CAAC,OAAe,EAAE,mBAA4B,KAAK;IAC3F,MAAM,GAAG,GAAG,GAAG,CAAC;IAChB,IAAI,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACvE,IAAI,gBAAgB,EAAE,CAAC;QACrB,YAAY,GAAG,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;AACjF,CAAC"}
@@ -1,4 +0,0 @@
1
- import { InterfaceDeclarationStructure, OptionalKind } from "ts-morph";
2
- import { Paths } from "../interfaces.js";
3
- export declare function generateMethodShortcuts(paths: Paths): OptionalKind<InterfaceDeclarationStructure>[];
4
- //# sourceMappingURL=shortcut-methods.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shortcut-methods.d.ts","sourceRoot":"","sources":["../../../../src/rlc-common/helpers/shortcut-methods.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,6BAA6B,EAA4B,YAAY,EAAE,MAAM,UAAU,CAAC;AACjG,OAAO,EAAgB,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIvD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,KAAK,GACX,YAAY,CAAC,6BAA6B,CAAC,EAAE,CA6B/C"}
@@ -1,49 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import { NameType, normalizeName } from "./name-utils.js";
4
- import { buildMethodDefinitions } from "./operation-helpers.js";
5
- export function generateMethodShortcuts(paths) {
6
- const keys = {};
7
- for (const path in paths) {
8
- const pathMetadata = paths[path];
9
- if (!pathMetadata) {
10
- continue;
11
- }
12
- const groupName = pathMetadata.operationGroupName;
13
- const definitions = buildOperationDefinitions(pathMetadata);
14
- if (!keys[groupName]) {
15
- keys[groupName] = definitions;
16
- }
17
- else {
18
- keys[groupName] = [...keys[groupName], ...definitions];
19
- }
20
- }
21
- const interfaces = [];
22
- for (const interfaceName in keys) {
23
- const methods = keys[interfaceName];
24
- interfaces.push({
25
- name: `${interfaceName}Operations`,
26
- methods: methods,
27
- isExported: true,
28
- docs: [`Contains operations for ${interfaceName} operations`],
29
- });
30
- }
31
- return interfaces;
32
- }
33
- function buildOperationDefinitions(path) {
34
- let ops = [];
35
- for (const verb in path.methods) {
36
- const methods = path.methods[verb];
37
- if (!methods) {
38
- continue;
39
- }
40
- for (const method of methods) {
41
- const name = normalizeName(method.operationName, NameType.Property);
42
- const pathParams = path.pathParameters;
43
- const methodDefinitions = buildMethodDefinitions({ [name]: [method] }, pathParams);
44
- ops = [...ops, ...methodDefinitions];
45
- }
46
- }
47
- return ops;
48
- }
49
- //# sourceMappingURL=shortcut-methods.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shortcut-methods.js","sourceRoot":"","sources":["../../../../src/rlc-common/helpers/shortcut-methods.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,UAAU,uBAAuB,CACrC,KAAY;IAEZ,MAAM,IAAI,GAA6D,EAAE,CAAC;IAC1E,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,SAAS;QACX,CAAC;QACD,MAAM,SAAS,GAAG,YAAY,CAAC,kBAAkB,CAAC;QAClD,MAAM,WAAW,GAAG,yBAAyB,CAAC,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAkD,EAAE,CAAC;IAErE,KAAK,MAAM,aAAa,IAAI,IAAI,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;QACpC,UAAU,CAAC,IAAI,CAAC;YACd,IAAI,EAAE,GAAG,aAAa,YAAY;YAClC,OAAO,EAAE,OAAO;YAChB,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,CAAC,2BAA2B,aAAa,aAAa,CAAC;SAC9D,CAAC,CAAC;IACL,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,yBAAyB,CAAC,IAAkB;IACnD,IAAI,GAAG,GAA6C,EAAE,CAAC;IAEvD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,SAAS;QACX,CAAC;QACD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACpE,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC;YACvC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;YACnF,GAAG,GAAG,CAAC,GAAG,GAAG,EAAE,GAAG,iBAAiB,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,12 +0,0 @@
1
- import { Schema } from "../interfaces.js";
2
- /**
3
- * Generate parameter type value for the given type and parameter name
4
- * @param type the typescript type
5
- * @param parameterName the parameter name
6
- * @param schemaMap the schema info to help generate the value
7
- * @param path optional path to help detect self reference
8
- * @param _allowMockValue the flag to indicate whether to allow mock value, currently we always generate mock value
9
- * @returns
10
- */
11
- export declare function generateParameterTypeValue(type: string, parameterName: string, schemaMap: Map<string, Schema>, path?: Set<string>, _allowMockValue?: boolean): string | undefined;
12
- //# sourceMappingURL=value-generation-util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"value-generation-util.d.ts","sourceRoot":"","sources":["../../../../src/rlc-common/helpers/value-generation-util.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,MAAM,EAEP,MAAM,kBAAkB,CAAC;AAe1B;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,EAC7B,eAAe,UAAO,GACrB,MAAM,GAAG,SAAS,CAyCpB"}
@@ -1,161 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import { getImmediateParentsNames } from "../build-object-types.js";
4
- import { SchemaContext, } from "../interfaces.js";
5
- import { TypeScriptType, getArrayObjectType, getNativeArrayType, getRecordType, getUnionType, isArrayObject, isNativeArray, leaveBracket, leaveStringQuotes, toTypeScriptTypeFromName, toTypeScriptTypeFromSchema, } from "./type-util.js";
6
- /**
7
- * Generate parameter type value for the given type and parameter name
8
- * @param type the typescript type
9
- * @param parameterName the parameter name
10
- * @param schemaMap the schema info to help generate the value
11
- * @param path optional path to help detect self reference
12
- * @param _allowMockValue the flag to indicate whether to allow mock value, currently we always generate mock value
13
- * @returns
14
- */
15
- export function generateParameterTypeValue(type, parameterName, schemaMap, path = new Set(), _allowMockValue = true) {
16
- type = leaveBracket(type?.trim());
17
- let tsType;
18
- // Give priority to suggest the ts-type from schema
19
- if (schemaMap.has(type)) {
20
- tsType = toTypeScriptTypeFromSchema(schemaMap.get(type));
21
- }
22
- // Fallback to suggest ts-type from the type iteself
23
- if (!tsType) {
24
- tsType = toTypeScriptTypeFromName(type);
25
- }
26
- switch (tsType) {
27
- case TypeScriptType.string:
28
- return `"{Your ${leaveStringQuotes(parameterName)}}"`;
29
- case TypeScriptType.number:
30
- return "123";
31
- case TypeScriptType.boolean:
32
- return "true";
33
- case TypeScriptType.date:
34
- return "new Date()";
35
- case TypeScriptType.unknown:
36
- return `"Unknown Type"`;
37
- case TypeScriptType.object: {
38
- return generateObjectValues(type, parameterName, schemaMap, path);
39
- }
40
- case TypeScriptType.array: {
41
- return generateArrayValues(type, parameterName, schemaMap, path);
42
- }
43
- case TypeScriptType.record: {
44
- return generateRecordValues(type, parameterName, schemaMap, path);
45
- }
46
- case TypeScriptType.enum: {
47
- return mockEnumValues(type, parameterName, schemaMap, path);
48
- }
49
- case TypeScriptType.union: {
50
- return mockUnionValues(type, parameterName, schemaMap, path);
51
- }
52
- case TypeScriptType.constant:
53
- return type;
54
- }
55
- return `undefined /**FIXME */`;
56
- }
57
- function mockEnumValues(type, parameterName, schemaMap, path = new Set()) {
58
- const schema = schemaMap.get(type);
59
- if (schema && schema.enum && schema.enum.length > 0) {
60
- return schema.enum[0].type;
61
- }
62
- return generateParameterTypeValue(getUnionType(type), parameterName, schemaMap, path);
63
- }
64
- function mockUnionValues(type, parameterName, schemaMap, path = new Set()) {
65
- const schema = schemaMap.get(type);
66
- if (schema && schema.enum && schema.enum.length > 0) {
67
- addToSchemaMap(schemaMap, schema.enum[0]);
68
- return generateParameterTypeValue(getAccurateTypeName(schema.enum[0]) ?? schema.enum[0], parameterName, schemaMap, path);
69
- }
70
- return generateParameterTypeValue(getUnionType(type), parameterName, schemaMap, path);
71
- }
72
- function generateRecordValues(type, parameterName, schemaMap, path = new Set()) {
73
- let recordType = getRecordType(type);
74
- const schema = schemaMap.get(type);
75
- if (schema && schema.additionalProperties) {
76
- recordType = getAccurateTypeName(schema.additionalProperties);
77
- addToSchemaMap(schemaMap, schema.additionalProperties);
78
- }
79
- return recordType
80
- ? `{"key": ${generateParameterTypeValue(recordType, parameterName, schemaMap, path)}}`
81
- : `{}`;
82
- }
83
- function generateArrayValues(type, parameterName, schemaMap, path = new Set()) {
84
- let arrayType;
85
- const schema = schemaMap.get(type);
86
- if (schema && schema.items) {
87
- arrayType = getAccurateTypeName(schema.items);
88
- addToSchemaMap(schemaMap, schema.items);
89
- }
90
- else if (isArrayObject(type)) {
91
- arrayType = getArrayObjectType(type);
92
- }
93
- else if (isNativeArray(type)) {
94
- arrayType = getNativeArrayType(type);
95
- }
96
- const itemValue = arrayType
97
- ? generateParameterTypeValue(arrayType, parameterName, schemaMap, path)
98
- : undefined;
99
- return itemValue ? `[${itemValue}]` : `[]`;
100
- }
101
- function generateObjectValues(type, _parameterName, schemaMap, path = new Set()) {
102
- if (path.has(type)) {
103
- // skip generating if self referenced
104
- return `{} as any /**FIXME */`;
105
- }
106
- path.add(type);
107
- // Extract all properties from the schema
108
- const allProperties = getAllProperties(schemaMap.get(type), schemaMap);
109
- const values = extractObjectProperties(allProperties, schemaMap, path);
110
- path.delete(type);
111
- return `{${values.join(", ")}}`;
112
- }
113
- function getAllProperties(schema, schemaMap = new Map()) {
114
- const propertiesMap = new Map();
115
- if (!schema) {
116
- return new Map();
117
- }
118
- getImmediateParentsNames(schema, [SchemaContext.Input])?.forEach((p) => {
119
- const parentProperties = getAllProperties(schemaMap.get(p), schemaMap);
120
- for (const prop of parentProperties.keys()) {
121
- propertiesMap.set(prop, parentProperties.get(prop));
122
- }
123
- });
124
- for (const prop in schema.properties) {
125
- const propValue = schema.properties[prop];
126
- if (propValue) {
127
- propertiesMap.set(prop, propValue);
128
- }
129
- }
130
- return propertiesMap;
131
- }
132
- function extractObjectProperties(properties, schemaMap = new Map(), path = new Set()) {
133
- const values = [];
134
- for (const name of properties.keys()) {
135
- const property = properties.get(name);
136
- if (!property || property.readOnly || property.type === "never") {
137
- continue;
138
- }
139
- addToSchemaMap(schemaMap, property);
140
- values.push(`${name}: ` +
141
- generateParameterTypeValue(getAccurateTypeName(property), name, schemaMap, path));
142
- }
143
- return values;
144
- }
145
- function getAccurateTypeName(schema) {
146
- // For extensible enum, fallback to use the type
147
- if (schema.typeName === "string" && schema.enum && schema.enum.length > 0) {
148
- return schema.type;
149
- }
150
- return schema.typeName ?? schema.type;
151
- }
152
- function addToSchemaMap(schemaMap, schema) {
153
- const type = getAccurateTypeName(schema);
154
- if (!type) {
155
- return;
156
- }
157
- if (!schemaMap.has(type) && !["string", "number", "boolean"].includes(schema.type)) {
158
- schemaMap.set(type, schema);
159
- }
160
- }
161
- //# sourceMappingURL=value-generation-util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"value-generation-util.js","sourceRoot":"","sources":["../../../../src/rlc-common/helpers/value-generation-util.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAKL,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CACxC,IAAY,EACZ,aAAqB,EACrB,SAA8B,EAC9B,OAAoB,IAAI,GAAG,EAAE,EAC7B,eAAe,GAAG,IAAI;IAEtB,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAClC,IAAI,MAAkC,CAAC;IACvC,mDAAmD;IACnD,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,GAAG,0BAA0B,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC;IAC5D,CAAC;IACD,oDAAoD;IACpD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IACD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,cAAc,CAAC,MAAM;YACxB,OAAO,UAAU,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC;QACxD,KAAK,cAAc,CAAC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AI,CAAC,EAAE,CAAC;QACnF,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -1,9 +0,0 @@
1
- import { RLCModel, RLCSampleGroup } from "./interfaces.js";
2
- /**
3
- * Transform the sample data based RLC detail e.g path, operations & schemas
4
- * @param model RLC detail
5
- * @param allowMockValue allow to mock value if not exist, currently we always generate mock value
6
- * @returns Generated sample data or undefined if not support to generate
7
- */
8
- export declare function transformSampleGroups(model: RLCModel, allowMockValue?: boolean): RLCSampleGroup[] | undefined;
9
- //# sourceMappingURL=transform-sample-groups.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform-sample-groups.d.ts","sourceRoot":"","sources":["../../../src/rlc-common/transform-sample-groups.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,QAAQ,EAER,cAAc,EAIf,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,UAAO,gCA6F3E"}