@typespec/http-client-js 0.7.0-dev.1 → 0.7.0-dev.3

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 (179) hide show
  1. package/dist/src/components/client-context/client-context-declaration.d.ts +2 -3
  2. package/dist/src/components/client-context/client-context-declaration.d.ts.map +1 -1
  3. package/dist/src/components/client-context/client-context-declaration.js +2 -2
  4. package/dist/src/components/client-context/client-context-factory.d.ts +3 -3
  5. package/dist/src/components/client-context/client-context-factory.d.ts.map +1 -1
  6. package/dist/src/components/client-context/client-context-factory.js +10 -10
  7. package/dist/src/components/client-context/client-context-options.d.ts +3 -3
  8. package/dist/src/components/client-context/client-context-options.d.ts.map +1 -1
  9. package/dist/src/components/client-context/client-context-options.js +3 -3
  10. package/dist/src/components/client-context/client-context.d.ts +3 -3
  11. package/dist/src/components/client-context/client-context.d.ts.map +1 -1
  12. package/dist/src/components/client-context/parametrized-endpoint.d.ts +3 -3
  13. package/dist/src/components/client-context/parametrized-endpoint.d.ts.map +1 -1
  14. package/dist/src/components/client-context/parametrized-endpoint.js +5 -5
  15. package/dist/src/components/client-directory.d.ts +4 -4
  16. package/dist/src/components/client-directory.d.ts.map +1 -1
  17. package/dist/src/components/client-directory.js +5 -5
  18. package/dist/src/components/client-operation.d.ts +4 -4
  19. package/dist/src/components/client-operation.d.ts.map +1 -1
  20. package/dist/src/components/client-operation.js +6 -6
  21. package/dist/src/components/client.d.ts +5 -5
  22. package/dist/src/components/client.d.ts.map +1 -1
  23. package/dist/src/components/client.js +14 -14
  24. package/dist/src/components/encoding-provider.d.ts +1 -1
  25. package/dist/src/components/encoding-provider.d.ts.map +1 -1
  26. package/dist/src/components/http-request-parameters-expression.d.ts +4 -4
  27. package/dist/src/components/http-request-parameters-expression.d.ts.map +1 -1
  28. package/dist/src/components/http-request-parameters-expression.js +10 -10
  29. package/dist/src/components/models.d.ts +1 -2
  30. package/dist/src/components/models.d.ts.map +1 -1
  31. package/dist/src/components/models.js +2 -3
  32. package/dist/src/components/operation-handlers/operation-pipeline.d.ts +1 -2
  33. package/dist/src/components/operation-handlers/operation-pipeline.d.ts.map +1 -1
  34. package/dist/src/components/operation-handlers/operation-pipeline.js +2 -2
  35. package/dist/src/components/operation-handlers/paging/page-response.d.ts +2 -3
  36. package/dist/src/components/operation-handlers/paging/page-response.d.ts.map +1 -1
  37. package/dist/src/components/operation-handlers/paging/page-response.js +3 -3
  38. package/dist/src/components/operation-handlers/paging/page-settings.d.ts +2 -3
  39. package/dist/src/components/operation-handlers/paging/page-settings.d.ts.map +1 -1
  40. package/dist/src/components/operation-handlers/paging/page-settings.js +3 -3
  41. package/dist/src/components/operation-handlers/paging/paginated-operation-handler.d.ts.map +1 -1
  42. package/dist/src/components/operation-handlers/paging/paginated-operation-handler.js +16 -16
  43. package/dist/src/components/operation-handlers/paging/request-send.d.ts +2 -3
  44. package/dist/src/components/operation-handlers/paging/request-send.d.ts.map +1 -1
  45. package/dist/src/components/operation-handlers/paging/request-send.js +1 -2
  46. package/dist/src/components/operation-handlers/types.d.ts +1 -1
  47. package/dist/src/components/operation-handlers/types.d.ts.map +1 -1
  48. package/dist/src/components/operation-options.d.ts +2 -3
  49. package/dist/src/components/operation-options.d.ts.map +1 -1
  50. package/dist/src/components/operation-options.js +3 -3
  51. package/dist/src/components/operation-parameters.d.ts +2 -2
  52. package/dist/src/components/operation-parameters.d.ts.map +1 -1
  53. package/dist/src/components/operation-parameters.js +2 -2
  54. package/dist/src/components/output.d.ts +3 -3
  55. package/dist/src/components/output.d.ts.map +1 -1
  56. package/dist/src/components/static-helpers/bytes-encoding.d.ts +6 -5
  57. package/dist/src/components/static-helpers/bytes-encoding.d.ts.map +1 -1
  58. package/dist/src/components/static-helpers/bytes-encoding.js +15 -19
  59. package/dist/src/components/static-helpers/interfaces.d.ts +3 -4
  60. package/dist/src/components/static-helpers/interfaces.d.ts.map +1 -1
  61. package/dist/src/components/static-helpers/interfaces.js +3 -3
  62. package/dist/src/components/static-helpers/multipart-helpers.d.ts +4 -5
  63. package/dist/src/components/static-helpers/multipart-helpers.d.ts.map +1 -1
  64. package/dist/src/components/static-helpers/multipart-helpers.js +8 -10
  65. package/dist/src/components/static-helpers/paging-helper.d.ts +3 -4
  66. package/dist/src/components/static-helpers/paging-helper.d.ts.map +1 -1
  67. package/dist/src/components/static-helpers/paging-helper.js +17 -23
  68. package/dist/src/components/static-helpers/rest-error.d.ts +3 -4
  69. package/dist/src/components/static-helpers/rest-error.d.ts.map +1 -1
  70. package/dist/src/components/static-helpers/rest-error.js +19 -25
  71. package/dist/src/components/testing/client-options.d.ts +3 -3
  72. package/dist/src/components/testing/client-options.d.ts.map +1 -1
  73. package/dist/src/components/testing/client-options.js +2 -2
  74. package/dist/src/components/transforms/content-type-encoding-provider.d.ts +1 -1
  75. package/dist/src/components/transforms/content-type-encoding-provider.d.ts.map +1 -1
  76. package/dist/src/components/transforms/json/json-array-transform.d.ts +6 -6
  77. package/dist/src/components/transforms/json/json-array-transform.d.ts.map +1 -1
  78. package/dist/src/components/transforms/json/json-array-transform.js +5 -5
  79. package/dist/src/components/transforms/json/json-model-additional-properties-transform.d.ts +4 -4
  80. package/dist/src/components/transforms/json/json-model-additional-properties-transform.d.ts.map +1 -1
  81. package/dist/src/components/transforms/json/json-model-additional-properties-transform.js +4 -4
  82. package/dist/src/components/transforms/json/json-model-base-transform.d.ts +4 -4
  83. package/dist/src/components/transforms/json/json-model-base-transform.d.ts.map +1 -1
  84. package/dist/src/components/transforms/json/json-model-property-transform.d.ts +3 -3
  85. package/dist/src/components/transforms/json/json-model-property-transform.d.ts.map +1 -1
  86. package/dist/src/components/transforms/json/json-model-property-transform.js +3 -3
  87. package/dist/src/components/transforms/json/json-model-transform.d.ts +6 -6
  88. package/dist/src/components/transforms/json/json-model-transform.d.ts.map +1 -1
  89. package/dist/src/components/transforms/json/json-model-transform.js +8 -8
  90. package/dist/src/components/transforms/json/json-record-transform.d.ts +6 -6
  91. package/dist/src/components/transforms/json/json-record-transform.d.ts.map +1 -1
  92. package/dist/src/components/transforms/json/json-record-transform.js +5 -5
  93. package/dist/src/components/transforms/json/json-transform-discriminator.d.ts +5 -5
  94. package/dist/src/components/transforms/json/json-transform-discriminator.d.ts.map +1 -1
  95. package/dist/src/components/transforms/json/json-transform-discriminator.js +13 -13
  96. package/dist/src/components/transforms/json/json-transform.d.ts +6 -5
  97. package/dist/src/components/transforms/json/json-transform.d.ts.map +1 -1
  98. package/dist/src/components/transforms/json/json-transform.js +2 -2
  99. package/dist/src/components/transforms/json/union-transform.d.ts +6 -6
  100. package/dist/src/components/transforms/json/union-transform.d.ts.map +1 -1
  101. package/dist/src/components/transforms/json/union-transform.js +6 -6
  102. package/dist/src/components/transforms/json/utils/transport-namer.d.ts +1 -1
  103. package/dist/src/components/transforms/json/utils/transport-namer.d.ts.map +1 -1
  104. package/dist/src/components/transforms/multipart/array-part-transform.d.ts +3 -3
  105. package/dist/src/components/transforms/multipart/array-part-transform.d.ts.map +1 -1
  106. package/dist/src/components/transforms/multipart/array-part-transform.js +5 -5
  107. package/dist/src/components/transforms/multipart/file-part-transform.d.ts +3 -3
  108. package/dist/src/components/transforms/multipart/file-part-transform.d.ts.map +1 -1
  109. package/dist/src/components/transforms/multipart/file-part-transform.js +2 -2
  110. package/dist/src/components/transforms/multipart/multipart-transform.d.ts +1 -2
  111. package/dist/src/components/transforms/multipart/multipart-transform.d.ts.map +1 -1
  112. package/dist/src/components/transforms/multipart/multipart-transform.js +2 -2
  113. package/dist/src/components/transforms/multipart/part-transform.d.ts +3 -3
  114. package/dist/src/components/transforms/multipart/part-transform.d.ts.map +1 -1
  115. package/dist/src/components/transforms/multipart/simple-part-transform.d.ts +3 -3
  116. package/dist/src/components/transforms/multipart/simple-part-transform.d.ts.map +1 -1
  117. package/dist/src/components/transforms/multipart/simple-part-transform.js +5 -5
  118. package/dist/src/components/transforms/operation-transform-declaration.d.ts +6 -6
  119. package/dist/src/components/transforms/operation-transform-declaration.d.ts.map +1 -1
  120. package/dist/src/components/transforms/operation-transform-declaration.js +3 -3
  121. package/dist/src/components/transforms/transform-name-policy.d.ts +1 -1
  122. package/dist/src/components/transforms/transform-name-policy.d.ts.map +1 -1
  123. package/dist/src/emitter.js +6 -6
  124. package/dist/src/utils/multipart.d.ts +1 -1
  125. package/dist/src/utils/multipart.d.ts.map +1 -1
  126. package/dist/src/utils/parameters.d.ts +2 -2
  127. package/dist/src/utils/parameters.d.ts.map +1 -1
  128. package/dist/src/utils/parameters.js +6 -6
  129. package/dist/tsconfig.tsbuildinfo +1 -1
  130. package/package.json +4 -4
  131. package/src/components/client-context/client-context-declaration.tsx +2 -2
  132. package/src/components/client-context/client-context-factory.tsx +19 -19
  133. package/src/components/client-context/client-context-options.tsx +5 -5
  134. package/src/components/client-context/client-context.tsx +2 -2
  135. package/src/components/client-context/parametrized-endpoint.tsx +8 -8
  136. package/src/components/client-directory.tsx +10 -10
  137. package/src/components/client-operation.tsx +11 -11
  138. package/src/components/client.tsx +21 -21
  139. package/src/components/encoding-provider.tsx +1 -1
  140. package/src/components/http-request-parameters-expression.tsx +19 -19
  141. package/src/components/models.tsx +2 -3
  142. package/src/components/operation-handlers/operation-pipeline.tsx +2 -2
  143. package/src/components/operation-handlers/paging/page-response.tsx +4 -4
  144. package/src/components/operation-handlers/paging/page-settings.tsx +4 -4
  145. package/src/components/operation-handlers/paging/paginated-operation-handler.tsx +18 -19
  146. package/src/components/operation-handlers/paging/request-send.tsx +1 -2
  147. package/src/components/operation-handlers/types.tsx +1 -1
  148. package/src/components/operation-options.tsx +4 -4
  149. package/src/components/operation-parameters.tsx +3 -3
  150. package/src/components/output.tsx +2 -2
  151. package/src/components/serializers.tsx +1 -1
  152. package/src/components/static-helpers/bytes-encoding.tsx +17 -16
  153. package/src/components/static-helpers/interfaces.tsx +3 -3
  154. package/src/components/static-helpers/multipart-helpers.tsx +7 -7
  155. package/src/components/static-helpers/paging-helper.tsx +17 -20
  156. package/src/components/static-helpers/rest-error.tsx +17 -17
  157. package/src/components/testing/client-options.tsx +3 -3
  158. package/src/components/transforms/content-type-encoding-provider.tsx +1 -1
  159. package/src/components/transforms/json/json-array-transform.tsx +8 -8
  160. package/src/components/transforms/json/json-model-additional-properties-transform.tsx +6 -6
  161. package/src/components/transforms/json/json-model-base-transform.tsx +3 -3
  162. package/src/components/transforms/json/json-model-property-transform.tsx +6 -6
  163. package/src/components/transforms/json/json-model-transform.tsx +12 -14
  164. package/src/components/transforms/json/json-record-transform.tsx +8 -8
  165. package/src/components/transforms/json/json-transform-discriminator.tsx +12 -12
  166. package/src/components/transforms/json/json-transform.tsx +6 -5
  167. package/src/components/transforms/json/union-transform.tsx +8 -8
  168. package/src/components/transforms/json/utils/transport-namer.ts +1 -1
  169. package/src/components/transforms/multipart/array-part-transform.tsx +6 -5
  170. package/src/components/transforms/multipart/file-part-transform.tsx +5 -5
  171. package/src/components/transforms/multipart/multipart-transform.tsx +3 -3
  172. package/src/components/transforms/multipart/part-transform.tsx +2 -2
  173. package/src/components/transforms/multipart/simple-part-transform.tsx +8 -8
  174. package/src/components/transforms/operation-transform-declaration.tsx +7 -6
  175. package/src/components/transforms/operation-transform-expression.tsx +1 -1
  176. package/src/components/transforms/transform-name-policy.ts +1 -1
  177. package/src/emitter.tsx +11 -11
  178. package/src/utils/multipart.ts +1 -1
  179. package/src/utils/parameters.tsx +9 -9
