@tim-smart/openapi-gen 0.3.21 → 0.3.22

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 (2) hide show
  1. package/main.js +7 -18
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -35539,9 +35539,6 @@ var layerTransformerSchema2 = sync6(OpenApiTransformer, () => {
35539
35539
  f,
35540
35540
  )
35541
35541
  : (f) => (request) => Effect.flatMap(httpClient.execute(request), f)
35542
- const jsonBody =
35543
- (body: unknown) => (request: HttpClientRequest.HttpClientRequest) =>
35544
- Effect.orDie(HttpClientRequest.bodyJson(request, body))
35545
35542
  const decodeSuccess =
35546
35543
  <A, I, R>(schema: S.Schema<A, I, R>) =>
35547
35544
  (response: HttpClientResponse.HttpClientResponse) =>
@@ -35566,7 +35563,6 @@ var layerTransformerSchema2 = sync6(OpenApiTransformer, () => {
35566
35563
  }
35567
35564
  const params = `${args2.join(", ")}`;
35568
35565
  const pipeline = [];
35569
- let effectfulRequest = false;
35570
35566
  if (operation.params) {
35571
35567
  const varName = operation.payload ? "options.params?." : "options?.";
35572
35568
  if (operation.urlParams.length > 0) {
@@ -35586,8 +35582,7 @@ var layerTransformerSchema2 = sync6(OpenApiTransformer, () => {
35586
35582
  if (operation.payload === "FormData") {
35587
35583
  pipeline.push(`HttpClientRequest.bodyFormData(${payloadVarName})`);
35588
35584
  } else if (operation.payload) {
35589
- effectfulRequest = true;
35590
- pipeline.push(`jsonBody(${payloadVarName})`);
35585
+ pipeline.push(`HttpClientRequest.bodyUnsafeJson(${payloadVarName})`);
35591
35586
  }
35592
35587
  const decodes = [];
35593
35588
  const singleSuccessCode = operation.successSchemas.size === 1;
@@ -35599,10 +35594,9 @@ var layerTransformerSchema2 = sync6(OpenApiTransformer, () => {
35599
35594
  decodes.push(`"${status2}": decodeError(${schema})`);
35600
35595
  });
35601
35596
  decodes.push(`orElse: unexpectedStatus`);
35602
- const execute2 = `withResponse(HttpClientResponse.matchStatus({
35597
+ pipeline.push(`withResponse(HttpClientResponse.matchStatus({
35603
35598
  ${decodes.join(",\n ")}
35604
- }))`;
35605
- pipeline.push(effectfulRequest ? `Effect.flatMap(${execute2})` : execute2);
35599
+ }))`);
35606
35600
  return `"${operation.id}": (${params}) => HttpClientRequest.make("${operation.method.toUpperCase()}")(${operation.pathTemplate}).pipe(
35607
35601
  ${pipeline.join(",\n ")}
35608
35602
  )`;
@@ -35708,10 +35702,6 @@ export const ${name2}Error = <Tag extends string, E>(
35708
35702
  f,
35709
35703
  )
35710
35704
  : (f) => (request) => Effect.flatMap(httpClient.execute(request), f)
35711
- const jsonBody =
35712
- (body: unknown) =>
35713
- (request: HttpClientRequest.HttpClientRequest) =>
35714
- Effect.orDie(HttpClientRequest.bodyJson(request, body))
35715
35705
  const decodeSuccess = <A>(response: HttpClientResponse.HttpClientResponse) =>
35716
35706
  response.json as Effect.Effect<A, HttpClientError.ResponseError>
35717
35707
  const decodeVoid = (_response: HttpClientResponse.HttpClientResponse) =>
@@ -35759,7 +35749,6 @@ export const ${name2}Error = <Tag extends string, E>(
35759
35749
  }
35760
35750
  const params = `${args2.join(", ")}`;
35761
35751
  const pipeline = [];
35762
- let effectfulRequest = false;
35763
35752
  if (operation.params) {
35764
35753
  const varName = operation.payload ? "options.params?." : "options?.";
35765
35754
  if (operation.urlParams.length > 0) {
@@ -35779,15 +35768,15 @@ export const ${name2}Error = <Tag extends string, E>(
35779
35768
  if (operation.payload === "FormData") {
35780
35769
  pipeline.push(`HttpClientRequest.bodyFormData(${payloadVarName})`);
35781
35770
  } else if (operation.payload) {
35782
- effectfulRequest = true;
35783
- pipeline.push(`jsonBody(${payloadVarName})`);
35771
+ pipeline.push(`HttpClientRequest.bodyUnsafeJson(${payloadVarName})`);
35784
35772
  }
35785
35773
  const successCodesRaw = Array.from(operation.successSchemas.keys());
35786
35774
  const successCodes = successCodesRaw.map((_) => JSON.stringify(_)).join(", ");
35787
35775
  const singleSuccessCode = successCodesRaw.length === 1 && successCodesRaw[0].startsWith("2");
35788
35776
  const errorCodes = operation.errorSchemas.size > 0 && Object.fromEntries(operation.errorSchemas.entries());
35789
- const execute2 = `onRequest([${singleSuccessCode ? `"2xx"` : successCodes}]${errorCodes ? `, ${JSON.stringify(errorCodes)}` : ""})`;
35790
- pipeline.push(effectfulRequest ? `Effect.flatMap(${execute2})` : execute2);
35777
+ pipeline.push(
35778
+ `onRequest([${singleSuccessCode ? `"2xx"` : successCodes}]${errorCodes ? `, ${JSON.stringify(errorCodes)}` : ""})`
35779
+ );
35791
35780
  return `"${operation.id}": (${params}) => HttpClientRequest.make("${operation.method.toUpperCase()}")(${operation.pathTemplate}).pipe(
35792
35781
  ${pipeline.join(",\n ")}
35793
35782
  )`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tim-smart/openapi-gen",
3
- "version": "0.3.21",
3
+ "version": "0.3.22",
4
4
  "description": "Generate Effect http clients from OpenAPI specs",
5
5
  "bin": "main.js",
6
6
  "repository": {