@typespec/http-client-js 0.8.0 → 0.9.0-dev.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/http-client-js",
3
- "version": "0.8.0",
3
+ "version": "0.9.0-dev.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",
@@ -30,20 +30,25 @@
30
30
  "peerDependencies": {
31
31
  "@typespec/compiler": "^1.3.0",
32
32
  "@typespec/http": "^1.3.0",
33
- "@typespec/rest": "^0.73.0"
33
+ "@typespec/rest": "^0.73.0 || >=0.74.0-dev <0.74.0"
34
34
  },
35
35
  "dependencies": {
36
36
  "@alloy-js/core": "^0.19.0",
37
37
  "@alloy-js/typescript": "^0.19.0",
38
- "prettier": "~3.6.2",
39
- "@typespec/emitter-framework": "^0.10.0",
40
- "@typespec/http-client": "^0.9.0"
38
+ "@typespec/emitter-framework": "^0.10.0 || >=0.11.0-dev <0.11.0",
39
+ "@typespec/http-client": "^0.9.0 || >=0.10.0-dev <0.10.0",
40
+ "prettier": "~3.6.2"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@alloy-js/cli": "^0.19.0",
44
44
  "@alloy-js/rollup-plugin": "^0.1.0",
45
45
  "@types/yargs": "~17.0.33",
46
+ "@typespec/http": "^1.3.0",
47
+ "@typespec/http-specs": "^0.1.0-alpha.25 || >=0.1.0-alpha.26-dev <0.1.0-alpha.26",
48
+ "@typespec/spector": "^0.1.0-alpha.17 || >=0.1.0-alpha.18-dev <0.1.0-alpha.18",
46
49
  "@typespec/ts-http-runtime": "0.3.0",
50
+ "@typespec/tspd": "^0.72.2 || >=0.73.0-dev <0.73.0",
51
+ "@typespec/versioning": "^0.73.0 || >=0.74.0-dev <0.74.0",
47
52
  "@vitest/ui": "^3.1.2",
48
53
  "change-case": "~5.4.4",
49
54
  "concurrently": "^9.1.2",
@@ -58,12 +63,7 @@
58
63
  "typescript": "~5.8.2",
59
64
  "uri-template": "^2.0.0",
60
65
  "vitest": "^3.1.2",
61
- "yargs": "~18.0.0",
62
- "@typespec/http": "^1.3.0",
63
- "@typespec/http-specs": "^0.1.0-alpha.25",
64
- "@typespec/spector": "^0.1.0-alpha.17",
65
- "@typespec/tspd": "^0.72.2",
66
- "@typespec/versioning": "^0.73.0"
66
+ "yargs": "~18.0.0"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "alloy build",
package/src/emitter.tsx CHANGED
@@ -1,7 +1,13 @@
1
- import { SourceDirectory } from "@alloy-js/core";
1
+ import { Children, SourceDirectory } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import { EmitContext } from "@typespec/compiler";
4
- import { writeOutput } from "@typespec/emitter-framework";
4
+ import {
5
+ Experimental_ComponentOverrides,
6
+ Experimental_ComponentOverridesConfig,
7
+ useTsp,
8
+ writeOutput,
9
+ } from "@typespec/emitter-framework";
10
+ import { TypeExpression } from "@typespec/emitter-framework/typescript";
5
11
  import { OperationsDirectory } from "./components/client-directory.jsx";
6
12
  import { Client } from "./components/client.jsx";
7
13
  import { Models } from "./components/models.js";
@@ -21,38 +27,58 @@ export async function $onEmit(context: EmitContext<JsClientEmitterOptions>) {
21
27
  const packageName = context.options["package-name"] ?? "test-package";
22
28
  const output = (
23
29
  <Output program={context.program}>
24
- <ts.PackageDirectory
25
- name={packageName}
26
- version="1.0.0"
27
- path="."
28
- scripts={{ build: "tsc" }}
29
- devDependencies={{ "@types/node": "~18.19.75" }}
30
- >
31
- <SourceDirectory path="src">
32
- <ts.BarrelFile export="." />
33
- <Client />
34
- <SourceDirectory path="models">
35
- <ts.BarrelFile export="models" />
36
- <Models />
37
- <SourceDirectory path="internal">
38
- <ModelSerializers />
30
+ <HttpClientOverrides>
31
+ <ts.PackageDirectory
32
+ name={packageName}
33
+ version="1.0.0"
34
+ path="."
35
+ scripts={{ build: "tsc" }}
36
+ devDependencies={{ "@types/node": "~18.19.75" }}
37
+ >
38
+ <SourceDirectory path="src">
39
+ <ts.BarrelFile export="." />
40
+ <Client />
41
+ <SourceDirectory path="models">
42
+ <ts.BarrelFile export="models" />
43
+ <Models />
44
+ <SourceDirectory path="internal">
45
+ <ModelSerializers />
46
+ </SourceDirectory>
47
+ </SourceDirectory>
48
+ <SourceDirectory path="api">
49
+ <OperationsDirectory />
50
+ </SourceDirectory>
51
+ <SourceDirectory path="helpers">
52
+ <PagingHelpers />
53
+ <Interfaces />
54
+ <MultipartHelpers />
55
+ <ts.SourceFile path="error.ts">
56
+ <RestError />
57
+ </ts.SourceFile>
39
58
  </SourceDirectory>
40
59
  </SourceDirectory>
41
- <SourceDirectory path="api">
42
- <OperationsDirectory />
43
- </SourceDirectory>
44
- <SourceDirectory path="helpers">
45
- <PagingHelpers />
46
- <Interfaces />
47
- <MultipartHelpers />
48
- <ts.SourceFile path="error.ts">
49
- <RestError />
50
- </ts.SourceFile>
51
- </SourceDirectory>
52
- </SourceDirectory>
53
- </ts.PackageDirectory>
60
+ </ts.PackageDirectory>
61
+ </HttpClientOverrides>
54
62
  </Output>
55
63
  );
56
64
 
57
65
  await writeOutput(context.program, output, context.emitterOutputDir);
58
66
  }
67
+
68
+ export function HttpClientOverrides(props: { children?: Children }) {
69
+ const { $ } = useTsp();
70
+ const overrides = Experimental_ComponentOverridesConfig().forTypeKind("Model", {
71
+ reference: (props) => {
72
+ if ($.httpPart.is(props.type)) {
73
+ return <TypeExpression type={$.httpPart.unpack(props.type)} />;
74
+ } else {
75
+ return props.default;
76
+ }
77
+ },
78
+ });
79
+ return (
80
+ <Experimental_ComponentOverrides overrides={overrides}>
81
+ {props.children}
82
+ </Experimental_ComponentOverrides>
83
+ );
84
+ }