@@ -1,4 +1,4 @@
1
- import { Children } from "@alloy-js/core";
1
+ import { type Children } from "@alloy-js/core";
2
2
  import { EncodingDefaults } from "../../context/encoding/types.js";
3
3
  import { EncodingProvider } from "../encoding-provider.jsx";
4
4
 
@@ -1,13 +1,13 @@
1
- import * as ay from "@alloy-js/core";
2
1
  import * as ts from "@alloy-js/typescript";
3
2
  import * as ef from "@typespec/emitter-framework/typescript";
4
3
 
5
- import { Model } from "@typespec/compiler";
4
+ import { type Children, type Refkey, code, refkey } from "@alloy-js/core";
5
+ import type { Model } from "@typespec/compiler";
6
6
  import { useTsp } from "@typespec/emitter-framework";
7
7
  import { JsonTransform } from "./json-transform.jsx";
8
8
 
9
9
  export interface JsonArrayTransformProps {
10
- itemRef: ay.Refkey | ay.Children;
10
+ itemRef: Refkey | Children;
11
11
  type: Model;
12
12
  target: "transport" | "application";
13
13
  }
@@ -20,7 +20,7 @@ export function JsonArrayTransform(props: JsonArrayTransformProps) {
20
20
 
21
21
  const elementType = $.array.getElementType(props.type);
22
22
 
23
- return ay.code`
23
+ return code`
24
24
  if(!${props.itemRef}) {
25
25
  return ${props.itemRef} as any;
26
26
  }
@@ -38,8 +38,8 @@ export function JsonArrayTransform(props: JsonArrayTransformProps) {
38
38
  export function getJsonArrayTransformRefkey(
39
39
  type: Model,
40
40
  target: "transport" | "application",
41
- ): ay.Refkey {
42
- return ay.refkey(type, "json_array_transform", target);
41
+ ): Refkey {
42
+ return refkey(type, "json_array_transform", target);
43
43
  }
44
44
 
45
45
  export interface JsonArrayTransformDeclarationProps {
@@ -63,10 +63,10 @@ export function JsonArrayTransformDeclaration(props: JsonArrayTransformDeclarati
63
63
  "function",
64
64
  );
65
65
 
66
- const itemType = ay.code`Array<${(<ef.TypeExpression type={elementType} />)}>`;
66
+ const itemType = code`Array<${(<ef.TypeExpression type={elementType} />)}>`;
67
67
  const returnType = props.target === "transport" ? "any" : itemType;
68
68
  const inputType = props.target === "transport" ? <>{itemType} | null</> : "any";
69
- const inputRef = ay.refkey();
69
+ const inputRef = refkey();
70
70
 
71
71
  const parameters: ts.ParameterDescriptor[] = [
72
72
  { name: "items_", type: inputType, refkey: inputRef, optional: true },
@@ -1,11 +1,11 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { Children, code, mapJoin } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
- import { Model } from "@typespec/compiler";
3
+ import type { Model } from "@typespec/compiler";
4
4
  import { useTsp } from "@typespec/emitter-framework";
5
5
  import { getJsonRecordTransformRefkey } from "./json-record-transform.jsx";
6
6
 
7
7
  export interface JsonAdditionalPropertiesTransformProps {
8
- itemRef: ay.Children;
8
+ itemRef: Children;
9
9
  type: Model;
10
10
  target: "transport" | "application";
11
11
  }
@@ -20,7 +20,7 @@ export function JsonAdditionalPropertiesTransform(props: JsonAdditionalPropertie
20
20
 
21
21
  if (props.target === "application") {
22
22
  const properties = $.model.getProperties(props.type, { includeExtended: true });
23
- const destructuredProperties = ay.mapJoin(
23
+ const destructuredProperties = mapJoin(
24
24
  () => properties,
25
25
  (name) => name,
26
26
  {
@@ -30,7 +30,7 @@ export function JsonAdditionalPropertiesTransform(props: JsonAdditionalPropertie
30
30
  );
31
31
 
32
32
  // Inline destructuring that extracts the properties and passes the rest to jsonRecordUnknownToApplicationTransform_2
33
- const inlineDestructure = ay.code`
33
+ const inlineDestructure = code`
34
34
  ${getJsonRecordTransformRefkey(additionalProperties, props.target)}(
35
35
  (({ ${destructuredProperties} ...rest }) => rest)(${props.itemRef})
36
36
  ),
@@ -43,7 +43,7 @@ export function JsonAdditionalPropertiesTransform(props: JsonAdditionalPropertie
43
43
  );
44
44
  }
45
45
 
46
- const itemRef = ay.code`${props.itemRef}.additionalProperties`;
46
+ const itemRef = code`${props.itemRef}.additionalProperties`;
47
47
 
48
48
  return (
49
49
  <>
@@ -1,9 +1,9 @@
1
- import * as ay from "@alloy-js/core";
2
- import { Model } from "@typespec/compiler";
1
+ import { type Children } from "@alloy-js/core";
2
+ import type { Model } from "@typespec/compiler";
3
3
  import { JsonTransform } from "./json-transform.jsx";
4
4
 
5
5
  export interface JsonModelBaseTransformProps {
6
- itemRef: ay.Children;
6
+ itemRef: Children;
7
7
  type: Model;
8
8
  target: "transport" | "application";
9
9
  }
@@ -1,4 +1,4 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { Children, code, NamePolicyContext, Refkey } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import { ModelProperty } from "@typespec/compiler";
4
4
  import { useTsp } from "@typespec/emitter-framework";
@@ -8,7 +8,7 @@ import { useTransformNamePolicy } from "../transform-name-policy.js";
8
8
  import { JsonTransform } from "./json-transform.jsx";
9
9
 
10
10
  export interface JsonModelPropertyTransformProps {
11
- itemRef: ay.Refkey | ay.Children;
11
+ itemRef: Refkey | Children;
12
12
  type: ModelProperty;
13
13
  target: "transport" | "application";
14
14
  }
@@ -23,8 +23,8 @@ export function JsonModelPropertyTransform(props: JsonModelPropertyTransformProp
23
23
  const targetName = props.target === "transport" ? transportName : applicationName;
24
24
  const sourceName = props.target === "transport" ? applicationName : transportName;
25
25
 
26
- const propertyValueRef = props.itemRef ? ay.code`${props.itemRef}.${sourceName}` : sourceName;
27
- let propertyValue: ay.Children;
26
+ const propertyValueRef = props.itemRef ? code`${props.itemRef}.${sourceName}` : sourceName;
27
+ let propertyValue: Children;
28
28
 
29
29
  if ($.scalar.is(propertyValueType)) {
30
30
  propertyValue = (
@@ -38,9 +38,9 @@ export function JsonModelPropertyTransform(props: JsonModelPropertyTransformProp
38
38
 
39
39
  if (props.target === "transport") {
40
40
  return (
41
- <ay.NamePolicyContext.Provider value={{ getName: (n) => n }}>
41
+ <NamePolicyContext.Provider value={{ getName: (n) => n }}>
42
42
  <ts.ObjectProperty name={targetName} value={propertyValue} />
43
- </ay.NamePolicyContext.Provider>
43
+ </NamePolicyContext.Provider>
44
44
  );
45
45
  }
46
46
 
@@ -1,7 +1,7 @@
1
- import * as ay from "@alloy-js/core";
2
1
  import * as ts from "@alloy-js/typescript";
3
2
 
4
- import { Model } from "@typespec/compiler";
3
+ import { type Children, code, For, type Refkey, refkey } from "@alloy-js/core";
4
+ import type { Model } from "@typespec/compiler";
5
5
  import { useTsp } from "@typespec/emitter-framework";
6
6
  import { JsonAdditionalPropertiesTransform } from "./json-model-additional-properties-transform.jsx";
7
7
  import { JsonModelPropertyTransform } from "./json-model-property-transform.jsx";
@@ -12,7 +12,7 @@ import {
12
12
  } from "./json-transform-discriminator.jsx";
13
13
 
14
14
  export interface JsonModelTransformProps {
15
- itemRef: ay.Refkey | ay.Children;
15
+ itemRef: Refkey | Children;
16
16
  type: Model;
17
17
  target: "transport" | "application";
18
18
  }
@@ -40,7 +40,7 @@ export function JsonModelTransform(props: JsonModelTransformProps) {
40
40
  ...{discriminate}({props.itemRef}),
41
41
  </>
42
42
  ) : null}
43
- <ay.For each={properties} joiner="," line>
43
+ <For each={properties} joiner="," line>
44
44
  {(property) => {
45
45
  return (
46
46
  <JsonModelPropertyTransform
@@ -50,7 +50,7 @@ export function JsonModelTransform(props: JsonModelTransformProps) {
50
50
  />
51
51
  );
52
52
  }}
53
- </ay.For>
53
+ </For>
54
54
  </ts.ObjectExpression>
55
55
  );
56
56
  }
@@ -58,8 +58,8 @@ export function JsonModelTransform(props: JsonModelTransformProps) {
58
58
  export function getJsonModelTransformRefkey(
59
59
  type: Model,
60
60
  target: "transport" | "application",
61
- ): ay.Refkey {
62
- return ay.refkey(type, "json_model_transform", target);
61
+ ): Refkey {
62
+ return refkey(type, "json_model_transform", target);
63
63
  }
64
64
 
65
65
  export interface JsonModelTransformDeclarationProps {
@@ -67,9 +67,7 @@ export interface JsonModelTransformDeclarationProps {
67
67
  target: "transport" | "application";
68
68
  }
69
69
 
70
- export function JsonModelTransformDeclaration(
71
- props: JsonModelTransformDeclarationProps,
72
- ): ay.Children {
70
+ export function JsonModelTransformDeclaration(props: JsonModelTransformDeclarationProps): Children {
73
71
  const { $ } = useTsp();
74
72
  const namePolicy = ts.useTSNamePolicy();
75
73
  const transformName = namePolicy.getName(
@@ -77,9 +75,9 @@ export function JsonModelTransformDeclaration(
77
75
  "function",
78
76
  );
79
77
 
80
- const returnType = props.target === "transport" ? "any" : ay.refkey(props.type);
81
- const inputType = props.target === "transport" ? <>{ay.refkey(props.type)} | null</> : "any";
82
- const inputRef = ay.refkey();
78
+ const returnType = props.target === "transport" ? "any" : refkey(props.type);
79
+ const inputType = props.target === "transport" ? <>{refkey(props.type)} | null</> : "any";
80
+ const inputRef = refkey();
83
81
 
84
82
  const parameters: ts.ParameterDescriptor[] = [
85
83
  // Make the input optional to make the transform more robust and check against null and undefined
@@ -103,7 +101,7 @@ export function JsonModelTransformDeclaration(
103
101
  parameters={parameters}
104
102
  refkey={declarationRefkey}
105
103
  >
106
- {ay.code`
104
+ {code`
107
105
  if(!${inputRef}) {
108
106
  return ${inputRef} as any;
109
107
  }
@@ -1,12 +1,12 @@
1
- import * as ay from "@alloy-js/core";
2
1
  import * as ts from "@alloy-js/typescript";
3
2
 
4
- import { Model } from "@typespec/compiler";
3
+ import { type Children, type Refkey, code, refkey } from "@alloy-js/core";
4
+ import type { Model } from "@typespec/compiler";
5
5
  import { useTsp } from "@typespec/emitter-framework";
6
6
  import { JsonTransform } from "./json-transform.jsx";
7
7
 
8
8
  export interface JsonRecordTransformProps {
9
- itemRef: ay.Refkey | ay.Children;
9
+ itemRef: Refkey | Children;
10
10
  type: Model;
11
11
  target: "transport" | "application";
12
12
  }
@@ -20,7 +20,7 @@ export function JsonRecordTransform(props: JsonRecordTransformProps) {
20
20
  const elementType = $.record.getElementType(props.type);
21
21
 
22
22
  // TODO: Do we need to cast?
23
- return ay.code`
23
+ return code`
24
24
  if(!${props.itemRef}) {
25
25
  return ${props.itemRef} as any;
26
26
  }
@@ -39,8 +39,8 @@ export function JsonRecordTransform(props: JsonRecordTransformProps) {
39
39
  export function getJsonRecordTransformRefkey(
40
40
  type: Model,
41
41
  target: "transport" | "application",
42
- ): ay.Refkey {
43
- return ay.refkey(type, "json_record_transform", target);
42
+ ): Refkey {
43
+ return refkey(type, "json_record_transform", target);
44
44
  }
45
45
 
46
46
  export interface JsonRecordTransformDeclarationProps {
@@ -64,10 +64,10 @@ export function JsonRecordTransformDeclaration(props: JsonRecordTransformDeclara
64
64
  "function",
65
65
  );
66
66
 
67
- const itemType = ay.code`Record<string, any>`;
67
+ const itemType = code`Record<string, any>`;
68
68
  const returnType = props.target === "transport" ? "any" : itemType;
69
69
  const inputType = props.target === "transport" ? <>{itemType} | null</> : "any";
70
- const inputRef = ay.refkey();
70
+ const inputRef = refkey();
71
71
 
72
72
  const parameters: ts.ParameterDescriptor[] = [
73
73
  { name: "items_", type: inputType, refkey: inputRef, optional: true },
@@ -1,11 +1,11 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { code, mapJoin, refkey, useNamePolicy, type Children, type Refkey } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import { Discriminator, Model, Union } from "@typespec/compiler";
4
4
  import { useTsp } from "@typespec/emitter-framework";
5
5
  import { JsonTransform } from "./json-transform.jsx";
6
6
 
7
7
  export interface JsonTransformDiscriminatorProps {
8
- itemRef: ay.Refkey | ay.Children;
8
+ itemRef: Refkey | Children;
9
9
  discriminator: Discriminator;
10
10
  type: Union | Model;
11
11
  target: "application" | "transport";
@@ -20,18 +20,18 @@ export function JsonTransformDiscriminator(props: JsonTransformDiscriminatorProp
20
20
  const propertyName = props.discriminator.propertyName;
21
21
 
22
22
  if (!discriminatedUnion || !propertyName) {
23
- return ay.code`${props.itemRef}`;
23
+ return code`${props.itemRef}`;
24
24
  }
25
25
 
26
- const discriminatorRef = ay.code`${props.itemRef}.${props.discriminator.propertyName}`;
26
+ const discriminatorRef = code`${props.itemRef}.${props.discriminator.propertyName}`;
27
27
 
28
28
  // Need to cast to make sure that the general types which usually have a broader
29
29
  // type in the discriminator are compatible.
30
- const itemRef = ay.code`${props.itemRef} as any`;
31
- const discriminatingCases = ay.mapJoin(
30
+ const itemRef = code`${props.itemRef} as any`;
31
+ const discriminatingCases = mapJoin(
32
32
  () => discriminatedUnion.variants,
33
33
  (name, variant) => {
34
- return ay.code`
34
+ return code`
35
35
  if( discriminatorValue === ${JSON.stringify(name)}) {
36
36
  return ${(<JsonTransform type={variant} target={props.target} itemRef={itemRef} />)}!
37
37
  }
@@ -52,7 +52,7 @@ export function getJsonTransformDiscriminatorRefkey(
52
52
  type: Union | Model,
53
53
  target: "application" | "transport",
54
54
  ) {
55
- return ay.refkey(type, "json_transform_discriminator_", target);
55
+ return refkey(type, "json_transform_discriminator_", target);
56
56
  }
57
57
 
58
58
  export interface JsonTransformDiscriminatorDeclarationProps {
@@ -77,16 +77,16 @@ export function JsonTransformDiscriminatorDeclaration(
77
77
  return null;
78
78
  }
79
79
 
80
- const namePolicy = ay.useNamePolicy();
80
+ const namePolicy = useNamePolicy();
81
81
  const transformName = namePolicy.getName(
82
82
  `json_${props.type.name}_to_${props.target}_discriminator`,
83
83
  "function",
84
84
  );
85
85
 
86
- const typeRef = ay.refkey(props.type);
86
+ const typeRef = refkey(props.type);
87
87
  const returnType = props.target === "transport" ? "any" : typeRef;
88
88
  const inputType = props.target === "transport" ? typeRef : "any";
89
- const inputRef = ay.refkey();
89
+ const inputRef = refkey();
90
90
 
91
91
  const parameters: ts.ParameterDescriptor[] = [
92
92
  { name: "input_", type: inputType, refkey: inputRef, optional: true },
@@ -100,7 +100,7 @@ export function JsonTransformDiscriminatorDeclaration(
100
100
  parameters={parameters}
101
101
  refkey={getJsonTransformDiscriminatorRefkey(props.type, props.target)}
102
102
  >
103
- {ay.code`
103
+ {code`
104
104
  if(!${inputRef}) {
105
105
  return ${inputRef} as any;
106
106
  }
@@ -1,5 +1,6 @@
1
- import * as ay from "@alloy-js/core";
2
- import { Type } from "@typespec/compiler";
1
+ import { code, Refkey } from "@alloy-js/core";
2
+ import { Children } from "@alloy-js/core/jsx-runtime";
3
+ import type { Type } from "@typespec/compiler";
3
4
  import { useTsp } from "@typespec/emitter-framework";
4
5
  import { ScalarDataTransform } from "../data-transform.jsx";
5
6
  import {
@@ -25,7 +26,7 @@ import {
25
26
  } from "./union-transform.jsx";
26
27
 
27
28
  export interface JsonTransformProps {
28
- itemRef: ay.Refkey | ay.Children;
29
+ itemRef: Refkey | Children;
29
30
  type: Type;
30
31
  target: "transport" | "application";
31
32
  }
@@ -36,7 +37,7 @@ export function JsonTransform(props: JsonTransformProps) {
36
37
  const declaredTransform = getTransformReference(type, props.target);
37
38
 
38
39
  if (declaredTransform) {
39
- return ay.code`${declaredTransform}(${props.itemRef})`;
40
+ return code`${declaredTransform}(${props.itemRef})`;
40
41
  }
41
42
 
42
43
  switch (type.kind) {
@@ -97,7 +98,7 @@ export function JsonTransformDeclaration(props: JsonTransformDeclarationProps) {
97
98
  function getTransformReference(
98
99
  type: Type,
99
100
  target: "transport" | "application",
100
- ): ay.Refkey | undefined {
101
+ ): Refkey | undefined {
101
102
  const { $ } = useTsp();
102
103
  if (type.kind === "Model" && Boolean(type.name)) {
103
104
  if ($.array.is(type)) {
@@ -1,6 +1,6 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { Children, code, refkey, Refkey } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
- import { Union } from "@typespec/compiler";
3
+ import type { Union } from "@typespec/compiler";
4
4
  import { useTsp } from "@typespec/emitter-framework";
5
5
  import {
6
6
  getJsonTransformDiscriminatorRefkey,
@@ -9,7 +9,7 @@ import {
9
9
  import { JsonTransform } from "./json-transform.jsx";
10
10
 
11
11
  export interface JsonUnionTransformProps {
12
- itemRef: ay.Refkey | ay.Children;
12
+ itemRef: Refkey | Children;
13
13
  type: Union;
14
14
  target: "transport" | "application";
15
15
  }
@@ -39,8 +39,8 @@ export function JsonUnionTransform(props: JsonUnionTransformProps) {
39
39
  export function getJsonUnionTransformRefkey(
40
40
  type: Union,
41
41
  target: "transport" | "application",
42
- ): ay.Refkey {
43
- return ay.refkey(type, "json_union_transform", target);
42
+ ): Refkey {
43
+ return refkey(type, "json_union_transform", target);
44
44
  }
45
45
  export interface JsonUnionTransformDeclarationProps {
46
46
  type: Union;
@@ -54,10 +54,10 @@ export function JsonUnionTransformDeclaration(props: JsonUnionTransformDeclarati
54
54
  "function",
55
55
  );
56
56
 
57
- const typeRef = ay.refkey(props.type);
57
+ const typeRef = refkey(props.type);
58
58
  const returnType = props.target === "transport" ? "any" : typeRef;
59
59
  const inputType = props.target === "transport" ? <>{typeRef} | null</> : "any";
60
- const inputRef = ay.refkey();
60
+ const inputRef = refkey();
61
61
 
62
62
  const parameters: ts.ParameterDescriptor[] = [
63
63
  { name: "input_", type: inputType, refkey: inputRef, optional: true },
@@ -74,7 +74,7 @@ export function JsonUnionTransformDeclaration(props: JsonUnionTransformDeclarati
74
74
  parameters={parameters}
75
75
  refkey={declarationRefkey}
76
76
  >
77
- {ay.code`
77
+ {code`
78
78
  if(!${inputRef}) {
79
79
  return ${inputRef} as any;
80
80
  }
@@ -1,4 +1,4 @@
1
- import { Type } from "@typespec/compiler";
1
+ import type { Type } from "@typespec/compiler";
2
2
  import { type Typekit } from "@typespec/compiler/typekit";
3
3
  import { reportDiagnostic } from "../../../../lib.js";
4
4
 
@@ -1,11 +1,12 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { code } from "@alloy-js/core";
2
+ import { Children } from "@alloy-js/core/jsx-runtime";
2
3
  import * as ts from "@alloy-js/typescript";
3
4
  import { HttpOperationPart } from "@typespec/http";
4
5
  import { HttpPartTransform } from "./part-transform.jsx";
5
6
 
6
7
  export interface ArrayPartTransformProps {
7
8
  part: HttpOperationPart;
8
- itemRef: ay.Children;
9
+ itemRef: Children;
9
10
  }
10
11
 
11
12
  export function ArrayPartTransform(props: ArrayPartTransformProps) {
@@ -29,15 +30,15 @@ export function ArrayPartTransform(props: ArrayPartTransformProps) {
29
30
  return (
30
31
  <>
31
32
  {inputExpression}.map({mapCallbackSignature}{" "}
32
- {ay.code`=> (${(<HttpPartTransform itemRef={null} part={partElement} />)})`} )
33
+ {code`=> (${(<HttpPartTransform itemRef={null} part={partElement} />)})`} )
33
34
  </>
34
35
  );
35
36
  }
36
37
 
37
- function getPartRef(itemRef: ay.Children, partName: string) {
38
+ function getPartRef(itemRef: Children, partName: string) {
38
39
  if (itemRef === null) {
39
40
  return partName;
40
41
  }
41
42
 
42
- return ay.code`${itemRef}.${partName}`;
43
+ return code`${itemRef}.${partName}`;
43
44
  }
@@ -1,11 +1,11 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { Children, code } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import { HttpOperationPart } from "@typespec/http";
4
4
  import { getCreateFilePartDescriptorReference } from "../../static-helpers/multipart-helpers.jsx";
5
5
 
6
6
  export interface FilePartTransformProps {
7
7
  part: HttpOperationPart;
8
- itemRef: ay.Children;
8
+ itemRef: Children;
9
9
  }
10
10
 
11
11
  export function FilePartTransform(props: FilePartTransformProps) {
@@ -13,7 +13,7 @@ export function FilePartTransform(props: FilePartTransformProps) {
13
13
  const defaultContentType = getContentType(props.part);
14
14
  const applicationName = namePolicy.getName(props.part.name!, "variable");
15
15
  const itemRef = getPartRef(props.itemRef, applicationName);
16
- const args: ay.Children = [JSON.stringify(props.part.name), itemRef];
16
+ const args: Children = [JSON.stringify(props.part.name), itemRef];
17
17
  if (defaultContentType) {
18
18
  args.push(ts.ValueExpression({ jsValue: defaultContentType }));
19
19
  }
@@ -35,10 +35,10 @@ function getContentType(part: HttpOperationPart) {
35
35
  return contentType;
36
36
  }
37
37
 
38
- function getPartRef(itemRef: ay.Children, partName: string) {
38
+ function getPartRef(itemRef: Children, partName: string) {
39
39
  if (itemRef === null) {
40
40
  return partName;
41
41
  }
42
42
 
43
- return ay.code`${itemRef}.${partName}`;
43
+ return code`${itemRef}.${partName}`;
44
44
  }
@@ -1,4 +1,4 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { For } from "@alloy-js/core";
2
2
  import { useTransformNamePolicy, useTsp } from "@typespec/emitter-framework";
3
3
  import { HttpOperationMultipartBody } from "@typespec/http";
4
4
  import { reportDiagnostic } from "../../../lib.js";
@@ -21,9 +21,9 @@ export function MultipartTransform(props: MultipartTransformProps) {
21
21
  const itemRef = transportNamer.getApplicationName(props.body.property);
22
22
 
23
23
  const partTransform = (
24
- <ay.For each={httpParts} comma line>
24
+ <For each={httpParts} comma line>
25
25
  {(part, _) => <HttpPartTransform part={part} itemRef={itemRef} />}
26
- </ay.For>
26
+ </For>
27
27
  );
28
28
 
29
29
  return <>[{partTransform}]</>;
@@ -1,4 +1,4 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { type Children } from "@alloy-js/core";
2
2
  import { HttpOperationPart } from "@typespec/http";
3
3
  import { ArrayPartTransform } from "./array-part-transform.jsx";
4
4
  import { FilePartTransform } from "./file-part-transform.jsx";
@@ -6,7 +6,7 @@ import { SimplePartTransform } from "./simple-part-transform.jsx";
6
6
 
7
7
  export interface HttpPartTransformProps {
8
8
  part: HttpOperationPart;
9
- itemRef: ay.Children;
9
+ itemRef: Children;
10
10
  }
11
11
 
12
12
  export function HttpPartTransform(props: HttpPartTransformProps) {
@@ -1,4 +1,4 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { Children, code, List } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import { useTsp } from "@typespec/emitter-framework";
4
4
  import { HttpOperationPart } from "@typespec/http";
@@ -7,7 +7,7 @@ import { JsonTransform } from "../json/json-transform.jsx";
7
7
 
8
8
  export interface SimplePartTransformProps {
9
9
  part: HttpOperationPart;
10
- itemRef: ay.Children;
10
+ itemRef: Children;
11
11
  }
12
12
 
13
13
  export function SimplePartTransform(props: SimplePartTransformProps) {
@@ -17,10 +17,10 @@ export function SimplePartTransform(props: SimplePartTransformProps) {
17
17
  const partName = ts.ValueExpression({ jsValue: props.part.name });
18
18
  const partContentType = props.part.body.contentTypes[0] ?? "application/json";
19
19
  const partRef = getPartRef(props.itemRef, applicationName);
20
- let bodyRef = ay.code`${partRef}`;
20
+ let bodyRef = code`${partRef}`;
21
21
 
22
22
  if (props.part.body.property) {
23
- bodyRef = ay.code`${partRef}.${props.part.body.property.name}`;
23
+ bodyRef = code`${partRef}.${props.part.body.property.name}`;
24
24
  }
25
25
 
26
26
  if (!partContentType.startsWith("application/json")) {
@@ -33,21 +33,21 @@ export function SimplePartTransform(props: SimplePartTransformProps) {
33
33
 
34
34
  return (
35
35
  <ts.ObjectExpression>
36
- <ay.List comma line>
36
+ <List comma line>
37
37
  <ts.ObjectProperty name="name" jsValue={partName} />
38
38
  <ts.ObjectProperty
39
39
  name="body"
40
40
  value={<JsonTransform itemRef={bodyRef} target="transport" type={props.part.body.type} />}
41
41
  />
42
- </ay.List>
42
+ </List>
43
43
  </ts.ObjectExpression>
44
44
  );
45
45
  }
46
46
 
47
- function getPartRef(itemRef: ay.Children, partName: string) {
47
+ function getPartRef(itemRef: Children, partName: string) {
48
48
  if (itemRef === null) {
49
49
  return partName;
50
50
  }
51
51
 
52
- return ay.code`${itemRef}.${partName}`;
52
+ return code`${itemRef}.${partName}`;
53
53
  }
@@ -1,16 +1,17 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { Refkey, refkey } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import * as ef from "@typespec/emitter-framework/typescript";
4
4
  import { HttpOperationBody } from "@typespec/http";
5
5
  import { ClientOperation } from "@typespec/http-client";
6
6
  import { JsonTransform } from "./json/json-transform.jsx";
7
+
7
8
  export interface TransformDeclarationProps {
8
9
  operation: ClientOperation;
9
- refkey?: ay.Refkey;
10
+ refkey?: Refkey;
10
11
  }
11
12
 
12
13
  export function getTransformDeclarationRef(operation: ClientOperation) {
13
- return ay.refkey(operation, "transform");
14
+ return refkey(operation, "transform");
14
15
  }
15
16
 
16
17
  export function TransformDeclaration(props: TransformDeclarationProps) {
@@ -26,11 +27,11 @@ export interface SingleBodyTransformDeclarationProps {
26
27
  name: string;
27
28
  operation: ClientOperation;
28
29
  payload: HttpOperationBody;
29
- refkey: ay.Refkey;
30
+ refkey: Refkey;
30
31
  }
31
32
 
32
33
  export function SingleBodyTransformDeclaration(props: SingleBodyTransformDeclarationProps) {
33
- const inputRef = ay.refkey(props.payload, "property");
34
+ const inputRef = refkey(props.payload, "property");
34
35
  const payloadParameter: ts.ParameterDescriptor = {
35
36
  name: "payload",
36
37
  type: <ef.TypeExpression type={props.payload.type} />,
@@ -52,7 +53,7 @@ export function SingleBodyTransformDeclaration(props: SingleBodyTransformDeclara
52
53
 
53
54
  interface TransformToTransportDeclarationProps {
54
55
  operation: ClientOperation;
55
- refkey: ay.Refkey;
56
+ refkey: Refkey;
56
57
  }
57
58
 
58
59
  function TransformToTransportDeclaration(props: TransformToTransportDeclarationProps) {
@@ -1,5 +1,5 @@
1
1
  import * as ts from "@alloy-js/typescript";
2
- import { Type } from "@typespec/compiler";
2
+ import type { Type } from "@typespec/compiler";
3
3
  import { HasName, TransformNamePolicyContext, useTsp } from "@typespec/emitter-framework";
4
4
  import { HttpOperation } from "@typespec/http";
5
5
  import { reportDiagnostic } from "../../lib.js";