@azure-tools/typespec-ts 0.55.0-dev.5 → 0.55.0-dev.7

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 (172) hide show
  1. package/README.md +3 -24
  2. package/dist/src/framework/hooks/binder.d.ts +1 -1
  3. package/dist/src/framework/hooks/binder.d.ts.map +1 -1
  4. package/dist/src/framework/load-static-helpers.d.ts.map +1 -1
  5. package/dist/src/framework/load-static-helpers.js +6 -8
  6. package/dist/src/framework/load-static-helpers.js.map +1 -1
  7. package/dist/src/index.d.ts.map +1 -1
  8. package/dist/src/index.js +20 -29
  9. package/dist/src/index.js.map +1 -1
  10. package/dist/src/lib.d.ts +0 -4
  11. package/dist/src/lib.d.ts.map +1 -1
  12. package/dist/src/lib.js +3 -21
  13. package/dist/src/lib.js.map +1 -1
  14. package/dist/src/rlc-common/build-client-definitions.d.ts.map +1 -1
  15. package/dist/src/rlc-common/build-client-definitions.js +4 -4
  16. package/dist/src/rlc-common/build-client-definitions.js.map +1 -1
  17. package/dist/src/rlc-common/build-client.d.ts.map +1 -1
  18. package/dist/src/rlc-common/build-client.js +4 -13
  19. package/dist/src/rlc-common/build-client.js.map +1 -1
  20. package/dist/src/rlc-common/build-index-file.d.ts.map +1 -1
  21. package/dist/src/rlc-common/build-index-file.js +21 -79
  22. package/dist/src/rlc-common/build-index-file.js.map +1 -1
  23. package/dist/src/rlc-common/build-is-unexpected-helper.d.ts.map +1 -1
  24. package/dist/src/rlc-common/build-is-unexpected-helper.js +1 -5
  25. package/dist/src/rlc-common/build-is-unexpected-helper.js.map +1 -1
  26. package/dist/src/rlc-common/build-logger.d.ts.map +1 -1
  27. package/dist/src/rlc-common/build-logger.js +2 -6
  28. package/dist/src/rlc-common/build-logger.js.map +1 -1
  29. package/dist/src/rlc-common/build-object-types.d.ts +1 -1
  30. package/dist/src/rlc-common/build-object-types.d.ts.map +1 -1
  31. package/dist/src/rlc-common/build-object-types.js +9 -11
  32. package/dist/src/rlc-common/build-object-types.js.map +1 -1
  33. package/dist/src/rlc-common/build-parameter-types.d.ts.map +1 -1
  34. package/dist/src/rlc-common/build-parameter-types.js +13 -66
  35. package/dist/src/rlc-common/build-parameter-types.js.map +1 -1
  36. package/dist/src/rlc-common/build-polling-helper.d.ts.map +1 -1
  37. package/dist/src/rlc-common/build-polling-helper.js +0 -2
  38. package/dist/src/rlc-common/build-polling-helper.js.map +1 -1
  39. package/dist/src/rlc-common/build-response-types.d.ts.map +1 -1
  40. package/dist/src/rlc-common/build-response-types.js +2 -5
  41. package/dist/src/rlc-common/build-response-types.js.map +1 -1
  42. package/dist/src/rlc-common/build-schema-type.d.ts.map +1 -1
  43. package/dist/src/rlc-common/build-schema-type.js +1 -8
  44. package/dist/src/rlc-common/build-schema-type.js.map +1 -1
  45. package/dist/src/rlc-common/build-top-level-index-file.d.ts.map +1 -1
  46. package/dist/src/rlc-common/build-top-level-index-file.js +1 -5
  47. package/dist/src/rlc-common/build-top-level-index-file.js.map +1 -1
  48. package/dist/src/rlc-common/helpers/name-constructors.d.ts +0 -9
  49. package/dist/src/rlc-common/helpers/name-constructors.d.ts.map +1 -1
  50. package/dist/src/rlc-common/helpers/name-constructors.js +0 -10
  51. package/dist/src/rlc-common/helpers/name-constructors.js.map +1 -1
  52. package/dist/src/rlc-common/index.d.ts +0 -2
  53. package/dist/src/rlc-common/index.d.ts.map +1 -1
  54. package/dist/src/rlc-common/index.js +0 -2
  55. package/dist/src/rlc-common/index.js.map +1 -1
  56. package/dist/src/rlc-common/interfaces.d.ts +1 -4
  57. package/dist/src/rlc-common/interfaces.d.ts.map +1 -1
  58. package/dist/src/rlc-common/interfaces.js.map +1 -1
  59. package/dist/src/rlc-common/metadata/build-api-extractor-config.d.ts +1 -1
  60. package/dist/src/rlc-common/metadata/build-api-extractor-config.d.ts.map +1 -1
  61. package/dist/src/rlc-common/metadata/build-api-extractor-config.js +4 -41
  62. package/dist/src/rlc-common/metadata/build-api-extractor-config.js.map +1 -1
  63. package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts +1 -1
  64. package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts.map +1 -1
  65. package/dist/src/rlc-common/metadata/build-es-lint-config.js +2 -37
  66. package/dist/src/rlc-common/metadata/build-es-lint-config.js.map +1 -1
  67. package/dist/src/rlc-common/metadata/build-package-file.d.ts.map +1 -1
  68. package/dist/src/rlc-common/metadata/build-package-file.js +22 -52
  69. package/dist/src/rlc-common/metadata/build-package-file.js.map +1 -1
  70. package/dist/src/rlc-common/metadata/build-readme-file.d.ts.map +1 -1
  71. package/dist/src/rlc-common/metadata/build-readme-file.js +6 -7
  72. package/dist/src/rlc-common/metadata/build-readme-file.js.map +1 -1
  73. package/dist/src/rlc-common/metadata/build-test-config.d.ts.map +1 -1
  74. package/dist/src/rlc-common/metadata/build-test-config.js +1 -4
  75. package/dist/src/rlc-common/metadata/build-test-config.js.map +1 -1
  76. package/dist/src/rlc-common/metadata/build-ts-config.d.ts +2 -2
  77. package/dist/src/rlc-common/metadata/build-ts-config.d.ts.map +1 -1
  78. package/dist/src/rlc-common/metadata/build-ts-config.js +18 -59
  79. package/dist/src/rlc-common/metadata/build-ts-config.js.map +1 -1
  80. package/dist/src/rlc-common/metadata/build-warp-config.d.ts +1 -1
  81. package/dist/src/rlc-common/metadata/build-warp-config.d.ts.map +1 -1
  82. package/dist/src/rlc-common/metadata/build-warp-config.js +0 -3
  83. package/dist/src/rlc-common/metadata/build-warp-config.js.map +1 -1
  84. package/dist/src/rlc-common/metadata/package-json/azure-package-common.d.ts +1 -38
  85. package/dist/src/rlc-common/metadata/package-json/azure-package-common.d.ts.map +1 -1
  86. package/dist/src/rlc-common/metadata/package-json/azure-package-common.js +1 -108
  87. package/dist/src/rlc-common/metadata/package-json/azure-package-common.js.map +1 -1
  88. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts +0 -38
  89. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts.map +1 -1
  90. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js +2 -18
  91. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js.map +1 -1
  92. package/dist/src/rlc-common/metadata/package-json/package-common.d.ts +1 -18
  93. package/dist/src/rlc-common/metadata/package-json/package-common.d.ts.map +1 -1
  94. package/dist/src/rlc-common/metadata/package-json/package-common.js +20 -94
  95. package/dist/src/rlc-common/metadata/package-json/package-common.js.map +1 -1
  96. package/dist/src/rlc-common/static/polling-content.d.ts +1 -1
  97. package/dist/src/rlc-common/static/polling-content.d.ts.map +1 -1
  98. package/dist/src/rlc-common/static/polling-content.js +1 -1
  99. package/dist/src/rlc-common/test/build-recorded-client.d.ts +1 -1
  100. package/dist/src/rlc-common/test/build-recorded-client.d.ts.map +1 -1
  101. package/dist/src/rlc-common/test/build-recorded-client.js +2 -5
  102. package/dist/src/rlc-common/test/build-recorded-client.js.map +1 -1
  103. package/dist/src/rlc-common/test/build-sample-test.d.ts +1 -1
  104. package/dist/src/rlc-common/test/build-sample-test.d.ts.map +1 -1
  105. package/dist/src/rlc-common/test/build-sample-test.js +2 -5
  106. package/dist/src/rlc-common/test/build-sample-test.js.map +1 -1
  107. package/dist/src/rlc-common/test/build-snippets.d.ts +1 -1
  108. package/dist/src/rlc-common/test/build-snippets.d.ts.map +1 -1
  109. package/dist/src/rlc-common/test/build-snippets.js +2 -5
  110. package/dist/src/rlc-common/test/build-snippets.js.map +1 -1
  111. package/dist/src/rlc-common/test/template.d.ts +2 -2
  112. package/dist/src/rlc-common/test/template.d.ts.map +1 -1
  113. package/dist/src/rlc-common/test/template.js +1 -31
  114. package/dist/src/rlc-common/test/template.js.map +1 -1
  115. package/dist/src/rlc-common/transform-sample-groups.d.ts.map +1 -1
  116. package/dist/src/rlc-common/transform-sample-groups.js +4 -8
  117. package/dist/src/rlc-common/transform-sample-groups.js.map +1 -1
  118. package/dist/src/transform/transfrom-rlc-options.d.ts.map +1 -1
  119. package/dist/src/transform/transfrom-rlc-options.js +0 -18
  120. package/dist/src/transform/transfrom-rlc-options.js.map +1 -1
  121. package/dist/tsconfig.tsbuildinfo +1 -1
  122. package/package.json +1 -1
  123. package/src/framework/hooks/binder.ts +1 -1
  124. package/src/framework/load-static-helpers.ts +8 -10
  125. package/src/index.ts +19 -31
  126. package/src/lib.ts +3 -26
  127. package/src/rlc-common/build-client-definitions.ts +4 -13
  128. package/src/rlc-common/build-client.ts +4 -22
  129. package/src/rlc-common/build-index-file.ts +21 -142
  130. package/src/rlc-common/build-is-unexpected-helper.ts +1 -8
  131. package/src/rlc-common/build-logger.ts +2 -12
  132. package/src/rlc-common/build-object-types.ts +5 -17
  133. package/src/rlc-common/build-parameter-types.ts +9 -103
  134. package/src/rlc-common/build-polling-helper.ts +0 -3
  135. package/src/rlc-common/build-response-types.ts +2 -12
  136. package/src/rlc-common/build-schema-type.ts +1 -11
  137. package/src/rlc-common/build-top-level-index-file.ts +1 -8
  138. package/src/rlc-common/helpers/name-constructors.ts +0 -15
  139. package/src/rlc-common/index.ts +0 -2
  140. package/src/rlc-common/interfaces.ts +1 -4
  141. package/src/rlc-common/metadata/build-api-extractor-config.ts +4 -46
  142. package/src/rlc-common/metadata/build-es-lint-config.ts +2 -38
  143. package/src/rlc-common/metadata/build-package-file.ts +21 -58
  144. package/src/rlc-common/metadata/build-readme-file.ts +6 -9
  145. package/src/rlc-common/metadata/build-test-config.ts +1 -6
  146. package/src/rlc-common/metadata/build-ts-config.ts +28 -70
  147. package/src/rlc-common/metadata/build-warp-config.ts +0 -4
  148. package/src/rlc-common/metadata/package-json/azure-package-common.ts +2 -134
  149. package/src/rlc-common/metadata/package-json/build-azure-monorepo-package.ts +2 -21
  150. package/src/rlc-common/metadata/package-json/package-common.ts +21 -114
  151. package/src/rlc-common/static/polling-content.ts +1 -1
  152. package/src/rlc-common/test/build-recorded-client.ts +2 -5
  153. package/src/rlc-common/test/build-sample-test.ts +2 -5
  154. package/src/rlc-common/test/build-snippets.ts +2 -5
  155. package/src/rlc-common/test/template.ts +1 -31
  156. package/src/rlc-common/transform-sample-groups.ts +3 -12
  157. package/src/transform/transfrom-rlc-options.ts +0 -20
  158. package/dist/src/rlc-common/helpers/package-util.d.ts +0 -4
  159. package/dist/src/rlc-common/helpers/package-util.d.ts.map +0 -1
  160. package/dist/src/rlc-common/helpers/package-util.js +0 -7
  161. package/dist/src/rlc-common/helpers/package-util.js.map +0 -1
  162. package/dist/src/rlc-common/metadata/build-rollup-config.d.ts +0 -6
  163. package/dist/src/rlc-common/metadata/build-rollup-config.d.ts.map +0 -1
  164. package/dist/src/rlc-common/metadata/build-rollup-config.js +0 -139
  165. package/dist/src/rlc-common/metadata/build-rollup-config.js.map +0 -1
  166. package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.d.ts +0 -8
  167. package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.d.ts.map +0 -1
  168. package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.js +0 -101
  169. package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.js.map +0 -1
  170. package/src/rlc-common/helpers/package-util.ts +0 -9
  171. package/src/rlc-common/metadata/build-rollup-config.ts +0 -146
  172. package/src/rlc-common/metadata/package-json/build-azure-standalone-package.ts +0 -123
