@typespec/http-client-js 0.14.1-dev.1 → 0.14.1

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.
@@ -205,7 +205,7 @@ async function processFile(file, options) {
205
205
  console.log(pc.yellow(`Skipping: ${relativePath}`));
206
206
  } else if (action === "abort") {
207
207
  console.log(pc.red("Aborting processing."));
208
- throw new Error("Processing aborted by user");
208
+ throw new Error("Processing aborted by user", { cause: error });
209
209
  }
210
210
  }
211
211
  return { status: "failed", relativePath, errorDetails };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/http-client-js",
3
- "version": "0.14.1-dev.1",
3
+ "version": "0.14.1",
4
4
  "type": "module",
5
5
  "homepage": "https://typespec.io",
6
6
  "readme": "https://github.com/microsoft/typespec/blob/main/packages/http-client-js/README.md",
@@ -28,27 +28,22 @@
28
28
  "license": "MIT",
29
29
  "description": "TypeSpec library for emitting Http Client libraries for JavaScript/TypeScript",
30
30
  "peerDependencies": {
31
- "@typespec/compiler": "^1.9.0 || >= 1.10.0-dev.7",
32
- "@typespec/http": "^1.9.1 || >= 1.10.0-dev.3",
33
- "@typespec/rest": "^0.79.0 || >= 0.80.0-dev.2"
31
+ "@typespec/compiler": "^1.10.0",
32
+ "@typespec/http": "^1.10.0",
33
+ "@typespec/rest": "^0.80.0"
34
34
  },
35
35
  "dependencies": {
36
36
  "@alloy-js/core": "^0.22.0",
37
37
  "@alloy-js/typescript": "^0.22.0",
38
- "@typespec/emitter-framework": "^0.16.0 || >= 0.17.0-dev.2",
39
- "@typespec/http-client": "^0.15.0 || >= 0.15.1-dev.2",
40
- "prettier": "~3.8.0"
38
+ "prettier": "~3.8.0",
39
+ "@typespec/http-client": "^0.15.1",
40
+ "@typespec/emitter-framework": "^0.17.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@alloy-js/cli": "^0.22.0",
44
44
  "@alloy-js/rollup-plugin": "^0.1.0",
45
45
  "@types/yargs": "~17.0.33",
46
- "@typespec/http": "^1.9.1 || >= 1.10.0-dev.3",
47
- "@typespec/http-specs": "^0.1.0-alpha.32 || >= 0.1.0-alpha.33-dev.4",
48
- "@typespec/spector": "^0.1.0-alpha.23 || >= 0.1.0-alpha.24-dev.3",
49
46
  "@typespec/ts-http-runtime": "0.3.3",
50
- "@typespec/tspd": "^0.74.0 || >= 0.74.1-dev.2",
51
- "@typespec/versioning": "^0.79.0 || >= 0.80.0-dev.2",
52
47
  "@vitest/ui": "^4.0.18",
53
48
  "change-case": "~5.4.4",
54
49
  "concurrently": "^9.1.2",
@@ -63,7 +58,12 @@
63
58
  "typescript": "~5.9.3",
64
59
  "uri-template": "^2.0.0",
65
60
  "vitest": "^4.0.18",
66
- "yargs": "~18.0.0"
61
+ "yargs": "~18.0.0",
62
+ "@typespec/http-specs": "^0.1.0-alpha.33",
63
+ "@typespec/http": "^1.10.0",
64
+ "@typespec/spector": "^0.1.0-alpha.24",
65
+ "@typespec/tspd": "^0.74.1",
66
+ "@typespec/versioning": "^0.80.0"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "alloy build",
package/test/test-host.ts CHANGED
@@ -1,15 +1,5 @@
1
1
  import { Diagnostic, resolvePath } from "@typespec/compiler";
2
- import {
3
- BasicTestRunner,
4
- createTester,
5
- createTestHost,
6
- createTestWrapper,
7
- expectDiagnosticEmpty,
8
- } from "@typespec/compiler/testing";
9
- import { HttpTestLibrary } from "@typespec/http/testing";
10
- import { RestTestLibrary } from "@typespec/rest/testing";
11
- import { join, relative } from "path";
12
- import { HttpClientJavascriptEmitterTestLibrary } from "../src/testing/index.js";
2
+ import { createTester, expectDiagnosticEmpty } from "@typespec/compiler/testing";
13
3
 
14
4
  const ApiTester = createTester(resolvePath(import.meta.dirname, ".."), {
15
5
  libraries: ["@typespec/http", "@typespec/rest", "@typespec/http-client-js"],
@@ -17,63 +7,11 @@ const ApiTester = createTester(resolvePath(import.meta.dirname, ".."), {
17
7
 
18
8
  export const Tester = ApiTester.emit("@typespec/http-client-js");
19
9
 
20
- export async function createHttpClientJsTestHost() {
21
- return createTestHost({
22
- libraries: [HttpClientJavascriptEmitterTestLibrary, HttpTestLibrary, RestTestLibrary],
23
- });
24
- }
25
-
26
- export async function createHttpClientJavascriptEmitterTestRunner() {
27
- const host = await createHttpClientJsTestHost();
28
-
29
- return createTestWrapper(host, {
30
- autoImports: ["@typespec/http", "@typespec/rest"],
31
- autoUsings: ["TypeSpec.Http", "TypeSpec.Rest"],
32
- compilerOptions: {
33
- noEmit: false,
34
- emit: ["@typespec/http-client-js"],
35
- },
36
- });
37
- }
38
-
39
- const emitterOutputDir = join("tsp-output", "http-client-js");
40
-
41
10
  export async function emitWithDiagnostics(
42
11
  code: string,
43
12
  ): Promise<[Record<string, string>, readonly Diagnostic[]]> {
44
- const runner = await createHttpClientJavascriptEmitterTestRunner();
45
- await runner.compileAndDiagnose(code, {
46
- outputDir: "tsp-output",
47
- });
48
- const result = await readFilesRecursively(emitterOutputDir, runner);
49
- return [result, runner.program.diagnostics];
50
- }
51
-
52
- async function readFilesRecursively(
53
- dir: string,
54
- runner: BasicTestRunner,
55
- ): Promise<Record<string, string>> {
56
- const entries = await runner.program.host.readDir(dir);
57
- const result: Record<string, string> = {};
58
-
59
- for (const entry of entries) {
60
- const fullPath = join(dir, entry);
61
- const stat = await runner.program.host.stat(fullPath);
62
-
63
- if (stat.isDirectory()) {
64
- // Recursively read files in the directory
65
- const nestedFiles = await readFilesRecursively(fullPath, runner);
66
- Object.assign(result, nestedFiles);
67
- } else if (stat.isFile()) {
68
- // Read the file
69
- // Read the file and store it with a relative path
70
- const relativePath = relative(emitterOutputDir, fullPath);
71
- const fileContent = await runner.program.host.readFile(fullPath);
72
- result[relativePath] = fileContent.text;
73
- }
74
- }
75
-
76
- return result;
13
+ const [result, diagnostics] = await Tester.compileAndDiagnose(code);
14
+ return [result.outputs, diagnostics];
77
15
  }
78
16
 
79
17
  export async function emit(code: string): Promise<Record<string, string>> {