@tim-smart/openapi-gen 0.3.2 → 0.3.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.
- package/main.js +10 -3
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -29815,7 +29815,12 @@ var operationToMethod = (operation) => {
|
|
|
29815
29815
|
}
|
|
29816
29816
|
return `readonly "${operation.id}": (${args.join(", ")}) => Effect.Effect<${success}, ${errors.join(" | ")}>`;
|
|
29817
29817
|
};
|
|
29818
|
-
var operationsToImpl = (name, operations) => `export const make = (
|
|
29818
|
+
var operationsToImpl = (name, operations) => `export const make = (
|
|
29819
|
+
httpClient: HttpClient.HttpClient,
|
|
29820
|
+
options: {
|
|
29821
|
+
readonly transformClient?: ((client: HttpClient.HttpClient) => Effect.Effect<HttpClient.HttpClient>) | undefined
|
|
29822
|
+
} = {}
|
|
29823
|
+
): ${name} => {
|
|
29819
29824
|
const unexpectedStatus = (request: HttpClientRequest.HttpClientRequest, response: HttpClientResponse.HttpClientResponse) =>
|
|
29820
29825
|
Effect.flatMap(
|
|
29821
29826
|
Effect.orElseSucceed(response.text, () => "Unexpected status code"),
|
|
@@ -29827,6 +29832,8 @@ var operationsToImpl = (name, operations) => `export const make = (httpClient: H
|
|
|
29827
29832
|
description
|
|
29828
29833
|
}))
|
|
29829
29834
|
)
|
|
29835
|
+
const applyClientTransform = (client: HttpClient.HttpClient): Effect.Effect<HttpClient.HttpClient> =>
|
|
29836
|
+
options.transformClient ? options.transformClient(client) : Effect.succeed(client)
|
|
29830
29837
|
const decodeError = <A, I, R>(response: HttpClientResponse.HttpClientResponse, schema: S.Schema<A, I, R>) => Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)(response), Effect.fail)
|
|
29831
29838
|
return {
|
|
29832
29839
|
${operations.map(operationToImpl).join(",\n ")}
|
|
@@ -29878,9 +29885,9 @@ var operationToImpl = (operation) => {
|
|
|
29878
29885
|
decodes.push(`"${status2}": r => decodeError(r, ${schema})`);
|
|
29879
29886
|
});
|
|
29880
29887
|
decodes.push(`orElse: (response) => unexpectedStatus(request, response)`);
|
|
29881
|
-
pipeline.push(`Effect.flatMap(request => Effect.flatMap(httpClient.execute(request), HttpClientResponse.matchStatus({
|
|
29888
|
+
pipeline.push(`Effect.flatMap(request => Effect.flatMap(applyClientTransform(httpClient), (httpClient) => Effect.flatMap(httpClient.execute(request), HttpClientResponse.matchStatus({
|
|
29882
29889
|
${decodes.join(",\n ")}
|
|
29883
|
-
})))`);
|
|
29890
|
+
}))))`);
|
|
29884
29891
|
pipeline.push(`Effect.scoped`);
|
|
29885
29892
|
return `"${operation.id}": (${params}) => HttpClientRequest.make("${operation.method.toUpperCase()}")(${operation.pathTemplate}).pipe(
|
|
29886
29893
|
${pipeline.join(",\n ")}
|