Skip to content

Commit

Permalink
fix: update generateOptionsFromSpec.ts to use ESM imports
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] and jamesbroadhead committed Jan 24, 2025
1 parent 63a2bad commit 10b823c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions generateOptionsFromSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ const typesMapping = {
boolean: 'boolean',
} as const;

(async () => {
const spec: OpenAPIV3.Document = (await SwaggerParser.dereference(
// Explicitly mark the IIFE as void to satisfy no-floating-promises
void (async () => {
const spec = (await SwaggerParser.dereference(
'./node_modules/@neondatabase/api-client/public-v2.yaml',
)) as any;
)) as OpenAPIV3.Document;
const outFile = createWriteStream('./src/parameters.gen.ts', 'utf8');
outFile.write('// FILE IS GENERATED, DO NOT EDIT\n\n');
EXTRACT_PROPERTIES.forEach((name) => {
Expand All @@ -40,7 +41,7 @@ const typesMapping = {
).forEach(([key, value]) => {
if (value.type === 'object' && value.properties) {
parseProperties(value, [...context, key]);
} else if (value.type! in typesMapping) {
} else if (value.type && value.type in typesMapping) {
outFile.write(
` '${[...context, key].join('.')}': {
type: ${JSON.stringify(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"lint:fix": "pnpm typecheck && eslint src --fix && prettier --w .",
"build": "pnpm generateParams && pnpm clean && tsc && cp src/*.html package*.json README.md ./dist",
"clean": "rm -rf dist",
"generateParams": "NODE_OPTIONS=\"--loader ts-node/esm\" node --experimental-specifier-resolution=node generateOptionsFromSpec.ts",
"generateParams": "ts-node generateOptionsFromSpec.ts",
"start": "node dist/index.js",
"pretest": "pnpm build",
"test": "vitest run",
Expand Down

0 comments on commit 10b823c

Please sign in to comment.