@typespec/http-client-js 0.7.0-dev.2 → 0.7.0-dev.4

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 (180) hide show
  1. package/.testignore +4 -0
  2. package/dist/src/components/client-context/client-context-declaration.d.ts +2 -3
  3. package/dist/src/components/client-context/client-context-declaration.d.ts.map +1 -1
  4. package/dist/src/components/client-context/client-context-declaration.js +2 -2
  5. package/dist/src/components/client-context/client-context-factory.d.ts +3 -3
  6. package/dist/src/components/client-context/client-context-factory.d.ts.map +1 -1
  7. package/dist/src/components/client-context/client-context-factory.js +10 -10
  8. package/dist/src/components/client-context/client-context-options.d.ts +3 -3
  9. package/dist/src/components/client-context/client-context-options.d.ts.map +1 -1
  10. package/dist/src/components/client-context/client-context-options.js +3 -3
  11. package/dist/src/components/client-context/client-context.d.ts +3 -3
  12. package/dist/src/components/client-context/client-context.d.ts.map +1 -1
  13. package/dist/src/components/client-context/parametrized-endpoint.d.ts +3 -3
  14. package/dist/src/components/client-context/parametrized-endpoint.d.ts.map +1 -1
  15. package/dist/src/components/client-context/parametrized-endpoint.js +5 -5
  16. package/dist/src/components/client-directory.d.ts +4 -4
  17. package/dist/src/components/client-directory.d.ts.map +1 -1
  18. package/dist/src/components/client-directory.js +5 -5
  19. package/dist/src/components/client-operation.d.ts +4 -4
  20. package/dist/src/components/client-operation.d.ts.map +1 -1
  21. package/dist/src/components/client-operation.js +6 -6
  22. package/dist/src/components/client.d.ts +5 -5
  23. package/dist/src/components/client.d.ts.map +1 -1
  24. package/dist/src/components/client.js +14 -14
  25. package/dist/src/components/encoding-provider.d.ts +1 -1
  26. package/dist/src/components/encoding-provider.d.ts.map +1 -1
  27. package/dist/src/components/http-request-parameters-expression.d.ts +4 -4
  28. package/dist/src/components/http-request-parameters-expression.d.ts.map +1 -1
  29. package/dist/src/components/http-request-parameters-expression.js +10 -10
  30. package/dist/src/components/models.d.ts +1 -2
  31. package/dist/src/components/models.d.ts.map +1 -1
  32. package/dist/src/components/models.js +2 -3
  33. package/dist/src/components/operation-handlers/operation-pipeline.d.ts +1 -2
  34. package/dist/src/components/operation-handlers/operation-pipeline.d.ts.map +1 -1
  35. package/dist/src/components/operation-handlers/operation-pipeline.js +2 -2
  36. package/dist/src/components/operation-handlers/paging/page-response.d.ts +2 -3
  37. package/dist/src/components/operation-handlers/paging/page-response.d.ts.map +1 -1
  38. package/dist/src/components/operation-handlers/paging/page-response.js +3 -3
  39. package/dist/src/components/operation-handlers/paging/page-settings.d.ts +2 -3
  40. package/dist/src/components/operation-handlers/paging/page-settings.d.ts.map +1 -1
  41. package/dist/src/components/operation-handlers/paging/page-settings.js +3 -3
  42. package/dist/src/components/operation-handlers/paging/paginated-operation-handler.d.ts.map +1 -1
  43. package/dist/src/components/operation-handlers/paging/paginated-operation-handler.js +16 -16
  44. package/dist/src/components/operation-handlers/paging/request-send.d.ts +2 -3
  45. package/dist/src/components/operation-handlers/paging/request-send.d.ts.map +1 -1
  46. package/dist/src/components/operation-handlers/paging/request-send.js +1 -2
  47. package/dist/src/components/operation-handlers/types.d.ts +1 -1
  48. package/dist/src/components/operation-handlers/types.d.ts.map +1 -1
  49. package/dist/src/components/operation-options.d.ts +2 -3
  50. package/dist/src/components/operation-options.d.ts.map +1 -1
  51. package/dist/src/components/operation-options.js +3 -3
  52. package/dist/src/components/operation-parameters.d.ts +2 -2
  53. package/dist/src/components/operation-parameters.d.ts.map +1 -1
  54. package/dist/src/components/operation-parameters.js +2 -2
  55. package/dist/src/components/output.d.ts +3 -3
  56. package/dist/src/components/output.d.ts.map +1 -1
  57. package/dist/src/components/static-helpers/bytes-encoding.d.ts +6 -5
  58. package/dist/src/components/static-helpers/bytes-encoding.d.ts.map +1 -1
  59. package/dist/src/components/static-helpers/bytes-encoding.js +15 -19
  60. package/dist/src/components/static-helpers/interfaces.d.ts +3 -4
  61. package/dist/src/components/static-helpers/interfaces.d.ts.map +1 -1
  62. package/dist/src/components/static-helpers/interfaces.js +3 -3
  63. package/dist/src/components/static-helpers/multipart-helpers.d.ts +4 -5
  64. package/dist/src/components/static-helpers/multipart-helpers.d.ts.map +1 -1
  65. package/dist/src/components/static-helpers/multipart-helpers.js +8 -10
  66. package/dist/src/components/static-helpers/paging-helper.d.ts +3 -4
  67. package/dist/src/components/static-helpers/paging-helper.d.ts.map +1 -1
  68. package/dist/src/components/static-helpers/paging-helper.js +17 -23
  69. package/dist/src/components/static-helpers/rest-error.d.ts +3 -4
  70. package/dist/src/components/static-helpers/rest-error.d.ts.map +1 -1
  71. package/dist/src/components/static-helpers/rest-error.js +19 -25
  72. package/dist/src/components/testing/client-options.d.ts +3 -3
  73. package/dist/src/components/testing/client-options.d.ts.map +1 -1
  74. package/dist/src/components/testing/client-options.js +2 -2
  75. package/dist/src/components/transforms/content-type-encoding-provider.d.ts +1 -1
  76. package/dist/src/components/transforms/content-type-encoding-provider.d.ts.map +1 -1
  77. package/dist/src/components/transforms/json/json-array-transform.d.ts +6 -6
  78. package/dist/src/components/transforms/json/json-array-transform.d.ts.map +1 -1
  79. package/dist/src/components/transforms/json/json-array-transform.js +5 -5
  80. package/dist/src/components/transforms/json/json-model-additional-properties-transform.d.ts +4 -4
  81. package/dist/src/components/transforms/json/json-model-additional-properties-transform.d.ts.map +1 -1
  82. package/dist/src/components/transforms/json/json-model-additional-properties-transform.js +4 -4
  83. package/dist/src/components/transforms/json/json-model-base-transform.d.ts +4 -4
  84. package/dist/src/components/transforms/json/json-model-base-transform.d.ts.map +1 -1
  85. package/dist/src/components/transforms/json/json-model-property-transform.d.ts +3 -3
  86. package/dist/src/components/transforms/json/json-model-property-transform.d.ts.map +1 -1
  87. package/dist/src/components/transforms/json/json-model-property-transform.js +3 -3
  88. package/dist/src/components/transforms/json/json-model-transform.d.ts +6 -6
  89. package/dist/src/components/transforms/json/json-model-transform.d.ts.map +1 -1
  90. package/dist/src/components/transforms/json/json-model-transform.js +8 -8
  91. package/dist/src/components/transforms/json/json-record-transform.d.ts +6 -6
  92. package/dist/src/components/transforms/json/json-record-transform.d.ts.map +1 -1
  93. package/dist/src/components/transforms/json/json-record-transform.js +5 -5
  94. package/dist/src/components/transforms/json/json-transform-discriminator.d.ts +5 -5
  95. package/dist/src/components/transforms/json/json-transform-discriminator.d.ts.map +1 -1
  96. package/dist/src/components/transforms/json/json-transform-discriminator.js +13 -13
  97. package/dist/src/components/transforms/json/json-transform.d.ts +6 -5
  98. package/dist/src/components/transforms/json/json-transform.d.ts.map +1 -1
  99. package/dist/src/components/transforms/json/json-transform.js +2 -2
  100. package/dist/src/components/transforms/json/union-transform.d.ts +6 -6
  101. package/dist/src/components/transforms/json/union-transform.d.ts.map +1 -1
  102. package/dist/src/components/transforms/json/union-transform.js +6 -6
  103. package/dist/src/components/transforms/json/utils/transport-namer.d.ts +1 -1
  104. package/dist/src/components/transforms/json/utils/transport-namer.d.ts.map +1 -1
  105. package/dist/src/components/transforms/multipart/array-part-transform.d.ts +3 -3
  106. package/dist/src/components/transforms/multipart/array-part-transform.d.ts.map +1 -1
  107. package/dist/src/components/transforms/multipart/array-part-transform.js +5 -5
  108. package/dist/src/components/transforms/multipart/file-part-transform.d.ts +3 -3
  109. package/dist/src/components/transforms/multipart/file-part-transform.d.ts.map +1 -1
  110. package/dist/src/components/transforms/multipart/file-part-transform.js +2 -2
  111. package/dist/src/components/transforms/multipart/multipart-transform.d.ts +1 -2
  112. package/dist/src/components/transforms/multipart/multipart-transform.d.ts.map +1 -1
  113. package/dist/src/components/transforms/multipart/multipart-transform.js +2 -2
  114. package/dist/src/components/transforms/multipart/part-transform.d.ts +3 -3
  115. package/dist/src/components/transforms/multipart/part-transform.d.ts.map +1 -1
  116. package/dist/src/components/transforms/multipart/simple-part-transform.d.ts +3 -3
  117. package/dist/src/components/transforms/multipart/simple-part-transform.d.ts.map +1 -1
  118. package/dist/src/components/transforms/multipart/simple-part-transform.js +5 -5
  119. package/dist/src/components/transforms/operation-transform-declaration.d.ts +6 -6
  120. package/dist/src/components/transforms/operation-transform-declaration.d.ts.map +1 -1
  121. package/dist/src/components/transforms/operation-transform-declaration.js +3 -3
  122. package/dist/src/components/transforms/transform-name-policy.d.ts +1 -1
  123. package/dist/src/components/transforms/transform-name-policy.d.ts.map +1 -1
  124. package/dist/src/emitter.js +6 -6
  125. package/dist/src/utils/multipart.d.ts +1 -1
  126. package/dist/src/utils/multipart.d.ts.map +1 -1
  127. package/dist/src/utils/parameters.d.ts +2 -2
  128. package/dist/src/utils/parameters.d.ts.map +1 -1
  129. package/dist/src/utils/parameters.js +6 -6
  130. package/dist/tsconfig.tsbuildinfo +1 -1
  131. package/package.json +1 -1
  132. package/src/components/client-context/client-context-declaration.tsx +2 -2
  133. package/src/components/client-context/client-context-factory.tsx +19 -19
  134. package/src/components/client-context/client-context-options.tsx +5 -5
  135. package/src/components/client-context/client-context.tsx +2 -2
  136. package/src/components/client-context/parametrized-endpoint.tsx +8 -8
  137. package/src/components/client-directory.tsx +10 -10
  138. package/src/components/client-operation.tsx +11 -11
  139. package/src/components/client.tsx +21 -21
  140. package/src/components/encoding-provider.tsx +1 -1
  141. package/src/components/http-request-parameters-expression.tsx +19 -19
  142. package/src/components/models.tsx +2 -3
  143. package/src/components/operation-handlers/operation-pipeline.tsx +2 -2
  144. package/src/components/operation-handlers/paging/page-response.tsx +4 -4
  145. package/src/components/operation-handlers/paging/page-settings.tsx +4 -4
  146. package/src/components/operation-handlers/paging/paginated-operation-handler.tsx +18 -19
  147. package/src/components/operation-handlers/paging/request-send.tsx +1 -2
  148. package/src/components/operation-handlers/types.tsx +1 -1
  149. package/src/components/operation-options.tsx +4 -4
  150. package/src/components/operation-parameters.tsx +3 -3
  151. package/src/components/output.tsx +2 -2
  152. package/src/components/serializers.tsx +1 -1
  153. package/src/components/static-helpers/bytes-encoding.tsx +17 -16
  154. package/src/components/static-helpers/interfaces.tsx +3 -3
  155. package/src/components/static-helpers/multipart-helpers.tsx +7 -7
  156. package/src/components/static-helpers/paging-helper.tsx +17 -20
  157. package/src/components/static-helpers/rest-error.tsx +17 -17
  158. package/src/components/testing/client-options.tsx +3 -3
  159. package/src/components/transforms/content-type-encoding-provider.tsx +1 -1
  160. package/src/components/transforms/json/json-array-transform.tsx +8 -8
  161. package/src/components/transforms/json/json-model-additional-properties-transform.tsx +6 -6
  162. package/src/components/transforms/json/json-model-base-transform.tsx +3 -3
  163. package/src/components/transforms/json/json-model-property-transform.tsx +6 -6
  164. package/src/components/transforms/json/json-model-transform.tsx +12 -14
  165. package/src/components/transforms/json/json-record-transform.tsx +8 -8
  166. package/src/components/transforms/json/json-transform-discriminator.tsx +12 -12
  167. package/src/components/transforms/json/json-transform.tsx +6 -5
  168. package/src/components/transforms/json/union-transform.tsx +8 -8
  169. package/src/components/transforms/json/utils/transport-namer.ts +1 -1
  170. package/src/components/transforms/multipart/array-part-transform.tsx +6 -5
  171. package/src/components/transforms/multipart/file-part-transform.tsx +5 -5
  172. package/src/components/transforms/multipart/multipart-transform.tsx +3 -3
  173. package/src/components/transforms/multipart/part-transform.tsx +2 -2
  174. package/src/components/transforms/multipart/simple-part-transform.tsx +8 -8
  175. package/src/components/transforms/operation-transform-declaration.tsx +7 -6
  176. package/src/components/transforms/operation-transform-expression.tsx +1 -1
  177. package/src/components/transforms/transform-name-policy.ts +1 -1
  178. package/src/emitter.tsx +11 -11
  179. package/src/utils/multipart.ts +1 -1
  180. package/src/utils/parameters.tsx +9 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/http-client-js",
