@tim-smart/openapi-gen 0.3.15 → 0.3.17

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 -7
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -35181,7 +35181,8 @@ var layerTransformerTs = succeed10(
35181
35181
  return true;
35182
35182
  },
35183
35183
  onTopLevel({ name: name2, source, schema, description }) {
35184
- return source[0] === "{" ? "oneOf" in schema ? `${toComment(description)}export enum ${name2} ${source}` : `${toComment(description)}export interface ${name2} ${source}` : `${toComment(description)}export type ${name2} = ${source}`;
35184
+ return source[0] === "{" ? "oneOf" in schema ? `${toComment(description)}export const ${name2} = ${source};
35185
+ export type ${name2} = (typeof ${name2})[keyof typeof ${name2}];` : `${toComment(description)}export interface ${name2} ${source}` : `${toComment(description)}export type ${name2} = ${source}`;
35185
35186
  },
35186
35187
  propertySeparator: ";\n ",
35187
35188
  onProperty(options3) {
@@ -35222,7 +35223,7 @@ var layerTransformerTs = succeed10(
35222
35223
  return items.map((_) => _.source).join(" | ");
35223
35224
  }
35224
35225
  return `{
35225
- ${items.map(({ description, title, source }) => `${toComment(description)}${JSON.stringify(getOrNull(title))} = ${source}`).join(",\n ")}}
35226
+ ${items.map(({ description, title, source }) => `${toComment(description)}${JSON.stringify(getOrNull(title))}: ${source}`).join(",\n ")}} as const
35226
35227
  `;
35227
35228
  }
35228
35229
  })
@@ -35747,13 +35748,12 @@ export const ${name2}Error = <Tag extends string, E>(
35747
35748
  } else {
35748
35749
  pipeline.push("Effect.succeed");
35749
35750
  }
35750
- const successCodes = Array.from(
35751
- operation.successSchemas.keys(),
35752
- (_) => JSON.stringify(_)
35753
- ).join(", ");
35751
+ const successCodesRaw = Array.from(operation.successSchemas.keys());
35752
+ const successCodes = successCodesRaw.map((_) => JSON.stringify(_)).join(", ");
35753
+ const singleSuccessCode = successCodesRaw.length === 1 && successCodesRaw[0].startsWith("2");
35754
35754
  const errorCodes = Object.fromEntries(operation.errorSchemas.entries());
35755
35755
  pipeline.push(
35756
- `Effect.flatMap(onRequest([${successCodes}], ${JSON.stringify(errorCodes)}))`
35756
+ `Effect.flatMap(onRequest([${singleSuccessCode ? `"2xx"` : successCodes}], ${JSON.stringify(errorCodes)}))`
35757
35757
  );
35758
35758
  return `"${operation.id}": (${params}) => HttpClientRequest.make("${operation.method.toUpperCase()}")(${operation.pathTemplate}).pipe(
35759
35759
  ${pipeline.join(",\n ")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tim-smart/openapi-gen",
3
- "version": "0.3.15",
3
+ "version": "0.3.17",
4
4
  "description": "Generate Effect http clients from OpenAPI specs",
5
5
  "bin": "main.js",
6
6
  "repository": {