@typespec/http-client-js 0.16.2-dev.1 → 0.16.2-dev.2

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 (225) hide show
  1. package/dist/tsconfig.tsbuildinfo +1 -1
  2. package/package.json +13 -9
  3. package/.github/copilot-instructions.md +0 -180
  4. package/.testignore +0 -19
  5. package/.turbo/turbo-build.log +0 -3
  6. package/CHANGELOG.md +0 -159
  7. package/eng/scripts/calculate-coverage.ts +0 -33
  8. package/eng/scripts/emit-e2e.ts +0 -317
  9. package/eng/scripts/run-e2e-tests.ts +0 -166
  10. package/eng/scripts/tspconfig.yaml +0 -6
  11. package/eng/scripts/upload-spector-results.ts +0 -139
  12. package/src/components/client-context/client-context-declaration.tsx +0 -26
  13. package/src/components/client-context/client-context-factory.tsx +0 -218
  14. package/src/components/client-context/client-context-options.tsx +0 -36
  15. package/src/components/client-context/client-context.tsx +0 -23
  16. package/src/components/client-context/parametrized-endpoint.tsx +0 -51
  17. package/src/components/client-directory.tsx +0 -51
  18. package/src/components/client-operation.tsx +0 -102
  19. package/src/components/client.tsx +0 -177
  20. package/src/components/encoding-provider.tsx +0 -17
  21. package/src/components/external-packages/ts-http-runtime.ts +0 -28
  22. package/src/components/external-packages/uri-template.ts +0 -11
  23. package/src/components/http-request-options.tsx +0 -88
  24. package/src/components/http-request-parameters-expression.tsx +0 -191
  25. package/src/components/http-request.tsx +0 -80
  26. package/src/components/http-response.tsx +0 -74
  27. package/src/components/index.ts +0 -12
  28. package/src/components/models.tsx +0 -26
  29. package/src/components/operation-handlers/index.tsx +0 -2
  30. package/src/components/operation-handlers/operation-pipeline.tsx +0 -33
  31. package/src/components/operation-handlers/paging/page-item.tsx +0 -14
  32. package/src/components/operation-handlers/paging/page-response.tsx +0 -57
  33. package/src/components/operation-handlers/paging/page-settings.tsx +0 -53
  34. package/src/components/operation-handlers/paging/paginated-operation-handler.tsx +0 -200
  35. package/src/components/operation-handlers/paging/request-send.tsx +0 -85
  36. package/src/components/operation-handlers/paging/response-deserialize.tsx +0 -60
  37. package/src/components/operation-handlers/paging/util.ts +0 -70
  38. package/src/components/operation-handlers/types.tsx +0 -18
  39. package/src/components/operation-options.tsx +0 -42
  40. package/src/components/operation-parameters.tsx +0 -44
  41. package/src/components/output.tsx +0 -32
  42. package/src/components/serializers.tsx +0 -74
  43. package/src/components/static-helpers/bytes-encoding.tsx +0 -61
  44. package/src/components/static-helpers/interfaces.tsx +0 -31
  45. package/src/components/static-helpers/multipart-helpers.tsx +0 -80
  46. package/src/components/static-helpers/paging-helper.tsx +0 -202
  47. package/src/components/static-helpers/rest-error.tsx +0 -102
  48. package/src/components/testing/client-options.tsx +0 -30
  49. package/src/components/transforms/content-type-encoding-provider.tsx +0 -26
  50. package/src/components/transforms/data-transform.tsx +0 -40
  51. package/src/components/transforms/json/json-array-transform.tsx +0 -87
  52. package/src/components/transforms/json/json-model-additional-properties-transform.tsx +0 -54
  53. package/src/components/transforms/json/json-model-base-transform.tsx +0 -24
  54. package/src/components/transforms/json/json-model-property-transform.tsx +0 -53
  55. package/src/components/transforms/json/json-model-transform.tsx +0 -115
  56. package/src/components/transforms/json/json-record-transform.tsx +0 -88
  57. package/src/components/transforms/json/json-transform-discriminator.tsx +0 -111
  58. package/src/components/transforms/json/json-transform.tsx +0 -120
  59. package/src/components/transforms/json/union-transform.tsx +0 -87
  60. package/src/components/transforms/json/utils/transport-namer.ts +0 -12
  61. package/src/components/transforms/multipart/array-part-transform.tsx +0 -44
  62. package/src/components/transforms/multipart/file-part-transform.tsx +0 -45
  63. package/src/components/transforms/multipart/multipart-transform.tsx +0 -30
  64. package/src/components/transforms/multipart/part-transform.tsx +0 -22
  65. package/src/components/transforms/multipart/simple-part-transform.tsx +0 -42
  66. package/src/components/transforms/operation-transform-declaration.tsx +0 -83
  67. package/src/components/transforms/operation-transform-expression.tsx +0 -62
  68. package/src/components/transforms/scalar-transform.tsx +0 -301
  69. package/src/components/transforms/transform-name-policy.ts +0 -134
  70. package/src/components/utils/unpack-model-property.ts +0 -44
  71. package/src/components/utils/url-template.tsx +0 -25
  72. package/src/context/encoding/encoding-context.tsx +0 -28
  73. package/src/context/encoding/types.ts +0 -6
  74. package/src/emitter.tsx +0 -85
  75. package/src/index.ts +0 -5
  76. package/src/lib.ts +0 -120
  77. package/src/testing/index.ts +0 -11
  78. package/src/utils/client-discovery.ts +0 -28
  79. package/src/utils/multipart.ts +0 -29
  80. package/src/utils/operations.ts +0 -112
  81. package/src/utils/parameters.tsx +0 -155
  82. package/test/e2e/assets/image.jpg +0 -0
  83. package/test/e2e/assets/image.png +0 -0
  84. package/test/e2e/http/authentication/api-key/main.test.ts +0 -38
  85. package/test/e2e/http/authentication/oauth2/main.test.ts +0 -31
  86. package/test/e2e/http/authentication/union/main.test.ts +0 -26
  87. package/test/e2e/http/encode/bytes/main.test.ts +0 -191
  88. package/test/e2e/http/encode/datetime/main.test.ts +0 -176
  89. package/test/e2e/http/encode/duration/main.test.ts +0 -126
  90. package/test/e2e/http/encode/numeric/main.test.ts +0 -26
  91. package/test/e2e/http/parameters/basic/main.test.ts +0 -35
  92. package/test/e2e/http/parameters/body-optionality/main.test.ts +0 -43
  93. package/test/e2e/http/parameters/collection-format/main.test.ts +0 -40
  94. package/test/e2e/http/parameters/spread/main.test.ts +0 -56
  95. package/test/e2e/http/payload/content-negotiation/main.test.ts +0 -40
  96. package/test/e2e/http/payload/json-merge-patch/main.test.ts +0 -122
  97. package/test/e2e/http/payload/media-type/main.test.ts +0 -28
  98. package/test/e2e/http/payload/multipart/main.test.ts +0 -200
  99. package/test/e2e/http/payload/pageable/main.test.ts +0 -78
  100. package/test/e2e/http/payload/xml/main.test.ts +0 -287
  101. package/test/e2e/http/routes/main.test.ts +0 -284
  102. package/test/e2e/http/serialization/encoded-name/json/main.test.ts +0 -20
  103. package/test/e2e/http/server/endpoint/not-defined/main.test.ts +0 -11
  104. package/test/e2e/http/server/path/multiple/main.test.ts +0 -22
  105. package/test/e2e/http/server/path/single/main.test.ts +0 -11
  106. package/test/e2e/http/server/versions/not-versioned/main.test.ts +0 -22
  107. package/test/e2e/http/server/versions/versioned/main.test.ts +0 -28
  108. package/test/e2e/http/special-headers/conditional-request/main.test.ts +0 -35
  109. package/test/e2e/http/special-headers/repeatability/main.test.ts +0 -18
  110. package/test/e2e/http/special-words/main.test.ts +0 -434
  111. package/test/e2e/http/type/array/array.test.ts +0 -256
  112. package/test/e2e/http/type/dictionary/main.test.ts +0 -229
  113. package/test/e2e/http/type/enum/extensible/main.test.ts +0 -34
  114. package/test/e2e/http/type/enum/fixed/main.test.ts +0 -29
  115. package/test/e2e/http/type/model/empty/main.test.ts +0 -21
  116. package/test/e2e/http/type/model/inheritance/enum-discriminator/main.test.ts +0 -51
  117. package/test/e2e/http/type/model/inheritance/nested-discriminator/main.test.ts +0 -168
  118. package/test/e2e/http/type/model/inheritance/not-discriminated/main.test.ts +0 -42
  119. package/test/e2e/http/type/model/inheritance/recursive/main.test.ts +0 -46
  120. package/test/e2e/http/type/model/inheritance/single-discriminator/main.test.ts +0 -99
  121. package/test/e2e/http/type/model/visibility/main.test.ts +0 -64
  122. package/test/e2e/http/type/property/additional-properties/main.test.ts +0 -185
  123. package/test/e2e/http/type/property/additional-properties/spreads.test.ts +0 -448
  124. package/test/e2e/http/type/property/nullable/main.test.ts +0 -275
  125. package/test/e2e/http/type/property/optionality/main.test.ts +0 -256
  126. package/test/e2e/http/type/property/value-types/main.test.ts +0 -193
  127. package/test/e2e/http/type/scalar/main.test.ts +0 -133
  128. package/test/e2e/http/type/scalar/scalar.test.ts +0 -95
  129. package/test/e2e/http/type/union/main.test.ts +0 -207
  130. package/test/e2e/http/versioning/added/main.test.ts +0 -60
  131. package/test/e2e/http/versioning/madeOptional/main.test.ts +0 -34
  132. package/test/e2e/http/versioning/removed/main.test.ts +0 -75
  133. package/test/e2e/http/versioning/renamedFrom/main.test.ts +0 -52
  134. package/test/e2e/http/versioning/returnTypeChangedFrom/main.test.ts +0 -22
  135. package/test/e2e/http/versioning/typeChangedFrom/main.test.ts +0 -31
  136. package/test/scenarios/additional-properties/extends.md +0 -67
  137. package/test/scenarios/additional-properties/is.md +0 -42
  138. package/test/scenarios/additional-properties/spread.md +0 -68
  139. package/test/scenarios/auth/basic_auth.md +0 -68
  140. package/test/scenarios/auth/bearer.md +0 -68
  141. package/test/scenarios/auth/client_parameters.md +0 -78
  142. package/test/scenarios/auth/client_structure.md +0 -36
  143. package/test/scenarios/auth/key_credential.md +0 -69
  144. package/test/scenarios/auth/oauth2.md +0 -90
  145. package/test/scenarios/auth/sub_client_override.md +0 -114
  146. package/test/scenarios/client/client_context.md +0 -34
  147. package/test/scenarios/client/dotted_namespace.md +0 -27
  148. package/test/scenarios/client/global_namespace.md +0 -69
  149. package/test/scenarios/client/multiple_top_level_clients.md +0 -72
  150. package/test/scenarios/client/nested_client.md +0 -102
  151. package/test/scenarios/client/wrapping_namespace.md +0 -41
  152. package/test/scenarios/encoding/bytes_body.md +0 -44
  153. package/test/scenarios/encoding/bytes_json_property.md +0 -55
  154. package/test/scenarios/encoding/bytes_nullable.md +0 -139
  155. package/test/scenarios/encoding/header_bytes.md +0 -130
  156. package/test/scenarios/encoding/header_date.md +0 -216
  157. package/test/scenarios/encoding/model_with_bytes_property.md +0 -45
  158. package/test/scenarios/encoding/query_bytes.md +0 -42
  159. package/test/scenarios/encoding/query_date.md +0 -216
  160. package/test/scenarios/http-operations/basic-request.md +0 -144
  161. package/test/scenarios/http-operations/basic-response.md +0 -219
  162. package/test/scenarios/http-operations/basic.md +0 -128
  163. package/test/scenarios/http-operations/constant-header.md +0 -33
  164. package/test/scenarios/http-operations/create-operation.md +0 -58
  165. package/test/scenarios/http-operations/on_response.md +0 -52
  166. package/test/scenarios/http-operations/optional-request-body.md +0 -50
  167. package/test/scenarios/http-operations/paging.md +0 -242
  168. package/test/scenarios/http-operations/path-parameter-in-model.md +0 -53
  169. package/test/scenarios/http-operations/path-parameter.md +0 -48
  170. package/test/scenarios/http-operations/query-parameter.md +0 -41
  171. package/test/scenarios/http-operations/scalar-payload.md +0 -57
  172. package/test/scenarios/http-operations/with-parameters.md +0 -78
  173. package/test/scenarios/models/array-properties.md +0 -47
  174. package/test/scenarios/models/basic.md +0 -118
  175. package/test/scenarios/models/dictionary-properties.md +0 -44
  176. package/test/scenarios/models/inheritance_2_discriminators.md +0 -346
  177. package/test/scenarios/models/inheritance_discriminator.md +0 -88
  178. package/test/scenarios/models/inline-models.md +0 -29
  179. package/test/scenarios/models/model_additional_properties.md +0 -75
  180. package/test/scenarios/models/model_extends.md +0 -97
  181. package/test/scenarios/models/model_spread.md +0 -63
  182. package/test/scenarios/models/nested_property.md +0 -41
  183. package/test/scenarios/models/property_references_property.md +0 -150
  184. package/test/scenarios/multipart/anonymous_part.md +0 -53
  185. package/test/scenarios/multipart/file.md +0 -154
  186. package/test/scenarios/multipart/file_content_type.md +0 -92
  187. package/test/scenarios/multipart/non-string-float.md +0 -55
  188. package/test/scenarios/multipart/simple_part.md +0 -65
  189. package/test/scenarios/operation-parameters/body_root_anonymous.md +0 -87
  190. package/test/scenarios/operation-parameters/constant_as_optional.md +0 -54
  191. package/test/scenarios/operation-parameters/default_value_as_optional.md +0 -54
  192. package/test/scenarios/operation-parameters/no_content_type.md +0 -62
  193. package/test/scenarios/operation-parameters/no_parameters.md +0 -50
  194. package/test/scenarios/operation-parameters/only_optional.md +0 -62
  195. package/test/scenarios/operation-parameters/only_required.md +0 -58
  196. package/test/scenarios/operation-parameters/reserved_names.md +0 -60
  197. package/test/scenarios/operation-parameters/spread_body.md +0 -70
  198. package/test/scenarios/operation-parameters/spread_with_nested.md +0 -82
  199. package/test/scenarios/operation-parameters/union_body.md +0 -86
  200. package/test/scenarios/operation-parameters/with_body_property.md +0 -67
  201. package/test/scenarios/operation-parameters/with_body_root.md +0 -69
  202. package/test/scenarios/serializers/arrays.md +0 -191
  203. package/test/scenarios/serializers/basic_model.md +0 -111
  204. package/test/scenarios/serializers/basic_model_wire_name.md +0 -48
  205. package/test/scenarios/serializers/discriminated_union.md +0 -86
  206. package/test/scenarios/serializers/discriminated_union_spread.md +0 -115
  207. package/test/scenarios/serializers/file.md +0 -67
  208. package/test/scenarios/serializers/model_date_time.md +0 -65
  209. package/test/scenarios/serializers/multipart.md +0 -62
  210. package/test/scenarios/serializers/polymorphic_single_level_inheritance.md +0 -157
  211. package/test/scenarios/serializers/property_references_property.md +0 -72
  212. package/test/scenarios/serializers/record.md +0 -97
  213. package/test/scenarios/serializers/scalars.md +0 -34
  214. package/test/scenarios/serializers/spread.md +0 -69
  215. package/test/scenarios/serializers/string_union.md +0 -55
  216. package/test/scenarios/server/default_url.md +0 -45
  217. package/test/scenarios/server/multiple-parameters.md +0 -55
  218. package/test/scenarios/server/no-server.md +0 -37
  219. package/test/scenarios/server/parametrized-endpoint.md +0 -51
  220. package/test/scenarios.test.ts +0 -24
  221. package/test/test-host.ts +0 -22
  222. package/tsconfig.json +0 -16
  223. package/tsconfig.test.json +0 -9
  224. package/vitest.config.e2e.ts +0 -16
  225. package/vitest.config.ts +0 -15