3
- "version": "0.7.0-dev.2",
3
+ "version": "0.7.0-dev.4",
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",
@@ -1,4 +1,4 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { refkey } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import * as cl from "@typespec/http-client";
4
4
  import { httpRuntimeTemplateLib } from "../external-packages/ts-http-runtime.js";
@@ -8,7 +8,7 @@ export interface ClientContextDeclarationProps {
8
8
  }
9
9
 
10
10
  export function getClientcontextDeclarationRef(client: cl.Client) {
11
- return ay.refkey(client, "declaration");
11
+ return refkey(client, "declaration");
12
12
  }
13
13
 
14
14
  export function ClientContextDeclaration(props: ClientContextDeclarationProps) {
@@ -1,4 +1,4 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { Children, For, List, refkey, Refkey } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import { useTsp } from "@typespec/emitter-framework";
4
4
  import { FunctionDeclaration } from "@typespec/emitter-framework/typescript";
@@ -16,7 +16,7 @@ export interface ClientContextFactoryProps {
16
16
  }
17
17
 
18
18
  export function getClientContextFactoryRef(client: cl.Client) {
19
- return ay.refkey(client, "contextFactory");
19
+ return refkey(client, "contextFactory");
20
20
  }
21
21
 
22
22
  export function ClientContextFactoryDeclaration(props: ClientContextFactoryProps) {
@@ -27,9 +27,9 @@ export function ClientContextFactoryDeclaration(props: ClientContextFactoryProps
27
27
  const factoryFunctionName = namePolicy.getName(`create_${props.client.name}Context`, "function");
28
28
 
29
29
  const clientConstructor = $.client.getConstructor(props.client);
30
- const parameters = buildClientParameters(props.client, ay.refkey());
30
+ const parameters = buildClientParameters(props.client, refkey());
31
31
  const urlTemplate = $.client.getUrlTemplate(props.client);
32
- const endpointRef = ay.refkey();
32
+ const endpointRef = refkey();
33
33
  const resolvedEndpoint = (
34
34
  <ParametrizedEndpoint
35
35
  refkey={endpointRef}
@@ -70,7 +70,7 @@ export function ClientContextFactoryDeclaration(props: ClientContextFactoryProps
70
70
 
71
71
  interface ClientFactoryArgumentsProps {
72
72
  client: cl.Client;
73
- endpointRef: ay.Refkey;
73
+ endpointRef: Refkey;
74
74
  credentialsRef?: string;
75
75
  }
76
76
 
@@ -105,10 +105,10 @@ function AuthScheme(props: AuthSchemeProps) {
105
105
  case "http":
106
106
  return (
107
107
  <ts.ObjectExpression>
108
- <ay.List comma>
108
+ <List comma>
109
109
  <ts.ObjectProperty name="kind" jsValue="http" />
110
110
  <ts.ObjectProperty name="scheme" jsValue={props.scheme.scheme.toLowerCase()} />
111
- </ay.List>
111
+ </List>
112
112
  </ts.ObjectExpression>
113
113
  );
114
114
  case "apiKey":
@@ -121,26 +121,26 @@ function AuthScheme(props: AuthSchemeProps) {
121
121
 
122
122
  return (
123
123
  <ts.ObjectExpression>
124
- <ay.List comma>
124
+ <List comma>
125
125
  <ts.ObjectProperty name="kind" jsValue="apiKey" />
126
126
  <ts.ObjectProperty name="apiKeyLocation" jsValue={props.scheme.in} />
127
127
  <ts.ObjectProperty name="name" jsValue={props.scheme.name} />
128
- </ay.List>
128
+ </List>
129
129
  </ts.ObjectExpression>
130
130
  );
131
131
  case "oauth2":
132
132
  return (
133
133
  <ts.ObjectExpression>
134
- <ay.List comma>
134
+ <List comma>
135
135
  <ts.ObjectProperty name="kind" jsValue="oauth2" />
136
136
  <ts.ObjectProperty name="flows">
137
137
  [
138
- <ay.For each={props.scheme.flows} comma line>
138
+ <For each={props.scheme.flows} comma line>
139
139
  {(flow) => <OAuth2Flow flow={flow} />}
140
- </ay.For>
140
+ </For>
141
141
  ]
142
142
  </ts.ObjectProperty>
143
- </ay.List>
143
+ </List>
144
144
  </ts.ObjectExpression>
145
145
  );
146
146
  default:
@@ -181,20 +181,20 @@ function AuthSchemeOptions(props: AuthSchemeOptionsProps) {
181
181
  return (
182
182
  <ts.ObjectProperty name="authSchemes">
183
183
  [
184
- <ay.For each={supportedSchemes} comma line>
184
+ <For each={supportedSchemes} comma line>
185
185
  {(scheme) => <AuthScheme scheme={scheme} client={props.client} />}
186
- </ay.For>
186
+ </For>
187
187
  ]
188
188
  </ts.ObjectProperty>
189
189
  );
190
190
  }
191
191
 
192
192
  interface ClientOptionsExpressionProps {
193
- children?: ay.Children;
193
+ children?: Children;
194
194
  }
195
195
 
196
196
  function ClientOptionsExpression(props: ClientOptionsExpressionProps) {
197
- const options: ay.Children = ["...options"];
197
+ const options: Children = ["...options"];
198
198
 
199
199
  // Conditionally add test options
200
200
  // based on the environment variable TYPESPEC_JS_EMITTER_TESTING
@@ -208,9 +208,9 @@ function ClientOptionsExpression(props: ClientOptionsExpressionProps) {
208
208
 
209
209
  return (
210
210
  <ts.ObjectExpression>
211
- <ay.For each={options} joiner="," line>
211
+ <For each={options} joiner="," line>
212
212
  {(child) => child}
213
- </ay.For>
213
+ </For>
214
214
  </ts.ObjectExpression>
215
215
  );
216
216
  }
@@ -1,4 +1,4 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { Children, For, refkey } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import * as cl from "@typespec/http-client";
4
4
  import { httpRuntimeTemplateLib } from "../external-packages/ts-http-runtime.js";
@@ -8,7 +8,7 @@ export interface ClientContextOptionsDeclarationProps {
8
8
  }
9
9
 
10
10
  export function getClientContextOptionsRef(client: cl.Client) {
11
- return ay.refkey(client, "options");
11
+ return refkey(client, "options");
12
12
  }
13
13
 
14
14
  export function ClientContextOptionsDeclaration(props: ClientContextOptionsDeclarationProps) {
@@ -17,7 +17,7 @@ export function ClientContextOptionsDeclaration(props: ClientContextOptionsDecla
17
17
  const name = namePolicy.getName(`${props.client.name}Options`, "interface");
18
18
 
19
19
  // TODO: Here we will calculate and include all the options that the client can accept
20
- const clientOptions: Map<string, ay.Children> = new Map();
20
+ const clientOptions: Map<string, Children> = new Map();
21
21
 
22
22
  return (
23
23
  <ts.InterfaceDeclaration
@@ -26,9 +26,9 @@ export function ClientContextOptionsDeclaration(props: ClientContextOptionsDecla
26
26
  refkey={ref}
27
27
  extends={<ts.Reference refkey={httpRuntimeTemplateLib.ClientOptions} />}
28
28
  >
29
- <ay.For each={Array.from(clientOptions.entries())} semicolon line>
29
+ <For each={Array.from(clientOptions.entries())} semicolon line>
30
30
  {([key, value]) => <ts.InterfaceMember optional name={key} type={value} />}
31
- </ay.For>
31
+ </For>
32
32
  <ts.InterfaceMember optional name="endpoint" type="string" />;
33
33
  </ts.InterfaceDeclaration>
34
34
  );
@@ -1,4 +1,4 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { type Children } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import * as cl from "@typespec/http-client";
4
4
  import { ClientContextDeclaration } from "./client-context-declaration.jsx";
@@ -7,7 +7,7 @@ import { ClientContextOptionsDeclaration } from "./client-context-options.jsx";
7
7
 
8
8
  export interface ClientContextProps {
9
9
  client: cl.Client;
10
- children?: ay.Children;
10
+ children?: Children;
11
11
  }
12
12
 
13
13
  export function ClientContext(props: ClientContextProps) {
@@ -1,22 +1,22 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { code, For, Refkey, refkey, StatementList } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import { ModelProperty } from "@typespec/compiler";
4
4
  import { useTransformNamePolicy } from "@typespec/emitter-framework";
5
5
  import { getDefaultValue } from "../../utils/parameters.jsx";
6
6
 
7
7
  export interface ParametrizedEndpointProps {
8
- refkey: ay.Refkey;
8
+ refkey: Refkey;
9
9
  template: string;
10
10
  params: ModelProperty[];
11
11
  }
12
12
 
13
13
  export function ParametrizedEndpoint(props: ParametrizedEndpointProps) {
14
14
  const propNamer = useTransformNamePolicy();
15
- const paramsRef = ay.refkey();
15
+ const paramsRef = refkey();
16
16
  const params = (
17
17
  <ts.VarDeclaration name="params" type={"Record<string, any>"} refkey={paramsRef}>
18
18
  <ts.ObjectExpression>
19
- <ay.For each={props.params} joiner="," line>
19
+ <For each={props.params} joiner="," line>
20
20
  {(p) => {
21
21
  const applicationName = propNamer.getApplicationName(p);
22
22
  const transportName = propNamer.getTransportName(p);
@@ -26,14 +26,14 @@ export function ParametrizedEndpoint(props: ParametrizedEndpointProps) {
26
26
  : applicationName;
27
27
  return <ts.ObjectProperty name={transportName} value={itemRef} />;
28
28
  }}
29
- </ay.For>
29
+ </For>
30
30
  </ts.ObjectExpression>
31
31
  </ts.VarDeclaration>
32
32
  );
33
33
 
34
34
  const resolvedEndpoint = (
35
35
  <ts.VarDeclaration name="resolvedEndpoint" refkey={props.refkey}>
36
- {ay.code`
36
+ {code`
37
37
  "${props.template}".replace(/{([^}]+)}/g, (_, key) =>
38
38
  key in ${paramsRef} ? String(params[key]) : (() => { throw new Error(\`Missing parameter: $\{key}\`); })()
39
39
  );
@@ -42,9 +42,9 @@ export function ParametrizedEndpoint(props: ParametrizedEndpointProps) {
42
42
  );
43
43
 
44
44
  return (
45
- <ay.StatementList>
45
+ <StatementList>
46
46
  {params}
47
47
  {resolvedEndpoint}
48
- </ay.StatementList>
48
+ </StatementList>
49
49
  );
50
50
  }
@@ -1,4 +1,4 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { Children, For, SourceDirectory, StatementList } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import * as cl from "@typespec/http-client";
4
4
  import { useClientLibrary } from "@typespec/http-client";
@@ -6,22 +6,22 @@ import { ClientContext } from "./client-context/client-context.jsx";
6
6
  import { ClientOperations } from "./client-operation.jsx";
7
7
 
8
8
  export interface OperationsDirectoryProps {
9
- children?: ay.Children;
9
+ children?: Children;
10
10
  }
11
11
 
12
12
  export function OperationsDirectory(props: OperationsDirectoryProps) {
13
13
  const { topLevel: clients } = useClientLibrary();
14
14
  // If it is the root client, we don't need to create a directory
15
15
  return (
16
- <ay.For each={clients} joiner="," line>
16
+ <For each={clients} joiner="," line>
17
17
  {(client) => (
18
- <ay.StatementList>
18
+ <StatementList>
19
19
  <ClientOperations client={client} />
20
20
  <ClientContext client={client} />
21
21
  <SubClients client={client} />
22
- </ay.StatementList>
22
+ </StatementList>
23
23
  )}
24
- </ay.For>
24
+ </For>
25
25
  );
26
26
  }
27
27
 
@@ -33,18 +33,18 @@ export function SubClients(props: SubClientsProps) {
33
33
  const subClients = props.client.subClients;
34
34
 
35
35
  return (
36
- <ay.For each={subClients}>
36
+ <For each={subClients}>
37
37
  {(subClient) => {
38
38
  const namePolicy = ts.useTSNamePolicy();
39
39
  const subClientName = namePolicy.getName(subClient.name, "variable");
40
40
  return (
41
- <ay.SourceDirectory path={subClientName}>
41
+ <SourceDirectory path={subClientName}>
42
42
  <ClientOperations client={subClient} />
43
43
  <ClientContext client={subClient} />
44
44
  <SubClients client={subClient} />
45
- </ay.SourceDirectory>
45
+ </SourceDirectory>
46
46
  );
47
47
  }}
48
- </ay.For>
48
+ </For>
49
49
  );
50
50
  }
@@ -1,4 +1,4 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { For, List, Refkey, refkey } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import { useTsp } from "@typespec/emitter-framework";
4
4
  import { FunctionDeclaration, TypeExpression } from "@typespec/emitter-framework/typescript";
@@ -28,26 +28,26 @@ export function ClientOperations(props: ClientOperationsProps) {
28
28
 
29
29
  return (
30
30
  <ts.SourceFile path={`${fileName}.ts`}>
31
- <ay.For each={clientOperations}>
31
+ <For each={clientOperations}>
32
32
  {(operation) => (
33
33
  <OperationPipeline
34
34
  httpOperation={operation.httpOperation}
35
35
  pipeline={{ handlers: [PaginatedOperationHandler] }}
36
36
  />
37
37
  )}
38
- </ay.For>
38
+ </For>
39
39
  </ts.SourceFile>
40
40
  );
41
41
  }
42
42
 
43
43
  export interface ClientOperationProps {
44
44
  httpOperation: HttpOperation;
45
- refkey: ay.Refkey;
45
+ refkey: Refkey;
46
46
  internal?: boolean;
47
47
  }
48
48
 
49
- function getClientOperationOptionsParamRef(httpOperation: HttpOperation): ay.Refkey {
50
- return ay.refkey(httpOperation, "client-operation-options-parameter");
49
+ function getClientOperationOptionsParamRef(httpOperation: HttpOperation): Refkey {
50
+ return refkey(httpOperation, "client-operation-options-parameter");
51
51
  }
52
52
 
53
53
  export function ClientOperation(props: ClientOperationProps) {
@@ -65,7 +65,7 @@ export function ClientOperation(props: ClientOperationProps) {
65
65
  }
66
66
 
67
67
  const returnType = $.httpOperation.getReturnType(props.httpOperation);
68
- const responseRefkey = ay.refkey(props.httpOperation, "http-response");
68
+ const responseRefkey = refkey(props.httpOperation, "http-response");
69
69
  const clientContextInterfaceRef = getClientcontextDeclarationRef(client);
70
70
  const signatureParams: ts.ParameterDescriptor[] = [
71
71
  {
@@ -75,7 +75,7 @@ export function ClientOperation(props: ClientOperationProps) {
75
75
  ...getOperationParameters(props.httpOperation, optionsRefkey),
76
76
  ];
77
77
  return (
78
- <ay.List hardline>
78
+ <List hardline>
79
79
  <OperationOptionsDeclaration operation={props.httpOperation} />
80
80
  <FunctionDeclaration
81
81
  export={!props.internal}
@@ -86,16 +86,16 @@ export function ClientOperation(props: ClientOperationProps) {
86
86
  parameters={signatureParams}
87
87
  refkey={props.refkey}
88
88
  >
89
- <ay.List hardline>
89
+ <List hardline>
90
90
  <HttpRequest
91
91
  httpOperation={props.httpOperation}
92
92
  responseRefkey={responseRefkey}
93
93
  operationOptionsParamRefkey={optionsRefkey}
94
94
  />
95
95
  <HttpResponse httpOperation={props.httpOperation} responseRefkey={responseRefkey} />
96
- </ay.List>
96
+ </List>
97
97
  </FunctionDeclaration>
98
98
  ;
99
- </ay.List>
99
+ </List>
100
100
  );
101
101
  }
@@ -1,4 +1,4 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { For, List, Refkey, refkey } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import { useTsp } from "@typespec/emitter-framework";
4
4
  import { ClassMethod } from "@typespec/emitter-framework/typescript";
@@ -18,19 +18,19 @@ export function Client(props: ClientProps) {
18
18
  const { topLevel } = useClientLibrary();
19
19
 
20
20
  return (
21
- <ay.For each={topLevel} hardline>
21
+ <For each={topLevel} hardline>
22
22
  {(client) => {
23
23
  const fileName = namePolicy.getName($.client.getName(client), "variable");
24
24
  const flatClients = flattenClients(client);
25
25
  return (
26
26
  <ts.SourceFile path={`${fileName}.ts`}>
27
- <ay.For each={flatClients} hardline>
27
+ <For each={flatClients} hardline>
28
28
  {(client) => <ClientClass client={client} />}
29
- </ay.For>
29
+ </For>
30
30
  </ts.SourceFile>
31
31
  );
32
32
  }}
33
- </ay.For>
33
+ </For>
34
34
  );
35
35
  }
36
36
 
@@ -39,11 +39,11 @@ export interface ClientClassProps {
39
39
  }
40
40
 
41
41
  export function getClientClassRef(client: cl.Client) {
42
- return ay.refkey(client.type, "client-class");
42
+ return refkey(client.type, "client-class");
43
43
  }
44
44
 
45
45
  function getClientContextFieldRef(client: cl.Client) {
46
- return ay.refkey(client.type, "client-context");
46
+ return refkey(client.type, "client-context");
47
47
  }
48
48
  export function ClientClass(props: ClientClassProps) {
49
49
  const { $ } = useTsp();
@@ -56,20 +56,20 @@ export function ClientClass(props: ClientClassProps) {
56
56
  const operations = props.client.operations;
57
57
  return (
58
58
  <ts.ClassDeclaration export name={clientName} refkey={clientClassRef}>
59
- <ay.List hardline>
59
+ <List hardline>
60
60
  <ts.ClassField
61
61
  name="context"
62
62
  jsPrivate
63
63
  refkey={contextMemberRef}
64
64
  type={contextDeclarationRef}
65
65
  />
66
- <ay.For each={subClients} hardline semicolon>
66
+ <For each={subClients} hardline semicolon>
67
67
  {(subClient) => <SubClientClassField client={subClient} />}
68
- </ay.For>
68
+ </For>
69
69
  <ClientConstructor client={props.client} />
70
- <ay.For each={operations} hardline semicolon>
70
+ <For each={operations} hardline semicolon>
71
71
  {(op) => {
72
- const parameters = getOperationParameters(op.httpOperation, ay.refkey());
72
+ const parameters = getOperationParameters(op.httpOperation, refkey());
73
73
  const args = parameters.flatMap((p) => p.refkey);
74
74
  const isPaging = Boolean($.operation.getPagingMetadata(op.httpOperation.operation));
75
75
 
@@ -83,15 +83,15 @@ export function ClientClass(props: ClientClassProps) {
83
83
  >
84
84
  return{" "}
85
85
  <ts.FunctionCallExpression
86
- target={ay.refkey(op.httpOperation.operation)}
86
+ target={refkey(op.httpOperation.operation)}
87
87
  args={[contextMemberRef, ...args]}
88
88
  />
89
89
  ;
90
90
  </ClassMethod>
91
91
  );
92
92
  }}
93
- </ay.For>
94
- </ay.List>
93
+ </For>
94
+ </List>
95
95
  </ts.ClassDeclaration>
96
96
  );
97
97
  }
@@ -101,7 +101,7 @@ interface SubClientClassFieldProps {
101
101
  }
102
102
 
103
103
  function getSubClientClassFieldRef(client: cl.Client) {
104
- return ay.refkey(client.type, "client-field");
104
+ return refkey(client.type, "client-field");
105
105
  }
106
106
 
107
107
  function SubClientClassField(props: SubClientClassFieldProps) {
@@ -131,14 +131,14 @@ function ClientConstructor(props: ClientConstructorProps) {
131
131
  );
132
132
  const clientContextFieldRef = getClientContextFieldRef(props.client);
133
133
  const clientContextFactoryRef = getClientContextFactoryRef(props.client);
134
- const constructorParameters = buildClientParameters(props.client, ay.refkey());
134
+ const constructorParameters = buildClientParameters(props.client, refkey());
135
135
  const args = Object.values(constructorParameters).map((p) => p.refkey);
136
136
 
137
137
  return (
138
138
  <ts.ClassMethod name="constructor" parameters={constructorParameters}>
139
139
  {clientContextFieldRef} ={" "}
140
140
  <ts.FunctionCallExpression target={clientContextFactoryRef} args={args} />;<br />
141
- <ay.For each={subClients} joiner=";" hardline>
141
+ <For each={subClients} joiner=";" hardline>
142
142
  {(subClient) => {
143
143
  const subClientFieldRef = getSubClientClassFieldRef(subClient);
144
144
  const subClientArgs = calculateSubClientArgs(subClient, constructorParameters);
@@ -148,13 +148,13 @@ function ClientConstructor(props: ClientConstructorProps) {
148
148
  </>
149
149
  );
150
150
  }}
151
- </ay.For>
151
+ </For>
152
152
  </ts.ClassMethod>
153
153
  );
154
154
  }
155
155
 
156
156
  function calculateSubClientArgs(subClient: cl.Client, parentParams: ts.ParameterDescriptor[]) {
157
- const subClientParams = buildClientParameters(subClient, ay.refkey()).map((p) => p.name);
157
+ const subClientParams = buildClientParameters(subClient, refkey()).map((p) => p.name);
158
158
  return parentParams
159
159
  .filter(({ name }) => subClientParams.includes(name))
160
160
  .flatMap((p) => (p.refkey ? p.refkey : []));
@@ -162,7 +162,7 @@ function calculateSubClientArgs(subClient: cl.Client, parentParams: ts.Parameter
162
162
 
163
163
  export interface NewClientExpressionProps {
164
164
  client: cl.Client;
165
- args: ay.Refkey[];
165
+ args: Refkey[];
166
166
  }
167
167
 
168
168
  function NewClientExpression(props: NewClientExpressionProps) {
@@ -1,4 +1,4 @@
1
- import { Children } from "@alloy-js/core";
1
+ import { type Children } from "@alloy-js/core";
2
2
  import { EncodingContext } from "../context/encoding/encoding-context.jsx";
3
3
  import { EncodingDefaults } from "../context/encoding/types.js";
4
4
  export interface EncodingProviderProps {
@@ -1,4 +1,4 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { Children, code, For, List, NamePolicyContext, useNamePolicy } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import { useTransformNamePolicy } from "@typespec/emitter-framework";
4
4
  import { HttpOperation, HttpProperty } from "@typespec/http";
@@ -6,13 +6,13 @@ import { getDefaultValue, hasDefaultValue } from "../utils/parameters.jsx";
6
6
  import { JsonTransform } from "./transforms/json/json-transform.jsx";
7
7
  export interface HttpRequestParametersExpressionProps {
8
8
  httpOperation: HttpOperation;
9
- optionsParameter: ay.Children;
9
+ optionsParameter: Children;
10
10
  parameters?: HttpProperty[];
11
- children?: ay.Children;
11
+ children?: Children;
12
12
  }
13
13
 
14
14
  export function HttpRequestParametersExpression(props: HttpRequestParametersExpressionProps) {
15
- const parameters: ay.Children[] = [];
15
+ const parameters: Children[] = [];
16
16
  const transformNamer = useTransformNamePolicy();
17
17
 
18
18
  if (props.children || (Array.isArray(props.children) && props.children.length)) {
@@ -27,7 +27,7 @@ export function HttpRequestParametersExpression(props: HttpRequestParametersExpr
27
27
 
28
28
  const optionsParamRef = props.optionsParameter ?? "options";
29
29
  const members = (
30
- <ay.For each={props.parameters} line comma>
30
+ <For each={props.parameters} line comma>
31
31
  {(httpProperty) => {
32
32
  const defaultValue = getDefaultValue(httpProperty);
33
33
  const propertyExpression = buildMemberChainExpression(
@@ -45,14 +45,14 @@ export function HttpRequestParametersExpression(props: HttpRequestParametersExpr
45
45
  </>
46
46
  );
47
47
  return (
48
- <ay.NamePolicyContext.Provider value={{ getName: (n) => n }}>
48
+ <NamePolicyContext.Provider value={{ getName: (n) => n }}>
49
49
  <ts.ObjectProperty name={transportParamName} value={paramValue} />
50
- </ay.NamePolicyContext.Provider>
50
+ </NamePolicyContext.Provider>
51
51
  );
52
52
  }
53
53
 
54
54
  if (propertyExpression.isNullish) {
55
- return ay.code`
55
+ return code`
56
56
  ...(${propertyExpression.fullExpression} && {${(<JsonTransform itemRef={propertyExpression.leadingExpression} type={httpProperty.property} target="transport" />)}})
57
57
  `;
58
58
  } else {
@@ -65,7 +65,7 @@ export function HttpRequestParametersExpression(props: HttpRequestParametersExpr
65
65
  );
66
66
  }
67
67
  }}
68
- </ay.For>
68
+ </For>
69
69
  );
70
70
 
71
71
  parameters.push(members);
@@ -76,8 +76,8 @@ export function HttpRequestParametersExpression(props: HttpRequestParametersExpr
76
76
  interface MemberChainExpression {
77
77
  propertyName: string;
78
78
  isNullish: boolean;
79
- fullExpression: ay.Children;
80
- leadingExpression?: ay.Children;
79
+ fullExpression: Children;
80
+ leadingExpression?: Children;
81
81
  }
82
82
 
83
83
  /**
@@ -101,11 +101,11 @@ interface MemberChainExpression {
101
101
  function buildMemberChainExpression(
102
102
  httpOperation: HttpOperation,
103
103
  httpProperty: HttpProperty,
104
- optionsParamRef?: ay.Children,
104
+ optionsParamRef?: Children,
105
105
  ): MemberChainExpression {
106
- const segments: ay.Children[] = [];
106
+ const segments: Children[] = [];
107
107
  let isNullish = httpProperty.property.optional === true;
108
- const namePolicy = ay.useNamePolicy();
108
+ const namePolicy = useNamePolicy();
109
109
  const propertyApplicationName = namePolicy.getName(httpProperty.property.name, "property");
110
110
 
111
111
  // If the property is at the top level, return early
@@ -114,8 +114,8 @@ function buildMemberChainExpression(
114
114
  return {
115
115
  propertyName: propertyApplicationName,
116
116
  isNullish,
117
- fullExpression: ay.code`${optionsParamRef}?.${propertyApplicationName}`,
118
- leadingExpression: ay.code`${optionsParamRef}`,
117
+ fullExpression: code`${optionsParamRef}?.${propertyApplicationName}`,
118
+ leadingExpression: code`${optionsParamRef}`,
119
119
  };
120
120
  }
121
121
  return {
@@ -146,7 +146,7 @@ function buildMemberChainExpression(
146
146
 
147
147
  // Use direct property access if possible.
148
148
  if (isValidIdentifier(parentName)) {
149
- segments.unshift(ay.code`${parentName}`);
149
+ segments.unshift(code`${parentName}`);
150
150
  } else {
151
151
  // For non-valid identifiers, use bracket notation.
152
152
  segments.unshift(`[${JSON.stringify(parentName)}]`);
@@ -158,11 +158,11 @@ function buildMemberChainExpression(
158
158
 
159
159
  const fullExpression = (
160
160
  <>
161
- <ay.List children={segments} />
161
+ <List children={segments} />
162
162
  {propertyApplicationName}
163
163
  </>
164
164
  );
165
- const leadingExpression = <ay.List children={segments.slice(0, -1)} />;
165
+ const leadingExpression = <List children={segments.slice(0, -1)} />;
166
166
 
167
167
  return {
168
168
  propertyName: propertyApplicationName,
@@ -1,5 +1,4 @@
1
- import * as ay from "@alloy-js/core";
2
- import { For } from "@alloy-js/core";
1
+ import { For, refkey } from "@alloy-js/core";
3
2
  import * as ts from "@alloy-js/typescript";
4
3
  import { useTsp } from "@typespec/emitter-framework";
5
4
  import * as ef from "@typespec/emitter-framework/typescript";
@@ -18,7 +17,7 @@ export function Models(props: ModelsProps) {
18
17
  <For each={dataTypes} hardline>
19
18
  {(type) => {
20
19
  return $.array.is(type) || $.record.is(type) ? null : (
21
- <ef.TypeDeclaration export type={type} refkey={ay.refkey(type)} />
20
+ <ef.TypeDeclaration export type={type} refkey={refkey(type)} />
22
21
  );
23
22
  }}
24
23
  </For>