@@ -73,7 +73,7 @@ can be used to authenticate the client.
73
73
 
74
74
  Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the \`AZURE_LOG_LEVEL\` environment variable to \`info\`. Alternatively, logging can be enabled at runtime by calling \`setLogLevel\` in the \`@azure/logger\`:
75
75
 
76
- \`\`\`ts {{#if azureSdkForJs}}{{#if generateTest}}snippet:SetLogLevel{{/if}}{{/if}}
76
+ \`\`\`ts {{#if generateTest}}snippet:SetLogLevel{{/if}}
77
77
  import { setLogLevel } from "@azure/logger";
78
78
 
79
79
  setLogLevel("info");
@@ -150,7 +150,7 @@ For more information about how to create a Microsoft Entra application check out
150
150
  {{#if azureArm}}
151
151
  Using Node.js and Node-like environments, you can use the \`DefaultAzureCredential\` class to authenticate the client.
152
152
 
153
- \`\`\`ts {{#if azureSdkForJs}}{{#if generateTest}}snippet:ReadmeSampleCreateClient_Node{{/if}}{{/if}}
153
+ \`\`\`ts {{#if generateTest}}snippet:ReadmeSampleCreateClient_Node{{/if}}
154
154
  import { {{ clientClassName }} } from "{{ clientPackageName }}";
155
155
  import { DefaultAzureCredential } from "@azure/identity";
156
156
 
@@ -164,7 +164,7 @@ const client = new {{ clientClassName }}(new DefaultAzureCredential());
164
164
 
165
165
  For browser environments, use the \`InteractiveBrowserCredential\` from the \`@azure/identity\` package to authenticate.
166
166
 
167
- \`\`\`ts {{#if azureSdkForJs}}{{#if generateTest}}snippet:ReadmeSampleCreateClient_Browser{{/if}}{{/if}}
167
+ \`\`\`ts {{#if generateTest}}snippet:ReadmeSampleCreateClient_Browser{{/if}}
168
168
  import { InteractiveBrowserCredential } from "@azure/identity";
169
169
  import { {{ clientClassName }} } from "{{ clientPackageName }}";
170
170
 
@@ -183,7 +183,7 @@ const client = new {{ clientClassName }}(credential);
183
183
  {{else}}
184
184
  Using Node.js and Node-like environments, you can use the \`DefaultAzureCredential\` class to authenticate the client.
185
185
 
186
- \`\`\`ts {{#if azureSdkForJs}}{{#if generateTest}}snippet:ReadmeSampleCreateClient_Node{{/if}}{{/if}}
186
+ \`\`\`ts {{#if generateTest}}snippet:ReadmeSampleCreateClient_Node{{/if}}
187
187
  import { {{ clientClassName }} } from "{{ clientPackageName }}";
188
188
  import { DefaultAzureCredential } from "@azure/identity";
189
189
 
@@ -192,7 +192,7 @@ const client = new {{ clientClassName }}("<endpoint>", new DefaultAzureCredentia
192
192
 
193
193
  For browser environments, use the \`InteractiveBrowserCredential\` from the \`@azure/identity\` package to authenticate.
194
194
 
195
- \`\`\`ts {{#if azureSdkForJs}}{{#if generateTest}}snippet:ReadmeSampleCreateClient_Browser{{/if}}{{/if}}
195
+ \`\`\`ts {{#if generateTest}}snippet:ReadmeSampleCreateClient_Browser{{/if}}
196
196
  import { InteractiveBrowserCredential } from "@azure/identity";
197
197
  import { {{ clientClassName }} } from "{{ clientPackageName }}";
198
198
 
@@ -221,7 +221,7 @@ To use this client library in the browser, first you need to use a bundler. For
221
221
 
222
222
  Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the \`AZURE_LOG_LEVEL\` environment variable to \`info\`. Alternatively, logging can be enabled at runtime by calling \`setLogLevel\` in the \`@azure/logger\`:
223
223
 
224
- \`\`\`ts {{#if azureSdkForJs}}{{#if generateTest}}snippet:SetLogLevel{{/if}}{{/if}}
224
+ \`\`\`ts {{#if generateTest}}snippet:SetLogLevel{{/if}}
225
225
  import { setLogLevel } from "@azure/logger";
226
226
 
227
227
  setLogLevel("info");
@@ -337,8 +337,6 @@ interface Metadata {
337
337
  isReleasablePackage?: boolean;
338
338
  /** The link to the contributing guide in the repository */
339
339
  contributingGuideURL?: string;
340
- /** Indicates if the package is generated to azure-sdk-for-js repo */
341
- azureSdkForJs?: boolean;
342
340
  /** Indicates if the package need generate test files */
343
341
  generateTest?: boolean;
344
342
  /** Indicates if the package need SubscriptionId as the client parameter */
@@ -469,7 +467,6 @@ function createMetadata(model: RLCModel): Metadata | undefined {
469
467
  identityPackageURL: repoURL && `${repoURL}/tree/main/sdk/identity/identity`,
470
468
  addCredentials: model.options.addCredentials,
471
469
  contributingGuideURL: repoURL && `${repoURL}/blob/main/CONTRIBUTING.md`,
472
- azureSdkForJs: model.options.azureSdkForJs,
473
470
  generateTest: model.options.generateTest,
474
471
  hasSubscriptionId: model.options.hasSubscriptionId,
475
472
  };
@@ -5,12 +5,7 @@ import { RLCModel } from "../interfaces.js";
5
5
  import { getPackageName } from "./utils.js";
6
6
 
7
7
  function shouldGenerateTestConfig(model: RLCModel): boolean {
8
- const isAzureSdkForJs = model.options?.azureSdkForJs ?? false;
9
- return !(
10
- model.options?.generateMetadata === false ||
11
- model.options?.generateTest === false ||
12
- isAzureSdkForJs !== true
13
- );
8
+ return !(model.options?.generateMetadata === false || model.options?.generateTest === false);
14
9
  }
15
10
 
16
11
  /**
@@ -7,83 +7,41 @@ import { RLCModel } from "../interfaces.js";
7
7
  /**
8
8
  * Builds the root tsconfig.json.
9
9
  *
10
- * For azureSdkForJs packages, emits project references pointing into the
11
- * `config/` subfolder (following the eng/tsconfigs pattern).
10
+ * Emits project references pointing into the `config/` subfolder
11
+ * (following the eng/tsconfigs pattern).
12
12
  */
13
13
  export function buildTsConfig(model: RLCModel) {
14
- const { packageDetails, azureSdkForJs } = model.options || {};
15
14
  const { generateTest, generateSample, generateReactNativeTarget } = model.options || {};
16
- const clientPackageName = packageDetails?.name ?? "";
17
15
  const project = new Project({ useInMemoryFileSystem: true });
18
16
 
19
- let tsConfig: Record<string, any>;
20
-
21
- if (azureSdkForJs) {
22
- const references: { path: string }[] = [
23
- { path: "./config/tsconfig.src.esm.json" },
24
- { path: "./config/tsconfig.src.browser.json" },
25
- ];
26
-
27
- if (generateReactNativeTarget) {
28
- references.push({ path: "./config/tsconfig.src.react-native.json" });
29
- }
30
-
31
- references.push({ path: "./config/tsconfig.src.cjs.json" });
32
-
33
- if (generateTest) {
34
- references.push(
35
- { path: "./config/tsconfig.test.node.json" },
36
- { path: "./config/tsconfig.test.browser.json" },
37
- );
38
- }
39
-
40
- if (generateSample) {
41
- references.push({ path: "./config/tsconfig.samples.json" });
42
- }
43
-
44
- if (generateTest) {
45
- references.push({ path: "./config/tsconfig.snippets.json" });
46
- }
47
-
48
- tsConfig = { references, files: [] };
49
- } else {
50
- const { options } = model;
51
- tsConfig = {
52
- compilerOptions: {
53
- target: "ES2017",
54
- module: options?.moduleKind === "esm" ? "NodeNext" : "es6",
55
- lib: [],
56
- declaration: true,
57
- declarationMap: true,
58
- inlineSources: true,
59
- sourceMap: true,
60
- importHelpers: true,
61
- strict: true,
62
- alwaysStrict: true,
63
- noUnusedLocals: true,
64
- noUnusedParameters: true,
65
- noImplicitReturns: true,
66
- noFallthroughCasesInSwitch: true,
67
- forceConsistentCasingInFileNames: true,
68
- moduleResolution: options?.moduleKind === "esm" ? "NodeNext" : "node",
69
- allowSyntheticDefaultImports: true,
70
- esModuleInterop: true,
71
- outDir: options?.moduleKind === "cjs" ? "./dist-esm" : undefined,
72
- declarationDir: options?.moduleKind === "cjs" ? "./types" : undefined,
73
- },
74
- include: ["src/**/*.ts"],
75
- };
76
-
77
- if (generateTest) {
78
- tsConfig["include"].push("test/**/*.ts");
79
- }
80
- if (generateSample) {
81
- tsConfig["include"].push("samples-dev/**/*.ts");
82
- tsConfig["compilerOptions"]["paths"] = {};
83
- tsConfig["compilerOptions"]["paths"][clientPackageName] = ["./src/index"];
84
- }
17
+ const references: { path: string }[] = [
18
+ { path: "./config/tsconfig.src.esm.json" },
19
+ { path: "./config/tsconfig.src.browser.json" },
20
+ ];
21
+
22
+ if (generateReactNativeTarget) {
23
+ references.push({ path: "./config/tsconfig.src.react-native.json" });
24
+ }
25
+
26
+ references.push({ path: "./config/tsconfig.src.cjs.json" });
27
+
28
+ if (generateTest) {
29
+ references.push(
30
+ { path: "./config/tsconfig.test.node.json" },
31
+ { path: "./config/tsconfig.test.browser.json" },
32
+ );
85
33
  }
86
34
 
35
+ if (generateSample) {
36
+ references.push({ path: "./config/tsconfig.samples.json" });
37
+ }
38
+
39
+ if (generateTest) {
40
+ references.push({ path: "./config/tsconfig.snippets.json" });
41
+ }
42
+
43
+ const tsConfig = { references, files: [] };
44
+
87
45
  const filePath = "tsconfig.json";
88
46
  const configFile = project.createSourceFile(filePath, JSON.stringify(tsConfig, null, 2), {
89
47
  overwrite: true,
@@ -68,10 +68,6 @@ targets:
68
68
  * in options to include it.
69
69
  */
70
70
  export function buildWarpConfig(model: RLCModel, { exports }: WarpConfigOptions = {}) {
71
- if (model.options?.moduleKind !== "esm") {
72
- return;
73
- }
74
-
75
71
  const allExports: Record<string, string> = {
76
72
  ...BASE_EXPORTS,
77
73
  ...exports,
@@ -1,152 +1,20 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
 
4
- import { PackageCommonInfoConfig, getCommonPackageDevDependencies } from "./package-common.js";
4
+ import { PackageCommonInfoConfig } from "./package-common.js";
5
5
 
6
6
  export interface AzurePackageInfoConfig extends PackageCommonInfoConfig {
7
7
  hasLro: boolean;
8
- specSource: "Swagger" | "TypeSpec";
9
8
  }
10
9
 
11
10
  /**
12
11
  * Build the common package.json config for an Azure package.
13
12
  */
14
- export function getAzureCommonPackageInfo(config: AzurePackageInfoConfig) {
13
+ export function getAzureCommonPackageInfo(_config: AzurePackageInfoConfig) {
15
14
  return {
16
15
  keywords: ["node", "azure", "cloud", "typescript", "browser", "isomorphic"],
17
16
  author: "Microsoft Corporation",
18
17
  license: "MIT",
19
- ...getAzureCjsCommonInfo(config),
20
- ...getAzureEsmCommonInfo(config),
21
- };
22
- }
23
-
24
- /**
25
- * Builds the common dependencies for an Azure package.
26
- */
27
- export function getAzurePackageDependencies({
28
- hasLro,
29
- specSource,
30
- dependencies,
31
- }: AzurePackageInfoConfig) {
32
- let azureDependencies: Record<string, string> = {
33
- ...dependencies,
34
- "@azure-rest/core-client": specSource === "Swagger" ? "^1.4.0" : "^2.3.1",
35
- "@azure/core-auth": "^1.6.0",
36
- "@azure/core-rest-pipeline": "^1.5.0",
37
- "@azure/logger": "^1.0.0",
38
- tslib: "^2.6.2",
39
- };
40
-
41
- if (hasLro) {
42
- azureDependencies = {
43
- ...azureDependencies,
44
- "@azure/core-lro": "^3.1.0",
45
- "@azure/abort-controller": "^2.1.2",
46
- };
47
- }
48
-
49
- return azureDependencies;
50
- }
51
-
52
- function getAzureCjsCommonInfo({
53
- withTests,
54
- withSamples,
55
- name,
56
- nameWithoutScope,
57
- moduleKind,
58
- }: AzurePackageInfoConfig) {
59
- if (moduleKind !== "cjs") {
60
- return {};
61
- }
62
-
63
- return {
64
- files: [
65
- "dist/",
66
- "!dist/**/*.d.*ts.map",
67
- withTests || withSamples ? "dist-esm/src/" : "dist-esm/",
68
- `types/${nameWithoutScope ?? name}.d.ts`,
69
- "README.md",
70
- "LICENSE",
71
- ],
72
- };
73
- }
74
-
75
- function getAzureEsmCommonInfo({ moduleKind }: AzurePackageInfoConfig) {
76
- if (moduleKind !== "esm") {
77
- return {};
78
- }
79
- return {
80
18
  files: ["dist/", "!dist/**/*.d.*ts.map", "README.md", "LICENSE"],
81
19
  };
82
20
  }
83
-
84
- function getAzurePackageCjsDevDependencies({ moduleKind, withTests }: AzurePackageInfoConfig) {
85
- if (moduleKind !== "cjs") {
86
- return {};
87
- }
88
- const testDevDependencies = {
89
- "@azure-tools/test-credential": "^1.1.0",
90
- "@azure-tools/test-recorder": "^3.0.0",
91
- nyc: "^15.1.0",
92
- mocha: "^11.0.2",
93
- "@types/mocha": "^10.0.0",
94
- "@types/chai": "^4.2.8",
95
- chai: "^4.2.0",
96
- "karma-chrome-launcher": "^3.0.0",
97
- "karma-coverage": "^2.0.0",
98
- "karma-env-preprocessor": "^0.1.1",
99
- "karma-firefox-launcher": "^2.1.3",
100
- "karma-junit-reporter": "^2.0.1",
101
- "karma-mocha-reporter": "^2.2.5",
102
- "karma-mocha": "^2.0.1",
103
- "karma-source-map-support": "~1.4.0",
104
- "karma-sourcemap-loader": "^0.4.0",
105
- karma: "^6.2.0",
106
- };
107
-
108
- return {
109
- ...(withTests && testDevDependencies),
110
- "source-map-support": "^0.5.9",
111
- };
112
- }
113
-
114
- function getAzurePackageEsmDevDependencies({ moduleKind, withTests }: AzurePackageInfoConfig) {
115
- if (moduleKind !== "esm") {
116
- return {};
117
- }
118
-
119
- let devDependencies: Record<string, string> = {};
120
-
121
- if (withTests) {
122
- devDependencies = {
123
- ...devDependencies,
124
- "@vitest/browser-playwright": "^4.0.6",
125
- "@vitest/coverage-istanbul": "^4.0.6",
126
- playwright: "^1.41.2",
127
- vitest: "^4.0.6",
128
- "@azure-tools/test-credential": "^2.0.0",
129
- "@azure-tools/test-recorder": "^4.0.0",
130
- };
131
- }
132
-
133
- return devDependencies;
134
- }
135
-
136
- export function getAzurePackageDevDependencies(config: AzurePackageInfoConfig) {
137
- const esmDevDependencies = getAzurePackageEsmDevDependencies(config);
138
- const cjsDevDependencies = getAzurePackageCjsDevDependencies(config);
139
-
140
- const testDevDependencies = {
141
- "@azure/identity": "^4.2.1",
142
- };
143
-
144
- return {
145
- dotenv: "^16.0.0",
146
- ...getCommonPackageDevDependencies(config),
147
- ...(config.withTests && testDevDependencies),
148
- ...(config.specSource === "Swagger" && { autorest: "latest" }),
149
- ...esmDevDependencies,
150
- ...cjsDevDependencies,
151
- };
152
- }
@@ -74,9 +74,6 @@ export function getAzureMonorepoDependencies(config: AzureMonorepoInfoConfig) {
74
74
  eslint: "catalog:",
75
75
  prettier: "catalog:",
76
76
  rimraf: "catalog:",
77
- ...(config.specSource === "Swagger" && {
78
- autorest: "catalog:",
79
- }),
80
77
  ...testDeps,
81
78
  },
82
79
  };
@@ -129,19 +126,8 @@ function getSampleMetadata({ name, version, withSamples }: AzureMonorepoInfoConf
129
126
  };
130
127
  }
131
128
 
132
- function addSwaggerMetadata(metadata: Record<string, any>, specSource: "Swagger" | "TypeSpec") {
133
- if (specSource !== "Swagger") {
134
- return;
135
- }
136
-
137
- metadata["constantPaths"].push({
138
- path: "swagger/README.md",
139
- prefix: "package-version",
140
- });
141
- }
142
-
143
129
  function getAzureMonorepoScripts(config: AzureMonorepoInfoConfig) {
144
- const esmScripts = getEsmScripts(config);
130
+ const esmScripts = getEsmScripts();
145
131
  const skipLinting = config.azureArm && config.isModularLibrary;
146
132
  const buildSampleScripts = config.azureArm
147
133
  ? "tsc -p config/tsconfig.samples.json && dev-tool samples publish -f"
@@ -170,11 +156,7 @@ function getAzureMonorepoScripts(config: AzureMonorepoInfoConfig) {
170
156
  };
171
157
  }
172
158
 
173
- function getEsmScripts({ moduleKind }: AzureMonorepoInfoConfig) {
174
- if (moduleKind !== "esm") {
175
- return {};
176
- }
177
-
159
+ function getEsmScripts() {
178
160
  return {
179
161
  build: "npm run clean && dev-tool run build-package && dev-tool run extract-api",
180
162
  "test:node": "dev-tool run test:vitest",
@@ -187,7 +169,6 @@ function getMetadataInfo(config: AzureMonorepoInfoConfig) {
187
169
  constantPaths: [],
188
170
  };
189
171
  const paths = config.isModularLibrary ? config.clientContextPaths : config.clientFilePaths;
190
- addSwaggerMetadata(metadata, config.specSource);
191
172
  for (const path of paths ?? []) {
192
173
  metadata["constantPaths"].push({
193
174
  path: path,
@@ -6,17 +6,15 @@ export interface PackageCommonInfoConfig {
6
6
  nameWithoutScope?: string;
7
7
  version: string;
8
8
  description: string;
9
- moduleKind: "esm" | "cjs";
10
9
  withTests: boolean;
11
10
  withSamples: boolean;
12
11
  exports?: Record<string, any>;
13
12
  dependencies?: Record<string, string>;
14
13
  azureArm?: boolean;
15
14
  isModularLibrary?: boolean;
16
- azureSdkForJs?: boolean;
17
15
  /**
18
16
  * When true, generates React Native build targets (dist/react-native, exports condition).
19
- * Defaults to false. Only applicable when azureSdkForJs is true.
17
+ * Defaults to false.
20
18
  */
21
19
  generateReactNativeTarget?: boolean;
22
20
  }
@@ -40,106 +38,34 @@ export function getPackageCommonInfo(config: PackageCommonInfoConfig) {
40
38
  };
41
39
  }
42
40
 
43
- export function getCommonPackageDevDependencies(config: PackageCommonInfoConfig) {
44
- return {
45
- "@types/node": "^20.0.0",
46
- eslint: "^9.9.0",
47
- typescript: "~5.8.2",
48
- ...getEsmDevDependencies(config),
49
- };
50
- }
51
-
52
- function getEsmDevDependencies({ moduleKind, azureSdkForJs }: PackageCommonInfoConfig) {
53
- if (moduleKind !== "esm") {
54
- return {};
55
- }
56
- // Azure monorepo packages use warp (invoked via dev-tool), no tshy needed
57
- if (azureSdkForJs) {
58
- return {};
59
- }
60
- return {
61
- tshy: "^2.0.0",
62
- };
63
- }
64
-
65
41
  function getEntryPointInformation(config: PackageCommonInfoConfig) {
66
- return {
67
- ...getCjsEntrypointInformation(config),
68
- ...getEsmEntrypointInformation(config),
69
- };
70
- }
71
-
72
- function getCjsEntrypointInformation({
73
- name,
74
- nameWithoutScope,
75
- moduleKind,
76
- withTests,
77
- withSamples,
78
- }: PackageCommonInfoConfig) {
79
- if (moduleKind !== "cjs") {
80
- return;
81
- }
82
-
83
- const types =
84
- withTests || withSamples
85
- ? `./types/src/${nameWithoutScope ?? name}.d.ts`
86
- : `./types/${nameWithoutScope ?? name}.d.ts`;
87
- const main = withTests || withSamples ? "dist/src/index.js" : "dist/index.js";
88
- return {
89
- main,
90
- module: withTests || withSamples ? "./dist-esm/src/index.js" : "./dist-esm/index.js",
91
- types,
92
- };
93
- }
94
-
95
- function getEsmEntrypointInformation(config: PackageCommonInfoConfig) {
96
- if (config.moduleKind !== "esm") {
97
- return;
98
- }
99
-
100
- // Azure monorepo packages use warp instead of tshy
101
- if (config.azureSdkForJs) {
102
- const result: Record<string, any> = {
103
- type: "module",
104
- main: "./dist/commonjs/index.js",
105
- module: "./dist/esm/index.js",
106
- types: "./dist/commonjs/index.d.ts",
107
- browser: "./dist/browser/index.js",
108
- imports: {
109
- "#platform/*": {
110
- browser: "./src/*-browser.mts",
111
- default: "./src/*.ts",
112
- } as Record<string, string>,
113
- },
114
- exports: resolveWarpExports(config.exports, config.generateReactNativeTarget),
115
- };
116
-
117
- if (config.generateReactNativeTarget) {
118
- result["react-native"] = "./dist/react-native/index.js";
119
- (result["imports"]["#platform/*"] as Record<string, string>)["react-native"] =
120
- "./src/*-react-native.mts";
121
- // Reorder so react-native comes before default
122
- const importsEntry = result["imports"]["#platform/*"] as Record<string, string>;
123
- result["imports"]["#platform/*"] = {
124
- browser: importsEntry["browser"],
125
- "react-native": importsEntry["react-native"],
126
- default: importsEntry["default"],
127
- };
128
- }
129
-
130
- return result;
131
- }
132
-
133
- // Non-monorepo packages use tshy which manages polyfill resolution
134
- // via esmDialects — do NOT add imports here.
42
+ // Azure monorepo packages use warp.
135
43
  const result: Record<string, any> = {
136
- tshy: getTshyConfig(config),
137
44
  type: "module",
45
+ main: "./dist/commonjs/index.js",
46
+ module: "./dist/esm/index.js",
47
+ types: "./dist/commonjs/index.d.ts",
138
48
  browser: "./dist/browser/index.js",
49
+ imports: {
50
+ "#platform/*": {
51
+ browser: "./src/*-browser.mts",
52
+ default: "./src/*.ts",
53
+ } as Record<string, string>,
54
+ },
55
+ exports: resolveWarpExports(config.exports, config.generateReactNativeTarget),
139
56
  };
140
57
 
141
58
  if (config.generateReactNativeTarget) {
142
59
  result["react-native"] = "./dist/react-native/index.js";
60
+ (result["imports"]["#platform/*"] as Record<string, string>)["react-native"] =
61
+ "./src/*-react-native.mts";
62
+ // Reorder so react-native comes before default
63
+ const importsEntry = result["imports"]["#platform/*"] as Record<string, string>;
64
+ result["imports"]["#platform/*"] = {
65
+ browser: importsEntry["browser"],
66
+ "react-native": importsEntry["react-native"],
67
+ default: importsEntry["default"],
68
+ };
143
69
  }
144
70
 
145
71
  return result;
@@ -201,25 +127,6 @@ export function resolveWarpExports(
201
127
  return exports;
202
128
  }
203
129
 
204
- export function getTshyConfig(config: PackageCommonInfoConfig) {
205
- const { exports = {} } = config;
206
- const esmDialects = config.generateReactNativeTarget ? ["browser", "react-native"] : ["browser"];
207
- const tshyConfig: Record<string, any> = {
208
- exports: {
209
- "./package.json": "./package.json",
210
- ".": "./src/index.ts",
211
- ...exports,
212
- },
213
- dialects: ["esm", "commonjs"],
214
- esmDialects,
215
- selfLink: false,
216
- };
217
- if (config.azureSdkForJs) {
218
- tshyConfig["project"] = "../../../tsconfig.src.build.json";
219
- }
220
- return tshyConfig;
221
- }
222
-
223
130
  export function getCommonPackageScripts() {
224
131
  return {
225
132
  clean: "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log",
@@ -17,7 +17,7 @@ import type {
17
17
  {{#each importedResponses}}
18
18
  {{this}},
19
19
  {{/each}}
20
- } from "./responses{{#if isEsm}}.js{{/if}}";
20
+ } from "./responses.js";
21
21
  {{/if}}
22
22
 
23
23
  /**
@@ -4,15 +4,12 @@ import hbs from "handlebars";
4
4
  import { RLCModel } from "../interfaces.js";
5
5
  import { recordedClientContent } from "./template.js";
6
6
 
7
- export function buildRecordedClientFile(model: RLCModel) {
7
+ export function buildRecordedClientFile(_model: RLCModel) {
8
8
  const recordedClientFileContents = hbs.compile(recordedClientContent, {
9
9
  noEscape: true,
10
10
  });
11
11
  return {
12
12
  path: "test/public/utils/recordedClient.ts",
13
- content: recordedClientFileContents({
14
- isEsm: model.options?.moduleKind === "esm",
15
- isCjs: model.options?.moduleKind === "cjs",
16
- }),
13
+ content: recordedClientFileContents({}),
17
14
  };
18
15
  }
@@ -4,12 +4,9 @@ import hbs from "handlebars";
4
4
  import { RLCModel } from "../interfaces.js";
5
5
  import { sampleTestContent } from "./template.js";
6
6
 
7
- export function buildSampleTest(model: RLCModel) {
7
+ export function buildSampleTest(_model: RLCModel) {
8
8
  return {
9
9
  path: "test/public/sampleTest.spec.ts",
10
- content: hbs.compile(sampleTestContent, { noEscape: true })({
11
- isEsm: model.options?.moduleKind === "esm",
12
- isCjs: model.options?.moduleKind === "cjs",
13
- }),
10
+ content: hbs.compile(sampleTestContent, { noEscape: true })({}),
14
11
  };
15
12
  }
@@ -5,21 +5,18 @@ import { getClientName } from "../helpers/name-constructors.js";
5
5
  import { RLCModel } from "../interfaces.js";
6
6
  import { snippetsContent } from "./template.js";
7
7
 
8
- export function buildSnippets(model: RLCModel, clientName?: string, azureSdkForJs?: boolean) {
9
- const azureSdkForJsInfo = azureSdkForJs ? azureSdkForJs : model.options?.azureSdkForJs;
8
+ export function buildSnippets(model: RLCModel, clientName?: string) {
10
9
  // to keep the same config for azure scope in buildReadmeFile.ts
11
10
  if (
12
11
  (model?.options?.packageDetails?.scopeName === "azure" ||
13
12
  model?.options?.packageDetails?.scopeName === "azure-rest") &&
14
- model.options.addCredentials &&
15
- azureSdkForJsInfo
13
+ model.options.addCredentials
16
14
  ) {
17
15
  return {
18
16
  path: "test/snippets.spec.ts",
19
17
  content: hbs.compile(snippetsContent, { noEscape: true })({
20
18
  clientClassName: clientName ? clientName : getClientName(model),
21
19
  azureArm: model.options?.azureArm,
22
- azureSdkForJs: azureSdkForJsInfo,
23
20
  isModularLibrary: model.options.isModularLibrary,
24
21
  hasSubscriptionId: model.options.hasSubscriptionId,
25
22
  }),