@@ -1,193 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- BooleanClient,
4
- BytesClient,
5
- CollectionsStringClient,
6
- DatetimeClient,
7
- Decimal128Client,
8
- DecimalClient,
9
- DurationClient,
10
- EnumClient,
11
- ExtensibleEnumClient,
12
- FixedInnerEnum,
13
- FloatClient,
14
- IntClient,
15
- StringClient,
16
- } from "../../../../generated/type/property/value-types/src/index.js";
17
-
18
- const str = "hello, world!";
19
- const encoder = new TextEncoder();
20
- const helloWorldUint8Array = encoder.encode(str);
21
-
22
- describe("Type.Property.ValueTypes", () => {
23
- describe("BooleanClient", () => {
24
- const client = new BooleanClient({ allowInsecureConnection: true });
25
-
26
- it("should handle a model with a boolean property", async () => {
27
- const response = await client.get();
28
- expect(response).toEqual({ property: true });
29
- });
30
-
31
- it("should send a model with a boolean property", async () => {
32
- await client.put({ property: true });
33
- });
34
- });
35
-
36
- describe("StringClient", () => {
37
- const client = new StringClient({ allowInsecureConnection: true });
38
-
39
- it("should handle a model with a string property", async () => {
40
- const response = await client.get();
41
- expect(response).toEqual({ property: "hello" });
42
- });
43
-
44
- it("should send a model with a string property", async () => {
45
- await client.put({ property: "hello" });
46
- });
47
- });
48
-
49
- describe("BytesClient", () => {
50
- const client = new BytesClient({
51
- allowInsecureConnection: true,
52
- retryOptions: { maxRetries: 1 },
53
- });
54
-
55
- it("should handle a model with a bytes property", async () => {
56
- const response = await client.get();
57
- expect(response.property).toStrictEqual(helloWorldUint8Array);
58
- });
59
-
60
- it("should send a model with a bytes property", async () => {
61
- await client.put({ property: helloWorldUint8Array });
62
- });
63
- });
64
-
65
- describe("IntClient", () => {
66
- const client = new IntClient({ allowInsecureConnection: true });
67
-
68
- it("should handle a model with an int property", async () => {
69
- const response = await client.get();
70
- expect(response).toEqual({ property: 42 });
71
- });
72
-
73
- it("should send a model with an int property", async () => {
74
- await client.put({ property: 42 });
75
- });
76
- });
77
-
78
- describe("FloatClient", () => {
79
- const client = new FloatClient({ allowInsecureConnection: true });
80
-
81
- it("should handle a model with a float property", async () => {
82
- const response = await client.get();
83
- expect(response).toEqual({ property: 43.125 });
84
- });
85
-
86
- it("should send a model with a float property", async () => {
87
- await client.put({ property: 43.125 });
88
- });
89
- });
90
-
91
- describe("DecimalClient", () => {
92
- const client = new DecimalClient({ allowInsecureConnection: true });
93
-
94
- it("should handle a model with a decimal property", async () => {
95
- const response = await client.get();
96
- expect(response).toEqual({ property: 0.33333 });
97
- });
98
-
99
- it("should send a model with a decimal property", async () => {
100
- await client.put({ property: 0.33333 });
101
- });
102
- });
103
-
104
- describe("Decimal128Client", () => {
105
- const client = new Decimal128Client({ allowInsecureConnection: true });
106
-
107
- it("should handle a model with a decimal128 property", async () => {
108
- const response = await client.get();
109
- expect(response).toEqual({ property: 0.33333 });
110
- });
111
-
112
- it("should send a model with a decimal128 property", async () => {
113
- await client.put({ property: 0.33333 });
114
- });
115
- });
116
-
117
- describe("DatetimeClient", () => {
118
- const client = new DatetimeClient({ allowInsecureConnection: true });
119
-
120
- it("should handle a model with a datetime property", async () => {
121
- const response = await client.get();
122
- expect(response).toEqual({ property: new Date("2022-08-26T18:38:00Z") });
123
- });
124
-
125
- it("should send a model with a datetime property", async () => {
126
- await client.put({ property: new Date("2022-08-26T18:38:00Z") });
127
- });
128
- });
129
-
130
- describe("DurationClient", () => {
131
- const client = new DurationClient({ allowInsecureConnection: true });
132
-
133
- it("should handle a model with a duration property", async () => {
134
- const response = await client.get();
135
- expect(response).toEqual({ property: "P123DT22H14M12.011S" });
136
- });
137
-
138
- it("should send a model with a duration property", async () => {
139
- await client.put({ property: "P123DT22H14M12.011S" });
140
- });
141
- });
142
-
143
- describe("EnumClient", () => {
144
- const client = new EnumClient({ allowInsecureConnection: true });
145
-
146
- it("should handle a model with an enum property", async () => {
147
- const response = await client.get();
148
- expect(response).toEqual({ property: "ValueOne" });
149
- });
150
-
151
- it("should send a model with an enum property", async () => {
152
- await client.put({ property: FixedInnerEnum.ValueOne });
153
- });
154
- });
155
-
156
- describe("ExtensibleEnumClient", () => {
157
- const client = new ExtensibleEnumClient({
158
- allowInsecureConnection: true,
159
- retryOptions: {
160
- maxRetries: 1,
161
- },
162
- });
163
-
164
- it("should handle a model with an extensible enum property", async () => {
165
- const response = await client.get();
166
- expect(response).toEqual({ property: "UnknownValue" });
167
- });
168
-
169
- it("should send a model with an extensible enum property", async () => {
170
- await client.put({ property: "UnknownValue" });
171
- });
172
- });
173
-
174
- describe("CollectionsStringClient", () => {
175
- const client = new CollectionsStringClient({
176
- allowInsecureConnection: true,
177
- retryOptions: {
178
- maxRetries: 1,
179
- },
180
- });
181
-
182
- it("should handle a model with a string collection property", async () => {
183
- const response = await client.get();
184
- expect(response).toEqual({ property: ["hello", "world"] });
185
- });
186
-
187
- it("should send a model with a string collection property", async () => {
188
- await client.put({ property: ["hello", "world"] });
189
- });
190
- });
191
-
192
- // You can add similar test cases for other clients provided in the spec.
193
- });
@@ -1,133 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- BooleanClient,
4
- Decimal128TypeClient,
5
- Decimal128VerifyClient,
6
- DecimalTypeClient,
7
- DecimalVerifyClient,
8
- StringClient,
9
- UnknownClient,
10
- } from "../../../generated/type/scalar/src/index.js";
11
-
12
- describe("Type.Scalar", () => {
13
- describe("StringClient", () => {
14
- const client = new StringClient({ allowInsecureConnection: true });
15
-
16
- it("should handle a string value returned from the server", async () => {
17
- const response = await client.get();
18
- expect(response).toBe("test");
19
- });
20
-
21
- // Mockapi plaintext issue
22
- it.skip("should send a string value to the server", async () => {
23
- await client.put("test");
24
- });
25
- });
26
-
27
- describe("BooleanClient", () => {
28
- const client = new BooleanClient({ allowInsecureConnection: true });
29
-
30
- it("should handle a boolean value returned from the server", async () => {
31
- const response = await client.get();
32
- expect(response).toBe(true);
33
- });
34
-
35
- it("should send a boolean value to the server", async () => {
36
- await client.put(true);
37
- });
38
- });
39
-
40
- describe("UnknownClient", () => {
41
- const client = new UnknownClient({ allowInsecureConnection: true });
42
-
43
- it("should handle an unknown value returned from the server", async () => {
44
- const response = await client.get();
45
- expect(response).toBe("test");
46
- });
47
-
48
- // Mockapi plaintext issue
49
- it.skip("should send an unknown value to the server", async () => {
50
- await client.put("test");
51
- });
52
- });
53
-
54
- describe("DecimalTypeClient", () => {
55
- const client = new DecimalTypeClient({
56
- allowInsecureConnection: true,
57
- retryOptions: {
58
- maxRetries: 1,
59
- },
60
- });
61
-
62
- it("should handle a decimal value in the response body", async () => {
63
- const response = await client.responseBody();
64
- expect(response).toBe(0.33333);
65
- });
66
-
67
- it("should send a decimal value in the request body", async () => {
68
- await client.requestBody(0.33333);
69
- });
70
-
71
- it("should handle a decimal request parameter", async () => {
72
- await client.requestParameter(0.33333);
73
- });
74
- });
75
-
76
- describe("Decimal128TypeClient", () => {
77
- const client = new Decimal128TypeClient({
78
- allowInsecureConnection: true,
79
- retryOptions: {
80
- maxRetries: 1,
81
- },
82
- });
83
-
84
- it("should handle a decimal128 value in the response body", async () => {
85
- const response = await client.responseBody();
86
- expect(response).toBe(0.33333);
87
- });
88
-
89
- it("should send a decimal128 value in the request body", async () => {
90
- await client.requestBody(0.33333);
91
- });
92
-
93
- it("should handle a decimal128 request parameter", async () => {
94
- await client.requestParameter(0.33333);
95
- });
96
- });
97
-
98
- describe("DecimalVerifyClient", () => {
99
- const client = new DecimalVerifyClient({
100
- allowInsecureConnection: true,
101
- retryOptions: {
102
- maxRetries: 1,
103
- },
104
- });
105
-
106
- it("should prepare verify values for decimal", async () => {
107
- const response = await client.prepareVerify();
108
- expect(response).toEqual([0.1, 0.1, 0.1]);
109
- });
110
-
111
- it("should send a decimal value to verify", async () => {
112
- await client.verify(0.3);
113
- });
114
- });
115
-
116
- describe("Decimal128VerifyClient", () => {
117
- const client = new Decimal128VerifyClient({
118
- allowInsecureConnection: true,
119
- retryOptions: {
120
- maxRetries: 1,
121
- },
122
- });
123
-
124
- it("should prepare verify values for decimal128", async () => {
125
- const response = await client.prepareVerify();
126
- expect(response).toEqual([0.1, 0.1, 0.1]);
127
- });
128
-
129
- it("should send a decimal128 value to verify", async () => {
130
- await client.verify(0.3);
131
- });
132
- });
133
- });
@@ -1,95 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- BooleanClient,
4
- DecimalTypeClient,
5
- DecimalVerifyClient,
6
- StringClient,
7
- UnknownClient,
8
- } from "../../../generated/type/scalar/src/index.js";
9
-
10
- describe.skip("Type.Scalar", () => {
11
- describe("StringClient", () => {
12
- const client = new StringClient({ allowInsecureConnection: true });
13
-
14
- it("should handle a string value returned from the server", async () => {
15
- const response = await client.get();
16
- expect(response).toBe("test"); // Mock API expected value
17
- });
18
-
19
- it("should send a string value to the server", async () => {
20
- await client.put("test");
21
- // Assert successful request
22
- });
23
- });
24
-
25
- describe("BooleanClient", () => {
26
- const client = new BooleanClient({ allowInsecureConnection: true });
27
-
28
- it("should handle a boolean value returned from the server", async () => {
29
- const response = await client.get();
30
- expect(response).toBe(true); // Mock API expected value
31
- });
32
-
33
- it("should send a boolean value to the server", async () => {
34
- await client.put(true);
35
- // Assert successful request
36
- });
37
- });
38
-
39
- describe("UnknownClient", () => {
40
- const client = new UnknownClient({ allowInsecureConnection: true });
41
-
42
- it("should handle an unknown value returned from the server", async () => {
43
- const response = await client.get();
44
- expect(response).toBe("test"); // Mock API expected value
45
- });
46
-
47
- it("should send an unknown value to the server", async () => {
48
- await client.put("test");
49
- // Assert successful request
50
- });
51
- });
52
-
53
- describe("DecimalTypeClient", () => {
54
- const client = new DecimalTypeClient({
55
- allowInsecureConnection: true,
56
- retryOptions: {
57
- maxRetries: 1,
58
- },
59
- });
60
-
61
- it("should handle a decimal value returned from the server", async () => {
62
- const response = await client.responseBody();
63
- expect(response).toBe(0.33333); // Mock API expected value
64
- });
65
-
66
- it("should send a decimal value to the server", async () => {
67
- await client.requestBody(0.33333);
68
- // Assert successful request
69
- });
70
-
71
- it("should handle a decimal request parameter", async () => {
72
- await client.requestParameter(0.33333);
73
- // Assert successful request
74
- });
75
- });
76
-
77
- describe("DecimalVerifyClient", () => {
78
- const client = new DecimalVerifyClient({
79
- allowInsecureConnection: true,
80
- retryOptions: {
81
- maxRetries: 1,
82
- },
83
- });
84
-
85
- it("should prepare verify values for decimal", async () => {
86
- const response = await client.prepareVerify();
87
- expect(response).toEqual([0.1, 0.1, 0.1]); // Mock API expected values
88
- });
89
-
90
- it("should send a decimal value to verify", async () => {
91
- await client.verify(0.3);
92
- // Assert successful request
93
- });
94
- });
95
- });
@@ -1,207 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- EnumsOnlyClient,
4
- FloatsOnlyClient,
5
- IntsOnlyClient,
6
- Lr,
7
- MixedLiteralsClient,
8
- MixedTypesClient,
9
- ModelsOnlyClient,
10
- StringAndArrayClient,
11
- StringExtensibleClient,
12
- StringExtensibleNamedClient,
13
- StringsOnlyClient,
14
- Ud,
15
- } from "../../../generated/type/union/src/index.js";
16
-
17
- describe("Type.Union", () => {
18
- describe("StringsOnlyClient", () => {
19
- const client = new StringsOnlyClient({
20
- allowInsecureConnection: true,
21
- retryOptions: {
22
- maxRetries: 1,
23
- },
24
- });
25
-
26
- it("should handle a union of strings in response", async () => {
27
- const response = await client.get();
28
- expect(response.prop).toBe("b"); // Mock API expected value
29
- });
30
-
31
- it("should send a union of strings", async () => {
32
- await client.send("b");
33
- // Assert successful request
34
- });
35
- });
36
-
37
- describe("StringExtensibleClient", () => {
38
- const client = new StringExtensibleClient({
39
- allowInsecureConnection: true,
40
- retryOptions: {
41
- maxRetries: 1,
42
- },
43
- });
44
-
45
- it("should handle an extensible string union in response", async () => {
46
- const response = await client.get();
47
- expect(response.prop).toBe("custom"); // Mock API expected value
48
- });
49
-
50
- it("should send an extensible string union", async () => {
51
- await client.send("custom");
52
- // Assert successful request
53
- });
54
- });
55
-
56
- describe("StringExtensibleNamedClient", () => {
57
- const client = new StringExtensibleNamedClient({
58
- allowInsecureConnection: true,
59
- retryOptions: {
60
- maxRetries: 1,
61
- },
62
- });
63
-
64
- it("should handle an extensible named string union in response", async () => {
65
- const response = await client.get();
66
- expect(response.prop).toBe("custom"); // Mock API expected value
67
- });
68
-
69
- it("should send an extensible named string union", async () => {
70
- await client.send("custom");
71
- // Assert successful request
72
- });
73
- });
74
-
75
- describe("IntsOnlyClient", () => {
76
- const client = new IntsOnlyClient({ allowInsecureConnection: true });
77
-
78
- it("should handle a union of integers in response", async () => {
79
- const response = await client.get();
80
- expect(response.prop).toBe(2); // Mock API expected value
81
- });
82
-
83
- it("should send a union of integers", async () => {
84
- await client.send(2);
85
- // Assert successful request
86
- });
87
- });
88
-
89
- describe("FloatsOnlyClient", () => {
90
- const client = new FloatsOnlyClient({ allowInsecureConnection: true });
91
-
92
- it("should handle a union of floats in response", async () => {
93
- const response = await client.get();
94
- expect(response.prop).toBe(2.2); // Mock API expected value
95
- });
96
-
97
- it("should send a union of floats", async () => {
98
- await client.send(2.2);
99
- // Assert successful request
100
- });
101
- });
102
-
103
- describe("ModelsOnlyClient", () => {
104
- const client = new ModelsOnlyClient({ allowInsecureConnection: true });
105
-
106
- it("should handle a union of models in response", async () => {
107
- const response = await client.get();
108
- expect(response.prop).toEqual({ name: "test" }); // Mock API expected value
109
- });
110
-
111
- it("should send a union of models", async () => {
112
- await client.send({ name: "test" });
113
- // Assert successful request
114
- });
115
- });
116
-
117
- describe("EnumsOnlyClient", () => {
118
- const client = new EnumsOnlyClient({ allowInsecureConnection: true });
119
-
120
- it("should handle a union of enums in response", async () => {
121
- const response = await client.get();
122
- expect(response.prop).toEqual({ lr: "right", ud: "up" }); // Mock API expected value
123
- });
124
-
125
- it("should send a union of enums", async () => {
126
- await client.send({ lr: Lr.Right, ud: Ud.Up });
127
- // Assert successful request
128
- });
129
- });
130
-
131
- describe("StringAndArrayClient", () => {
132
- const client = new StringAndArrayClient({
133
- allowInsecureConnection: true,
134
- retryOptions: {
135
- maxRetries: 1,
136
- },
137
- });
138
-
139
- it("should handle a union of string and array in response", async () => {
140
- const response = await client.get();
141
- expect(response.prop).toEqual({
142
- string: "test",
143
- array: ["test1", "test2"],
144
- }); // Mock API expected value
145
- });
146
-
147
- it("should send a union of string and array", async () => {
148
- await client.send({ string: "test", array: ["test1", "test2"] });
149
- // Assert successful request
150
- });
151
- });
152
-
153
- describe("MixedLiteralsClient", () => {
154
- const client = new MixedLiteralsClient({
155
- allowInsecureConnection: true,
156
- retryOptions: {
157
- maxRetries: 1,
158
- },
159
- });
160
-
161
- it("should handle a union of mixed literals in response", async () => {
162
- const response = await client.get();
163
- expect(response.prop).toEqual({
164
- stringLiteral: "a",
165
- intLiteral: 2,
166
- floatLiteral: 3.3,
167
- booleanLiteral: true,
168
- }); // Mock API expected value
169
- });
170
-
171
- it("should send a union of mixed literals", async () => {
172
- await client.send({
173
- stringLiteral: "a",
174
- intLiteral: 2,
175
- floatLiteral: 3.3,
176
- booleanLiteral: true,
177
- });
178
- // Assert successful request
179
- });
180
- });
181
-
182
- describe("MixedTypesClient", () => {
183
- const client = new MixedTypesClient({ allowInsecureConnection: true });
184
-
185
- it("should handle a union of mixed types in response", async () => {
186
- const response = await client.get();
187
- expect(response.prop).toEqual({
188
- model: { name: "test" },
189
- literal: "a",
190
- int: 2,
191
- boolean: true,
192
- array: [{ name: "test" }, "a", 2, true],
193
- }); // Mock API expected value
194
- });
195
-
196
- it("should send a union of mixed types", async () => {
197
- await client.send({
198
- model: { name: "test" },
199
- literal: "a",
200
- int: 2,
201
- boolean: true,
202
- array: [{ name: "test" }, "a", 2, true],
203
- });
204
- // Assert successful request
205
- });
206
- });
207
- });
@@ -1,60 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import type { ModelV1, ModelV2 } from "../../../generated/versioning/added/src/index.js";
3
- import {
4
- AddedClient,
5
- EnumV1,
6
- EnumV2,
7
- InterfaceV2Client,
8
- Versions,
9
- } from "../../../generated/versioning/added/src/index.js";
10
-
11
- describe("Versioning.Added", () => {
12
- const client = new AddedClient("http://localhost:3000", Versions.V2, {
13
- allowInsecureConnection: true,
14
- retryOptions: {
15
- maxRetries: 0,
16
- },
17
- });
18
-
19
- // Issue in spec op v1(@body body: ModelV1, @added(Versions.v2) @header headerV2: string): ModelV1;
20
- // Mock expects header-v2 as the name.
21
- it.skip("should send and receive v1 operation with ModelV1 at latest version", async () => {
22
- const body: ModelV1 = {
23
- prop: "foo",
24
- unionProp: 10,
25
- enumProp: EnumV1.EnumMemberV2,
26
- };
27
-
28
- const response = await client.v1(body, "bar");
29
- expect(response).toEqual(body);
30
- });
31
-
32
- it("should send and receive v2 operation with ModelV2 at latest version", async () => {
33
- const body: ModelV2 = {
34
- prop: "foo",
35
- enumProp: EnumV2.EnumMember,
36
- unionProp: "bar",
37
- };
38
- const response = await client.v2(body);
39
- expect(response).toEqual(body);
40
- });
41
-
42
- describe("InterfaceV2Client", () => {
43
- const interfaceV2Client = new InterfaceV2Client("http://localhost:3000", Versions.V2, {
44
- allowInsecureConnection: true,
45
- retryOptions: {
46
- maxRetries: 1,
47
- },
48
- });
49
-
50
- it("should send and receive v2InInterface operation with ModelV2", async () => {
51
- const body: ModelV2 = {
52
- prop: "foo",
53
- enumProp: EnumV2.EnumMember,
54
- unionProp: "bar",
55
- };
56
- const response = await interfaceV2Client.v2InInterface(body);
57
- expect(response).toEqual(body);
58
- });
59
- });
60
- });