@keq-request/cli 5.0.0-alpha.23 → 5.0.0-alpha.24
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/CHANGELOG.md +15 -0
- package/dist/cli.cjs +111 -150
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +111 -150
- package/dist/cli.js.map +1 -1
- package/dist/compiler/tasks/download/index.d.ts.map +1 -1
- package/dist/compiler/tasks/setup/index.d.ts.map +1 -1
- package/dist/index.cjs +109 -150
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +109 -150
- package/dist/index.js.map +1 -1
- package/dist/models/api-document_v3_1.d.ts +0 -1
- package/dist/models/api-document_v3_1.d.ts.map +1 -1
- package/dist/models/artifact.d.ts +0 -2
- package/dist/models/artifact.d.ts.map +1 -1
- package/dist/plugins/generate-micro-function/generators/micro_function/micro-function.generator.d.ts.map +1 -1
- package/dist/plugins/generate-nestjs-module/generators/nestjs-module.generator.d.ts.map +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/initialize/initialize.plugin.d.ts.map +1 -1
- package/dist/plugins/overwrite-operation-id/index.d.ts +2 -0
- package/dist/plugins/overwrite-operation-id/index.d.ts.map +1 -0
- package/dist/plugins/overwrite-operation-id/overwrite-operation-id.plugin.d.ts +20 -0
- package/dist/plugins/overwrite-operation-id/overwrite-operation-id.plugin.d.ts.map +1 -0
- package/dist/plugins/overwrite-query-options/index.d.ts +2 -0
- package/dist/plugins/overwrite-query-options/index.d.ts.map +1 -0
- package/dist/plugins/overwrite-query-options/overwrite-query-options.plugin.d.ts +18 -0
- package/dist/plugins/overwrite-query-options/overwrite-query-options.plugin.d.ts.map +1 -0
- package/dist/plugins/prettier/index.d.ts +1 -5
- package/dist/plugins/prettier/index.d.ts.map +1 -1
- package/dist/plugins/prettier/prettier.plugin.d.ts +6 -0
- package/dist/plugins/prettier/prettier.plugin.d.ts.map +1 -0
- package/dist/plugins/shaking/shaking.plugin.d.ts.map +1 -1
- package/dist/plugins.cjs +172 -93
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.js +170 -93
- package/dist/plugins.js.map +1 -1
- package/dist/transformers/api-document/nestjs-client.renderer.d.ts +0 -3
- package/dist/transformers/api-document/nestjs-client.renderer.d.ts.map +1 -1
- package/dist/transformers/operation-definition/declaration.renderer.d.ts.map +1 -1
- package/dist/transformers/operation-definition/micro-function.renderer.d.ts +1 -1
- package/dist/transformers/operation-definition/micro-function.renderer.d.ts.map +1 -1
- package/dist/transformers/operation-definition/nestjs-method.renderer.d.ts +1 -1
- package/dist/transformers/operation-definition/nestjs-method.renderer.d.ts.map +1 -1
- package/dist/transformers/operation-definition/{typescript-helper.d.ts → typescript-snippet.d.ts} +1 -4
- package/dist/transformers/operation-definition/typescript-snippet.d.ts.map +1 -0
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/runtime-config.d.ts +1 -17
- package/dist/types/runtime-config.d.ts.map +1 -1
- package/dist/utils/openapi-utils/index.d.ts +4 -2
- package/dist/utils/openapi-utils/index.d.ts.map +1 -1
- package/dist/utils/openapi-utils/map-operation.d.ts +4 -0
- package/dist/utils/openapi-utils/map-operation.d.ts.map +1 -0
- package/dist/utils/openapi-utils/map-parameter.d.ts +4 -0
- package/dist/utils/openapi-utils/map-parameter.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/transformers/operation-definition/typescript-helper.d.ts.map +0 -1
- package/dist/types/operation-id-factory.d.ts +0 -10
- package/dist/types/operation-id-factory.d.ts.map +0 -1
- package/dist/types/qs.d.ts +0 -9
- package/dist/types/qs.d.ts.map +0 -1
- package/dist/utils/openapi-utils/update-operation-id.d.ts +0 -5
- package/dist/utils/openapi-utils/update-operation-id.d.ts.map +0 -1
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/constants/supported-methods.ts","../src/utils/logger.ts","../src/compiler/compiler.ts","../src/compiler/tasks/setup/index.ts","../src/utils/ignore-matcher.ts","../src/types/qs.ts","../src/constants/qs-array-format.ts","../src/types/runtime-config.ts","../src/constants/file-naming-style.ts","../src/compiler/tasks/setup/utils/validate-modules.ts","../src/compiler/tasks/setup/utils/find-nearest-package-json.ts","../src/compiler/tasks/setup/utils/get-project-module-system.ts","../src/compiler/tasks/download/index.ts","../src/models/artifact.ts","../src/models/utils/to-comment.ts","../src/models/anchor.ts","../src/models/api-document_v3_1.ts","../src/models/module-definition.ts","../src/models/operation-definition.ts","../src/utils/is-keywords.ts","../src/utils/is-reserved-word.ts","../src/models/schema-definition.ts","../src/models/asset.ts","../src/exception.ts","../src/utils/openapi-utils/dereference.ts","../src/utils/openapi-utils/dereference-operation.ts","../src/utils/openapi-utils/remove-undefined-ref.ts","../src/utils/openapi-utils/is-ref-defined.ts","../src/utils/openapi-utils/update-operation-id.ts","../src/utils/json-schema-utils/is-array.ts","../src/utils/json-schema-utils/is-mixed.ts","../src/utils/json-schema-utils/is-non-array.ts","../src/utils/json-schema-utils/is-ref.ts","../src/utils/json-schema-utils/index.ts","../src/utils/openapi-utils/dereference-deep.ts","../src/utils/openapi-utils/to-3_1.ts","../src/utils/openapi-utils/index.ts","../src/compiler/tasks/persist/index.ts","../src/compiler/tasks/compile/index.ts","../src/compiler/intercepter/print-information.ts","../src/compiler/intercepter/perfect-error-message.ts","../src/plugins/eslint/index.ts","../src/plugins/prettier/index.ts","../src/plugins/body-fallback/index.ts","../src/plugins/generate-micro-function/generate-micro-function.plugin.ts","../src/plugins/generate-micro-function/constants/metadata-storage.ts","../src/plugins/generate-micro-function/generators/micro_function/micro-function.generator.ts","../src/plugins/generate-declaration/generate-declaration.plugin.ts","../src/plugins/generate-declaration/generators/operation-declaration/operation.generator.ts","../src/transformers/json-schema/comment.renderer.ts","../src/transformers/json-schema/declaration.renderer.ts","../src/utils/indent.ts","../src/transformers/json-schema/reference.transformer.ts","../src/transformers/json-schema/json-schema.transformer.ts","../src/transformers/schema-definition/schema-definition.transformer.ts","../src/transformers/operation-definition/comment.renderer.ts","../src/transformers/operation-definition/declaration.renderer.ts","../src/transformers/operation-definition/utils/type-name-factory.ts","../src/transformers/operation-definition/micro-function.renderer.ts","../src/transformers/operation-definition/typescript-helper.ts","../src/transformers/operation-definition/nestjs-method.renderer.ts","../src/transformers/operation-definition/operation-definition.transformer.ts","../src/transformers/entrypoint/entrypoint.transformer.ts","../src/transformers/api-document/nestjs-client.renderer.ts","../src/transformers/api-document/nestjs-module.renderer.ts","../src/transformers/api-document/api-document.transformer.ts","../src/plugins/generate-declaration/generators/schema-declaration/schema.generator.ts","../src/plugins/generate-declaration/constants/metadata-storage.ts","../src/plugins/generate-micro-function/generators/request/request.generator.ts","../src/plugins/generate-nestjs-module/generate-nestjs-module.ts","../src/plugins/generate-nestjs-module/constants/metadata-storage.ts","../src/plugins/generate-nestjs-module/generators/nestjs-module.generator.ts","../src/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.ts","../src/plugins/download-http-file/download-http-file.plugin.ts","../src/plugins/download-local-file/download-local-file.plugin.ts","../src/plugins/shaking/shaking.plugin.ts","../src/plugins/terminal-select/utils/select-operation-definitions.ts","../src/plugins/terminal-select/terminal-select.plugin.ts","../src/plugins/initialize/initialize.plugin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport semver from 'semver'\nimport { Argument, Command, Option } from 'commander'\nimport { SupportedMethods } from './constants/supported-methods.js'\nimport { logger } from './utils/logger.js'\nimport { Compiler } from './compiler/compiler.js'\n\n\nif (semver.lt(process.version, '20.0.0')) {\n throw new Error('Node.js version must be greater than 20')\n}\n\nconst program = new Command()\n\n\nprogram\n .command('build')\n .option('-c --config <config>', 'The keq-cli config file')\n .option('--module <modules...>', 'Filter module(s) to generate')\n .option('--debug', 'Print debug information')\n .option('--tolerant', 'Tolerate wrong swagger/openapi structure')\n .option('-i --interactive', 'Interactive select the scope of generation')\n .action(async (options) => {\n const compiler = new Compiler({\n build: true,\n config: options.config,\n includes: options.module,\n debug: !!options.debug,\n tolerant: !!options.tolerant,\n interactive: !!options.interactive && {\n mode: 'except',\n clear: true,\n },\n })\n\n await compiler.run()\n })\n\n\nprogram\n .command('ignore')\n .addArgument(\n new Argument('<mode>', 'The ignore mode')\n .choices(['all', 'add', 'except'])\n .argRequired(),\n )\n .option('-c --config <config>', 'The keq-cli config file')\n .option('--debug', 'Print debug information')\n .option('--module <modules...>')\n .option('--build', 'Build after updating .keqignore file')\n .addOption(\n new Option('--method <method>', 'Only generate files of the specified operation method')\n .choices([\n ...SupportedMethods,\n ...SupportedMethods.map((method) => method.toUpperCase()),\n ]),\n )\n .option('--pathname <pathnames>', 'Only generate files of the specified operation pathname')\n .option('-i --interactive', 'Interactive select the scope of generation')\n .action(async (mode, options) => {\n let compiler: Compiler\n\n if (mode === 'all') {\n if (options.build) throw new Error(\"'--build' cannot be used with 'all' mode\")\n\n compiler = new Compiler({\n build: false,\n config: options.config,\n includes: options.module,\n debug: !!options.debug,\n interactive: false,\n ignore: {\n rules: [{\n persist: true,\n ignore: true,\n moduleName: '*',\n operationMethod: '*',\n operationPathname: '*',\n }],\n },\n })\n } else if (options.interactive) {\n if (options.interactive) {\n if (options.method) throw new Error(\"'--method' cannot be used with '--interactive'\")\n if (options.pathname) throw new Error(\"'--pathname' cannot be used with '--interactive'\")\n }\n\n compiler = new Compiler({\n build: !!options.build,\n config: options.config,\n includes: options.module,\n debug: !!options.debug,\n\n interactive: {\n mode,\n persist: true,\n },\n })\n } else {\n if (!options.method && !options.pathname) {\n throw new Error(\"at least one of '-i --interactive', '--method' or '--pathname' must be specified\")\n }\n\n const moduleNames = options.module || ['*']\n\n compiler = new Compiler({\n build: !!options.build,\n config: options.config,\n debug: !!options.debug,\n includes: options.module,\n ignore: {\n rules: moduleNames.map((moduleNames) => ({\n persist: true,\n ignore: mode === 'add',\n moduleName: moduleNames,\n operationMethod: options.method,\n operationPathname: options.pathname,\n })),\n },\n interactive: false,\n })\n }\n\n await compiler.run()\n })\n\nasync function main(): Promise<void> {\n program.on('command:*', function (operands) {\n throw new Error(`Unknown command '${String(operands[0])}'`)\n })\n\n try {\n await program.parseAsync(process.argv)\n } catch (err) {\n if (process.argv.includes('--debug')) {\n console.error(err)\n } else {\n logger.error(err instanceof Error ? err.message : String(err))\n }\n }\n}\n\nvoid main()\n","export const SupportedMethods = [\n 'get',\n 'post',\n 'put',\n 'delete',\n 'patch',\n 'head',\n 'options',\n]\n","import chalk from 'chalk'\n\n\nexport const logger = {\n log: (str: string) => console.log(chalk.green(str)),\n warn: (str: string) => console.warn(chalk.yellow(str)),\n error: (str: string) => console.error(chalk.red(str)),\n}\n","\n\nimport { Listr } from 'listr2'\nimport { AsyncParallelHook, AsyncSeriesBailHook, AsyncSeriesHook, AsyncSeriesWaterfallHook, SyncHook } from 'tapable'\nimport { CompilerHooks, CompilerContext } from './types/index.js'\nimport {\n ModuleDefinition,\n} from '~/models/index.js'\nimport {\n createCompileTask,\n createDownloadTask,\n createPersistTask,\n createSetupTask,\n SetupTaskOptions,\n TaskWrapper,\n} from './tasks/index.js'\nimport {\n perfectErrorMessage,\n printInformation,\n} from './intercepter/index.js'\nimport {\n InitializePlugin,\n TerminalSelectPluginOptions,\n} from '~/plugins/index.js'\n\n\ninterface Options extends SetupTaskOptions {\n includes: string[]\n build: boolean\n interactive?: boolean | TerminalSelectPluginOptions\n}\n\n\nexport class Compiler {\n context: CompilerContext = {}\n\n hooks: CompilerHooks = {\n setup: new AsyncParallelHook<[TaskWrapper]>(['task']),\n afterSetup: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n\n beforeDownload: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n download: new AsyncSeriesBailHook<[string, ModuleDefinition, TaskWrapper], string | undefined>(['address', 'moduleDefinition', 'task']),\n afterDownload: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n\n beforeCompile: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n compile: new AsyncParallelHook<[TaskWrapper]>(['task']),\n afterCompile: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n\n beforePersist: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n persist: new AsyncParallelHook<[TaskWrapper]>(['task']),\n afterPersist: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n\n done: new SyncHook<[]>(),\n }\n\n constructor(\n public options: Options,\n ) {\n for (const hook of Object.values(this.hooks)) {\n hook.intercept(perfectErrorMessage())\n }\n\n this.hooks.afterSetup.intercept(printInformation(0))\n this.hooks.afterPersist.intercept(printInformation(0))\n\n new InitializePlugin({\n build: options.build,\n interactive: options.interactive,\n includes: options.includes,\n }).apply(this)\n }\n\n async run(): Promise<void> {\n const options = this.options\n\n const tasks = new Listr<CompilerContext>(\n [\n createSetupTask(this, options),\n createDownloadTask(this, { skipIgnoredModules: !options.interactive }),\n createCompileTask(this, { enabled: !!options.build }),\n createPersistTask(this),\n ],\n {\n concurrent: false,\n renderer: 'default',\n rendererOptions: {\n suffixSkips: true,\n collapseSubtasks: false,\n collapseErrors: false,\n },\n },\n )\n\n await tasks.run(this.context)\n\n await this.hooks.done.promise()\n }\n}\n","import fs from 'fs-extra'\nimport path from 'path'\nimport { CosmiconfigResult } from 'cosmiconfig'\nimport { Value } from '@sinclair/typebox/value'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { ListrTask } from 'listr2'\nimport { IgnoreMatcher, IgnoreMatcherRule } from '~/utils/ignore-matcher.js'\nimport { RuntimeConfig } from '~/types/index.js'\nimport { validateModules, findNearestPackageJson, getProjectModuleSystem } from './utils/index.js'\nimport type { BaseTaskOptions } from '../types/base-task-options.js'\nimport type { Compiler } from '../../compiler.js'\nimport { CompilerContext } from '../../types/index.js'\n\n\nexport interface SetupTaskOptions {\n config?: string\n debug?: boolean\n tolerant?: boolean\n\n ignore?: false | {\n rules: IgnoreMatcherRule[]\n }\n}\n\nconst explore = cosmiconfig('keq')\n\nfunction main(compiler: Compiler, options: SetupTaskOptions): ListrTask<CompilerContext> {\n return {\n task: async (context, task) => {\n const result: CosmiconfigResult = options?.config\n ? await explore.load(options.config)\n : await explore.search()\n\n if (!result || ('isEmpty' in result && result.isEmpty)) {\n throw new Error('Cannot find config file.')\n }\n\n if (!Value.Check(RuntimeConfig, result.config)) {\n const errors = [...Value.Errors(RuntimeConfig, result.config)]\n const message = errors.map(({ path, message }) => `${path}: ${message}`).join('\\n')\n throw new Error(`Invalid Config: ${message}`)\n }\n\n const rc = Value.Default(RuntimeConfig, result.config) as RuntimeConfig\n\n validateModules(rc.modules)\n\n if (options?.debug) {\n await fs.ensureDir('.keq')\n rc.debug = true\n }\n\n if (options?.tolerant) {\n rc.tolerant = true\n }\n\n const packageJsonInfo = findNearestPackageJson()\n if (packageJsonInfo) {\n const moduleSystem = getProjectModuleSystem(packageJsonInfo)\n rc.esm = moduleSystem === 'esm'\n }\n\n context.rc = rc\n\n // Apply Plugins\n if (rc.plugins && rc.plugins.length) {\n for (const plugin of rc.plugins) {\n plugin.apply(compiler)\n }\n }\n\n\n // Setup IgnoreMatcher\n\n let matcher: IgnoreMatcher = new IgnoreMatcher([])\n if (result.filepath) {\n const ignoreFilepath = path.resolve(path.dirname(result.filepath), '.keqignore')\n if (await fs.exists(ignoreFilepath)) {\n matcher = await IgnoreMatcher.read(ignoreFilepath)\n }\n }\n\n const ignoreRules = options.ignore === false ? [] : options.ignore?.rules || []\n for (const rule of ignoreRules) {\n matcher.append({\n persist: !!rule.persist,\n ignore: rule.ignore,\n moduleName: rule.moduleName,\n operationMethod: rule.operationMethod,\n operationPathname: rule.operationPathname,\n })\n }\n\n context.matcher = matcher\n\n await compiler.hooks.setup.promise(task)\n },\n }\n}\n\nexport function createSetupTask(compiler: Compiler, options: SetupTaskOptions & BaseTaskOptions): ListrTask<CompilerContext> {\n return {\n title: 'Setup',\n enabled: options?.enabled,\n skip: options?.skip,\n task: (context, task) => task.newListr(\n [\n main(compiler, options),\n {\n task: (context, task) => compiler.hooks.afterSetup\n .promise(task),\n },\n ],\n {\n concurrent: false,\n },\n ),\n }\n}\n","import * as R from 'ramda'\nimport fs from 'fs-extra'\nimport { OperationDefinition, ModuleDefinition } from '~/models/index.js'\n\n\nexport interface IgnoreMatcherRule {\n persist: boolean\n ignore: boolean\n moduleName: string\n operationMethod: string\n operationPathname: string\n}\n\n\nexport class IgnoreMatcher {\n private rules: IgnoreMatcherRule[]\n\n constructor(rules: IgnoreMatcherRule[]) {\n this.rules = rules\n }\n\n static async read(filepath: string): Promise<IgnoreMatcher> {\n let content = await fs.readFile(filepath, 'utf-8')\n\n content = content\n .replace(/\\r\\n/g, '\\n')\n .replace(/\\r/g, '\\n')\n .replace(/#.*$/gm, '')\n .replace(/\\n+/g, '\\n')\n .trim()\n\n let rules = content\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.length > 0)\n .map((line): IgnoreMatcherRule => {\n const matched = line.match(/^(!)?\\s*([^\\s/]+)\\s+([^\\s/]+)\\s+([^\\s]+)$/)\n if (!matched) throw new Error(`Invalid ignore rule: \"${line}\"`)\n\n const [, flag, moduleName, operationMethod, operationPathname] = matched\n\n return {\n persist: true,\n ignore: !flag,\n moduleName,\n operationMethod: operationMethod.toLowerCase(),\n operationPathname,\n }\n })\n rules = R.sortBy(\n R.prop('ignore'),\n rules,\n )\n\n rules = R.uniqWith(\n (a, b) => a.moduleName === b.moduleName && a.operationMethod === b.operationMethod && a.operationPathname === b.operationPathname,\n rules,\n )\n\n return new IgnoreMatcher(rules)\n }\n\n async write(filepath: string): Promise<void> {\n const ruleGroups = R.compose(\n R.groupBy((rule: IgnoreMatcherRule) => rule.moduleName),\n R.reverse,\n R.uniqWith<IgnoreMatcherRule>(\n (a, b) => a.moduleName === b.moduleName && a.operationMethod === b.operationMethod && a.operationPathname === b.operationPathname,\n ),\n R.filter((rule: IgnoreMatcherRule) => rule.persist),\n )(this.rules)\n\n const content = Object.entries(ruleGroups)\n .sort((a, b) => {\n const aModuleName = a[0]\n const bModuleName = b[0]\n\n if (aModuleName === '*') return -1\n if (bModuleName === '*') return 1\n\n return aModuleName.localeCompare(bModuleName)\n })\n .map(([, rules]) => (rules || [])\n .sort((a, b) => {\n if (a.ignore !== b.ignore) return a.ignore ? -1 : 1\n\n if (a.operationMethod === '*') return -1\n if (b.operationMethod === '*') return 1\n if (a.operationPathname === '*') return -1\n if (b.operationPathname === '*') return 1\n\n if (a.operationMethod !== b.operationMethod) return a.operationMethod.localeCompare(b.operationMethod)\n if (a.operationPathname !== b.operationPathname) return a.operationPathname.localeCompare(b.operationPathname)\n\n return 0\n })\n .map((rule) => `${rule.ignore ? '' : '! '}${rule.moduleName} ${rule.operationMethod.toUpperCase()} ${rule.operationPathname}`)\n .join('\\n'))\n .join('\\n\\n')\n\n await fs.writeFile(filepath, content, 'utf-8')\n }\n\n append(rule: IgnoreMatcherRule): void {\n this.rules.unshift(rule)\n }\n\n // if operation is ignored, return true\n isOperationIgnored(operationDefinition: OperationDefinition): boolean {\n const moduleName = operationDefinition.module.name\n const operationMethod = operationDefinition.method.toLowerCase()\n const operationPathname = operationDefinition.pathname\n\n for (const rule of this.rules) {\n if (rule.moduleName !== '*' && rule.moduleName !== moduleName) continue\n if (rule.operationMethod !== '*' && rule.operationMethod !== operationMethod) continue\n if (rule.operationPathname !== '*' && rule.operationPathname !== operationPathname) continue\n\n return rule.ignore\n }\n\n return false\n }\n\n isModuleIgnored(moduleDefinition: ModuleDefinition): boolean {\n const moduleName = moduleDefinition.name\n\n for (const rule of this.rules) {\n if (!rule.ignore) {\n if (rule.moduleName === '*' || rule.moduleName === moduleName) return false\n continue\n }\n\n if (rule.operationMethod !== '*') continue\n if (rule.operationPathname !== '*') continue\n\n if (rule.moduleName === '*' || rule.moduleName === moduleName) return true\n }\n\n return false\n }\n}\n","import { Static, Type } from '@sinclair/typebox'\nimport { QsArrayFormat } from '~/constants/qs-array-format.js'\n\n\nexport const Qs = Type.Object({\n indices: Type.Optional(Type.Boolean()),\n arrayFormat: Type.Optional(Type.Enum(QsArrayFormat)),\n allowDots: Type.Optional(Type.Boolean()),\n})\n\nexport type Qs = Static<typeof Qs>\n","export enum QsArrayFormat {\n brackets = 'brackets',\n indices = 'indices',\n repeat = 'repeat',\n comma = 'comma',\n space = 'space',\n pipe = 'pipe',\n}\n","import { KeqQueryOptions } from 'keq'\nimport { Static, Type } from '@sinclair/typebox'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { OperationIdFactory } from './operation-id-factory.js'\nimport { FileNamingStyle } from '../constants/file-naming-style.js'\nimport { Qs } from './qs.js'\nimport { Plugin } from './plugin.js'\n\n\nexport const RuntimeConfig = Type.Object({\n mode: Type.Optional(\n Type.Union([\n Type.Literal('micro-function'),\n Type.Literal('nestjs-module'),\n Type.Literal('none'),\n ], { default: 'micro-function' }),\n ),\n\n /**\n * Whether to generate ES Module code\n *\n * If not specified, the module system will be inferred from the nearest package.json \"type\" field\n * or defaults to \"cjs\" if no package.json is found.\n */\n esm: Type.Optional(Type.Boolean({ default: false })),\n\n /**\n * Output directory for generated files\n */\n outdir: Type.String({ default: `${process.cwd()}/api` }),\n\n /**\n * File naming style for generated files\n */\n fileNamingStyle: Type.Enum(FileNamingStyle, { default: FileNamingStyle.snakeCase }),\n\n modules: Type.Record(Type.String(), Type.String()),\n\n operationIdFactory: Type.Optional(Type.Function([Type.Any()], Type.String())),\n\n qs: Type.Optional(Type.Union([\n Qs,\n Type.Function([Type.Any()], Qs),\n ])),\n\n debug: Type.Optional(Type.Boolean({ default: false })),\n\n /**\n * Whether to tolerate wrong openapi/swagger structure\n */\n tolerant: Type.Optional(Type.Boolean({ default: false })),\n\n plugins: Type.Optional(Type.Array(Type.Any(), { default: [] })),\n})\n\n\nexport type KeqQueryOptionsFactory = (parameter: OpenAPIV3_1.ParameterObject) => KeqQueryOptions | undefined\n\nexport interface RuntimeConfig extends Omit<Static<typeof RuntimeConfig>, 'operationId' | 'qs' | 'plugins'> {\n operationIdFactory?: OperationIdFactory\n qs?: KeqQueryOptions | KeqQueryOptionsFactory\n plugins?: Plugin[]\n}\n","\nexport enum FileNamingStyle {\n camelCase = 'camelCase',\n capitalCase = 'capitalCase',\n constantCase = 'constantCase',\n dotCase = 'dotCase',\n headerCase = 'headerCase',\n noCase = 'noCase',\n paramCase = 'paramCase',\n pascalCase = 'pascalCase',\n pathCase = 'pathCase',\n sentenceCase = 'sentenceCase',\n snakeCase = 'snakeCase',\n}\n","import * as R from 'ramda'\nimport validator from 'validator'\n\n\nexport function validateModules(modules: Record<string, string>): void {\n const keys = Object.keys(modules)\n\n for (const key of keys) {\n if (!/^[A-Za-z_][A-Za-z0-9_$]*$/.test(key)) {\n throw new Error(`Module name \"${key}\" is not valid. It must start with a letter or underscore, and can only contain letters, numbers, and underscores.`)\n }\n }\n\n const keysGroupByLowerCase = R.groupBy(R.toLower, keys)\n\n for (const groupKey in keysGroupByLowerCase) {\n const keys = keysGroupByLowerCase[groupKey] || []\n if (keys.length > 1) {\n throw new Error(`Module names ${keys.map((name) => `\"${name}\"`).join(', ')} are case-insensitively duplicated.`)\n }\n }\n\n for (const key in modules) {\n const address = modules[key]\n\n if (validator.isURL(address, { require_host: true, require_protocol: true, protocols: ['http', 'https'] })) {\n continue\n }\n\n if (/^(\\/|\\.\\/|\\.\\.\\/)/.test(address)) {\n continue\n }\n\n throw new Error(`Module address \"${address}\" of module \"${key}\" is not valid. It must be a URL or a local path.`)\n }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nexport interface PackageJsonInfo {\n json: any\n path: string\n}\n\n\nexport function findNearestPackageJson(startDir = process.cwd()): PackageJsonInfo | null {\n let dir = startDir\n // 向上遍历直到磁盘根目录\n while (true) {\n const pkgPath = path.join(dir, 'package.json')\n if (fs.existsSync(pkgPath)) {\n const json = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))\n return { json, path: pkgPath }\n }\n const parent = path.dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n return null\n}\n","import { PackageJsonInfo } from './find-nearest-package-json.js'\n\ntype ModuleSystem = 'esm' | 'cjs'\n\nexport function getProjectModuleSystem(pkgInfo: PackageJsonInfo): ModuleSystem {\n if (!pkgInfo?.json) return 'cjs'\n const { json } = pkgInfo\n\n if (json.type === 'module') return 'esm'\n return 'cjs'\n}\n","import { ListrTask, PRESET_TIMER } from 'listr2'\nimport { validate } from '@scalar/openapi-parser'\nimport { ModuleDefinition, ApiDocumentV3_1 } from '~/models/index.js'\nimport { BaseTaskOptions } from '../types/base-task-options.js'\nimport type { Compiler } from '~/compiler/compiler.js'\nimport { CompilerContext } from '~/compiler/index.js'\nimport { Exception } from '~/exception.js'\nimport { OpenapiUtils } from '~/utils/openapi-utils/index.js'\n\n\ninterface DownloadTaskOptions {\n skipIgnoredModules?: boolean\n}\n\nfunction main(compiler: Compiler, options?: DownloadTaskOptions): ListrTask<CompilerContext> {\n return {\n task: (context, task) => {\n if (!context.rc || !context.matcher) {\n throw new Error('Please run setup task first.')\n }\n\n const rc = context.rc\n const matcher = context.matcher\n\n context.documents = []\n\n return task.newListr(\n Object.entries(rc.modules)\n .map(([moduleName, address]) => new ModuleDefinition(moduleName, address))\n .map((moduleDefinition): ListrTask<CompilerContext> => ({\n title: moduleDefinition.name,\n task: async (ctx, task) => {\n if (options?.skipIgnoredModules && matcher.isModuleIgnored(moduleDefinition)) {\n task.skip(`(${moduleDefinition.name}) is ignored`)\n return\n }\n\n task.output = `Downloaded from ${moduleDefinition.address}`\n\n const content = await compiler.hooks.download.promise(moduleDefinition.address, moduleDefinition, task)\n\n if (!content) {\n throw new Exception(moduleDefinition, `Cannot download document from ${moduleDefinition.address}`)\n }\n\n let spec = JSON.parse(content)\n\n const { valid, errors } = await validate(spec)\n if (!valid) {\n const message = `${moduleDefinition.name} module openapi/swagger file does not conform to the openapi specifications or have grammatical errors, which may cause unexpected errors: \\n${errors?.map((e) => ` - ${e.message}`).join('\\n')}`\n task.output = message\n }\n\n OpenapiUtils.dereferenceOperation(spec)\n const rc = context.rc\n if (rc?.operationIdFactory) {\n const operationIdFactory = rc.operationIdFactory\n spec = OpenapiUtils.updateOperationId(\n spec,\n (method, pathname, operation) => operationIdFactory({ method, pathname, operation, module: moduleDefinition }),\n )\n }\n\n const document = new ApiDocumentV3_1(\n spec,\n moduleDefinition,\n )\n\n ctx.documents?.push(document)\n },\n })),\n {\n concurrent: true,\n exitOnError: false,\n collectErrors: 'minimal',\n rendererOptions: {\n collapseSubtasks: false,\n // collapseSkips: false,\n suffixSkips: true,\n timer: PRESET_TIMER,\n },\n },\n )\n },\n }\n}\n\nexport function createDownloadTask(compiler: Compiler, options?: DownloadTaskOptions & BaseTaskOptions): ListrTask<CompilerContext> {\n return {\n title: 'Download',\n enabled: options?.enabled,\n skip: options?.skip,\n task: (_, task) => task.newListr(\n [\n main(compiler, options),\n {\n task: (context, task) => compiler.hooks.afterDownload\n .promise(task),\n },\n ],\n {\n concurrent: false,\n },\n ),\n }\n}\n","import * as path from 'path'\nimport { toComment } from './utils/to-comment.js'\nimport { Anchor } from './anchor.js'\n\n\nconst HeaderComment = [\n '// Code generated by keq-cli. DO NOT EDIT.',\n '// Code generated by keq-cli. DO NOT EDIT.',\n '// Code generated by keq-cli. DO NOT EDIT.',\n '',\n '',\n].join('\\n')\n\nexport class Artifact {\n id: string\n filepath: string\n warns: string[] = []\n content: string\n extensionName\n anchor = new Anchor(this)\n\n constructor(options: {\n id: string\n filepath: string\n content: string\n extensionName?: string\n }) {\n this.id = options.id\n this.filepath = options.filepath\n this.extensionName = options.extensionName || path.extname(options.filepath)\n this.content = options.content\n }\n\n get dirname(): string {\n return path.dirname(this.filepath)\n }\n\n addWarn(message: string): void {\n this.warns.push(message)\n }\n\n renderer(): string {\n let $warns = ''\n\n if (this.warns.length) {\n $warns = toComment([\n '!!! Here is some Problems !!!',\n '',\n this.warns,\n ].join('\\n'))\n $warns += '\\n\\n'\n }\n\n return `${HeaderComment}${$warns}${this.content}`\n }\n}\n","export function toComment(msg?: string): string {\n if (!msg) return ''\n\n return msg.split('\\n')\n .map((str) => `// ${str}`)\n .join('\\n')\n}\n","import type { Artifact } from './artifact.js'\n\nclass AnchorBlock {\n constructor(\n private artifact: Artifact,\n ) {}\n\n /**\n * Append content to the end of the anchor block.\n */\n append(anchorName: string, content: string): void {\n const lines = this.artifact.content.split('\\n')\n\n const anchor = `@anchor:${anchorName}:end`\n const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`))\n\n if (anchorIndex === -1) {\n throw new Error(`\"${anchor}\" not found in artifact \"${this.artifact.filepath}\".`)\n }\n\n lines.splice(anchorIndex, 0, content)\n this.artifact.content = lines.join('\\n')\n }\n\n prepend(anchorName: string, content: string): void {\n const lines = this.artifact.content.split('\\n')\n\n const anchor = `@anchor:${anchorName}:start`\n const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`))\n\n if (anchorIndex === -1) {\n throw new Error(`\"${anchor}\" not found in artifact \"${this.artifact.filepath}\".`)\n }\n\n lines.splice(anchorIndex + 1, 0, content)\n this.artifact.content = lines.join('\\n')\n }\n\n replace(anchorName: string, content: string): void {\n const lines = this.artifact.content.split('\\n')\n const startIndex = lines.findIndex((line) => line.includes(`/* @anchor:${anchorName}:start */`))\n const endIndex = lines.findIndex((line) => line.includes(`/* @anchor:${anchorName}:end */`))\n\n if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {\n throw new Error(`\"@anchor:${anchorName}:start\" or \"@anchor:${anchorName}:end\" not found in artifact \"${this.artifact.filepath}\".`)\n }\n\n lines.splice(startIndex + 1, endIndex - startIndex - 1, content)\n this.artifact.content = lines.join('\\n')\n }\n}\n\n\nexport class Anchor {\n block: AnchorBlock\n\n constructor(\n private artifact: Artifact,\n ) {\n this.block = new AnchorBlock(artifact)\n }\n\n append(anchorName: string, content: string): void {\n const lines = this.artifact.content.split('\\n')\n\n const anchor = `@anchor:${anchorName}`\n const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`))\n\n if (anchorIndex === -1) {\n throw new Error(`\"${anchor}\" not found in artifact \"${this.artifact.filepath}\".`)\n }\n\n lines.splice(anchorIndex + 1, 0, content)\n this.artifact.content = lines.join('\\n')\n }\n\n prepend(anchorName: string, content: string): void {\n const lines = this.artifact.content.split('\\n')\n\n const anchor = `@anchor:${anchorName}`\n const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`))\n\n if (anchorIndex === -1) {\n throw new Error(`\"${anchor}\" not found in artifact \"${this.artifact.filepath}\".`)\n }\n\n lines.splice(anchorIndex, 0, content)\n this.artifact.content = lines.join('\\n')\n }\n}\n","import * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { ModuleDefinition } from './module-definition.js'\nimport { SupportedMethods } from '~/constants/supported-methods.js'\nimport { OperationDefinition } from './operation-definition.js'\nimport { SchemaDefinition } from './schema-definition.js'\nimport { logger } from '~/utils/logger.js'\nimport { openapiShakingSync } from '@opendoc/openapi-shaking'\n\n\nexport class ApiDocumentV3_1 {\n readonly module: ModuleDefinition\n readonly specification: OpenAPIV3_1.Document\n\n constructor(specification: OpenAPIV3_1.Document, module: ModuleDefinition) {\n this.module = module\n this.specification = specification\n }\n\n get schemas(): SchemaDefinition[] {\n const module = this.module\n\n return Object.entries(this.specification.components?.schemas || {})\n .map(([name, schema]) => new SchemaDefinition({\n name,\n schema,\n module,\n document: this,\n }))\n }\n\n get operations(): OperationDefinition[] {\n const module = this.module\n\n return Object.entries(this.specification.paths || {})\n .flatMap(([pathname, pathItem]) => Object.entries(pathItem || {})\n .filter(([method]) => SupportedMethods.includes(method.toLowerCase()))\n .map(([method, operation]) => new OperationDefinition({\n method,\n pathname,\n operation,\n module,\n document: this,\n })))\n }\n\n isEmpty(): boolean {\n return R.isEmpty(this.specification.paths)\n }\n\n dereference($ref: string): SchemaDefinition | undefined {\n if ($ref.startsWith('#/')) {\n return this.schemas.find((schema) => schema.id.endsWith($ref))\n }\n\n logger.warn(`The $ref(${$ref}) is not defined in ${this.module.name} openapi/swagger.`)\n }\n\n isRefDefined($ref: string): boolean {\n if ($ref.startsWith('#/')) {\n const path = $ref.replace('#/', '').split('/')\n return R.path(path, this.specification) !== undefined\n }\n\n return false\n }\n\n sharking(filter: (operationDefinition: OperationDefinition) => boolean): ApiDocumentV3_1 {\n const isAccepted = (pathname: string, method: string, operation: OpenAPIV3_1.Document): boolean => {\n if (!SupportedMethods.includes(method)) return false\n\n const operationDefinition = new OperationDefinition({\n method,\n pathname,\n operation,\n module: this.module,\n document: this,\n })\n\n return filter(operationDefinition)\n }\n\n\n const sharkedSwagger = openapiShakingSync(\n this.specification as any,\n isAccepted as any,\n { tolerant: true },\n ) as OpenAPIV3_1.Document\n\n return new ApiDocumentV3_1(\n sharkedSwagger,\n new ModuleDefinition(\n this.module.name,\n `file://${this.module.name}.v3_1.sharked.json`,\n ),\n )\n }\n\n static unknown(): ApiDocumentV3_1 {\n return new ApiDocumentV3_1({}, ModuleDefinition.unknown())\n }\n}\n","export class ModuleDefinition {\n name: string\n address: string\n\n constructor(name: string, address: string) {\n this.name = name\n this.address = address\n }\n\n static unknown(): ModuleDefinition {\n return new ModuleDefinition('', '')\n }\n}\n","import * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { ModuleDefinition } from './module-definition.js'\nimport { isKeywords } from '~/utils/is-keywords.js'\nimport { isReservedWord } from '~/utils/is-reserved-word.js'\nimport { ApiDocumentV3_1 } from './api-document_v3_1.js'\nimport { JSONPath } from 'jsonpath-plus'\nimport { SchemaDefinition } from './schema-definition.js'\n\n\nexport class OperationDefinition {\n readonly module: ModuleDefinition\n\n readonly operationId: string\n readonly method: string\n readonly pathname: string\n readonly operation: OpenAPIV3_1.OperationObject\n readonly document: ApiDocumentV3_1\n\n get id(): string {\n return `${this.module.address}#/paths/${this.pathname}/${this.method}`\n }\n\n constructor(args: {\n method: string\n pathname: string\n operation: OpenAPIV3_1.OperationObject\n module: ModuleDefinition\n document: ApiDocumentV3_1\n }) {\n this.module = args.module\n this.method = args.method.toLowerCase()\n this.pathname = args.pathname\n this.document = args.document\n this.operationId = this.formatOperationId(args.method, args.pathname, args.operation)\n\n this.operation = {\n ...args.operation,\n operationId: this.operationId,\n }\n }\n\n private formatOperationId(method: string, pathname: string, operation: OpenAPIV3_1.OperationObject): string {\n const operationId = operation.operationId\n\n if (\n operationId\n && operationId !== 'index'\n && !isKeywords(operationId)\n && !isReservedWord(operationId)\n ) {\n return operationId as string\n }\n\n return `${method}_${pathname}`\n .replace(/\\//g, '_')\n .replace(/-/g, '_')\n .replace(/:/g, '$$')\n .replace(/{(.+)}/, '$$$1')\n }\n\n getDependencies(): SchemaDefinition[] {\n const refs = R.uniq([\n ...JSONPath<string>({\n path: '$.requestBody.content..schema..$ref',\n json: this.operation,\n }),\n ...JSONPath<string>({\n path: '$.responses..content..schema..$ref',\n json: this.operation,\n }),\n ...JSONPath<string>({\n path: '$.parameters..schema..$ref',\n json: this.operation,\n }),\n ])\n\n const dependencies = refs\n .filter((ref) => typeof ref === 'string' && ref)\n .map((ref) => {\n const schemaDefinition = this.document.dereference(ref)\n if (schemaDefinition) return schemaDefinition\n\n return SchemaDefinition.unknown()\n })\n\n return dependencies\n }\n}\n","const keywords = [\n 'break',\n 'case',\n 'catch',\n 'continue',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'in',\n 'instanceof',\n 'new',\n 'return',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n]\n\nexport function isKeywords(str: string): boolean {\n return keywords.includes(str)\n}\n","\nconst reservedWords = [\n 'abstract',\n 'boolean',\n 'byte',\n 'char',\n 'class',\n 'const',\n 'debugger',\n 'double',\n 'enum',\n 'export',\n 'extends',\n 'final',\n 'float',\n 'goto',\n 'implements',\n 'import',\n 'int',\n 'interface',\n 'long',\n 'native',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'short',\n 'static',\n 'super',\n 'synchronized',\n 'throws',\n 'transient',\n 'volatile',\n]\n\nexport function isReservedWord(str: string): boolean {\n return reservedWords.includes(str)\n}\n","import * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { ModuleDefinition } from './module-definition.js'\nimport { JSONPath } from 'jsonpath-plus'\nimport { ApiDocumentV3_1 } from './api-document_v3_1.js'\n\n\nexport class SchemaDefinition {\n readonly name: string\n readonly schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject\n readonly module: ModuleDefinition\n readonly document: ApiDocumentV3_1\n\n get id(): string {\n return `${this.module.address}#/components/schemas/${this.name}`\n }\n\n constructor(args: {\n name: string\n schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject\n module: ModuleDefinition\n document: ApiDocumentV3_1\n }) {\n this.module = args.module\n this.name = args.name\n this.schema = args.schema\n this.document = args.document\n }\n\n getDependencies(): SchemaDefinition[] {\n const refs: string[] = R.uniq(JSONPath({\n path: \"$..*['$ref']\",\n json: this.schema,\n }))\n\n return refs\n .filter((ref) => typeof ref === 'string' && !!ref.trim())\n .map((ref) => {\n const definition = this.document.dereference(ref)\n if (definition) return definition\n\n return SchemaDefinition.unknown()\n })\n }\n\n static unknown(): SchemaDefinition {\n return new SchemaDefinition({\n name: '',\n schema: {},\n module: ModuleDefinition.unknown(),\n document: ApiDocumentV3_1.unknown(),\n })\n }\n\n static isUnknown(definition: SchemaDefinition): boolean {\n return definition.name === ''\n }\n}\n","export class Asset {\n path: string\n\n constructor(path: string) {\n this.path = path\n }\n}\n","import { CustomError } from 'ts-custom-error'\nimport wrap from 'word-wrap'\nimport { ModuleDefinition } from '~/models/index.js'\n\n\nexport class Exception extends CustomError {\n constructor(module: ModuleDefinition | string, message: string) {\n const moduleName = typeof module === 'string' ? module : module.name\n\n const msg = wrap(message, { width: 60, indent: ' ' })\n super(`${moduleName} module failed to compile:\\n${msg}`)\n\n Object.defineProperty(this, 'name', { value: 'KeqCLI_Exception' })\n }\n}\n","import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\n\nexport function dereference<T extends OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ResponseObject | OpenAPIV3_1.ParameterObject | OpenAPIV3_1.RequestBodyObject | OpenAPIV3_1.ReferenceObject>($ref: string, swagger: OpenAPIV3_1.Document): T {\n let value\n\n for (const key of $ref.split('/')) {\n if (key === '#') {\n value = swagger\n } else {\n value = value[key]\n }\n\n if (!value) break\n }\n\n return value as T\n}\n","import * as R from 'ramda'\nimport jsonpointer from 'jsonpointer'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { JSONPath } from 'jsonpath-plus'\nimport { removeUndefinedRef } from './remove-undefined-ref.js'\nimport { dereference } from './dereference.js'\n\n\nfunction dereferencePathObject(swagger: OpenAPIV3_1.Document): void {\n const matches = JSONPath({\n path: '$.paths.*.$ref^',\n json: swagger,\n resultType: 'all',\n })\n\n for (const match of matches) {\n const value = dereference(match.value.$ref, swagger)\n jsonpointer.set(swagger, match.pointer, value)\n }\n}\n\nfunction dereferenceRequestBody(swagger: OpenAPIV3_1.Document): void {\n const matches = JSONPath({\n path: '$.paths.*.*.requestBody.$ref^',\n json: swagger,\n resultType: 'all',\n })\n\n for (const match of matches) {\n const value = dereference(match.value.$ref, swagger)\n jsonpointer.set(swagger, match.pointer, value)\n }\n}\n\nexport function dereferenceResponses(swagger: OpenAPIV3_1.Document): void {\n const matches = [\n ...JSONPath({\n path: '$.paths.*.*.responses.*.$ref^',\n json: swagger,\n resultType: 'all',\n }),\n ...JSONPath({\n path: '$.paths.*.*.responses.*.headers.*.$ref^',\n json: swagger,\n resultType: 'all',\n }),\n ]\n\n for (const match of matches) {\n const value = dereference(match.value.$ref, swagger)\n jsonpointer.set(swagger, match.pointer, value)\n }\n}\n\nfunction dereferenceParameters(swagger: OpenAPIV3_1.Document): void {\n const matches = JSONPath({\n path: '$.paths.*.*.parameters.*.$ref^',\n json: swagger,\n resultType: 'all',\n })\n\n for (const match of matches) {\n const value = dereference(match.value.$ref, swagger)\n jsonpointer.set(swagger, match.pointer, value)\n }\n}\n\nexport function dereferenceOperation(swagger: OpenAPIV3_1.Document): OpenAPIV3_1.Document {\n const shadow = R.clone(swagger)\n\n dereferencePathObject(shadow)\n dereferenceRequestBody(shadow)\n dereferenceResponses(shadow)\n dereferenceParameters(shadow)\n\n return removeUndefinedRef(shadow)\n}\n","import * as R from 'ramda'\nimport jsonpointer from 'jsonpointer'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { JSONPath } from 'jsonpath-plus'\nimport { isRefDefined } from './is-ref-defined.js'\n\n\n// remove schema $ref if the reference is not founded\nexport function removeUndefinedRef(swagger: OpenAPIV3_1.Document): OpenAPIV3_1.Document {\n const shadow = R.clone(swagger)\n\n const matches = JSONPath({\n path: \"$..*['$ref']^\",\n json: swagger,\n resultType: 'all',\n })\n\n for (const match of matches) {\n if (match.value.$ref && !isRefDefined(match.value.$ref, swagger)) {\n jsonpointer.set(shadow, match.pointer, R.omit(['$ref'], match.value))\n }\n }\n\n return shadow\n}\n","import * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\n\nexport function isRefDefined($ref: string, swagger: OpenAPIV3_1.Document): boolean {\n if ($ref.startsWith('#/')) {\n const path = $ref.replace('#/', '').split('/')\n return R.path(path, swagger) !== undefined\n }\n\n return false\n}\n\n","import * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { SupportedMethods } from '~/constants/supported-methods.js'\n\n\ntype OperationUpdater = (method: string, pathname: string, operation: OpenAPIV3_1.OperationObject) => string | undefined\n\n\nexport function updateOperationId(swagger: OpenAPIV3_1.Document, fn: OperationUpdater): OpenAPIV3_1.Document {\n const shadow = R.clone(swagger)\n\n for (const [pathname, pathItem] of Object.entries(shadow.paths || {})) {\n for (const m in pathItem) {\n const method = m.toLowerCase()\n if (!SupportedMethods.includes(method)) continue\n if (typeof pathItem[m] !== 'object' || Array.isArray(pathItem[m]) || pathItem[m] === null) continue\n\n const operation: OpenAPIV3_1.OperationObject = pathItem[m]\n const operationId = fn(method, pathname, operation)\n\n if (typeof operationId === 'string' && operationId.length > 0) {\n operation.operationId = operationId\n }\n }\n }\n\n return shadow\n}\n","import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nexport function isArray(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject): schema is OpenAPIV3_1.ArraySchemaObject {\n return schema.type === 'array'\n}\n","\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { MixedSchemaObject } from './types/mixed-schema-object.js'\n\nexport function isMixed(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject): schema is MixedSchemaObject {\n return Array.isArray(schema.type)\n}\n","import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nexport function isNonArray(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject): schema is OpenAPIV3_1.NonArraySchemaObject {\n return typeof schema.type === 'string' && schema.type !== 'array'\n}\n","import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\n\nexport function isRef(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.ResponseObject | OpenAPIV3_1.ParameterObject): schema is OpenAPIV3_1.ReferenceObject {\n return '$ref' in schema\n}\n","import { isArray } from './is-array.js'\nimport { isMixed } from './is-mixed.js'\nimport { isNonArray } from './is-non-array.js'\nimport { isRef } from './is-ref.js'\n\n\nexport class JsonSchemaUtils {\n static isRef = isRef\n static isArray = isArray\n static isNonArray = isNonArray\n static isMixed = isMixed\n}\n","import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { dereference } from './dereference.js'\nimport { JsonSchemaUtils } from '../json-schema-utils/index.js'\n\n\nexport function dereferenceDeep<T extends OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ResponseObject | OpenAPIV3_1.ParameterObject | OpenAPIV3_1.RequestBodyObject>($ref: string, swagger: OpenAPIV3_1.Document): T {\n const stack = [$ref]\n let value\n\n while (true) {\n const last = stack[stack.length - 1]\n value = dereference(last, swagger)\n\n if (JsonSchemaUtils.isRef(value)) {\n if (!stack.includes(value.$ref)) {\n stack.push(value.$ref)\n continue\n } else {\n // Circular reference detected\n throw new Error(`Circular reference detected: ${stack.join(' -> ')} -> ${value.$ref}`)\n }\n }\n\n break\n }\n\n return value as T\n}\n","import { upgrade } from '@scalar/openapi-parser'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nexport function To3_1(openapi: object): OpenAPIV3_1.Document {\n const { specification } = upgrade(openapi)\n return specification\n}\n","import { dereference } from './dereference.js'\nimport { dereferenceOperation } from './dereference-operation.js'\nimport { isRefDefined } from './is-ref-defined.js'\nimport { removeUndefinedRef } from './remove-undefined-ref.js'\nimport { updateOperationId } from './update-operation-id.js'\nimport { dereferenceDeep } from './dereference-deep.js'\nimport { To3_1 } from './to-3_1.js'\n\n\nexport class OpenapiUtils {\n static isRefDefined = isRefDefined\n static dereference = dereference\n static dereferenceDeep = dereferenceDeep\n static removeUndefinedRef = removeUndefinedRef\n static dereferenceOperation = dereferenceOperation\n static updateOperationId = updateOperationId\n static to3_1 = To3_1\n}\n","import * as path from 'path'\nimport fs from 'fs-extra'\nimport { ListrTask } from 'listr2'\nimport { BaseTaskOptions } from '../types/base-task-options.js'\nimport type { Compiler, CompilerContext } from '~/compiler/index.js'\nimport { Asset } from '~/models/index.js'\n\n\nfunction createPersistArtifactTask(): ListrTask<CompilerContext> {\n return {\n title: 'Write files',\n task: async (context, task) => {\n if (!context.rc) throw new Error('Please run setup task first.')\n if (!context.artifacts || context.artifacts.length === 0) {\n task.skip('No compiled artifacts to persist.')\n return\n }\n\n const rc = context.rc\n const artifacts = context.artifacts\n\n const total = artifacts.length\n let completed = 0\n\n const files = await Promise.all(artifacts.map(async (artifact): Promise<Asset> => {\n const realpath = `./${path.join(rc.outdir, artifact.filepath)}`\n await fs.ensureFile(realpath)\n await fs.writeFile(realpath, artifact.renderer())\n\n completed += 1\n task.output = `Persisted ${completed}/${total} files`\n\n return new Asset(path.resolve(realpath))\n }))\n\n context.assets = files\n },\n }\n}\n\nfunction createPersistIgnoreTask(): ListrTask<CompilerContext> {\n return {\n title: 'Update .keqignore',\n task: async (context, task) => {\n if (!context.matcher) throw new Error('Please run setup task first.')\n\n const matcher = context.matcher\n await matcher.write('.keqignore')\n },\n }\n}\n\n\nfunction main(): ListrTask<CompilerContext> {\n return {\n task: (context, task) => task.newListr(\n [\n createPersistArtifactTask(),\n createPersistIgnoreTask(),\n ],\n {\n concurrent: true,\n rendererOptions: {\n collapseSubtasks: true,\n },\n },\n ),\n }\n}\n\nexport function createPersistTask(compiler: Compiler, options?: BaseTaskOptions): ListrTask<CompilerContext> {\n return {\n title: 'Persist',\n enabled: options?.enabled,\n skip: options?.skip,\n task: (context, task) => task.newListr(\n [\n main(),\n {\n task: (context, task) => compiler.hooks.afterPersist\n .promise(task),\n },\n ],\n {\n concurrent: false,\n },\n ),\n }\n}\n","import { ListrTask } from 'listr2'\nimport { BaseTaskOptions } from '../types/base-task-options.js'\nimport type { Compiler } from '~/compiler/compiler.js'\nimport { CompilerContext } from '~/compiler/index.js'\n// import { RequestGenerator } from '~/generators/index.js'\n\n\nfunction main(compiler: Compiler): ListrTask<CompilerContext> {\n return {\n task: async (context, task) => {\n if (!context.rc) throw new Error('Please run setup task first.')\n if (!context.documents) throw new Error('Please run shaking task first.')\n\n context.artifacts = []\n\n await compiler.hooks.compile.promise(task)\n },\n }\n}\n\nexport function createCompileTask(compiler: Compiler, options?: BaseTaskOptions): ListrTask<CompilerContext> {\n return {\n title: 'Compile',\n enabled: options?.enabled,\n skip: options?.skip,\n task: (context, task) => task.newListr(\n [\n {\n task: (context, task) => compiler.hooks.beforeCompile\n .promise(task),\n },\n main(compiler),\n {\n task: (context, task) => compiler.hooks.afterCompile\n .promise(task),\n },\n ],\n {\n concurrent: false,\n },\n ),\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport { FullTap, HookInterceptor } from 'tapable'\nimport { TaskWrapper } from '../tasks/index.js'\n\n\nexport function proxyTaskWrapper(pluginName: string, task: TaskWrapper): TaskWrapper {\n return new Proxy(task, {\n set(target, prop, value) {\n if (prop !== 'output') {\n return Reflect.set(target, prop, value)\n }\n\n target.output = `[Plugin: ${pluginName}] ${value}`\n return true\n },\n })\n}\n\n\nexport function printInformation(taskIndex: number): HookInterceptor<unknown, unknown> {\n return {\n register: <T extends FullTap>(tap: T): T => {\n const fn = tap.fn\n\n if (tap.type === 'promise') {\n tap.fn = (...args: any[]) => {\n const task = args[taskIndex] as TaskWrapper\n const proxyTask = proxyTaskWrapper(tap.name, task)\n args[taskIndex] = proxyTask\n proxyTask.output = 'Processing...'\n return fn(...args)\n }\n }\n\n if (tap.type === 'sync') {\n tap.fn = (...args: any[]) => {\n const task = args[taskIndex] as TaskWrapper\n const proxyTask = proxyTaskWrapper(tap.name, task)\n args[taskIndex] = proxyTask\n proxyTask.output = 'Processing...'\n return fn(...args)\n }\n }\n\n if (tap.type === 'async') {\n tap.fn = (...args: any[]) => {\n const task = args[taskIndex] as TaskWrapper\n const proxyTask = proxyTaskWrapper(tap.name, task)\n args[taskIndex] = proxyTask\n proxyTask.output = 'Processing...'\n return fn(...args)\n }\n }\n\n return tap\n },\n }\n}\n\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport * as R from 'ramda'\nimport { FullTap, HookInterceptor, InnerCallback } from 'tapable'\n\nexport function perfectErrorMessage(): HookInterceptor<unknown, unknown> {\n return {\n register: <T extends FullTap>(tap: T): T => {\n const fn = tap.fn\n\n function prefix(err: unknown): void {\n if (err instanceof Error) {\n err.message = `[Plugin: ${tap.name}] ${err.message}`\n }\n }\n\n if (tap.type === 'promise') {\n tap.fn = async (...args: any[]) => {\n try {\n return await fn(...args)\n } catch (err) {\n prefix(err)\n throw err\n }\n }\n }\n\n if (tap.type === 'sync') {\n tap.fn = (...args: any[]) => {\n try {\n return fn(...args)\n } catch (err) {\n prefix(err)\n throw err\n }\n }\n }\n\n if (tap.type === 'async') {\n tap.fn = (...args: any[]) => {\n const callback = R.last(args) as InnerCallback<Error, any>\n\n return fn(...R.init(args), (err: Error | null, result: any) => {\n prefix(err)\n return callback(err, result)\n })\n }\n }\n\n return tap\n },\n }\n}\n","import { Compiler } from '~/compiler/compiler.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { ESLint } from 'eslint'\n\n\ninterface EslintPluginOptions {\n /**\n * List of ESLint rules to disable\n */\n disable?: string[]\n}\n\nexport class EslintPlugin implements Plugin {\n constructor(private options: EslintPluginOptions = {}) {}\n\n\n apply(compiler: Compiler): void {\n if (!compiler.options.build) return\n\n if (this.options.disable && this.options.disable.length > 0) {\n const $rules = [\n ...this.options.disable.map((rule) => `/* eslint-disable ${rule} */`),\n ].join('\\n')\n\n compiler.hooks.afterCompile.tap(EslintPlugin.name, () => {\n const artifacts = compiler.context.artifacts || []\n\n for (const artifact of artifacts) {\n artifact.anchor.append('file:start', $rules)\n }\n })\n }\n\n compiler.hooks.afterPersist.tapPromise(EslintPlugin.name, async (task) => {\n const files = compiler.context.assets || []\n if (files.length === 0) return\n\n const eslint = new ESLint({ fix: true })\n const results = await eslint.lintFiles(files.map((file) => file.path))\n await ESLint.outputFixes(results)\n })\n }\n}\n","import { Compiler } from '~/compiler/compiler.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { exec } from 'child_process'\nimport { promisify } from 'util'\n\nconst execAsync = promisify(exec)\n\n\nexport class PrettierPlugin implements Plugin {\n apply(compiler: Compiler): void {\n if (!compiler.options.build) return\n\n compiler.hooks.afterPersist.tapPromise(PrettierPlugin.name, async () => {\n const files = compiler.context.assets || []\n if (files.length === 0) return\n\n const filePaths = files.map((file) => file.path).join(' ')\n await execAsync(`prettier --write ${filePaths}`)\n })\n }\n}\n","import * as R from 'ramda'\nimport { Compiler } from '~/compiler/compiler.js'\nimport { Artifact, OperationDefinition } from '~/models/index.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { JsonSchemaUtils } from '~/utils/json-schema-utils/index.js'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nimport { GenerateMicroFunctionPlugin } from '../generate-micro-function/index.js'\n\n\nexport class BodyFallbackPlugin implements Plugin {\n apply(compiler: Compiler): void {\n compiler.hooks.setup.tap(BodyFallbackPlugin.name, () => {\n const generateMicroFunctionPluginMetadata = GenerateMicroFunctionPlugin.of(compiler)\n\n if (!generateMicroFunctionPluginMetadata) {\n throw new Error('BodyFallbackPlugin requires GenerateMicroFunctionPlugin to be applied first.')\n }\n\n generateMicroFunctionPluginMetadata.hooks.afterMicroFunctionArtifactGenerated\n .tap(BodyFallbackPlugin.name, (artifact: Artifact, operationDefinition: OperationDefinition) => {\n const operation = operationDefinition.operation\n\n const parameters = operation.parameters?.filter((p): p is OpenAPIV3_1.ParameterObject => !JsonSchemaUtils.isRef(p)) || []\n const keys = parameters.map((p) => p.name).filter(R.isNotNil)\n\n const $acc = !keys.length\n ? ' acc[key] = args[key]'\n : [\n ` if (![${keys.map((k) => JSON.stringify(k)).join(', ')}].includes(key)) {`,\n ' acc[key] = args[key]',\n ' }',\n ].join('\\n')\n\n artifact.anchor.block.replace('body', [\n // $mediaType ? `${$mediaType}\\n` : undefined,\n ' if (typeof args === \"object\" && args !== null && !Array.isArray(args)) {',\n ' const requestBody = Object.keys(args)',\n ' .reduce((acc, key) => {',\n $acc,\n ' return acc',\n ' }, {} as Record<string, unknown>)',\n '',\n ' if (Object.keys(requestBody).length > 0) {',\n ' req.send(requestBody)',\n ' }',\n ' }',\n ].filter(R.isNotNil).join('\\n'))\n\n return artifact\n })\n })\n }\n}\n","import { AsyncSeriesWaterfallHook } from 'tapable'\nimport { Plugin } from '~/types/index.js'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { Artifact, OperationDefinition } from '~/models/index.js'\nimport { GenerateMicroFunctionPluginMetadata, MetadataStorage } from './constants/index.js'\nimport { MicroFunctionGenerator, RequestGenerator } from './generators/index.js'\n\n\nexport class GenerateMicroFunctionPlugin implements Plugin {\n private readonly microFunctionGenerator = new MicroFunctionGenerator()\n private readonly requestGenerator = new RequestGenerator()\n\n apply(compiler: Compiler): void {\n GenerateMicroFunctionPlugin.register(compiler)\n\n compiler.hooks.compile.tapPromise(GenerateMicroFunctionPlugin.name, async (task: TaskWrapper) => {\n const artifacts = [\n ...(await this.requestGenerator.compile(compiler, task)),\n ...(await this.microFunctionGenerator.compile(compiler, task)),\n ]\n\n compiler.context.artifacts!.push(...artifacts)\n })\n }\n\n static register(compiler: Compiler): GenerateMicroFunctionPluginMetadata {\n if (!MetadataStorage.has(compiler)) {\n MetadataStorage.set(compiler, {\n hooks: {\n afterEntrypointArtifactGenerated: new AsyncSeriesWaterfallHook<[Artifact, TaskWrapper]>(['artifact', 'task']),\n afterMicroFunctionArtifactGenerated: new AsyncSeriesWaterfallHook<[Artifact, OperationDefinition, TaskWrapper]>(['artifact', 'operationDefinition', 'task']),\n },\n })\n }\n\n return MetadataStorage.get(compiler)!\n }\n\n\n static of(compiler: Compiler): GenerateMicroFunctionPluginMetadata | undefined {\n return this.register(compiler)\n }\n}\n","import { AsyncSeriesWaterfallHook } from 'tapable'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { Artifact, OperationDefinition } from '~/models/index.js'\n\nexport interface GenerateMicroFunctionPluginMetadata {\n hooks: {\n afterEntrypointArtifactGenerated: AsyncSeriesWaterfallHook<[Artifact, TaskWrapper]>\n afterMicroFunctionArtifactGenerated: AsyncSeriesWaterfallHook<[Artifact, OperationDefinition, TaskWrapper]>\n }\n}\n\nexport const MetadataStorage = new WeakMap<Compiler, GenerateMicroFunctionPluginMetadata>()\n","import * as R from 'ramda'\nimport * as path from 'path'\nimport * as changeCase from 'change-case'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { Generator, RuntimeConfig } from '~/types/index.js'\nimport { Artifact, ModuleDefinition, OperationDefinition } from '~/models/index.js'\nimport { OperationDeclarationGenerator } from '~/plugins/generate-declaration/index.js'\nimport { OperationDefinitionTransformer } from '~/transformers/index.js'\nimport { EntrypointTransformer } from '~/transformers/index.js'\nimport { FileNamingStyle } from '~/constants/index.js'\nimport { MetadataStorage } from '../../constants/metadata-storage.js'\nimport { RequestGenerator } from '../request/index.js'\n\n\nexport const MICRO_FUNCTION_GENERATOR = 'microFunctionGenerator'\n\nexport class MicroFunctionGenerator implements Generator {\n async compile(compiler: Compiler, task: TaskWrapper): Promise<Artifact[]> {\n const metadata = MetadataStorage.get(compiler)!\n const context = compiler.context\n const rc = context.rc!\n const documents = context.documents!\n\n const operationDefinitions = documents.flatMap((document) => document.operations)\n\n const artifactMap = new Map<OperationDefinition, Artifact>(\n await Promise.all(\n operationDefinitions.map(async (operationDefinition) => (<const>[\n operationDefinition,\n await metadata.hooks.afterMicroFunctionArtifactGenerated.promise(\n this.generateOperationDefinitionArtifact(operationDefinition, rc),\n operationDefinition,\n task,\n ),\n ])),\n ),\n )\n\n\n const entrypoints = await Promise.all(\n R.collectBy(\n (operationDefinition: OperationDefinition) => operationDefinition.module.name,\n operationDefinitions,\n )\n .map((operationDefinitions) => (<const>[\n operationDefinitions[0].module,\n operationDefinitions\n .map((operationDefinition) => artifactMap.get(operationDefinition))\n .filter((artifact): artifact is Artifact => Boolean(artifact)),\n ]))\n .map(async ([moduleDefinition, artifacts]) => await metadata.hooks.afterEntrypointArtifactGenerated.promise(\n this.generateEntrypointArtifact(\n moduleDefinition,\n artifacts,\n rc,\n ),\n task,\n )),\n )\n\n return [...entrypoints, ...artifactMap.values()]\n }\n\n\n private generateOperationDefinitionArtifact(operationDefinition: OperationDefinition, rc: RuntimeConfig): Artifact {\n const filepath = MicroFunctionGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle)\n const dirpath = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: MicroFunctionGenerator.getOperationDefinitionArtifactId(operationDefinition),\n filepath,\n content: OperationDefinitionTransformer.toMicroFunction(operationDefinition, {\n qs: rc.qs,\n esm: rc.esm,\n getOperationDefinitionDeclarationFilepath(operationDefinition: OperationDefinition): string {\n const relativePath = path.relative(\n dirpath,\n OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle),\n )\n\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n },\n getRequestFilepath(): string {\n const relativePath = path.relative(\n dirpath,\n RequestGenerator.getRequestArtifactFilepath(),\n )\n\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n },\n }),\n extensionName: '.type.ts',\n })\n\n return artifact\n }\n\n private generateEntrypointArtifact(moduleDefinition: ModuleDefinition, exports: Artifact[], rc: RuntimeConfig): Artifact {\n const filepath = MicroFunctionGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle)\n const dirpath = filepath.substring(0, filepath.lastIndexOf('/'))\n\n const artifact = new Artifact({\n id: MicroFunctionGenerator.getEntrypointArtifactId(moduleDefinition),\n filepath,\n content: EntrypointTransformer.toTypescript(exports, { dirpath }),\n })\n\n return artifact\n }\n\n\n static getOperationDefinitionArtifactFilepath(operationDefinition: OperationDefinition, fileNamingStyle: FileNamingStyle): string {\n const filename = `${changeCase[fileNamingStyle](operationDefinition.operationId)}.fn.ts`\n const filepath = [\n '.',\n changeCase[fileNamingStyle](operationDefinition.module.name),\n 'operations',\n filename,\n ].join('/')\n\n return filepath\n }\n\n static getOperationDefinitionArtifactId(operationDefinition: OperationDefinition): string {\n return `${operationDefinition.id}?generator=${MICRO_FUNCTION_GENERATOR}`\n }\n\n static getEntrypointArtifactFilepath(moduleDefinition: ModuleDefinition, fileNamingStyle: FileNamingStyle): string {\n return [\n '.',\n changeCase[fileNamingStyle](moduleDefinition.name),\n 'operations',\n 'index.ts',\n ].join('/')\n }\n\n static getEntrypointArtifactId(moduleDefinition: ModuleDefinition): string {\n return `${moduleDefinition.address}/paths/entrypoint?generator=${MICRO_FUNCTION_GENERATOR}`\n }\n}\n","import { AsyncSeriesWaterfallHook } from 'tapable'\nimport { Plugin } from '~/types/plugin.js'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { Artifact, OperationDefinition, SchemaDefinition } from '~/models/index.js'\nimport { OperationDeclarationGenerator, SchemaDeclarationGenerator } from './generators/index.js'\nimport { GenerateDeclarationPluginMetadata, MetadataStorage } from './constants/index.js'\n\n\nexport const DECLARATION_GENERATOR = 'declarationGenerator'\n\nexport class GenerateDeclarationPlugin implements Plugin {\n name = DECLARATION_GENERATOR\n\n operationGenerator = new OperationDeclarationGenerator()\n schemaGenerator = new SchemaDeclarationGenerator()\n\n constructor() {}\n\n apply(compiler: Compiler): void {\n GenerateDeclarationPlugin.register(compiler)\n\n compiler.hooks.compile.tapPromise(GenerateDeclarationPlugin.name, async (task: TaskWrapper) => {\n compiler.context.artifacts?.push(\n ...await this.schemaGenerator.compile(compiler, task),\n ...await this.operationGenerator.compile(compiler, task),\n )\n })\n }\n\n static register(compiler: Compiler): GenerateDeclarationPluginMetadata {\n if (!MetadataStorage.has(compiler)) {\n MetadataStorage.set(compiler, {\n hooks: {\n afterEntrypointArtifactGenerated: new AsyncSeriesWaterfallHook<[Artifact, TaskWrapper], Artifact>(['artifact', 'task']),\n afterSchemaDeclarationArtifactGenerated: new AsyncSeriesWaterfallHook<[Artifact, SchemaDefinition, TaskWrapper], Artifact>(['artifact', 'schemaDefinition', 'task']),\n afterOperationDeclarationArtifactGenerated: new AsyncSeriesWaterfallHook<[Artifact, OperationDefinition, TaskWrapper], Artifact>(['artifact', 'operationDefinition', 'task']),\n },\n })\n }\n return MetadataStorage.get(compiler)!\n }\n\n static of(compiler: Compiler): GenerateDeclarationPluginMetadata | undefined {\n return this.register(compiler)\n }\n}\n","import * as path from 'path'\nimport * as changeCase from 'change-case'\nimport { Artifact, ModuleDefinition, OperationDefinition } from '~/models/index.js'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { OperationDefinitionTransformer, EntrypointTransformer } from '~/transformers/index.js'\nimport { FileNamingStyle } from '~/constants/index.js'\nimport type { Generator, RuntimeConfig } from '~/types/index.js'\nimport { SchemaDeclarationGenerator } from '../schema-declaration/index.js'\nimport { MetadataStorage } from '../../constants/metadata-storage.js'\n\n\nexport const OPERATION_GENERATOR = 'operationDeclarationGenerator'\n\nexport class OperationDeclarationGenerator implements Generator {\n async compile(compiler: Compiler, task: TaskWrapper): Promise<Artifact[]> {\n const context = compiler.context\n const metadata = MetadataStorage.get(compiler)!\n\n const rc = context.rc!\n // const matcher = context.matcher!\n const documents = context.documents!\n // .filter((document) => !matcher.isModuleIgnored(document.module))\n\n const operationDefinitions = documents.flatMap((document) => document.operations)\n\n const artifactMap = new Map<OperationDefinition, Artifact>(\n await Promise.all(\n operationDefinitions.map(async (operationDefinition) => (<const>[\n operationDefinition,\n await metadata.hooks.afterOperationDeclarationArtifactGenerated.promise(\n this.generateOperationDefinitionArtifact(operationDefinition, rc),\n operationDefinition,\n task,\n ),\n ])),\n ),\n )\n\n return Array.from(artifactMap.values())\n }\n\n\n private generateOperationDefinitionArtifact(operationDefinition: OperationDefinition, rc: RuntimeConfig): Artifact {\n const filepath = OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle)\n const dirpath = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: OperationDeclarationGenerator.getOperationDefinitionArtifactId(operationDefinition),\n filepath,\n content: OperationDefinitionTransformer.toDeclaration(\n operationDefinition,\n {\n esm: rc.esm,\n getDependentSchemaDefinitionFilepath(dependentSchemaDefinition) {\n const relativePath = path.relative(\n dirpath,\n SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(dependentSchemaDefinition, rc.fileNamingStyle),\n )\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n },\n },\n ),\n extensionName: '.type.ts',\n })\n\n return artifact\n }\n\n private generateEntrypointArtifact(moduleDefinition: ModuleDefinition, exports: Artifact[], rc: RuntimeConfig): Artifact {\n const filepath = OperationDeclarationGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle)\n const dirpath = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: OperationDeclarationGenerator.getEntrypointArtifactId(moduleDefinition),\n filepath,\n content: EntrypointTransformer.toTypescript(exports, { dirpath }),\n })\n\n return artifact\n }\n\n\n static getOperationDefinitionArtifactFilepath(operationDefinition: OperationDefinition, fileNamingStyle: FileNamingStyle): string {\n const filename = `${changeCase[fileNamingStyle](operationDefinition.operationId)}.type.ts`\n const filepath = [\n '.',\n changeCase[fileNamingStyle](operationDefinition.module.name),\n 'types',\n 'operations',\n filename,\n ].join('/')\n\n return filepath\n }\n\n static getOperationDefinitionArtifactId(operationDefinition: OperationDefinition): string {\n return `${operationDefinition.id}?generator=${OPERATION_GENERATOR}`\n }\n\n static getEntrypointArtifactFilepath(moduleDefinition: ModuleDefinition, fileNamingStyle: FileNamingStyle): string {\n return [\n '.',\n changeCase[fileNamingStyle](moduleDefinition.name),\n 'types',\n 'operations',\n 'index.ts',\n ].join('/')\n }\n\n static getEntrypointArtifactId(moduleDefinition: ModuleDefinition): string {\n return `${moduleDefinition.address}/paths/entrypoint?generator=${OPERATION_GENERATOR}`\n }\n}\n","import { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { Renderer } from '../types/renderer.js'\n\n\nexport class CommentRenderer implements Renderer {\n constructor(\n private readonly schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject,\n ) {}\n\n render(): string {\n const schema = this.schema\n\n const lines = ['/**']\n\n if (schema.description) {\n const description = schema.description.replace('*/', '*\\\\/')\n lines.push(...description.split('\\n').map((line) => ` * ${line}`))\n }\n\n if (schema.deprecated) {\n lines.push(' * @deprecated')\n }\n\n if (schema.readOnly) {\n lines.push(' * @readonly')\n }\n\n if (schema.format) {\n lines.push(` * @format ${schema.format}`)\n }\n\n lines.push(' */')\n\n if (lines.length === 2) return ''\n return lines.join('\\n')\n }\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\n\nimport * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { MixedSchemaObject } from './types/mixed-schema-object.js'\nimport { JsonSchemaUtils } from '~/utils/json-schema-utils/index.js'\nimport { indent } from '~/utils/indent.js'\nimport { CommentRenderer } from './comment.renderer.js'\nimport { ReferenceTransformer } from './reference.transformer.js'\nimport { Renderer } from '../types/renderer.js'\n\n\nexport interface JsonSchemaDeclarationRendererOptions {\n referenceTransformer?: (schema: OpenAPIV3_1.ReferenceObject) => string\n}\n\nexport class DeclarationRenderer implements Renderer {\n constructor(\n private readonly schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject,\n private readonly options: JsonSchemaDeclarationRendererOptions = {},\n ) {\n }\n\n render(): string {\n return this.renderSchema(this.schema)\n }\n\n private renderSchema(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject): string {\n if (typeof schema === 'boolean') return 'unknown'\n\n if (JsonSchemaUtils.isRef(schema)) return this.renderReference(schema)\n if (JsonSchemaUtils.isMixed(schema)) return this.renderMixed(schema)\n if (JsonSchemaUtils.isArray(schema)) return this.renderArray(schema)\n\n if (schema.type === 'object') return this.renderObject(schema)\n if (schema.enum) return this.renderEnum(schema)\n if (schema.oneOf) return this.renderOneOf(schema)\n if (schema.anyOf) return this.renderAnyOf(schema)\n if (schema.allOf) return this.renderAllOf(schema)\n if (schema.type === 'string') return this.renderString(schema)\n if (schema.type === 'number') return this.renderNumber(schema)\n if (schema.type === 'boolean') return this.renderBoolean(schema)\n if (schema.type === 'null') return this.renderNull(schema)\n if (schema.type === 'integer') return this.renderInteger(schema)\n\n return 'unknown'\n }\n\n\n private renderMixed(schema: MixedSchemaObject): string {\n if (Array.isArray(schema.type)) {\n schema.type\n .map((type): (OpenAPIV3_1.ArraySchemaObject | OpenAPIV3_1.NonArraySchemaObject) => ({ ...schema, type }))\n .map((schema) => this.renderSchema(schema))\n .join(' | ')\n }\n\n return 'unknown'\n }\n\n private renderReference(schema: OpenAPIV3_1.ReferenceObject): string {\n if (!this.options.referenceTransformer) {\n return ReferenceTransformer.toDeclaration(schema)\n }\n\n return this.options.referenceTransformer(schema)\n }\n\n private renderArray(schema: OpenAPIV3_1.ArraySchemaObject): string {\n if (schema.items && Array.isArray(schema.items)) {\n const items = schema.items.map((s) => this.renderSchema(s)).join(', ')\n return `[${items}]`\n }\n\n if (schema.items && typeof schema.items === 'object') {\n return `${this.renderSchema(schema.items)}[]`\n }\n\n return 'any[]'\n }\n\n\n private renderObject(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n if (\n (!schema.properties || R.isEmpty(schema.properties))\n && (!schema.additionalProperties || R.isEmpty(schema.additionalProperties))\n ) {\n return 'object'\n }\n\n\n const $properties = Object.entries(schema.properties || {})\n .map(([propertyName, propertySchema]) => {\n let $comment = new CommentRenderer(propertySchema).render()\n if ($comment) $comment += '\\n'\n\n const $key = `\"${propertyName}\"${schema.required?.includes(propertyName) ? '' : '?'}`\n const $value = this.renderSchema(propertySchema)\n\n return indent(2, `${$comment}${$key}: ${$value}`)\n })\n\n if (schema.additionalProperties) {\n const $value = schema.additionalProperties === true\n ? 'any'\n : this.renderSchema(schema.additionalProperties)\n $properties.push(indent(2, `[key: string]: ${$value}`))\n }\n\n return [\n '{',\n ...$properties,\n '}',\n ].join('\\n')\n }\n\n private renderOneOf(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n if (!schema.oneOf) return 'unknown'\n\n return schema.oneOf.map((s) => this.renderSchema(s)).join(' | ')\n }\n\n private renderAnyOf(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n if (!schema.anyOf) return 'unknown'\n\n return schema.anyOf.map((s) => this.renderSchema(s)).join(' | ')\n }\n\n private renderAllOf(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n if (!schema.allOf) return 'unknown'\n\n return schema.allOf.map((s) => this.renderSchema(s)).join(' & ')\n }\n\n private renderEnum(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n if (!schema.enum) return 'unknown'\n return schema.enum.map((v) => JSON.stringify(v)).join(' | ')\n }\n\n private renderString(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n if (schema.contentMediaType === 'application/octet-stream') return 'Blob | Buffer'\n if (schema.format === 'binary') return 'Blob | Buffer'\n return 'string'\n }\n\n private renderNumber(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n return 'number'\n }\n\n private renderBoolean(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n return 'boolean'\n }\n\n private renderNull(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n return 'null'\n }\n\n private renderInteger(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n return 'number'\n }\n}\n","export function indent(space: number, text: string): string {\n if (text === '') return ''\n\n const indentation = ' '.repeat(space)\n return text.split('\\n')\n .map((line) => (line ? `${indentation}${line}` : line))\n .join('\\n')\n}\n","import * as R from 'ramda'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\n\n\nexport class ReferenceTransformer {\n static toDeclaration(schema: OpenAPIV3_1.ReferenceObject, alias: (name: string) => string = R.identity): string {\n if (!schema.$ref || !schema.$ref.startsWith('#')) return `unknown /* ${schema.$ref.replace('*/', '*\\\\/')} */`\n\n const parts: string[] = schema.$ref.split('/')\n // return parts[parts.length - 1] || 'unknown'\n\n return alias(parts[parts.length - 1]) || 'unknown'\n }\n}\n","import { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { CommentRenderer } from './comment.renderer.js'\nimport { DeclarationRenderer, JsonSchemaDeclarationRendererOptions } from './declaration.renderer.js'\n\n\nexport class JsonSchemaTransformer {\n static toComment(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject): string {\n return new CommentRenderer(schema).render()\n }\n\n static toDeclaration(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject, options?: JsonSchemaDeclarationRendererOptions): string {\n return new DeclarationRenderer(schema, options).render()\n }\n}\n","import * as R from 'ramda'\nimport { SchemaDefinition } from '~/models/index.js'\nimport { JsonSchemaUtils } from '~/utils/json-schema-utils/index.js'\nimport { JsonSchemaTransformer } from '../json-schema/index.js'\n\n\ninterface SchemaDefinitionDeclarationRendererOptions {\n esm?: boolean\n\n getDependentSchemaDefinitionFilepath: (schemaDefinition: SchemaDefinition) => string\n}\n\nexport class SchemaDefinitionTransformer {\n static toDeclaration(schemaDefinition: SchemaDefinition, options: SchemaDefinitionDeclarationRendererOptions): string {\n const dependencies = schemaDefinition.getDependencies()\n let $dependencies = dependencies\n .filter((dep) => !SchemaDefinition.isUnknown(dep))\n .map((dep) => {\n const filepath = options.getDependentSchemaDefinitionFilepath(dep)\n return `import type { ${dep.name} } from \"${filepath}\"`\n })\n .map((str) => str.replace(/ from \"(\\.\\.?\\/.+?)(\\.ts|\\.mts|\\.cts|\\.js|\\.cjs|\\.mjs)?\"/, options.esm ? ' from \"$1.js\"' : ' from \"$1\"'))\n .join('\\n')\n\n if ($dependencies) $dependencies += '\\n'\n\n let $comment = JsonSchemaTransformer.toComment(schemaDefinition.schema)\n if ($comment) $comment += '\\n'\n\n if (typeof schemaDefinition.schema === 'boolean') {\n return [\n '/* @anchor:file:start */',\n '',\n $dependencies,\n $comment || undefined,\n `type ${schemaDefinition.name} = unknown`,\n '',\n '/* @anchor:file:end */',\n ].filter(R.isNotNil).join('\\n')\n }\n\n if (JsonSchemaUtils.isNonArray(schemaDefinition.schema) && schemaDefinition.schema.type === 'object') {\n const $schema = JsonSchemaTransformer.toDeclaration(schemaDefinition.schema)\n\n const $declaration = $schema.startsWith('{')\n ? `export interface ${schemaDefinition.name} ${$schema}`\n : `export type ${schemaDefinition.name} = ${$schema}`\n\n return [\n '/* @anchor:file:start */',\n '',\n $dependencies,\n $comment || undefined,\n $declaration,\n '',\n '/* @anchor:file:end */',\n ].filter(R.isNotNil).join('\\n')\n }\n\n return [\n '/* @anchor:file:start */',\n '',\n $dependencies,\n $comment || undefined,\n `export type ${schemaDefinition.name} = ${JsonSchemaTransformer.toDeclaration(schemaDefinition.schema)}`,\n '',\n '/* @anchor:file:end */',\n ].filter(R.isNotNil).join('\\n')\n }\n}\n","import * as R from 'ramda'\nimport { OperationDefinition } from '~/models/index.js'\nimport { Renderer } from '../types/renderer.js'\n\n\nexport class CommentRenderer implements Renderer {\n constructor(\n private readonly operationDefinition: OperationDefinition,\n ) {}\n\n render(): string {\n const operation = this.operationDefinition.operation\n if (!operation.summary && !operation.description) return ''\n\n const lines = ['/**']\n\n if (operation.summary && typeof operation.summary === 'string') {\n lines.push(` * ${R.trim(operation.summary)}`)\n lines.push(' *')\n }\n\n if (operation.description && typeof operation.description === 'string') {\n lines.push(` * @description ${R.trim(operation.description)}`)\n }\n\n lines.push(' */')\n\n return lines.join('\\n')\n }\n}\n","import * as R from 'ramda'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { OperationDefinition, SchemaDefinition } from '~/models/index.js'\nimport { typeNameFactory, TypeNameFn } from './utils/index.js'\nimport { JsonSchemaUtils } from '~/utils/json-schema-utils/index.js'\nimport { indent } from '~/utils/indent.js'\nimport { OpenapiUtils } from '~/utils/openapi-utils/index.js'\nimport { JsonSchemaTransformer, JsonSchemaDeclarationRendererOptions, ReferenceTransformer } from '../json-schema/index.js'\nimport { Renderer } from '../types/renderer.js'\n\n\nexport interface OperationDefinitionDeclarationRendererOptions {\n esm?: boolean\n\n getDependentSchemaDefinitionFilepath(dependentSchemaDefinition: SchemaDefinition): string\n}\n\nconst alias = (name: string): string => `${name}Schema`\n\nexport class DeclarationRenderer implements Renderer {\n private typeName: TypeNameFn\n\n constructor(\n private readonly operationDefinition: OperationDefinition,\n private readonly options: OperationDefinitionDeclarationRendererOptions,\n ) {\n this.typeName = typeNameFactory(operationDefinition)\n }\n\n private renderResponseBodies(operation: OpenAPIV3_1.OperationObject, options: JsonSchemaDeclarationRendererOptions): string {\n if (!operation.responses || R.isEmpty(operation.responses)) {\n return `export interface ${this.typeName('ResponseBodies')} {}`\n }\n\n const $responses = Object.entries(operation.responses)\n .map(([statusCode, response]) => {\n if (!JsonSchemaUtils.isRef(response)) {\n const $value = Object.values(response.content || {})\n .map((mediaTypeObject) => mediaTypeObject.schema)\n .filter((schema) => !!schema)\n .map((schema) => JsonSchemaTransformer.toDeclaration(schema, options))\n .join(' | ')\n\n return indent(2, `${statusCode}: ${$value || 'void'}`)\n }\n })\n .join('\\n')\n\n return [\n `export interface ${this.typeName('ResponseBodies')} {`,\n $responses,\n '}',\n ].join('\\n')\n }\n\n private renderRequestBodies(operation: OpenAPIV3_1.OperationObject, options: JsonSchemaDeclarationRendererOptions): string {\n let $requestBodies = `export interface ${this.typeName('RequestBodies')} {}`\n\n if (operation.requestBody && !JsonSchemaUtils.isRef(operation.requestBody)) {\n const $mediaTypes = Object.entries(operation.requestBody.content || {})\n .map(([mediaType, mediaTypeObject]) => <const>[mediaType, mediaTypeObject.schema])\n .map(([mediaType, schema]) => {\n if (!schema) return `${JSON.stringify(mediaType)}: unknown`\n\n // if (mediaType === 'multipart/form-data') {\n // return `${JSON.stringify(mediaType)}: FormData | ${generateSchema(schema, alias)}`\n // } else if (mediaType === 'application/x-www-form-urlencoded') {\n // return `${JSON.stringify(mediaType)}: URLSearchParams | ${generateSchema(schema, alias)}`\n // }\n\n return `${JSON.stringify(mediaType)}: ${JsonSchemaTransformer.toDeclaration(schema, options)}`\n })\n .map((pair) => indent(2, pair))\n\n $requestBodies = [\n `export interface ${this.typeName('RequestBodies')} {`,\n ...$mediaTypes,\n '}',\n ].join('\\n')\n }\n\n return $requestBodies\n }\n\n private renderParameterBodies(operationDefinition: OperationDefinition, options: JsonSchemaDeclarationRendererOptions): string {\n const { operation } = operationDefinition\n let parameterBodies = ''\n // let parameterBodies = `interface ${typeName('ParameterBodies')} {}`\n\n if (operation.requestBody && !JsonSchemaUtils.isRef(operation.requestBody)) {\n const $mediaTypes = Object.entries(operation.requestBody.content || {})\n .map(([mediaType, mediaTypeObject]) => <const>[mediaType, mediaTypeObject.schema])\n // .filter((pair): pair is [string, OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject] => !!pair[1])\n .map(([mediaType, schemaOrRef]) => {\n if (!schemaOrRef) return `${JSON.stringify(mediaType)}: unknown`\n\n const schema = JsonSchemaUtils.isRef(schemaOrRef)\n ? OpenapiUtils.dereferenceDeep<OpenAPIV3_1.SchemaObject>(schemaOrRef.$ref, operationDefinition.document.specification)\n : schemaOrRef\n\n if (schema.type === 'object' || schema.properties) {\n return `${JSON.stringify(mediaType)}: ${JsonSchemaTransformer.toDeclaration(schemaOrRef, options)} & { [key: string]: any }`\n }\n\n return `${JSON.stringify(mediaType)}: { [key: string]: any }`\n })\n .map((pair) => indent(2, pair))\n\n // $requestBodies = `export type ${typeName('RequestBody')} = ${$value || 'unknown'}`\n parameterBodies = [\n `interface ${this.typeName('ParameterBodies')} {`,\n ...$mediaTypes,\n '}',\n '',\n ].join('\\n')\n }\n\n return parameterBodies\n }\n\n private renderRequestParameters(operation: OpenAPIV3_1.OperationObject, options: JsonSchemaDeclarationRendererOptions): string {\n const mediaTypes = operation.requestBody && !JsonSchemaUtils.isRef(operation.requestBody)\n ? Object.keys(operation.requestBody.content || {})\n : []\n\n const base = `${this.typeName('RequestQuery')} & ${this.typeName('RouteParameters')} & ${this.typeName('RequestHeaders')}`\n\n if (mediaTypes.length === 1) {\n return `export type ${this.typeName('RequestParameters')} = ${base} & ${this.typeName('RequestBodies')}[${JSON.stringify(mediaTypes[0])}]`\n }\n\n if (mediaTypes.length > 1) {\n const unions = mediaTypes\n .map((mediaType) => `(${base} & ${this.typeName('RequestBodies')}[${JSON.stringify(mediaType)}] & { \"content-type\": ${JSON.stringify(mediaType)} })`)\n .join('\\n| ')\n\n return `export type ${this.typeName('RequestParameters')} = ${unions}`\n }\n\n return `export type ${this.typeName('RequestParameters')} = ${base}`\n }\n\n private rendererParameters(name: string, parameters: OpenAPIV3_1.ParameterObject[], options: JsonSchemaDeclarationRendererOptions): string {\n if (parameters.length === 0) {\n return `export type ${name} = {}`\n }\n\n const $parameters = parameters.map((parameter) => {\n const parameterName = `\"${parameter.name}\"`\n const $key = parameter.required ? parameterName : `${parameterName}?`\n const $value = JsonSchemaTransformer.toDeclaration(parameter.schema || { type: 'any' }, options)\n\n return indent(2, `${$key}: ${$value}`)\n })\n .join('\\n')\n\n\n return [\n `export type ${name} = {`,\n $parameters,\n '}',\n ].filter(Boolean).join('\\n')\n }\n\n private renderDependencies(): string {\n const schemaDefinitions = this.operationDefinition.getDependencies()\n .filter((schemaDefinition) => !SchemaDefinition.isUnknown(schemaDefinition))\n\n const $schemaDefinitions = schemaDefinitions\n .map((schemaDefinition) => {\n const filepath = this.options.getDependentSchemaDefinitionFilepath(schemaDefinition)\n const schemaName = schemaDefinition.name\n\n return `import type { ${schemaName} as ${alias(schemaName)} } from \"${filepath}\"`\n })\n .map((str) => (str.replace(/ from \"(\\.\\.?\\/.+?)(\\.ts|\\.mts|\\.cts|\\.js|\\.cjs|\\.mjs)?\"/, this.options.esm ? ' from \"$1.js\"' : ' from \"$1\"')))\n\n return [\n 'import type { KeqOperation, KeqPathParameterInit, KeqQueryInit } from \"keq\"',\n ...$schemaDefinitions,\n ].join('\\n')\n }\n\n render(): string {\n const { operation } = this.operationDefinition\n\n if (!operation.responses) return ''\n\n const jsonSchemaDeclarationRendererOptions: JsonSchemaDeclarationRendererOptions = {\n referenceTransformer: (schema: OpenAPIV3_1.ReferenceObject) => {\n return ReferenceTransformer.toDeclaration(schema, alias)\n },\n }\n\n const $dependencies = this.renderDependencies()\n\n const $responseBodies = this.renderResponseBodies(operation, jsonSchemaDeclarationRendererOptions)\n const $requestBodies = this.renderRequestBodies(operation, jsonSchemaDeclarationRendererOptions)\n const $parameterBodies = this.renderParameterBodies(this.operationDefinition, jsonSchemaDeclarationRendererOptions)\n const $requestParameters = this.renderRequestParameters(operation, jsonSchemaDeclarationRendererOptions)\n const $requestQuery = this.rendererParameters(\n `${this.typeName('RequestQuery')}`,\n operation.parameters?.filter((p) => !JsonSchemaUtils.isRef(p) && p.in === 'query') || [],\n jsonSchemaDeclarationRendererOptions,\n )\n const $routeParameters = this.rendererParameters(\n `${this.typeName('RouteParameters')}`,\n operation.parameters?.filter((p) => !JsonSchemaUtils.isRef(p) && p.in === 'path') || [],\n jsonSchemaDeclarationRendererOptions,\n )\n const $requestHeaders = this.rendererParameters(\n `${this.typeName('RequestHeaders')}`,\n operation.parameters?.filter((p) => !JsonSchemaUtils.isRef(p) && p.in === 'header') || [],\n jsonSchemaDeclarationRendererOptions,\n )\n\n return [\n '/* @anchor:file:start */',\n '',\n $dependencies,\n '',\n $responseBodies,\n '',\n $requestBodies,\n '',\n $requestQuery,\n '',\n $routeParameters,\n '',\n $requestHeaders,\n '',\n $parameterBodies || undefined,\n $requestParameters,\n '',\n `export interface ${this.typeName('Operation')}<STATUS extends keyof ${this.typeName('ResponseBodies')}, CONTENT_TYPE extends ${$parameterBodies ? `keyof ${this.typeName('ParameterBodies')}` : 'string'} > extends KeqOperation {`,\n ` requestParams: ${this.typeName('RouteParameters')} & { [key: string]: KeqPathParameterInit }`,\n ` requestQuery: ${this.typeName('RequestQuery')} & { [key: string]: KeqQueryInit }`,\n ` requestHeaders: ${this.typeName('RequestHeaders')} & { [key: string]: string | number }`,\n ` requestBody: ${$parameterBodies ? `${this.typeName('ParameterBodies')}[CONTENT_TYPE] | ` : 'object | '}BodyInit`,\n ` responseBody: ${this.typeName('ResponseBodies')}[STATUS]`,\n '}',\n '',\n '/* @anchor:file:end */',\n ].filter(R.isNotNil).join('\\n')\n }\n}\n","import * as changeCase from 'change-case'\nimport { OperationDefinition } from '~/models/index.js'\n\nexport type TypeNameFn = (name: string) => string\n\nexport function typeNameFactory(operationDefinition: OperationDefinition): TypeNameFn {\n const pascalCaseOperationId = changeCase.pascalCase(operationDefinition.operationId)\n return (name: string) => `${pascalCaseOperationId}${name}`\n}\n","import * as R from 'ramda'\nimport { OperationDefinition } from '~/models/index.js'\nimport { Renderer } from '../types/renderer.js'\nimport { typeNameFactory, TypeNameFn } from './utils/index.js'\nimport { indent } from '~/utils/indent.js'\nimport { Exception } from '~/exception.js'\nimport { CommentRenderer } from './comment.renderer.js'\nimport { OperationDefinitionSnippet, OperationDefinitionSnippetOptions } from './typescript-helper.js'\n\n\nexport interface OperationDefinitionMicroFunctionRendererOptions extends OperationDefinitionSnippetOptions {\n getOperationDefinitionDeclarationFilepath(operationDefinition: OperationDefinition): string\n getRequestFilepath(): string\n}\n\nexport class OperationDefinitionMicroFunctionRenderer implements Renderer {\n helper: OperationDefinitionSnippet\n typeName: TypeNameFn\n\n constructor(\n private readonly operationDefinition: OperationDefinition,\n private readonly options: OperationDefinitionMicroFunctionRendererOptions,\n ) {\n this.typeName = typeNameFactory(operationDefinition)\n this.helper = new OperationDefinitionSnippet(operationDefinition, options)\n }\n\n render(): string {\n const { operation, operationId, method, pathname } = this.operationDefinition\n if (!operation.responses) return ''\n\n const $dependencies = this.renderDependencies()\n const $comment = new CommentRenderer(this.operationDefinition).render()\n\n const moduleName = this.operationDefinition.module.name\n\n const $method = method.toLowerCase()\n const $queryParameters = this.helper.renderRequestQuery()\n const $headerParameters = this.helper.renderRequestHeaders()\n const $pathParameters = this.helper.renderRequestPathParameters()\n\n const $mediaType = this.helper.renderMediaType()\n\n const $requestBody = this.helper.renderRequestBody()\n\n const $operationDeclaration = this.renderOperationDeclaration()\n\n return [\n '/* @anchor:file:start */',\n '',\n $dependencies,\n '',\n `const moduleName = \"${moduleName}\"`,\n `const method = \"${method}\"`,\n `const pathname = \"${pathname}\"`,\n '',\n $comment || undefined,\n `export ${$operationDeclaration} {`,\n ` const req = request.${$method}<${this.typeName('ResponseBodies')}[STATUS]>(\"${pathname}\")`,\n ' .option(\\'module\\', { name: moduleName, pathname, method })',\n '',\n $mediaType || undefined,\n ' /* @anchor:query:start */',\n $queryParameters ? indent(2, $queryParameters) : undefined,\n ' /* @anchor:query:end */',\n '',\n ' /* @anchor:headers:start */',\n $headerParameters ? indent(2, $headerParameters) : undefined,\n ' /* @anchor:headers:end */',\n '',\n ' /* @anchor:path-parameters:start */',\n $pathParameters ? indent(2, $pathParameters) : undefined,\n ' /* @anchor:path-parameters:end */',\n '',\n ' /* @anchor:body:start */',\n $requestBody ? indent(2, $requestBody) : undefined,\n ' /* @anchor:body:end */',\n '',\n ' /* @anchor:operation-return */',\n ` return req as ReturnType<typeof ${operationId}<STATUS${$operationDeclaration.includes('CONTENT_TYPE') ? ', CONTENT_TYPE' : ''}>>`,\n '}',\n '',\n `${operationId}.pathname = pathname`,\n `${operationId}.method = method`,\n '/* @anchor:file:end */',\n ].filter(R.isNotNil).join('\\n')\n }\n\n private renderDependencies(): string {\n const declarationFilepath = this.options.getOperationDefinitionDeclarationFilepath(this.operationDefinition)\n const requestFilepath = this.options.getRequestFilepath()\n\n return [\n 'import { Keq } from \"keq\"',\n `import { request } from \"${requestFilepath}\"`,\n `import type { ${this.typeName('Operation')}, ${this.typeName('ResponseBodies')}, ${this.typeName('RequestParameters')} } from \"${declarationFilepath}\"`,\n `export type { ${this.typeName('RequestQuery')}, ${this.typeName('RequestHeaders')}, ${this.typeName('RequestBodies')} } from \"${declarationFilepath}\"`,\n ]\n .map((str) => (str.replace(/ from \"(\\.\\.?\\/.+?)(\\.ts|\\.mts|\\.cts|\\.js|\\.cjs|\\.mjs)?\"/, this.options.esm ? ' from \"$1.js\"' : ' from \"$1\"')))\n .join('\\n')\n }\n\n private renderOperationDeclaration(): string {\n const { operationId } = this.operationDefinition\n\n const mediaTypes = this.helper.getRequestMediaTypes()\n\n if (mediaTypes.length === 0) {\n return `function ${operationId}<STATUS extends keyof ${this.typeName('ResponseBodies')}, CONTENT_TYPE extends never = never>(args?: ${this.typeName('RequestParameters')}): Keq<${this.typeName('Operation')}<STATUS, CONTENT_TYPE>>`\n } else if (mediaTypes.length === 1) {\n return `function ${operationId}<STATUS extends keyof ${this.typeName('ResponseBodies')}, CONTENT_TYPE extends ${JSON.stringify(mediaTypes[0])} = ${JSON.stringify(mediaTypes[0])}>(args?: ${this.typeName('RequestParameters')}): Keq<${this.typeName('Operation')}<STATUS, CONTENT_TYPE>>`\n } else if (mediaTypes.length > 1) {\n return `function ${operationId}<STATUS extends keyof ${this.typeName('ResponseBodies')}, CONTENT_TYPE extends ${this.typeName('RequestParameters')}[\"content-type\"]>(args?: Extract<${this.typeName('RequestParameters')}, { \"content-type\": CONTENT_TYPE }>): Keq<${this.typeName('Operation')}<STATUS, CONTENT_TYPE>>`\n }\n\n throw new Exception(this.operationDefinition.module, '[operationDeclarationRenderer] Unreachable')\n }\n}\n","import * as R from 'ramda'\nimport { KeqQueryOptions } from 'keq'\nimport { OperationDefinition } from '~/models/index.js'\nimport { KeqQueryOptionsFactory } from '~/types/index.js'\nimport { typeNameFactory, TypeNameFn } from './utils/index.js'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { JsonSchemaUtils } from '~/utils/json-schema-utils/index.js'\nimport { OpenapiUtils } from '~/utils/openapi-utils/index.js'\n\n\nexport interface OperationDefinitionSnippetOptions {\n esm?: boolean\n qs?: KeqQueryOptions | KeqQueryOptionsFactory\n}\n\nexport class OperationDefinitionSnippet {\n typeName: TypeNameFn\n\n constructor(\n private readonly operationDefinition: OperationDefinition,\n private readonly options: OperationDefinitionSnippetOptions,\n ) {\n this.typeName = typeNameFactory(operationDefinition)\n }\n\n\n private getQsParameters(parameter: OpenAPIV3_1.ParameterObject): KeqQueryOptions | undefined {\n if (typeof this.options.qs === 'function') {\n return this.options.qs(parameter)\n } else if (typeof this.options.qs === 'object') {\n return this.options.qs\n }\n\n const style = parameter.style || 'form'\n const explode = parameter.explode ?? true\n\n if (style === 'deepObject') {\n return { arrayFormat: 'brackets' }\n } else if (explode) {\n return { arrayFormat: 'repeat' }\n } else {\n if (style === 'form') {\n return { arrayFormat: 'comma' }\n } else if (style === 'spaceDelimited') {\n return { arrayFormat: 'space' }\n } else if (style === 'pipeDelimited') {\n return { arrayFormat: 'pipe' }\n }\n }\n\n return {}\n }\n\n\n // render: \"if (args && 'Authorization' in args) req.header('Authorization', args['Authorization'])\"\n renderRequestHeaders(): string {\n const { operation } = this.operationDefinition\n\n const $headers = (operation.parameters || [])\n .filter((p): p is OpenAPIV3_1.ParameterObject => !JsonSchemaUtils.isRef(p))\n .filter((p) => p.in === 'header')\n .map((p) => `if (args && ${JSON.stringify(p.name)} in args) req.header(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}])`)\n .join('\\n')\n\n return $headers\n }\n\n // render: \"if (args && 'id' in args) req.query('id', args['id'], options)\"\n renderRequestQuery(): string {\n const { operation } = this.operationDefinition\n\n const $query = (operation.parameters || [])\n .filter((p): p is OpenAPIV3_1.ParameterObject => !JsonSchemaUtils.isRef(p))\n .filter((p) => p.in === 'query')\n .map((p) => {\n const option = this.getQsParameters(p)\n const $option = (!option || R.isEmpty(option)) ? '' : `, ${JSON.stringify(option)}`\n\n return `if (args && ${JSON.stringify(p.name)} in args) req.query(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}]${$option})`\n })\n .join('\\n')\n\n return $query\n }\n\n // render: \"if (args && 'id' in args) req.params('id', args['id'])\"\n renderRequestPathParameters(): string {\n const { operation } = this.operationDefinition\n\n const $pathParameters = (operation.parameters || [])\n .filter((p): p is OpenAPIV3_1.ParameterObject => !JsonSchemaUtils.isRef(p))\n .filter((p) => p.in === 'path')\n .map((p) => `if (args && ${JSON.stringify(p.name)} in args) req.params(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}])`)\n .join('\\n')\n\n return $pathParameters\n }\n\n getRequestMediaTypes(): string[] {\n const { operation } = this.operationDefinition\n const requestBodyContent = (operation.requestBody?.content || {}) as Record<string, OpenAPIV3_1.MediaTypeObject>\n return Object.keys(requestBodyContent)\n }\n\n // render \"req.type(\"application/json\")\"\n renderMediaType(): string {\n const mediaTypes = this.getRequestMediaTypes()\n\n if (mediaTypes.length === 1 && !mediaTypes[0].endsWith('/*')) {\n return `req.type(\"${mediaTypes[0]}\")\\n`\n } else if (mediaTypes.some((mediaType) => mediaType === '*/*')) {\n // no-op\n } else if (mediaTypes.some((mediaType) => mediaType.endsWith('/*'))) {\n return 'if(args?.[\"content-type\"]) req.type(args[\"content-type\"])\\n'\n } else if (mediaTypes.length > 1) {\n return 'if(args?.[\"content-type\"]) req.type(args[\"content-type\"])\\n'\n }\n\n return ''\n }\n\n\n // render body\n\n private requestBodyFormDataPropertyRenderer(\n propertyName: string,\n propertySchema: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject,\n mediaType: string,\n ): string {\n try {\n const $propertyName = JSON.stringify(propertyName)\n\n const schema = JsonSchemaUtils.isRef(propertySchema)\n ? OpenapiUtils.dereferenceDeep<OpenAPIV3_1.SchemaObject>(propertySchema.$ref, this.operationDefinition.document.specification)\n : propertySchema\n\n if (\n (schema.type === 'string' && schema.format === 'binary')\n || schema.contentMediaType === 'application/octet-stream') {\n return `if (args && ${$propertyName} in args && args[${$propertyName}]) req.attach(${$propertyName}, args[${$propertyName}])`\n } else if (\n schema.type === 'string'\n || (schema.type === 'array' && schema.items && schema.items.type === 'string')\n ) {\n return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, args[${$propertyName}])`\n } else if (schema.type === 'number' || schema.type === 'integer') {\n return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, String(args[${$propertyName}]))`\n }\n\n return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, String(args[${$propertyName}]) /* type is non-string in schema; triggers type coercion here */)`\n } catch (err) {\n return this.renderErrorComment(err, mediaType)\n }\n }\n\n private requestBodyPropertyRenderer(\n propertyName: string,\n propertySchema: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject,\n mediaType: string,\n ): string {\n if (mediaType === 'application/json') {\n const $propertyName = JSON.stringify(propertyName)\n return `if (args && ${$propertyName} in args) req.send({ ${$propertyName}: args[${$propertyName}] })`\n } else if (mediaType === 'multipart/form-data') {\n return this.requestBodyFormDataPropertyRenderer(propertyName, propertySchema, mediaType)\n } else {\n throw new Error(`Unsupported media type: ${mediaType}`)\n }\n }\n\n renderRequestBody(): string {\n const { operation } = this.operationDefinition\n const requestBodyContent = (operation.requestBody?.content || {}) as Record<string, OpenAPIV3_1.MediaTypeObject>\n\n const $requestBody = Object.entries(requestBodyContent)\n .map(([mediaType, mediaTypeObject]): string | undefined => {\n if (!mediaTypeObject.schema) return\n\n try {\n const schema = JsonSchemaUtils.isRef(mediaTypeObject.schema)\n ? OpenapiUtils.dereferenceDeep<OpenAPIV3_1.SchemaObject>(mediaTypeObject.schema.$ref, this.operationDefinition.document.specification)\n : mediaTypeObject.schema\n\n if (schema.type !== 'object') return\n\n const properties = (schema.properties || {}) as OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject\n\n return Object.entries(properties)\n .map(([propertyName, propertySchema]) => this.requestBodyPropertyRenderer(propertyName, propertySchema, mediaType))\n .join('\\n')\n } catch (err) {\n return this.renderErrorComment(err, mediaType)\n }\n })\n .filter(R.isNotNil)\n .join('\\n')\n\n return $requestBody\n }\n\n private renderErrorComment(err: unknown, mediaType: string): string {\n const $err = String(err)\n .split('\\n')\n .map(((line) => ` * ${line}`))\n .join('\\n')\n\n return [\n '/**',\n ` * Unable to dereference schema for media type ${mediaType}`,\n $err,\n ' */',\n ].join('\\n')\n }\n}\n","import * as R from 'ramda'\nimport { TypeNameFn, typeNameFactory } from './utils/index.js'\nimport { OperationDefinition } from '~/models/index.js'\nimport { OperationDefinitionSnippet, OperationDefinitionSnippetOptions } from './typescript-helper.js'\nimport { CommentRenderer } from './comment.renderer.js'\nimport { indent } from '~/utils/indent.js'\nimport { Renderer } from '../types/renderer.js'\nimport { Exception } from '~/exception.js'\n\n\nexport type OperationDefinitionNestjsMethodRendererOptions = OperationDefinitionSnippetOptions\n\nexport class OperationDefinitionNestjsMethodRenderer implements Renderer {\n helper: OperationDefinitionSnippet\n typeName: TypeNameFn\n\n constructor(\n private readonly operationDefinition: OperationDefinition,\n private readonly options: OperationDefinitionNestjsMethodRendererOptions,\n ) {\n this.typeName = typeNameFactory(operationDefinition)\n this.helper = new OperationDefinitionSnippet(operationDefinition, options)\n }\n\n\n render(): string {\n // const operationId = changeCase.camelCase(this.operationDefinition.operationId)\n const pathname = this.operationDefinition.pathname\n\n const $comment = new CommentRenderer(this.operationDefinition).render()\n const $method = this.operationDefinition.method.toLowerCase()\n const $mediaType = this.helper.renderMediaType()\n const $operationDeclaration = this.renderOperationDeclaration(this.operationDefinition)\n const $queryParameters = this.helper.renderRequestQuery()\n const $headerParameters = this.helper.renderRequestHeaders()\n const $pathParameters = this.helper.renderRequestPathParameters()\n const $requestBody = this.helper.renderRequestBody()\n\n return [\n $comment,\n `${$operationDeclaration} {`,\n ` const req = this.request.${$method}<${this.typeName('ResponseBodies')}[STATUS]>(${JSON.stringify(pathname)})`,\n ' .option(',\n ' \"module\",',\n ' {',\n ` name: ${JSON.stringify(this.operationDefinition.module.name)},`,\n ` pathname: ${JSON.stringify(pathname)},`,\n ` method: ${JSON.stringify($method)},`,\n ' },',\n ' )',\n '',\n $mediaType ? indent(2, $mediaType) : undefined,\n '',\n ' /* @anchor:query:start */',\n $queryParameters ? indent(2, $queryParameters) : undefined,\n ' /* @anchor:query:end */',\n '',\n ' /* @anchor:headers:start */',\n $headerParameters ? indent(2, $headerParameters) : undefined,\n ' /* @anchor:headers:end */',\n '',\n ' /* @anchor:path-parameters:start */',\n $pathParameters ? indent(2, $pathParameters) : undefined,\n ' /* @anchor:path-parameters:end */',\n '',\n ' /* @anchor:body:start */',\n $requestBody ? indent(2, $requestBody) : undefined,\n ' /* @anchor:body:end */',\n '',\n ' return req',\n '}',\n ].filter(R.isNotNil).join('\\n')\n }\n\n private renderOperationDeclaration(operationDefinition: OperationDefinition): string {\n const { operationId } = operationDefinition\n const typeName = typeNameFactory(operationDefinition)\n\n const mediaTypes = this.helper.getRequestMediaTypes()\n\n if (mediaTypes.length === 0) {\n return `${operationId}<STATUS extends keyof ${typeName('ResponseBodies')}, CONTENT_TYPE extends never = never>(args?: ${typeName('RequestParameters')}): Keq<${typeName('Operation')}<STATUS, CONTENT_TYPE>>`\n } else if (mediaTypes.length === 1) {\n return `${operationId}<STATUS extends keyof ${typeName('ResponseBodies')}, CONTENT_TYPE extends ${JSON.stringify(mediaTypes[0])} = ${JSON.stringify(mediaTypes[0])}>(args?: ${typeName('RequestParameters')}): Keq<${typeName('Operation')}<STATUS, CONTENT_TYPE>>`\n } else if (mediaTypes.length > 1) {\n return `${operationId}<STATUS extends keyof ${typeName('ResponseBodies')}, CONTENT_TYPE extends ${typeName('RequestParameters')}[\"content-type\"]>(args?: Extract<${typeName('RequestParameters')}, { \"content-type\": CONTENT_TYPE }>): Keq<${typeName('Operation')}<STATUS, CONTENT_TYPE>>`\n }\n\n throw new Exception(operationDefinition.module, '[operationDeclarationRenderer] Unreachable')\n }\n}\n","import * as R from 'ramda'\nimport { OperationDefinition } from '~/models/index.js'\nimport { CommentRenderer } from './comment.renderer.js'\nimport { DeclarationRenderer, OperationDefinitionDeclarationRendererOptions } from './declaration.renderer.js'\nimport { OperationDefinitionMicroFunctionRendererOptions, OperationDefinitionMicroFunctionRenderer } from './micro-function.renderer.js'\nimport { OperationDefinitionNestjsMethodRenderer, OperationDefinitionNestjsMethodRendererOptions } from './nestjs-method.renderer.js'\n\n\nexport class OperationDefinitionTransformer {\n static toDeclaration(operationDefinition: OperationDefinition, options: OperationDefinitionDeclarationRendererOptions): string {\n return new DeclarationRenderer(operationDefinition, options).render()\n }\n\n static toMicroFunction(operationDefinition: OperationDefinition, options: OperationDefinitionMicroFunctionRendererOptions): string {\n return new OperationDefinitionMicroFunctionRenderer(operationDefinition, options).render()\n }\n\n static toNestjsMethod(operationDefinition: OperationDefinition, options: OperationDefinitionNestjsMethodRendererOptions): string {\n return new OperationDefinitionNestjsMethodRenderer(operationDefinition, options).render()\n }\n\n static toComment(operationDefinition: OperationDefinition): string {\n return new CommentRenderer(operationDefinition).render()\n }\n}\n","import * as path from 'path'\nimport { Artifact } from '~/models/index.js'\n\n\ninterface EntrypointTypescriptRendererOptions {\n esm?: boolean\n\n // The directory path of the entrypoint file being generated\n dirpath: string\n}\n\nexport class EntrypointTransformer {\n static toTypescript(exports: Artifact[], options: EntrypointTypescriptRendererOptions): string {\n const $exports = exports.map((exportArtifact) => {\n const relativePath = path.relative(\n options.dirpath,\n exportArtifact.filepath,\n )\n .replace(/(\\.ts|\\.mts|\\.cts|\\.js|\\.cjs|\\.mjs)?$/, options.esm ? '.js' : '')\n\n return relativePath.startsWith('.')\n ? `export * from '${relativePath}'`\n : `export * from './${relativePath}'`\n })\n\n return [\n '/* @anchor:file:start */',\n '',\n ...$exports,\n '',\n '/* @anchor:file:end */',\n ].join('\\n')\n }\n}\n","import * as R from 'ramda'\nimport * as changeCase from 'change-case'\nimport { ApiDocumentV3_1, OperationDefinition } from '~/models/index.js'\nimport { Renderer } from '../types/renderer.js'\nimport { OperationDefinitionTransformer, typeNameFactory } from '../operation-definition/index.js'\nimport { KeqQueryOptionsFactory } from '~/types/index.js'\nimport { KeqQueryOptions } from 'keq'\nimport { indent } from '~/utils/indent.js'\n\n\nexport interface ApiDocumentNestjsClientRendererOptions {\n esm?: boolean\n qs?: KeqQueryOptions | KeqQueryOptionsFactory\n\n getOperationDefinitionDeclarationFilepath(this: void, operationDefinition: OperationDefinition): string\n}\n\n\nexport class NestjsClientRenderer implements Renderer {\n constructor(\n private readonly document: ApiDocumentV3_1,\n private readonly options: ApiDocumentNestjsClientRendererOptions,\n ) {\n\n }\n\n private renderDependencies(): string {\n const $operations = this.document.operations\n .map((operationDefinition) => {\n const filepath = this.options.getOperationDefinitionDeclarationFilepath(operationDefinition)\n const typeName = typeNameFactory(operationDefinition)\n\n return `import type { ${typeName('Operation')}, ${typeName('ResponseBodies')}, ${typeName('RequestParameters')} } from \"${filepath}\"`\n })\n .map((str) => (str.replace(/ from \"(\\.\\.?\\/.+?)(\\.ts|\\.mts|\\.cts|\\.js|\\.cjs|\\.mjs)?\"/, this.options.esm ? ' from \"$1.js\"' : ' from \"$1\"')))\n\n return [\n 'import { Injectable, Logger } from \"@nestjs/common\"',\n 'import { Keq, KeqRequest } from \"keq\"',\n ...$operations,\n ]\n .join('\\n')\n }\n\n render(): string {\n const moduleName = changeCase.pascalCase(this.document.module.name)\n\n const $dependencies = this.renderDependencies()\n const $operations = this.document.operations\n .map((operation) => OperationDefinitionTransformer.toNestjsMethod(operation, {\n esm: this.options.esm,\n qs: this.options.qs,\n }))\n .join('\\n\\n')\n\n return [\n '/* @anchor:file:start */',\n '',\n $dependencies,\n '',\n '@Injectable()',\n `export class ${moduleName}Client {`,\n ` private readonly logger = new Logger(${moduleName}Client.name)`,\n '',\n ' constructor(',\n ' // @anchor:client-constructor-parameters:start',\n ' private readonly request: KeqRequest,',\n ' // @anchor:client-constructor-parameters:end',\n ' ) {}',\n '',\n indent(2, $operations),\n '}',\n '',\n '/* @anchor:file:end */',\n ].filter(R.isNotNil).join('\\n')\n }\n}\n","import * as changeCase from 'change-case'\nimport { ApiDocumentV3_1 } from '~/models/api-document_v3_1.js'\n\nexport interface ApiDocumentNestjsModuleRendererOptions {\n esm?: boolean\n\n getNestjsClientFilepath(document: ApiDocumentV3_1): string\n}\n\nexport class NestjsModuleRenderer {\n constructor(\n private readonly document: ApiDocumentV3_1,\n private readonly options: ApiDocumentNestjsModuleRendererOptions,\n ) {\n }\n\n render(): string {\n const moduleName = changeCase.pascalCase(this.document.module.name)\n const clientFilepath = this.options.getNestjsClientFilepath(this.document)\n .replace(/(\\.ts|\\.mts|\\.cts|\\.js|\\.cjs|\\.mjs)?$/, this.options.esm ? '.js' : '')\n\n return [\n '/* @anchor:file:start */',\n 'import { Module, Inject, ConfigurableModuleBuilder, Global } from \"@nestjs/common\"',\n 'import { KeqRequest } from \"keq\"',\n 'import { KeqModuleOptions } from \"@keq-request/nestjs\"',\n `import { ${moduleName}Client } from \"${clientFilepath}\"`,\n '',\n '',\n 'const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE, ASYNC_OPTIONS_TYPE } = new ConfigurableModuleBuilder<KeqModuleOptions>().build()',\n '',\n '@Global()',\n '@Module({',\n ' imports: [],',\n ' controllers: [],',\n ` providers: [${moduleName}Client],`,\n ` exports: [${moduleName}Client],`,\n '})',\n `export class ${moduleName}Module extends ConfigurableModuleClass {`,\n '',\n ' constructor(',\n ' @Inject(MODULE_OPTIONS_TOKEN) private readonly options: KeqModuleOptions,',\n ' private readonly request: KeqRequest,',\n ' ) {',\n ' super()',\n ' }',\n '',\n ' onModuleInit() {',\n ' if (this.options.middlewares) {',\n ' for (const middleware of this.options.middlewares) {',\n ' this.request.use(middleware)',\n ' }',\n ' }',\n ' }',\n '}',\n '',\n '/* @anchor:file:end */',\n ].join('\\n')\n }\n}\n","import { ApiDocumentV3_1 } from '~/models/index.js'\nimport { ApiDocumentNestjsClientRendererOptions, NestjsClientRenderer } from './nestjs-client.renderer.js'\nimport { ApiDocumentNestjsModuleRendererOptions, NestjsModuleRenderer } from './nestjs-module.renderer.js'\n\n\nexport class ApiDocumentTransformer {\n static toNestjsModule(document: ApiDocumentV3_1, options: ApiDocumentNestjsModuleRendererOptions): string {\n return new NestjsModuleRenderer(document, options).render()\n }\n\n static toNestjsClient(document: ApiDocumentV3_1, options: ApiDocumentNestjsClientRendererOptions): string {\n return new NestjsClientRenderer(document, options).render()\n }\n}\n","import * as R from 'ramda'\nimport * as path from 'path'\nimport { Artifact, ModuleDefinition, SchemaDefinition } from '~/models/index.js'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { SchemaDefinitionTransformer } from '~/transformers/index.js'\nimport { EntrypointTransformer } from '~/transformers/entrypoint/entrypoint.transformer.js'\nimport { FileNamingStyle } from '~/constants/file-naming-style.js'\nimport * as changeCase from 'change-case'\nimport type { Generator, RuntimeConfig } from '~/types/index.js'\nimport { MetadataStorage } from '../../constants/metadata-storage.js'\n\n\nexport const SCHEMA_GENERATOR = 'schemaGenerator'\n\nexport class SchemaDeclarationGenerator implements Generator {\n async compile(compiler: Compiler, task: TaskWrapper): Promise<Artifact[]> {\n const context = compiler.context\n const metadata = MetadataStorage.get(compiler)!\n\n const rc = context.rc!\n // const matcher = context.matcher!\n const documents = context.documents!\n // .filter((document) => !matcher.isModuleIgnored(document.module))\n\n const schemaDefinitions = documents.flatMap((document) => document.schemas)\n\n const artifactMap = new Map<SchemaDefinition, Artifact>(\n await Promise.all(\n schemaDefinitions.map(async (schemaDefinition) => (<const>[\n schemaDefinition,\n await metadata.hooks.afterSchemaDeclarationArtifactGenerated.promise(\n this.generateSchemaDefinitionsArtifact(schemaDefinition, rc),\n schemaDefinition,\n task,\n ),\n ])),\n ),\n )\n\n\n const entrypoints = R.collectBy(\n (schemaDefinition) => schemaDefinition.module.name,\n schemaDefinitions,\n )\n .map((schemaDefinitions) => <const>[\n schemaDefinitions[0].module,\n schemaDefinitions\n .map((schemaDefinition) => artifactMap.get(schemaDefinition))\n .filter((artifact): artifact is Artifact => Boolean(artifact)),\n ])\n\n .map(([moduleDefinition, artifacts]) => this.generateEntrypointArtifact(\n moduleDefinition,\n artifacts,\n rc,\n ))\n\n return [...artifactMap.values(), ...entrypoints]\n }\n\n private generateSchemaDefinitionsArtifact(schemaDefinition: SchemaDefinition, rc: RuntimeConfig): Artifact {\n const filepath = SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(schemaDefinition, rc.fileNamingStyle)\n const dirpath = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: SchemaDeclarationGenerator.getSchemaDefinitionArtifactId(schemaDefinition),\n filepath,\n content: SchemaDefinitionTransformer.toDeclaration(\n schemaDefinition,\n {\n esm: rc.esm,\n getDependentSchemaDefinitionFilepath(dependentSchemaDefinition: SchemaDefinition): string {\n const relativePath = path.relative(\n dirpath,\n SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(dependentSchemaDefinition, rc.fileNamingStyle),\n )\n\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n },\n },\n ),\n extensionName: '.schema.ts',\n })\n\n return artifact\n }\n\n private generateEntrypointArtifact(moduleDefinition: ModuleDefinition, exports: Artifact[], rc: RuntimeConfig): Artifact {\n const filepath = SchemaDeclarationGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle)\n const dirpath = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: SchemaDeclarationGenerator.getEntrypointArtifactId(moduleDefinition),\n filepath,\n content: EntrypointTransformer.toTypescript(exports, { dirpath }),\n })\n\n return artifact\n }\n\n static getEntrypointArtifactFilepath(moduleDefinition: ModuleDefinition, fileNamingStyle: FileNamingStyle): string {\n return [\n '.',\n changeCase[fileNamingStyle](moduleDefinition.name),\n 'types',\n 'components',\n 'schemas',\n 'index.ts',\n ].join('/')\n }\n\n static getEntrypointArtifactId(moduleDefinition: ModuleDefinition): string {\n return `${moduleDefinition.address}/components/schemas/entrypoint?generator=${SCHEMA_GENERATOR}`\n }\n\n static getSchemaDefinitionArtifactFilepath(schemaDefinition: SchemaDefinition, fileNamingStyle: FileNamingStyle): string {\n const filename = `${changeCase[fileNamingStyle](schemaDefinition.name)}.schema.ts`\n return [\n '.',\n changeCase[fileNamingStyle](schemaDefinition.module.name),\n 'types',\n 'components',\n 'schemas',\n filename,\n ].join('/')\n }\n\n static getSchemaDefinitionArtifactId(schemaDefinition: SchemaDefinition): string {\n return `${schemaDefinition.id}?generator=${SCHEMA_GENERATOR}`\n }\n}\n","import { AsyncSeriesWaterfallHook } from 'tapable'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { Artifact, OperationDefinition, SchemaDefinition } from '~/models/index.js'\n\n\nexport interface GenerateDeclarationPluginMetadata {\n hooks: {\n afterEntrypointArtifactGenerated: AsyncSeriesWaterfallHook<[Artifact, TaskWrapper]>\n afterSchemaDeclarationArtifactGenerated: AsyncSeriesWaterfallHook<[Artifact, SchemaDefinition, TaskWrapper]>\n afterOperationDeclarationArtifactGenerated: AsyncSeriesWaterfallHook<[Artifact, OperationDefinition, TaskWrapper]>\n }\n}\n\nexport const MetadataStorage = new WeakMap<Compiler, GenerateDeclarationPluginMetadata>()\n","import { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { Artifact } from '~/models/index.js'\nimport { Generator } from '~/types/index.js'\n\n\nexport const MICRO_FUNCTION_REQUEST_GENERATOR = 'microFunctionRequestGenerator'\n\nexport class RequestGenerator implements Generator {\n private generateRequestArtifact(): Artifact {\n const content = [\n '/* @anchor:file:start */',\n '',\n 'import { KeqRequest } from \"keq\"',\n '',\n '/* @anchor:request-declaration */',\n 'export const request = new KeqRequest()',\n '',\n '/* @anchor:file:end */',\n ].join('\\n')\n\n return new Artifact({\n id: RequestGenerator.getRequestArtifactId(),\n filepath: RequestGenerator.getRequestArtifactFilepath(),\n content,\n })\n }\n\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async compile(compiler: Compiler, task: TaskWrapper): Promise<Artifact[]> {\n return [\n this.generateRequestArtifact(),\n ]\n }\n\n static getRequestArtifactFilepath(): string {\n return './request.ts'\n }\n\n static getRequestArtifactId(): string {\n return `request?generator=${MICRO_FUNCTION_REQUEST_GENERATOR}`\n }\n}\n","import { AsyncSeriesWaterfallHook } from 'tapable'\nimport { Plugin } from '~/types/index.js'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { ApiDocumentV3_1, Artifact } from '~/models/index.js'\nimport { GenerateNestjsModulePluginMetadata, MetadataStorage } from './constants/index.js'\nimport { NestjsModuleGenerator } from './generators/nestjs-module.generator.js'\n\n\nexport class GenerateNestjsModulePlugin implements Plugin {\n private readonly nestjsModuleGenerator = new NestjsModuleGenerator()\n\n apply(compiler: Compiler): void {\n GenerateNestjsModulePlugin.register(compiler)\n\n compiler.hooks.compile.tapPromise(GenerateNestjsModulePlugin.name, async (task) => {\n const artifacts = await this.nestjsModuleGenerator.compile(compiler, task)\n compiler.context.artifacts!.push(...artifacts)\n })\n }\n\n static register(compiler: Compiler): GenerateNestjsModulePluginMetadata {\n if (!MetadataStorage.has(compiler)) {\n MetadataStorage.set(compiler, {\n hooks: {\n afterNestjsModuleArtifactGenerated: new AsyncSeriesWaterfallHook<[Artifact, ApiDocumentV3_1, TaskWrapper]>(['artifact', 'document', 'task']),\n },\n })\n }\n\n return MetadataStorage.get(compiler)!\n }\n\n static of(compiler: Compiler): GenerateNestjsModulePluginMetadata | undefined {\n return MetadataStorage.get(compiler)\n }\n}\n","import { AsyncSeriesWaterfallHook } from 'tapable'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { ApiDocumentV3_1, Artifact } from '~/models/index.js'\n\nexport interface GenerateNestjsModulePluginMetadata {\n hooks: {\n afterNestjsModuleArtifactGenerated: AsyncSeriesWaterfallHook<[Artifact, ApiDocumentV3_1, TaskWrapper]>\n }\n}\n\nexport const MetadataStorage = new WeakMap<Compiler, GenerateNestjsModulePluginMetadata>()\n","import * as path from 'path'\nimport * as changeCase from 'change-case'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { ApiDocumentV3_1, Artifact } from '~/models/index.js'\nimport { MetadataStorage } from '../constants/metadata-storage.js'\nimport { FileNamingStyle } from '~/constants/index.js'\nimport { Generator, RuntimeConfig } from '~/types/index.js'\nimport { ApiDocumentTransformer } from '~/transformers/index.js'\nimport { OperationDeclarationGenerator } from '~/plugins/generate-declaration/index.js'\n\n\nconst NESTJS_MODULE_GENERATOR = 'nestjs-module-generator'\n\nexport class NestjsModuleGenerator implements Generator {\n private generateNestjsModuleArtifact(document: ApiDocumentV3_1, rc: RuntimeConfig): Artifact {\n const filepath = NestjsModuleGenerator.getNestjsModuleArtifactFilepath(document, rc.fileNamingStyle)\n const dirname = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: NestjsModuleGenerator.getNestjsModuleArtifactId(document),\n filepath,\n content: ApiDocumentTransformer.toNestjsModule(document, {\n esm: rc.esm,\n getNestjsClientFilepath(document) {\n const relativePath = path.relative(\n dirname,\n NestjsModuleGenerator.getNestjsClientArtifactFilepath(document, rc.fileNamingStyle),\n )\n\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n },\n }),\n })\n\n return artifact\n }\n\n private generateNestjsClientArtifact(document: ApiDocumentV3_1, rc: RuntimeConfig): Artifact {\n const filepath = NestjsModuleGenerator.getNestjsClientArtifactFilepath(document, rc.fileNamingStyle)\n const dirpath = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: NestjsModuleGenerator.getNestjsClientArtifactId(document),\n filepath,\n content: ApiDocumentTransformer.toNestjsClient(document, {\n esm: rc.esm,\n qs: rc.qs,\n getOperationDefinitionDeclarationFilepath(operationDefinition) {\n const relativePath = path.relative(\n dirpath,\n OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle),\n )\n\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n },\n }),\n })\n\n return artifact\n }\n\n async compile(compiler: Compiler, task: TaskWrapper): Promise<Artifact[]> {\n const metadata = MetadataStorage.get(compiler)!\n const rc = compiler.context.rc!\n const documents = compiler.context.documents!\n\n const nestjsModuleArtifacts = await Promise.all(\n documents.map((document) => metadata.hooks.afterNestjsModuleArtifactGenerated.promise(\n this.generateNestjsModuleArtifact(document, rc),\n document,\n task,\n )),\n )\n\n const nestjsClientArtifacts = await Promise.all(\n documents.map((document) => metadata.hooks.afterNestjsModuleArtifactGenerated.promise(\n this.generateNestjsClientArtifact(document, rc),\n document,\n task,\n )),\n )\n\n return [...nestjsModuleArtifacts, ...nestjsClientArtifacts]\n }\n\n static getNestjsModuleArtifactFilepath(document: ApiDocumentV3_1, fileNamingStyle: FileNamingStyle): string {\n const filename = `${changeCase[fileNamingStyle](document.module.name)}.module.ts`\n\n const filepath = [\n '.',\n changeCase[fileNamingStyle](document.module.name),\n filename,\n ]\n\n return filepath.join('/')\n }\n\n static getNestjsModuleArtifactId(document: ApiDocumentV3_1): string {\n return `${document.module.address}?generate=${NESTJS_MODULE_GENERATOR}`\n }\n\n static getNestjsClientArtifactFilepath(document: ApiDocumentV3_1, fileNamingStyle: FileNamingStyle): string {\n const filename = `${changeCase[fileNamingStyle](document.module.name)}.client.ts`\n\n const filepath = [\n '.',\n changeCase[fileNamingStyle](document.module.name),\n filename,\n ]\n\n return filepath.join('/')\n }\n\n static getNestjsClientArtifactId(document: ApiDocumentV3_1): string {\n return `${document.module.address}?generate=${NESTJS_MODULE_GENERATOR}-client`\n }\n}\n","\nimport { fixSwagger } from 'swagger-fix'\nimport { Compiler } from '~/compiler/index.js'\nimport { ApiDocumentV3_1 } from '~/models/index.js'\n\n\nexport class ChineseToPinyinPlugin {\n apply(compiler: Compiler): void {\n compiler.hooks.afterDownload.tap(ChineseToPinyinPlugin.name, (task) => {\n const documents = compiler.context.documents!\n\n compiler.context.documents = documents.map((doc) => {\n return new ApiDocumentV3_1(\n fixSwagger(doc.specification as any),\n doc.module,\n )\n })\n })\n }\n}\n","import * as validUrl from 'valid-url'\nimport { Compiler } from '~/compiler/index.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { OpenapiUtils } from '~/utils/openapi-utils/index.js'\n\n\nexport class DownloadHttpFilePlugin implements Plugin {\n apply(compiler: Compiler): void {\n compiler.hooks.download.tapPromise(DownloadHttpFilePlugin.name, async (address, task) => {\n if (!validUrl.isUri(address)) return undefined\n const content = await this.download(address)\n const spec = this.deserialize(content)\n return JSON.stringify(spec)\n })\n }\n\n async download(address): Promise<string> {\n try {\n const res = await fetch(address)\n if (res.status >= 400) throw new Error(`failed with status code ${res.status}`)\n\n return await res.text()\n } catch (e) {\n if (e instanceof Error) {\n e.message = `Unable get the openapi/swagger file from ${address}: ${e.message}`\n }\n\n throw e\n }\n }\n\n deserialize(content: string): object {\n const json = JSON.parse(content)\n const spec = OpenapiUtils.to3_1(json)\n return spec\n }\n}\n","import * as path from 'path'\nimport * as fs from 'fs/promises'\nimport * as yaml from 'js-yaml'\nimport { Compiler } from '~/compiler/index.js'\nimport { Plugin } from '~/types/index.js'\nimport { OpenapiUtils } from '~/utils/openapi-utils/index.js'\n\n\nexport class DownloadLocalFilePlugin implements Plugin {\n apply(compiler: Compiler): void {\n compiler.hooks.download.tapPromise(DownloadLocalFilePlugin.name, async (address, task) => {\n if (!address.startsWith('./') && !address.startsWith('/') && !address.startsWith('../')) return undefined\n\n const fileExt = path.extname(address)\n const content = await fs.readFile(address, 'utf8')\n\n if (['.yml', '.yaml'].includes(fileExt)) {\n const value = yaml.load(content)\n return JSON.stringify(OpenapiUtils.to3_1(value))\n } else if (fileExt === '.json') {\n return JSON.stringify(OpenapiUtils.to3_1(JSON.parse(content)))\n }\n })\n }\n}\n","import { Plugin } from '~/types/index.js'\nimport { Compiler } from '~/compiler/index.js'\nimport { ApiDocumentV3_1, ModuleDefinition, OperationDefinition } from '~/models/index.js'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { SupportedMethods } from '~/constants/index.js'\nimport { openapiShakingSync } from '@opendoc/openapi-shaking'\n\nexport class ShakingPlugin implements Plugin {\n apply(compiler: Compiler): void {\n compiler.hooks.beforeCompile.tap(ShakingPlugin.name, (task) => {\n const matcher = compiler.context.matcher!\n const documents = compiler.context.documents!\n\n compiler.context.documents = documents\n .map((document) => this.shaking(compiler, document))\n .filter((document) => !document.isEmpty())\n .filter((document) => !matcher.isModuleIgnored(document.module))\n })\n }\n\n shaking(compiler: Compiler, document: ApiDocumentV3_1): ApiDocumentV3_1 {\n const matcher = compiler.context.matcher!\n\n const isAccepted = (pathname: string, method: string, operation: OpenAPIV3_1.Document): boolean => {\n if (!SupportedMethods.includes(method)) return false\n\n return !matcher.isOperationIgnored(new OperationDefinition({\n method,\n pathname,\n operation,\n module: document.module,\n document: document,\n }))\n }\n\n\n const sharkedSwagger = openapiShakingSync(\n document.specification as any,\n isAccepted as any,\n { tolerant: true },\n ) as OpenAPIV3_1.Document\n\n return new ApiDocumentV3_1(\n sharkedSwagger,\n new ModuleDefinition(\n document.module.name,\n `file://${document.module.name}.v3_1.sharked.json`,\n ),\n )\n }\n}\n","import { ListrTaskWrapper } from 'listr2'\nimport { OperationDefinition } from '~/models/index.js'\nimport { select } from 'inquirer-select-pro'\nimport { ListrInquirerPromptAdapter } from '@listr2/prompt-adapter-inquirer'\nimport { CompilerContext } from '~/compiler/index.js'\n\nexport async function selectOperationDefinitions(\n task: ListrTaskWrapper<CompilerContext, any, any>,\n operationDefinitions: OperationDefinition[],\n): Promise<OperationDefinition[]> {\n const selectedOperationDefinitions = await task.prompt(ListrInquirerPromptAdapter).run(\n select<OperationDefinition>,\n {\n message: 'Select Pathname',\n defaultValue: [],\n options: (input) => {\n const items = operationDefinitions.map((op) => ({ name: `${op.module.name} ${op.method.toUpperCase()} ${op.pathname}`, value: op }))\n\n if (!input) return items\n const keys = input\n .trim()\n .toLowerCase()\n .split(/\\s+/)\n\n return items.filter((i) => {\n const name = i.name.toLowerCase()\n return keys.every((q) => name.includes(q))\n })\n },\n },\n )\n\n return selectedOperationDefinitions\n}\n","import { Compiler } from '~/compiler/index.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { selectOperationDefinitions } from './utils/select-operation-definitions.js'\nimport { IgnoreMode } from './types/index.js'\n\nexport interface TerminalSelectPluginOptions {\n mode: IgnoreMode\n\n persist?: boolean\n\n /**\n * Remove all previously matcher rules.\n * This means that all rules form `.keqignore` file will be removed.\n */\n clear?: boolean\n}\n\n\nexport class TerminalSelectPlugin implements Plugin {\n constructor(private options: TerminalSelectPluginOptions) {}\n\n apply(compiler: Compiler): void {\n compiler.hooks.afterDownload.tapPromise(TerminalSelectPlugin.name, async (task) => {\n const context = compiler.context\n\n const matcher = context.matcher!\n const documents = context.documents!\n const operationDefinitions = documents.flatMap((document) => document.operations)\n const selectedOperationDefinitions = await selectOperationDefinitions(task, operationDefinitions)\n\n if (this.options.clear) {\n matcher.append({\n persist: false,\n ignore: true,\n moduleName: '*',\n operationMethod: '*',\n operationPathname: '*',\n })\n }\n\n for (const op of selectedOperationDefinitions) {\n matcher.append({\n persist: !!this.options.persist,\n ignore: this.options.mode === 'add',\n moduleName: op.module.name,\n operationMethod: op.method,\n operationPathname: op.pathname,\n })\n }\n })\n }\n}\n","import * as R from 'ramda'\nimport { Compiler } from '~/compiler/index.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { DownloadHttpFilePlugin } from '../download-http-file/index.js'\nimport { DownloadLocalFilePlugin } from '../download-local-file/index.js'\nimport { GenerateDeclarationPlugin } from '../generate-declaration/index.js'\nimport { ShakingPlugin } from '../shaking/index.js'\nimport { TerminalSelectPlugin, TerminalSelectPluginOptions } from '../terminal-select/index.js'\nimport { GenerateMicroFunctionPlugin } from '../generate-micro-function/index.js'\nimport { GenerateNestjsModulePlugin } from '../generate-nestjs-module/index.js'\n\n\ninterface InitializePluginOptions {\n build?: boolean\n interactive?: boolean | TerminalSelectPluginOptions\n\n includes?: string[]\n}\n\nexport class InitializePlugin implements Plugin {\n constructor(private options: InitializePluginOptions) {\n }\n\n apply(compiler: Compiler): void {\n compiler.hooks.setup.tap(InitializePlugin.name, (task) => {\n new DownloadHttpFilePlugin().apply(compiler)\n new DownloadLocalFilePlugin().apply(compiler)\n\n new GenerateDeclarationPlugin().apply(compiler)\n\n if (this.options.build) {\n new ShakingPlugin().apply(compiler)\n }\n\n if (this.options.interactive) {\n new TerminalSelectPlugin(\n typeof this.options.interactive === 'object'\n ? this.options.interactive\n : { mode: 'except' },\n ).apply(compiler)\n }\n\n const rc = compiler.context.rc!\n\n if (rc.mode === 'micro-function') {\n new GenerateMicroFunctionPlugin().apply(compiler)\n } else if (rc.mode === 'nestjs-module') {\n new GenerateNestjsModulePlugin().apply(compiler)\n }\n })\n\n if (this.options.includes && this.options.includes.length) {\n const modulesIncludes = this.options.includes\n\n compiler.hooks.afterSetup.tap(InitializePlugin.name, (task) => {\n const rc = compiler.context.rc!\n const matcher = compiler.context.matcher!\n\n const notExistModules = modulesIncludes.filter((moduleName) => !(moduleName in rc.modules))\n if (notExistModules.length) {\n throw new Error(`Cannot find module(s) ${notExistModules.join(', ')} in config file.`)\n }\n\n const ignoredModules = R.difference(R.keys(rc.modules), modulesIncludes)\n for (const moduleName of ignoredModules) {\n matcher.append({\n persist: false,\n ignore: true,\n moduleName,\n operationMethod: '*',\n operationPathname: '*',\n })\n }\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oBAAmB;AACnB,uBAA0C;;;ACFnC,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ACRA,mBAAkB;AAGX,IAAM,SAAS;AAAA,EACpB,KAAK,CAAC,QAAgB,QAAQ,IAAI,aAAAA,QAAM,MAAM,GAAG,CAAC;AAAA,EAClD,MAAM,CAAC,QAAgB,QAAQ,KAAK,aAAAA,QAAM,OAAO,GAAG,CAAC;AAAA,EACrD,OAAO,CAAC,QAAgB,QAAQ,MAAM,aAAAA,QAAM,IAAI,GAAG,CAAC;AACtD;;;ACLA,IAAAC,iBAAsB;AACtB,IAAAC,kBAA4G;;;ACH5G,IAAAC,mBAAe;AACf,kBAAiB;AAEjB,mBAAsB;AACtB,yBAA4B;;;ACJ5B,QAAmB;AACnB,sBAAe;AAaR,IAAM,gBAAN,MAAM,eAAc;AAAA,EACjB;AAAA,EAER,YAAY,OAA4B;AACtC,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA,aAAa,KAAK,UAA0C;AAC1D,QAAI,UAAU,MAAM,gBAAAC,QAAG,SAAS,UAAU,OAAO;AAEjD,cAAU,QACP,QAAQ,SAAS,IAAI,EACrB,QAAQ,OAAO,IAAI,EACnB,QAAQ,UAAU,EAAE,EACpB,QAAQ,QAAQ,IAAI,EACpB,KAAK;AAER,QAAI,QAAQ,QACT,MAAM,IAAI,EACV,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,EAChC,IAAI,CAAC,SAA4B;AAChC,YAAM,UAAU,KAAK,MAAM,2CAA2C;AACtE,UAAI,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AAI,CAACC,kBAAiB;AAAA,UACvC,SAAS;AAAA,UACT,QAAQ,SAAS;AAAA,UACjB,YAAYA;AAAA,UACZ,iBAAiB,QAAQ;AAAA,UACzB,mBAAmB,QAAQ;AAAA,QAC7B,EAAE;AAAA,MACJ;AAAA,MACA,aAAa;AAAA,IACf,CAAC;AAAA,EACH;AAEA,QAAM,SAAS,IAAI;AACrB,CAAC;AAEH,eAAeC,QAAsB;AACnC,UAAQ,GAAG,aAAa,SAAU,UAAU;AAC1C,UAAM,IAAI,MAAM,oBAAoB,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG;AAAA,EAC5D,CAAC;AAED,MAAI;AACF,UAAM,QAAQ,WAAW,QAAQ,IAAI;AAAA,EACvC,SAAS,KAAK;AACZ,QAAI,QAAQ,KAAK,SAAS,SAAS,GAAG;AACpC,cAAQ,MAAM,GAAG;AAAA,IACnB,OAAO;AACL,aAAO,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,IAC/D;AAAA,EACF;AACF;AAEA,KAAKA,MAAK;","names":["chalk","import_listr2","import_tapable","import_fs_extra","fs","QsArrayFormat","import_typebox","FileNamingStyle","R","keys","validator","path","fs","path","message","fs","context","task","import_openapi_parser","path","R","R","import_jsonpath_plus","R","module","path","filter","path","module","wrap","R","import_jsonpointer","import_jsonpath_plus","R","import_jsonpath_plus","R","path","jsonpointer","jsonpointer","R","last","main","task","rc","path","import_fs_extra","fs","main","context","task","main","context","task","prop","R","R","import_tapable","R","path","changeCase","path","changeCase","R","R","alias","schema","R","R","CommentRenderer","R","DeclarationRenderer","R","R","CommentRenderer","R","CommentRenderer","DeclarationRenderer","CommentRenderer","path","exports","R","changeCase","changeCase","R","path","changeCase","MetadataStorage","MetadataStorage","schemaDefinitions","exports","changeCase","MetadataStorage","exports","changeCase","MetadataStorage","operationDefinitions","operationDefinition","exports","changeCase","import_tapable","MetadataStorage","path","changeCase","dirname","document","MetadataStorage","changeCase","MetadataStorage","path","fs","import_openapi_shaking","keys","R","semver","moduleNames","main"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/constants/supported-methods.ts","../src/utils/logger.ts","../src/compiler/compiler.ts","../src/compiler/tasks/setup/index.ts","../src/utils/ignore-matcher.ts","../src/types/runtime-config.ts","../src/constants/file-naming-style.ts","../src/compiler/tasks/setup/utils/validate-modules.ts","../src/compiler/tasks/setup/utils/find-nearest-package-json.ts","../src/compiler/tasks/setup/utils/get-project-module-system.ts","../src/compiler/tasks/download/index.ts","../src/models/artifact.ts","../src/models/anchor.ts","../src/models/api-document_v3_1.ts","../src/models/module-definition.ts","../src/models/operation-definition.ts","../src/utils/is-keywords.ts","../src/utils/is-reserved-word.ts","../src/models/schema-definition.ts","../src/models/asset.ts","../src/exception.ts","../src/utils/openapi-utils/dereference.ts","../src/utils/openapi-utils/dereference-operation.ts","../src/utils/openapi-utils/remove-undefined-ref.ts","../src/utils/openapi-utils/is-ref-defined.ts","../src/utils/json-schema-utils/is-array.ts","../src/utils/json-schema-utils/is-mixed.ts","../src/utils/json-schema-utils/is-non-array.ts","../src/utils/json-schema-utils/is-ref.ts","../src/utils/json-schema-utils/index.ts","../src/utils/openapi-utils/dereference-deep.ts","../src/utils/openapi-utils/to-3_1.ts","../src/utils/openapi-utils/map-operation.ts","../src/utils/openapi-utils/map-parameter.ts","../src/utils/openapi-utils/index.ts","../src/compiler/tasks/persist/index.ts","../src/compiler/tasks/compile/index.ts","../src/compiler/intercepter/print-information.ts","../src/compiler/intercepter/perfect-error-message.ts","../src/plugins/eslint/index.ts","../src/plugins/prettier/prettier.plugin.ts","../src/plugins/body-fallback/index.ts","../src/plugins/generate-micro-function/generate-micro-function.plugin.ts","../src/plugins/generate-micro-function/constants/metadata-storage.ts","../src/plugins/generate-micro-function/generators/micro_function/micro-function.generator.ts","../src/plugins/generate-declaration/generate-declaration.plugin.ts","../src/plugins/generate-declaration/generators/operation-declaration/operation.generator.ts","../src/transformers/json-schema/comment.renderer.ts","../src/transformers/json-schema/declaration.renderer.ts","../src/utils/indent.ts","../src/transformers/json-schema/reference.transformer.ts","../src/transformers/json-schema/json-schema.transformer.ts","../src/transformers/schema-definition/schema-definition.transformer.ts","../src/transformers/operation-definition/comment.renderer.ts","../src/transformers/operation-definition/declaration.renderer.ts","../src/transformers/operation-definition/utils/type-name-factory.ts","../src/transformers/operation-definition/micro-function.renderer.ts","../src/transformers/operation-definition/typescript-snippet.ts","../src/constants/qs-array-format.ts","../src/transformers/operation-definition/nestjs-method.renderer.ts","../src/transformers/operation-definition/operation-definition.transformer.ts","../src/transformers/entrypoint/entrypoint.transformer.ts","../src/transformers/api-document/nestjs-client.renderer.ts","../src/transformers/api-document/nestjs-module.renderer.ts","../src/transformers/api-document/api-document.transformer.ts","../src/plugins/generate-declaration/generators/schema-declaration/schema.generator.ts","../src/plugins/generate-declaration/constants/metadata-storage.ts","../src/plugins/generate-micro-function/generators/request/request.generator.ts","../src/plugins/generate-nestjs-module/generate-nestjs-module.ts","../src/plugins/generate-nestjs-module/constants/metadata-storage.ts","../src/plugins/generate-nestjs-module/generators/nestjs-module.generator.ts","../src/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.ts","../src/plugins/download-http-file/download-http-file.plugin.ts","../src/plugins/download-local-file/download-local-file.plugin.ts","../src/plugins/shaking/shaking.plugin.ts","../src/plugins/terminal-select/utils/select-operation-definitions.ts","../src/plugins/terminal-select/terminal-select.plugin.ts","../src/plugins/initialize/initialize.plugin.ts","../src/plugins/overwrite-query-options/overwrite-query-options.plugin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport semver from 'semver'\nimport { Argument, Command, Option } from 'commander'\nimport { SupportedMethods } from './constants/supported-methods.js'\nimport { logger } from './utils/logger.js'\nimport { Compiler } from './compiler/compiler.js'\n\n\nif (semver.lt(process.version, '20.0.0')) {\n throw new Error('Node.js version must be greater than 20')\n}\n\nconst program = new Command()\n\n\nprogram\n .command('build')\n .option('-c --config <config>', 'The keq-cli config file')\n .option('--module <modules...>', 'Filter module(s) to generate')\n .option('--debug', 'Print debug information')\n .option('--tolerant', 'Tolerate wrong swagger/openapi structure')\n .option('-i --interactive', 'Interactive select the scope of generation')\n .action(async (options) => {\n const compiler = new Compiler({\n build: true,\n config: options.config,\n includes: options.module,\n debug: !!options.debug,\n tolerant: !!options.tolerant,\n interactive: !!options.interactive && {\n mode: 'except',\n clear: true,\n },\n })\n\n await compiler.run()\n })\n\n\nprogram\n .command('ignore')\n .addArgument(\n new Argument('<mode>', 'The ignore mode')\n .choices(['all', 'add', 'except'])\n .argRequired(),\n )\n .option('-c --config <config>', 'The keq-cli config file')\n .option('--debug', 'Print debug information')\n .option('--module <modules...>')\n .option('--build', 'Build after updating .keqignore file')\n .addOption(\n new Option('--method <method>', 'Only generate files of the specified operation method')\n .choices([\n ...SupportedMethods,\n ...SupportedMethods.map((method) => method.toUpperCase()),\n ]),\n )\n .option('--pathname <pathnames>', 'Only generate files of the specified operation pathname')\n .option('-i --interactive', 'Interactive select the scope of generation')\n .action(async (mode, options) => {\n let compiler: Compiler\n\n if (mode === 'all') {\n if (options.build) throw new Error(\"'--build' cannot be used with 'all' mode\")\n\n compiler = new Compiler({\n build: false,\n config: options.config,\n includes: options.module,\n debug: !!options.debug,\n interactive: false,\n ignore: {\n rules: [{\n persist: true,\n ignore: true,\n moduleName: '*',\n operationMethod: '*',\n operationPathname: '*',\n }],\n },\n })\n } else if (options.interactive) {\n if (options.interactive) {\n if (options.method) throw new Error(\"'--method' cannot be used with '--interactive'\")\n if (options.pathname) throw new Error(\"'--pathname' cannot be used with '--interactive'\")\n }\n\n compiler = new Compiler({\n build: !!options.build,\n config: options.config,\n includes: options.module,\n debug: !!options.debug,\n\n interactive: {\n mode,\n persist: true,\n },\n })\n } else {\n if (!options.method && !options.pathname) {\n throw new Error(\"at least one of '-i --interactive', '--method' or '--pathname' must be specified\")\n }\n\n const moduleNames = options.module || ['*']\n\n compiler = new Compiler({\n build: !!options.build,\n config: options.config,\n debug: !!options.debug,\n includes: options.module,\n ignore: {\n rules: moduleNames.map((moduleNames) => ({\n persist: true,\n ignore: mode === 'add',\n moduleName: moduleNames,\n operationMethod: options.method,\n operationPathname: options.pathname,\n })),\n },\n interactive: false,\n })\n }\n\n await compiler.run()\n })\n\nasync function main(): Promise<void> {\n program.on('command:*', function (operands) {\n throw new Error(`Unknown command '${String(operands[0])}'`)\n })\n\n try {\n await program.parseAsync(process.argv)\n } catch (err) {\n if (process.argv.includes('--debug')) {\n console.error(err)\n } else {\n logger.error(err instanceof Error ? err.message : String(err))\n }\n }\n}\n\nvoid main()\n","export const SupportedMethods = [\n 'get',\n 'post',\n 'put',\n 'delete',\n 'patch',\n 'head',\n 'options',\n]\n","import chalk from 'chalk'\n\n\nexport const logger = {\n log: (str: string) => console.log(chalk.green(str)),\n warn: (str: string) => console.warn(chalk.yellow(str)),\n error: (str: string) => console.error(chalk.red(str)),\n}\n","\n\nimport { Listr } from 'listr2'\nimport { AsyncParallelHook, AsyncSeriesBailHook, AsyncSeriesHook, AsyncSeriesWaterfallHook, SyncHook } from 'tapable'\nimport { CompilerHooks, CompilerContext } from './types/index.js'\nimport {\n ModuleDefinition,\n} from '~/models/index.js'\nimport {\n createCompileTask,\n createDownloadTask,\n createPersistTask,\n createSetupTask,\n SetupTaskOptions,\n TaskWrapper,\n} from './tasks/index.js'\nimport {\n perfectErrorMessage,\n printInformation,\n} from './intercepter/index.js'\nimport {\n InitializePlugin,\n TerminalSelectPluginOptions,\n} from '~/plugins/index.js'\n\n\ninterface Options extends SetupTaskOptions {\n includes: string[]\n build: boolean\n interactive?: boolean | TerminalSelectPluginOptions\n}\n\n\nexport class Compiler {\n context: CompilerContext = {}\n\n hooks: CompilerHooks = {\n setup: new AsyncParallelHook<[TaskWrapper]>(['task']),\n afterSetup: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n\n beforeDownload: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n download: new AsyncSeriesBailHook<[string, ModuleDefinition, TaskWrapper], string | undefined>(['address', 'moduleDefinition', 'task']),\n afterDownload: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n\n beforeCompile: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n compile: new AsyncParallelHook<[TaskWrapper]>(['task']),\n afterCompile: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n\n beforePersist: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n persist: new AsyncParallelHook<[TaskWrapper]>(['task']),\n afterPersist: new AsyncSeriesHook<[TaskWrapper]>(['task']),\n\n done: new SyncHook<[]>(),\n }\n\n constructor(\n public options: Options,\n ) {\n for (const hook of Object.values(this.hooks)) {\n hook.intercept(perfectErrorMessage())\n }\n\n this.hooks.afterSetup.intercept(printInformation(0))\n this.hooks.afterPersist.intercept(printInformation(0))\n\n new InitializePlugin({\n build: options.build,\n interactive: options.interactive,\n includes: options.includes,\n }).apply(this)\n }\n\n async run(): Promise<void> {\n const options = this.options\n\n const tasks = new Listr<CompilerContext>(\n [\n createSetupTask(this, options),\n createDownloadTask(this, { skipIgnoredModules: !options.interactive }),\n createCompileTask(this, { enabled: !!options.build }),\n createPersistTask(this),\n ],\n {\n concurrent: false,\n renderer: 'default',\n rendererOptions: {\n suffixSkips: true,\n collapseSubtasks: false,\n collapseErrors: false,\n },\n },\n )\n\n await tasks.run(this.context)\n\n await this.hooks.done.promise()\n }\n}\n","import fs from 'fs-extra'\nimport path from 'path'\nimport { CosmiconfigResult } from 'cosmiconfig'\nimport { Value } from '@sinclair/typebox/value'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { ListrTask } from 'listr2'\nimport { IgnoreMatcher, IgnoreMatcherRule } from '~/utils/ignore-matcher.js'\nimport { RuntimeConfig } from '~/types/index.js'\nimport { validateModules, findNearestPackageJson, getProjectModuleSystem } from './utils/index.js'\nimport type { BaseTaskOptions } from '../types/base-task-options.js'\nimport type { Compiler } from '../../compiler.js'\nimport { CompilerContext } from '../../types/index.js'\n\n\nexport interface SetupTaskOptions {\n config?: string\n debug?: boolean\n tolerant?: boolean\n\n ignore?: false | {\n rules: IgnoreMatcherRule[]\n }\n}\n\nconst explore = cosmiconfig('keq')\n\nfunction main(compiler: Compiler, options: SetupTaskOptions): ListrTask<CompilerContext> {\n return {\n task: async (context, task) => {\n const result: CosmiconfigResult = options?.config\n ? await explore.load(options.config)\n : await explore.search()\n\n if (!result || ('isEmpty' in result && result.isEmpty)) {\n throw new Error('Cannot find config file.')\n }\n\n if (!Value.Check(RuntimeConfig, result.config)) {\n const errors = [...Value.Errors(RuntimeConfig, result.config)]\n const message = errors.map(({ path, message }) => `${path}: ${message}`).join('\\n')\n throw new Error(`Invalid Config: ${message}`)\n }\n\n const rc = Value.Default(RuntimeConfig, result.config) as RuntimeConfig\n\n validateModules(rc.modules)\n\n if (options?.debug) {\n await fs.ensureDir('.keq')\n rc.debug = true\n }\n\n rc.tolerant = Boolean(rc.tolerant)\n\n const packageJsonInfo = findNearestPackageJson()\n if (packageJsonInfo) {\n const moduleSystem = getProjectModuleSystem(packageJsonInfo)\n rc.esm = moduleSystem === 'esm'\n }\n\n context.rc = rc\n\n\n // Setup IgnoreMatcher\n\n let matcher: IgnoreMatcher = new IgnoreMatcher([])\n if (result.filepath) {\n const ignoreFilepath = path.resolve(path.dirname(result.filepath), '.keqignore')\n if (await fs.exists(ignoreFilepath)) {\n matcher = await IgnoreMatcher.read(ignoreFilepath)\n }\n }\n\n const ignoreRules = options.ignore === false ? [] : options.ignore?.rules || []\n for (const rule of ignoreRules) {\n matcher.append({\n persist: !!rule.persist,\n ignore: rule.ignore,\n moduleName: rule.moduleName,\n operationMethod: rule.operationMethod,\n operationPathname: rule.operationPathname,\n })\n }\n\n context.matcher = matcher\n\n await compiler.hooks.setup.promise(task)\n },\n }\n}\n\nexport function createSetupTask(compiler: Compiler, options: SetupTaskOptions & BaseTaskOptions): ListrTask<CompilerContext> {\n return {\n title: 'Setup',\n enabled: options?.enabled,\n skip: options?.skip,\n task: (context, task) => task.newListr(\n [\n main(compiler, options),\n {\n task: (context, task) => compiler.hooks.afterSetup\n .promise(task),\n },\n ],\n {\n concurrent: false,\n },\n ),\n }\n}\n","import * as R from 'ramda'\nimport fs from 'fs-extra'\nimport { OperationDefinition, ModuleDefinition } from '~/models/index.js'\n\n\nexport interface IgnoreMatcherRule {\n persist: boolean\n ignore: boolean\n moduleName: string\n operationMethod: string\n operationPathname: string\n}\n\n\nexport class IgnoreMatcher {\n private rules: IgnoreMatcherRule[]\n\n constructor(rules: IgnoreMatcherRule[]) {\n this.rules = rules\n }\n\n static async read(filepath: string): Promise<IgnoreMatcher> {\n let content = await fs.readFile(filepath, 'utf-8')\n\n content = content\n .replace(/\\r\\n/g, '\\n')\n .replace(/\\r/g, '\\n')\n .replace(/#.*$/gm, '')\n .replace(/\\n+/g, '\\n')\n .trim()\n\n let rules = content\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.length > 0)\n .map((line): IgnoreMatcherRule => {\n const matched = line.match(/^(!)?\\s*([^\\s/]+)\\s+([^\\s/]+)\\s+([^\\s]+)$/)\n if (!matched) throw new Error(`Invalid ignore rule: \"${line}\"`)\n\n const [, flag, moduleName, operationMethod, operationPathname] = matched\n\n return {\n persist: true,\n ignore: !flag,\n moduleName,\n operationMethod: operationMethod.toLowerCase(),\n operationPathname,\n }\n })\n rules = R.sortBy(\n R.prop('ignore'),\n rules,\n )\n\n rules = R.uniqWith(\n (a, b) => a.moduleName === b.moduleName && a.operationMethod === b.operationMethod && a.operationPathname === b.operationPathname,\n rules,\n )\n\n return new IgnoreMatcher(rules)\n }\n\n async write(filepath: string): Promise<void> {\n const ruleGroups = R.compose(\n R.groupBy((rule: IgnoreMatcherRule) => rule.moduleName),\n R.reverse,\n R.uniqWith<IgnoreMatcherRule>(\n (a, b) => a.moduleName === b.moduleName && a.operationMethod === b.operationMethod && a.operationPathname === b.operationPathname,\n ),\n R.filter((rule: IgnoreMatcherRule) => rule.persist),\n )(this.rules)\n\n const content = Object.entries(ruleGroups)\n .sort((a, b) => {\n const aModuleName = a[0]\n const bModuleName = b[0]\n\n if (aModuleName === '*') return -1\n if (bModuleName === '*') return 1\n\n return aModuleName.localeCompare(bModuleName)\n })\n .map(([, rules]) => (rules || [])\n .sort((a, b) => {\n if (a.ignore !== b.ignore) return a.ignore ? -1 : 1\n\n if (a.operationMethod === '*') return -1\n if (b.operationMethod === '*') return 1\n if (a.operationPathname === '*') return -1\n if (b.operationPathname === '*') return 1\n\n if (a.operationMethod !== b.operationMethod) return a.operationMethod.localeCompare(b.operationMethod)\n if (a.operationPathname !== b.operationPathname) return a.operationPathname.localeCompare(b.operationPathname)\n\n return 0\n })\n .map((rule) => `${rule.ignore ? '' : '! '}${rule.moduleName} ${rule.operationMethod.toUpperCase()} ${rule.operationPathname}`)\n .join('\\n'))\n .join('\\n\\n')\n\n await fs.writeFile(filepath, content, 'utf-8')\n }\n\n append(rule: IgnoreMatcherRule): void {\n this.rules.unshift(rule)\n }\n\n // if operation is ignored, return true\n isOperationIgnored(operationDefinition: OperationDefinition): boolean {\n const moduleName = operationDefinition.module.name\n const operationMethod = operationDefinition.method.toLowerCase()\n const operationPathname = operationDefinition.pathname\n\n for (const rule of this.rules) {\n if (rule.moduleName !== '*' && rule.moduleName !== moduleName) continue\n if (rule.operationMethod !== '*' && rule.operationMethod !== operationMethod) continue\n if (rule.operationPathname !== '*' && rule.operationPathname !== operationPathname) continue\n\n return rule.ignore\n }\n\n return false\n }\n\n isModuleIgnored(moduleDefinition: ModuleDefinition): boolean {\n const moduleName = moduleDefinition.name\n\n for (const rule of this.rules) {\n if (!rule.ignore) {\n if (rule.moduleName === '*' || rule.moduleName === moduleName) return false\n continue\n }\n\n if (rule.operationMethod !== '*') continue\n if (rule.operationPathname !== '*') continue\n\n if (rule.moduleName === '*' || rule.moduleName === moduleName) return true\n }\n\n return false\n }\n}\n","import { KeqQueryOptions } from 'keq'\nimport { Static, Type } from '@sinclair/typebox'\nimport { FileNamingStyle } from '../constants/file-naming-style.js'\nimport { Plugin } from './plugin.js'\n\n\nexport const RuntimeConfig = Type.Object({\n mode: Type.Optional(\n Type.Union([\n Type.Literal('micro-function'),\n Type.Literal('nestjs-module'),\n Type.Literal('none'),\n ], { default: 'micro-function' }),\n ),\n\n /**\n * Whether to generate ES Module code\n *\n * If not specified, the module system will be inferred from the nearest package.json \"type\" field\n * or defaults to \"cjs\" if no package.json is found.\n */\n esm: Type.Optional(Type.Boolean({ default: false })),\n\n /**\n * Output directory for generated files\n */\n outdir: Type.String({ default: `${process.cwd()}/api` }),\n\n /**\n * File naming style for generated files\n */\n fileNamingStyle: Type.Enum(FileNamingStyle, { default: FileNamingStyle.snakeCase }),\n\n modules: Type.Record(Type.String(), Type.String()),\n\n debug: Type.Optional(Type.Boolean({ default: false })),\n\n /**\n * Whether to tolerate wrong openapi/swagger structure\n */\n tolerant: Type.Optional(Type.Boolean({ default: false })),\n\n plugins: Type.Optional(Type.Array(Type.Any(), { default: [] })),\n})\n\n\nexport interface RuntimeConfig extends Omit<Static<typeof RuntimeConfig>, 'operationId' | 'plugins'> {\n plugins?: Plugin[]\n}\n","\nexport enum FileNamingStyle {\n camelCase = 'camelCase',\n capitalCase = 'capitalCase',\n constantCase = 'constantCase',\n dotCase = 'dotCase',\n headerCase = 'headerCase',\n noCase = 'noCase',\n paramCase = 'paramCase',\n pascalCase = 'pascalCase',\n pathCase = 'pathCase',\n sentenceCase = 'sentenceCase',\n snakeCase = 'snakeCase',\n}\n","import * as R from 'ramda'\nimport validator from 'validator'\n\n\nexport function validateModules(modules: Record<string, string>): void {\n const keys = Object.keys(modules)\n\n for (const key of keys) {\n if (!/^[A-Za-z_][A-Za-z0-9_$]*$/.test(key)) {\n throw new Error(`Module name \"${key}\" is not valid. It must start with a letter or underscore, and can only contain letters, numbers, and underscores.`)\n }\n }\n\n const keysGroupByLowerCase = R.groupBy(R.toLower, keys)\n\n for (const groupKey in keysGroupByLowerCase) {\n const keys = keysGroupByLowerCase[groupKey] || []\n if (keys.length > 1) {\n throw new Error(`Module names ${keys.map((name) => `\"${name}\"`).join(', ')} are case-insensitively duplicated.`)\n }\n }\n\n for (const key in modules) {\n const address = modules[key]\n\n if (validator.isURL(address, { require_host: true, require_protocol: true, protocols: ['http', 'https'] })) {\n continue\n }\n\n if (/^(\\/|\\.\\/|\\.\\.\\/)/.test(address)) {\n continue\n }\n\n throw new Error(`Module address \"${address}\" of module \"${key}\" is not valid. It must be a URL or a local path.`)\n }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nexport interface PackageJsonInfo {\n json: any\n path: string\n}\n\n\nexport function findNearestPackageJson(startDir = process.cwd()): PackageJsonInfo | null {\n let dir = startDir\n // 向上遍历直到磁盘根目录\n while (true) {\n const pkgPath = path.join(dir, 'package.json')\n if (fs.existsSync(pkgPath)) {\n const json = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))\n return { json, path: pkgPath }\n }\n const parent = path.dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n return null\n}\n","import { PackageJsonInfo } from './find-nearest-package-json.js'\n\ntype ModuleSystem = 'esm' | 'cjs'\n\nexport function getProjectModuleSystem(pkgInfo: PackageJsonInfo): ModuleSystem {\n if (!pkgInfo?.json) return 'cjs'\n const { json } = pkgInfo\n\n if (json.type === 'module') return 'esm'\n return 'cjs'\n}\n","import { ListrTask, PRESET_TIMER } from 'listr2'\nimport { validate } from '@scalar/openapi-parser'\nimport { ModuleDefinition, ApiDocumentV3_1 } from '~/models/index.js'\nimport { BaseTaskOptions } from '../types/base-task-options.js'\nimport type { Compiler } from '~/compiler/compiler.js'\nimport { CompilerContext } from '~/compiler/index.js'\nimport { Exception } from '~/exception.js'\nimport { OpenapiUtils } from '~/utils/openapi-utils/index.js'\n\n\ninterface DownloadTaskOptions {\n skipIgnoredModules?: boolean\n}\n\nfunction main(compiler: Compiler, options?: DownloadTaskOptions): ListrTask<CompilerContext> {\n return {\n task: (context, task) => {\n if (!context.rc || !context.matcher) {\n throw new Error('Please run setup task first.')\n }\n\n const rc = context.rc\n const matcher = context.matcher\n\n context.documents = []\n\n return task.newListr(\n Object.entries(rc.modules)\n .map(([moduleName, address]) => new ModuleDefinition(moduleName, address))\n .map((moduleDefinition): ListrTask<CompilerContext> => ({\n title: moduleDefinition.name,\n task: async (ctx, task) => {\n if (options?.skipIgnoredModules && matcher.isModuleIgnored(moduleDefinition)) {\n task.skip(`(${moduleDefinition.name}) is ignored`)\n return\n }\n\n task.output = `Downloaded from ${moduleDefinition.address}`\n\n const content = await compiler.hooks.download.promise(moduleDefinition.address, moduleDefinition, task)\n\n if (!content) {\n throw new Exception(moduleDefinition, `Cannot download document from ${moduleDefinition.address}`)\n }\n\n const spec = JSON.parse(content)\n\n const { valid, errors } = await validate(spec)\n if (!valid) {\n const message = `${moduleDefinition.name} module openapi/swagger file does not conform to the openapi specifications or have grammatical errors, which may cause unexpected errors: \\n${errors?.map((e) => ` - ${e.message}`).join('\\n')}`\n task.output = message\n }\n\n OpenapiUtils.dereferenceOperation(spec)\n\n const document = new ApiDocumentV3_1(\n spec,\n moduleDefinition,\n )\n\n ctx.documents?.push(document)\n },\n })),\n {\n concurrent: true,\n exitOnError: false,\n collectErrors: 'minimal',\n rendererOptions: {\n collapseSubtasks: false,\n // collapseSkips: false,\n suffixSkips: true,\n timer: PRESET_TIMER,\n },\n },\n )\n },\n }\n}\n\nexport function createDownloadTask(compiler: Compiler, options?: DownloadTaskOptions & BaseTaskOptions): ListrTask<CompilerContext> {\n return {\n title: 'Download',\n enabled: options?.enabled,\n skip: options?.skip,\n task: (_, task) => task.newListr(\n [\n main(compiler, options),\n {\n task: (context, task) => compiler.hooks.afterDownload\n .promise(task),\n },\n ],\n {\n concurrent: false,\n },\n ),\n }\n}\n","import * as path from 'path'\nimport { Anchor } from './anchor.js'\n\n\nconst HeaderComment = [\n '// Code generated by keq-cli. DO NOT EDIT.',\n '// Code generated by keq-cli. DO NOT EDIT.',\n '// Code generated by keq-cli. DO NOT EDIT.',\n '',\n '',\n].join('\\n')\n\nexport class Artifact {\n id: string\n filepath: string\n content: string\n extensionName\n anchor = new Anchor(this)\n\n constructor(options: {\n id: string\n filepath: string\n content: string\n extensionName?: string\n }) {\n this.id = options.id\n this.filepath = options.filepath\n this.extensionName = options.extensionName || path.extname(options.filepath)\n this.content = options.content\n }\n\n get dirname(): string {\n return path.dirname(this.filepath)\n }\n\n renderer(): string {\n return `${HeaderComment}${this.content}`\n }\n}\n","import type { Artifact } from './artifact.js'\n\nclass AnchorBlock {\n constructor(\n private artifact: Artifact,\n ) {}\n\n /**\n * Append content to the end of the anchor block.\n */\n append(anchorName: string, content: string): void {\n const lines = this.artifact.content.split('\\n')\n\n const anchor = `@anchor:${anchorName}:end`\n const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`))\n\n if (anchorIndex === -1) {\n throw new Error(`\"${anchor}\" not found in artifact \"${this.artifact.filepath}\".`)\n }\n\n lines.splice(anchorIndex, 0, content)\n this.artifact.content = lines.join('\\n')\n }\n\n prepend(anchorName: string, content: string): void {\n const lines = this.artifact.content.split('\\n')\n\n const anchor = `@anchor:${anchorName}:start`\n const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`))\n\n if (anchorIndex === -1) {\n throw new Error(`\"${anchor}\" not found in artifact \"${this.artifact.filepath}\".`)\n }\n\n lines.splice(anchorIndex + 1, 0, content)\n this.artifact.content = lines.join('\\n')\n }\n\n replace(anchorName: string, content: string): void {\n const lines = this.artifact.content.split('\\n')\n const startIndex = lines.findIndex((line) => line.includes(`/* @anchor:${anchorName}:start */`))\n const endIndex = lines.findIndex((line) => line.includes(`/* @anchor:${anchorName}:end */`))\n\n if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {\n throw new Error(`\"@anchor:${anchorName}:start\" or \"@anchor:${anchorName}:end\" not found in artifact \"${this.artifact.filepath}\".`)\n }\n\n lines.splice(startIndex + 1, endIndex - startIndex - 1, content)\n this.artifact.content = lines.join('\\n')\n }\n}\n\n\nexport class Anchor {\n block: AnchorBlock\n\n constructor(\n private artifact: Artifact,\n ) {\n this.block = new AnchorBlock(artifact)\n }\n\n append(anchorName: string, content: string): void {\n const lines = this.artifact.content.split('\\n')\n\n const anchor = `@anchor:${anchorName}`\n const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`))\n\n if (anchorIndex === -1) {\n throw new Error(`\"${anchor}\" not found in artifact \"${this.artifact.filepath}\".`)\n }\n\n lines.splice(anchorIndex + 1, 0, content)\n this.artifact.content = lines.join('\\n')\n }\n\n prepend(anchorName: string, content: string): void {\n const lines = this.artifact.content.split('\\n')\n\n const anchor = `@anchor:${anchorName}`\n const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`))\n\n if (anchorIndex === -1) {\n throw new Error(`\"${anchor}\" not found in artifact \"${this.artifact.filepath}\".`)\n }\n\n lines.splice(anchorIndex, 0, content)\n this.artifact.content = lines.join('\\n')\n }\n}\n","import * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { ModuleDefinition } from './module-definition.js'\nimport { SupportedMethods } from '~/constants/supported-methods.js'\nimport { OperationDefinition } from './operation-definition.js'\nimport { SchemaDefinition } from './schema-definition.js'\nimport { logger } from '~/utils/logger.js'\n\n\nexport class ApiDocumentV3_1 {\n readonly module: ModuleDefinition\n readonly specification: OpenAPIV3_1.Document\n\n constructor(specification: OpenAPIV3_1.Document, module: ModuleDefinition) {\n this.module = module\n this.specification = specification\n }\n\n get schemas(): SchemaDefinition[] {\n const module = this.module\n\n return Object.entries(this.specification.components?.schemas || {})\n .map(([name, schema]) => new SchemaDefinition({\n name,\n schema,\n module,\n document: this,\n }))\n }\n\n get operations(): OperationDefinition[] {\n const module = this.module\n\n return Object.entries(this.specification.paths || {})\n .flatMap(([pathname, pathItem]) => Object.entries(pathItem || {})\n .filter(([method]) => SupportedMethods.includes(method.toLowerCase()))\n .map(([method, operation]) => new OperationDefinition({\n method,\n pathname,\n operation,\n module,\n document: this,\n })))\n }\n\n isEmpty(): boolean {\n return R.isEmpty(this.specification.paths)\n }\n\n dereference($ref: string): SchemaDefinition | undefined {\n if ($ref.startsWith('#/')) {\n return this.schemas.find((schema) => schema.id.endsWith($ref))\n }\n\n logger.warn(`The $ref(${$ref}) is not defined in ${this.module.name} openapi/swagger.`)\n }\n\n isRefDefined($ref: string): boolean {\n if ($ref.startsWith('#/')) {\n const path = $ref.replace('#/', '').split('/')\n return R.path(path, this.specification) !== undefined\n }\n\n return false\n }\n\n static unknown(): ApiDocumentV3_1 {\n return new ApiDocumentV3_1({}, ModuleDefinition.unknown())\n }\n}\n","export class ModuleDefinition {\n name: string\n address: string\n\n constructor(name: string, address: string) {\n this.name = name\n this.address = address\n }\n\n static unknown(): ModuleDefinition {\n return new ModuleDefinition('', '')\n }\n}\n","import * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { ModuleDefinition } from './module-definition.js'\nimport { isKeywords } from '~/utils/is-keywords.js'\nimport { isReservedWord } from '~/utils/is-reserved-word.js'\nimport { ApiDocumentV3_1 } from './api-document_v3_1.js'\nimport { JSONPath } from 'jsonpath-plus'\nimport { SchemaDefinition } from './schema-definition.js'\n\n\nexport class OperationDefinition {\n readonly module: ModuleDefinition\n\n readonly operationId: string\n readonly method: string\n readonly pathname: string\n readonly operation: OpenAPIV3_1.OperationObject\n readonly document: ApiDocumentV3_1\n\n get id(): string {\n return `${this.module.address}#/paths/${this.pathname}/${this.method}`\n }\n\n constructor(args: {\n method: string\n pathname: string\n operation: OpenAPIV3_1.OperationObject\n module: ModuleDefinition\n document: ApiDocumentV3_1\n }) {\n this.module = args.module\n this.method = args.method.toLowerCase()\n this.pathname = args.pathname\n this.document = args.document\n this.operationId = this.formatOperationId(args.method, args.pathname, args.operation)\n\n this.operation = {\n ...args.operation,\n operationId: this.operationId,\n }\n }\n\n private formatOperationId(method: string, pathname: string, operation: OpenAPIV3_1.OperationObject): string {\n const operationId = operation.operationId\n\n if (\n operationId\n && operationId !== 'index'\n && !isKeywords(operationId)\n && !isReservedWord(operationId)\n ) {\n return operationId as string\n }\n\n return `${method}_${pathname}`\n .replace(/\\//g, '_')\n .replace(/-/g, '_')\n .replace(/:/g, '$$')\n .replace(/{(.+)}/, '$$$1')\n }\n\n getDependencies(): SchemaDefinition[] {\n const refs = R.uniq([\n ...JSONPath<string>({\n path: '$.requestBody.content..schema..$ref',\n json: this.operation,\n }),\n ...JSONPath<string>({\n path: '$.responses..content..schema..$ref',\n json: this.operation,\n }),\n ...JSONPath<string>({\n path: '$.parameters..schema..$ref',\n json: this.operation,\n }),\n ])\n\n const dependencies = refs\n .filter((ref) => typeof ref === 'string' && ref)\n .map((ref) => {\n const schemaDefinition = this.document.dereference(ref)\n if (schemaDefinition) return schemaDefinition\n\n return SchemaDefinition.unknown()\n })\n\n return dependencies\n }\n}\n","const keywords = [\n 'break',\n 'case',\n 'catch',\n 'continue',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'in',\n 'instanceof',\n 'new',\n 'return',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n]\n\nexport function isKeywords(str: string): boolean {\n return keywords.includes(str)\n}\n","\nconst reservedWords = [\n 'abstract',\n 'boolean',\n 'byte',\n 'char',\n 'class',\n 'const',\n 'debugger',\n 'double',\n 'enum',\n 'export',\n 'extends',\n 'final',\n 'float',\n 'goto',\n 'implements',\n 'import',\n 'int',\n 'interface',\n 'long',\n 'native',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'short',\n 'static',\n 'super',\n 'synchronized',\n 'throws',\n 'transient',\n 'volatile',\n]\n\nexport function isReservedWord(str: string): boolean {\n return reservedWords.includes(str)\n}\n","import * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { ModuleDefinition } from './module-definition.js'\nimport { JSONPath } from 'jsonpath-plus'\nimport { ApiDocumentV3_1 } from './api-document_v3_1.js'\n\n\nexport class SchemaDefinition {\n readonly name: string\n readonly schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject\n readonly module: ModuleDefinition\n readonly document: ApiDocumentV3_1\n\n get id(): string {\n return `${this.module.address}#/components/schemas/${this.name}`\n }\n\n constructor(args: {\n name: string\n schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject\n module: ModuleDefinition\n document: ApiDocumentV3_1\n }) {\n this.module = args.module\n this.name = args.name\n this.schema = args.schema\n this.document = args.document\n }\n\n getDependencies(): SchemaDefinition[] {\n const refs: string[] = R.uniq(JSONPath({\n path: \"$..*['$ref']\",\n json: this.schema,\n }))\n\n return refs\n .filter((ref) => typeof ref === 'string' && !!ref.trim())\n .map((ref) => {\n const definition = this.document.dereference(ref)\n if (definition) return definition\n\n return SchemaDefinition.unknown()\n })\n }\n\n static unknown(): SchemaDefinition {\n return new SchemaDefinition({\n name: '',\n schema: {},\n module: ModuleDefinition.unknown(),\n document: ApiDocumentV3_1.unknown(),\n })\n }\n\n static isUnknown(definition: SchemaDefinition): boolean {\n return definition.name === ''\n }\n}\n","export class Asset {\n path: string\n\n constructor(path: string) {\n this.path = path\n }\n}\n","import { CustomError } from 'ts-custom-error'\nimport wrap from 'word-wrap'\nimport { ModuleDefinition } from '~/models/index.js'\n\n\nexport class Exception extends CustomError {\n constructor(module: ModuleDefinition | string, message: string) {\n const moduleName = typeof module === 'string' ? module : module.name\n\n const msg = wrap(message, { width: 60, indent: ' ' })\n super(`${moduleName} module failed to compile:\\n${msg}`)\n\n Object.defineProperty(this, 'name', { value: 'KeqCLI_Exception' })\n }\n}\n","import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\n\nexport function dereference<T extends OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ResponseObject | OpenAPIV3_1.ParameterObject | OpenAPIV3_1.RequestBodyObject | OpenAPIV3_1.ReferenceObject>($ref: string, swagger: OpenAPIV3_1.Document): T {\n let value\n\n for (const key of $ref.split('/')) {\n if (key === '#') {\n value = swagger\n } else {\n value = value[key]\n }\n\n if (!value) break\n }\n\n return value as T\n}\n","import * as R from 'ramda'\nimport jsonpointer from 'jsonpointer'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { JSONPath } from 'jsonpath-plus'\nimport { removeUndefinedRef } from './remove-undefined-ref.js'\nimport { dereference } from './dereference.js'\n\n\nfunction dereferencePathObject(swagger: OpenAPIV3_1.Document): void {\n const matches = JSONPath({\n path: '$.paths.*.$ref^',\n json: swagger,\n resultType: 'all',\n })\n\n for (const match of matches) {\n const value = dereference(match.value.$ref, swagger)\n jsonpointer.set(swagger, match.pointer, value)\n }\n}\n\nfunction dereferenceRequestBody(swagger: OpenAPIV3_1.Document): void {\n const matches = JSONPath({\n path: '$.paths.*.*.requestBody.$ref^',\n json: swagger,\n resultType: 'all',\n })\n\n for (const match of matches) {\n const value = dereference(match.value.$ref, swagger)\n jsonpointer.set(swagger, match.pointer, value)\n }\n}\n\nexport function dereferenceResponses(swagger: OpenAPIV3_1.Document): void {\n const matches = [\n ...JSONPath({\n path: '$.paths.*.*.responses.*.$ref^',\n json: swagger,\n resultType: 'all',\n }),\n ...JSONPath({\n path: '$.paths.*.*.responses.*.headers.*.$ref^',\n json: swagger,\n resultType: 'all',\n }),\n ]\n\n for (const match of matches) {\n const value = dereference(match.value.$ref, swagger)\n jsonpointer.set(swagger, match.pointer, value)\n }\n}\n\nfunction dereferenceParameters(swagger: OpenAPIV3_1.Document): void {\n const matches = JSONPath({\n path: '$.paths.*.*.parameters.*.$ref^',\n json: swagger,\n resultType: 'all',\n })\n\n for (const match of matches) {\n const value = dereference(match.value.$ref, swagger)\n jsonpointer.set(swagger, match.pointer, value)\n }\n}\n\nexport function dereferenceOperation(swagger: OpenAPIV3_1.Document): OpenAPIV3_1.Document {\n const shadow = R.clone(swagger)\n\n dereferencePathObject(shadow)\n dereferenceRequestBody(shadow)\n dereferenceResponses(shadow)\n dereferenceParameters(shadow)\n\n return removeUndefinedRef(shadow)\n}\n","import * as R from 'ramda'\nimport jsonpointer from 'jsonpointer'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { JSONPath } from 'jsonpath-plus'\nimport { isRefDefined } from './is-ref-defined.js'\n\n\n// remove schema $ref if the reference is not founded\nexport function removeUndefinedRef(swagger: OpenAPIV3_1.Document): OpenAPIV3_1.Document {\n const shadow = R.clone(swagger)\n\n const matches = JSONPath({\n path: \"$..*['$ref']^\",\n json: swagger,\n resultType: 'all',\n })\n\n for (const match of matches) {\n if (match.value.$ref && !isRefDefined(match.value.$ref, swagger)) {\n jsonpointer.set(shadow, match.pointer, R.omit(['$ref'], match.value))\n }\n }\n\n return shadow\n}\n","import * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\n\nexport function isRefDefined($ref: string, swagger: OpenAPIV3_1.Document): boolean {\n if ($ref.startsWith('#/')) {\n const path = $ref.replace('#/', '').split('/')\n return R.path(path, swagger) !== undefined\n }\n\n return false\n}\n\n","import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nexport function isArray(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject): schema is OpenAPIV3_1.ArraySchemaObject {\n return schema.type === 'array'\n}\n","\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { MixedSchemaObject } from './types/mixed-schema-object.js'\n\nexport function isMixed(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject): schema is MixedSchemaObject {\n return Array.isArray(schema.type)\n}\n","import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nexport function isNonArray(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject): schema is OpenAPIV3_1.NonArraySchemaObject {\n return typeof schema.type === 'string' && schema.type !== 'array'\n}\n","import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\n\nexport function isRef(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.ResponseObject | OpenAPIV3_1.ParameterObject): schema is OpenAPIV3_1.ReferenceObject {\n return '$ref' in schema\n}\n","import { isArray } from './is-array.js'\nimport { isMixed } from './is-mixed.js'\nimport { isNonArray } from './is-non-array.js'\nimport { isRef } from './is-ref.js'\n\n\nexport class JsonSchemaUtils {\n static isRef = isRef\n static isArray = isArray\n static isNonArray = isNonArray\n static isMixed = isMixed\n}\n","import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { dereference } from './dereference.js'\nimport { JsonSchemaUtils } from '../json-schema-utils/index.js'\n\n\nexport function dereferenceDeep<T extends OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ResponseObject | OpenAPIV3_1.ParameterObject | OpenAPIV3_1.RequestBodyObject>($ref: string, swagger: OpenAPIV3_1.Document): T {\n const stack = [$ref]\n let value\n\n while (true) {\n const last = stack[stack.length - 1]\n value = dereference(last, swagger)\n\n if (JsonSchemaUtils.isRef(value)) {\n if (!stack.includes(value.$ref)) {\n stack.push(value.$ref)\n continue\n } else {\n // Circular reference detected\n throw new Error(`Circular reference detected: ${stack.join(' -> ')} -> ${value.$ref}`)\n }\n }\n\n break\n }\n\n return value as T\n}\n","import { upgrade } from '@scalar/openapi-parser'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nexport function To3_1(openapi: object): OpenAPIV3_1.Document {\n const { specification } = upgrade(openapi)\n return specification\n}\n","import * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { SupportedMethods } from '~/constants/supported-methods.js'\n\n\nexport type OpenapiOperationMapper = (method: string, pathname: string, operation: OpenAPIV3_1.OperationObject) => OpenAPIV3_1.OperationObject\n\n\nexport function mapOperation(specification: OpenAPIV3_1.Document, mapper: OpenapiOperationMapper): OpenAPIV3_1.Document {\n const shadow = R.clone(specification)\n\n for (const [pathname, pathItem] of Object.entries(shadow.paths || {})) {\n for (const m in pathItem) {\n const method = m.toLowerCase()\n if (!SupportedMethods.includes(method)) continue\n if (typeof pathItem[m] !== 'object' || Array.isArray(pathItem[m]) || pathItem[m] === null) continue\n\n const operation: OpenAPIV3_1.OperationObject = pathItem[m]\n pathItem[m] = mapper(method, pathname, operation)\n }\n }\n\n return shadow\n}\n","import * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { mapOperation } from './map-operation.js'\n\n\nexport type OpenapiParameterMapper = (method: string, pathname: string, operation: OpenAPIV3_1.OperationObject, parameter: OpenAPIV3_1.ParameterObject) => OpenAPIV3_1.ParameterObject\n\nexport function mapParameter(\n specification: OpenAPIV3_1.Document,\n mapper: OpenapiParameterMapper,\n): OpenAPIV3_1.Document {\n return mapOperation(specification, (method, pathname, operation) => {\n if (!operation.parameters) return operation\n\n operation.parameters = operation.parameters\n .map((parameter) => mapper(method, pathname, operation, parameter as OpenAPIV3_1.ParameterObject))\n\n return operation\n })\n}\n","import { dereference } from './dereference.js'\nimport { dereferenceOperation } from './dereference-operation.js'\nimport { isRefDefined } from './is-ref-defined.js'\nimport { removeUndefinedRef } from './remove-undefined-ref.js'\nimport { dereferenceDeep } from './dereference-deep.js'\nimport { To3_1 } from './to-3_1.js'\nimport { mapOperation } from './map-operation.js'\nimport { mapParameter } from './map-parameter.js'\n\n\nexport class OpenapiUtils {\n static isRefDefined = isRefDefined\n static dereference = dereference\n static dereferenceDeep = dereferenceDeep\n static removeUndefinedRef = removeUndefinedRef\n static dereferenceOperation = dereferenceOperation\n static mapOperation = mapOperation\n static mapParameter = mapParameter\n // static updateOperationId = updateOperationId\n static to3_1 = To3_1\n}\n","import * as path from 'path'\nimport fs from 'fs-extra'\nimport { ListrTask } from 'listr2'\nimport { BaseTaskOptions } from '../types/base-task-options.js'\nimport type { Compiler, CompilerContext } from '~/compiler/index.js'\nimport { Asset } from '~/models/index.js'\n\n\nfunction createPersistArtifactTask(): ListrTask<CompilerContext> {\n return {\n title: 'Write files',\n task: async (context, task) => {\n if (!context.rc) throw new Error('Please run setup task first.')\n if (!context.artifacts || context.artifacts.length === 0) {\n task.skip('No compiled artifacts to persist.')\n return\n }\n\n const rc = context.rc\n const artifacts = context.artifacts\n\n const total = artifacts.length\n let completed = 0\n\n const files = await Promise.all(artifacts.map(async (artifact): Promise<Asset> => {\n const realpath = `./${path.join(rc.outdir, artifact.filepath)}`\n await fs.ensureFile(realpath)\n await fs.writeFile(realpath, artifact.renderer())\n\n completed += 1\n task.output = `Persisted ${completed}/${total} files`\n\n return new Asset(path.resolve(realpath))\n }))\n\n context.assets = files\n },\n }\n}\n\nfunction createPersistIgnoreTask(): ListrTask<CompilerContext> {\n return {\n title: 'Update .keqignore',\n task: async (context, task) => {\n if (!context.matcher) throw new Error('Please run setup task first.')\n\n const matcher = context.matcher\n await matcher.write('.keqignore')\n },\n }\n}\n\n\nfunction main(): ListrTask<CompilerContext> {\n return {\n task: (context, task) => task.newListr(\n [\n createPersistArtifactTask(),\n createPersistIgnoreTask(),\n ],\n {\n concurrent: true,\n rendererOptions: {\n collapseSubtasks: true,\n },\n },\n ),\n }\n}\n\nexport function createPersistTask(compiler: Compiler, options?: BaseTaskOptions): ListrTask<CompilerContext> {\n return {\n title: 'Persist',\n enabled: options?.enabled,\n skip: options?.skip,\n task: (context, task) => task.newListr(\n [\n main(),\n {\n task: (context, task) => compiler.hooks.afterPersist\n .promise(task),\n },\n ],\n {\n concurrent: false,\n },\n ),\n }\n}\n","import { ListrTask } from 'listr2'\nimport { BaseTaskOptions } from '../types/base-task-options.js'\nimport type { Compiler } from '~/compiler/compiler.js'\nimport { CompilerContext } from '~/compiler/index.js'\n// import { RequestGenerator } from '~/generators/index.js'\n\n\nfunction main(compiler: Compiler): ListrTask<CompilerContext> {\n return {\n task: async (context, task) => {\n if (!context.rc) throw new Error('Please run setup task first.')\n if (!context.documents) throw new Error('Please run shaking task first.')\n\n context.artifacts = []\n\n await compiler.hooks.compile.promise(task)\n },\n }\n}\n\nexport function createCompileTask(compiler: Compiler, options?: BaseTaskOptions): ListrTask<CompilerContext> {\n return {\n title: 'Compile',\n enabled: options?.enabled,\n skip: options?.skip,\n task: (context, task) => task.newListr(\n [\n {\n task: (context, task) => compiler.hooks.beforeCompile\n .promise(task),\n },\n main(compiler),\n {\n task: (context, task) => compiler.hooks.afterCompile\n .promise(task),\n },\n ],\n {\n concurrent: false,\n },\n ),\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport { FullTap, HookInterceptor } from 'tapable'\nimport { TaskWrapper } from '../tasks/index.js'\n\n\nexport function proxyTaskWrapper(pluginName: string, task: TaskWrapper): TaskWrapper {\n return new Proxy(task, {\n set(target, prop, value) {\n if (prop !== 'output') {\n return Reflect.set(target, prop, value)\n }\n\n target.output = `[Plugin: ${pluginName}] ${value}`\n return true\n },\n })\n}\n\n\nexport function printInformation(taskIndex: number): HookInterceptor<unknown, unknown> {\n return {\n register: <T extends FullTap>(tap: T): T => {\n const fn = tap.fn\n\n if (tap.type === 'promise') {\n tap.fn = (...args: any[]) => {\n const task = args[taskIndex] as TaskWrapper\n const proxyTask = proxyTaskWrapper(tap.name, task)\n args[taskIndex] = proxyTask\n proxyTask.output = 'Processing...'\n return fn(...args)\n }\n }\n\n if (tap.type === 'sync') {\n tap.fn = (...args: any[]) => {\n const task = args[taskIndex] as TaskWrapper\n const proxyTask = proxyTaskWrapper(tap.name, task)\n args[taskIndex] = proxyTask\n proxyTask.output = 'Processing...'\n return fn(...args)\n }\n }\n\n if (tap.type === 'async') {\n tap.fn = (...args: any[]) => {\n const task = args[taskIndex] as TaskWrapper\n const proxyTask = proxyTaskWrapper(tap.name, task)\n args[taskIndex] = proxyTask\n proxyTask.output = 'Processing...'\n return fn(...args)\n }\n }\n\n return tap\n },\n }\n}\n\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport * as R from 'ramda'\nimport { FullTap, HookInterceptor, InnerCallback } from 'tapable'\n\nexport function perfectErrorMessage(): HookInterceptor<unknown, unknown> {\n return {\n register: <T extends FullTap>(tap: T): T => {\n const fn = tap.fn\n\n function prefix(err: unknown): void {\n if (err instanceof Error) {\n err.message = `[Plugin: ${tap.name}] ${err.message}`\n }\n }\n\n if (tap.type === 'promise') {\n tap.fn = async (...args: any[]) => {\n try {\n return await fn(...args)\n } catch (err) {\n prefix(err)\n throw err\n }\n }\n }\n\n if (tap.type === 'sync') {\n tap.fn = (...args: any[]) => {\n try {\n return fn(...args)\n } catch (err) {\n prefix(err)\n throw err\n }\n }\n }\n\n if (tap.type === 'async') {\n tap.fn = (...args: any[]) => {\n const callback = R.last(args) as InnerCallback<Error, any>\n\n return fn(...R.init(args), (err: Error | null, result: any) => {\n prefix(err)\n return callback(err, result)\n })\n }\n }\n\n return tap\n },\n }\n}\n","import { Compiler } from '~/compiler/compiler.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { ESLint } from 'eslint'\n\n\ninterface EslintPluginOptions {\n /**\n * List of ESLint rules to disable\n */\n disable?: string[]\n}\n\nexport class EslintPlugin implements Plugin {\n constructor(private options: EslintPluginOptions = {}) {}\n\n\n apply(compiler: Compiler): void {\n if (!compiler.options.build) return\n\n if (this.options.disable && this.options.disable.length > 0) {\n const $rules = [\n ...this.options.disable.map((rule) => `/* eslint-disable ${rule} */`),\n ].join('\\n')\n\n compiler.hooks.afterCompile.tap(EslintPlugin.name, () => {\n const artifacts = compiler.context.artifacts || []\n\n for (const artifact of artifacts) {\n artifact.anchor.append('file:start', $rules)\n }\n })\n }\n\n compiler.hooks.afterPersist.tapPromise(EslintPlugin.name, async (task) => {\n const files = compiler.context.assets || []\n if (files.length === 0) return\n\n const eslint = new ESLint({ fix: true })\n const results = await eslint.lintFiles(files.map((file) => file.path))\n await ESLint.outputFixes(results)\n })\n }\n}\n","import { Compiler } from '~/compiler/compiler.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { exec } from 'child_process'\nimport { promisify } from 'util'\n\nconst execAsync = promisify(exec)\n\n\nexport class PrettierPlugin implements Plugin {\n apply(compiler: Compiler): void {\n if (!compiler.options.build) return\n\n compiler.hooks.afterPersist.tapPromise(PrettierPlugin.name, async () => {\n const files = compiler.context.assets || []\n if (files.length === 0) return\n\n const filePaths = files.map((file) => file.path).join(' ')\n await execAsync(`prettier --write ${filePaths}`)\n })\n }\n}\n","import * as R from 'ramda'\nimport { Compiler } from '~/compiler/compiler.js'\nimport { Artifact, OperationDefinition } from '~/models/index.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { JsonSchemaUtils } from '~/utils/json-schema-utils/index.js'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nimport { GenerateMicroFunctionPlugin } from '../generate-micro-function/index.js'\n\n\nexport class BodyFallbackPlugin implements Plugin {\n apply(compiler: Compiler): void {\n compiler.hooks.setup.tap(BodyFallbackPlugin.name, () => {\n const generateMicroFunctionPluginMetadata = GenerateMicroFunctionPlugin.of(compiler)\n\n if (!generateMicroFunctionPluginMetadata) {\n throw new Error('BodyFallbackPlugin requires GenerateMicroFunctionPlugin to be applied first.')\n }\n\n generateMicroFunctionPluginMetadata.hooks.afterMicroFunctionArtifactGenerated\n .tap(BodyFallbackPlugin.name, (artifact: Artifact, operationDefinition: OperationDefinition) => {\n const operation = operationDefinition.operation\n\n const parameters = operation.parameters?.filter((p): p is OpenAPIV3_1.ParameterObject => !JsonSchemaUtils.isRef(p)) || []\n const keys = parameters.map((p) => p.name).filter(R.isNotNil)\n\n const $acc = !keys.length\n ? ' acc[key] = args[key]'\n : [\n ` if (![${keys.map((k) => JSON.stringify(k)).join(', ')}].includes(key)) {`,\n ' acc[key] = args[key]',\n ' }',\n ].join('\\n')\n\n artifact.anchor.block.replace('body', [\n // $mediaType ? `${$mediaType}\\n` : undefined,\n ' if (typeof args === \"object\" && args !== null && !Array.isArray(args)) {',\n ' const requestBody = Object.keys(args)',\n ' .reduce((acc, key) => {',\n $acc,\n ' return acc',\n ' }, {} as Record<string, unknown>)',\n '',\n ' if (Object.keys(requestBody).length > 0) {',\n ' req.send(requestBody)',\n ' }',\n ' }',\n ].filter(R.isNotNil).join('\\n'))\n\n return artifact\n })\n })\n }\n}\n","import { AsyncSeriesWaterfallHook } from 'tapable'\nimport { Plugin } from '~/types/index.js'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { Artifact, OperationDefinition } from '~/models/index.js'\nimport { GenerateMicroFunctionPluginMetadata, MetadataStorage } from './constants/index.js'\nimport { MicroFunctionGenerator, RequestGenerator } from './generators/index.js'\n\n\nexport class GenerateMicroFunctionPlugin implements Plugin {\n private readonly microFunctionGenerator = new MicroFunctionGenerator()\n private readonly requestGenerator = new RequestGenerator()\n\n apply(compiler: Compiler): void {\n GenerateMicroFunctionPlugin.register(compiler)\n\n compiler.hooks.compile.tapPromise(GenerateMicroFunctionPlugin.name, async (task: TaskWrapper) => {\n const artifacts = [\n ...(await this.requestGenerator.compile(compiler, task)),\n ...(await this.microFunctionGenerator.compile(compiler, task)),\n ]\n\n compiler.context.artifacts!.push(...artifacts)\n })\n }\n\n static register(compiler: Compiler): GenerateMicroFunctionPluginMetadata {\n if (!MetadataStorage.has(compiler)) {\n MetadataStorage.set(compiler, {\n hooks: {\n afterEntrypointArtifactGenerated: new AsyncSeriesWaterfallHook<[Artifact, TaskWrapper]>(['artifact', 'task']),\n afterMicroFunctionArtifactGenerated: new AsyncSeriesWaterfallHook<[Artifact, OperationDefinition, TaskWrapper]>(['artifact', 'operationDefinition', 'task']),\n },\n })\n }\n\n return MetadataStorage.get(compiler)!\n }\n\n\n static of(compiler: Compiler): GenerateMicroFunctionPluginMetadata | undefined {\n return this.register(compiler)\n }\n}\n","import { AsyncSeriesWaterfallHook } from 'tapable'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { Artifact, OperationDefinition } from '~/models/index.js'\n\nexport interface GenerateMicroFunctionPluginMetadata {\n hooks: {\n afterEntrypointArtifactGenerated: AsyncSeriesWaterfallHook<[Artifact, TaskWrapper]>\n afterMicroFunctionArtifactGenerated: AsyncSeriesWaterfallHook<[Artifact, OperationDefinition, TaskWrapper]>\n }\n}\n\nexport const MetadataStorage = new WeakMap<Compiler, GenerateMicroFunctionPluginMetadata>()\n","import * as R from 'ramda'\nimport * as path from 'path'\nimport * as changeCase from 'change-case'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { Generator, RuntimeConfig } from '~/types/index.js'\nimport { Artifact, ModuleDefinition, OperationDefinition } from '~/models/index.js'\nimport { OperationDeclarationGenerator } from '~/plugins/generate-declaration/index.js'\nimport { OperationDefinitionTransformer } from '~/transformers/index.js'\nimport { EntrypointTransformer } from '~/transformers/index.js'\nimport { FileNamingStyle } from '~/constants/index.js'\nimport { MetadataStorage } from '../../constants/metadata-storage.js'\nimport { RequestGenerator } from '../request/index.js'\n\n\nexport const MICRO_FUNCTION_GENERATOR = 'microFunctionGenerator'\n\nexport class MicroFunctionGenerator implements Generator {\n async compile(compiler: Compiler, task: TaskWrapper): Promise<Artifact[]> {\n const metadata = MetadataStorage.get(compiler)!\n const context = compiler.context\n const rc = context.rc!\n const documents = context.documents!\n\n const operationDefinitions = documents.flatMap((document) => document.operations)\n\n const artifactMap = new Map<OperationDefinition, Artifact>(\n await Promise.all(\n operationDefinitions.map(async (operationDefinition) => (<const>[\n operationDefinition,\n await metadata.hooks.afterMicroFunctionArtifactGenerated.promise(\n this.generateOperationDefinitionArtifact(operationDefinition, rc),\n operationDefinition,\n task,\n ),\n ])),\n ),\n )\n\n\n const entrypoints = await Promise.all(\n R.collectBy(\n (operationDefinition: OperationDefinition) => operationDefinition.module.name,\n operationDefinitions,\n )\n .map((operationDefinitions) => (<const>[\n operationDefinitions[0].module,\n operationDefinitions\n .map((operationDefinition) => artifactMap.get(operationDefinition))\n .filter((artifact): artifact is Artifact => Boolean(artifact)),\n ]))\n .map(async ([moduleDefinition, artifacts]) => await metadata.hooks.afterEntrypointArtifactGenerated.promise(\n this.generateEntrypointArtifact(\n moduleDefinition,\n artifacts,\n rc,\n ),\n task,\n )),\n )\n\n return [...entrypoints, ...artifactMap.values()]\n }\n\n\n private generateOperationDefinitionArtifact(operationDefinition: OperationDefinition, rc: RuntimeConfig): Artifact {\n const filepath = MicroFunctionGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle)\n const dirpath = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: MicroFunctionGenerator.getOperationDefinitionArtifactId(operationDefinition),\n filepath,\n content: OperationDefinitionTransformer.toMicroFunction(operationDefinition, {\n esm: rc.esm,\n getOperationDefinitionDeclarationFilepath(operationDefinition: OperationDefinition): string {\n const relativePath = path.relative(\n dirpath,\n OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle),\n )\n\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n },\n getRequestFilepath(): string {\n const relativePath = path.relative(\n dirpath,\n RequestGenerator.getRequestArtifactFilepath(),\n )\n\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n },\n }),\n extensionName: '.type.ts',\n })\n\n return artifact\n }\n\n private generateEntrypointArtifact(moduleDefinition: ModuleDefinition, exports: Artifact[], rc: RuntimeConfig): Artifact {\n const filepath = MicroFunctionGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle)\n const dirpath = filepath.substring(0, filepath.lastIndexOf('/'))\n\n const artifact = new Artifact({\n id: MicroFunctionGenerator.getEntrypointArtifactId(moduleDefinition),\n filepath,\n content: EntrypointTransformer.toTypescript(exports, { dirpath }),\n })\n\n return artifact\n }\n\n\n static getOperationDefinitionArtifactFilepath(operationDefinition: OperationDefinition, fileNamingStyle: FileNamingStyle): string {\n const filename = `${changeCase[fileNamingStyle](operationDefinition.operationId)}.fn.ts`\n const filepath = [\n '.',\n changeCase[fileNamingStyle](operationDefinition.module.name),\n 'operations',\n filename,\n ].join('/')\n\n return filepath\n }\n\n static getOperationDefinitionArtifactId(operationDefinition: OperationDefinition): string {\n return `${operationDefinition.id}?generator=${MICRO_FUNCTION_GENERATOR}`\n }\n\n static getEntrypointArtifactFilepath(moduleDefinition: ModuleDefinition, fileNamingStyle: FileNamingStyle): string {\n return [\n '.',\n changeCase[fileNamingStyle](moduleDefinition.name),\n 'operations',\n 'index.ts',\n ].join('/')\n }\n\n static getEntrypointArtifactId(moduleDefinition: ModuleDefinition): string {\n return `${moduleDefinition.address}/paths/entrypoint?generator=${MICRO_FUNCTION_GENERATOR}`\n }\n}\n","import { AsyncSeriesWaterfallHook } from 'tapable'\nimport { Plugin } from '~/types/plugin.js'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { Artifact, OperationDefinition, SchemaDefinition } from '~/models/index.js'\nimport { OperationDeclarationGenerator, SchemaDeclarationGenerator } from './generators/index.js'\nimport { GenerateDeclarationPluginMetadata, MetadataStorage } from './constants/index.js'\n\n\nexport const DECLARATION_GENERATOR = 'declarationGenerator'\n\nexport class GenerateDeclarationPlugin implements Plugin {\n name = DECLARATION_GENERATOR\n\n operationGenerator = new OperationDeclarationGenerator()\n schemaGenerator = new SchemaDeclarationGenerator()\n\n constructor() {}\n\n apply(compiler: Compiler): void {\n GenerateDeclarationPlugin.register(compiler)\n\n compiler.hooks.compile.tapPromise(GenerateDeclarationPlugin.name, async (task: TaskWrapper) => {\n compiler.context.artifacts?.push(\n ...await this.schemaGenerator.compile(compiler, task),\n ...await this.operationGenerator.compile(compiler, task),\n )\n })\n }\n\n static register(compiler: Compiler): GenerateDeclarationPluginMetadata {\n if (!MetadataStorage.has(compiler)) {\n MetadataStorage.set(compiler, {\n hooks: {\n afterEntrypointArtifactGenerated: new AsyncSeriesWaterfallHook<[Artifact, TaskWrapper], Artifact>(['artifact', 'task']),\n afterSchemaDeclarationArtifactGenerated: new AsyncSeriesWaterfallHook<[Artifact, SchemaDefinition, TaskWrapper], Artifact>(['artifact', 'schemaDefinition', 'task']),\n afterOperationDeclarationArtifactGenerated: new AsyncSeriesWaterfallHook<[Artifact, OperationDefinition, TaskWrapper], Artifact>(['artifact', 'operationDefinition', 'task']),\n },\n })\n }\n return MetadataStorage.get(compiler)!\n }\n\n static of(compiler: Compiler): GenerateDeclarationPluginMetadata | undefined {\n return this.register(compiler)\n }\n}\n","import * as path from 'path'\nimport * as changeCase from 'change-case'\nimport { Artifact, ModuleDefinition, OperationDefinition } from '~/models/index.js'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { OperationDefinitionTransformer, EntrypointTransformer } from '~/transformers/index.js'\nimport { FileNamingStyle } from '~/constants/index.js'\nimport type { Generator, RuntimeConfig } from '~/types/index.js'\nimport { SchemaDeclarationGenerator } from '../schema-declaration/index.js'\nimport { MetadataStorage } from '../../constants/metadata-storage.js'\n\n\nexport const OPERATION_GENERATOR = 'operationDeclarationGenerator'\n\nexport class OperationDeclarationGenerator implements Generator {\n async compile(compiler: Compiler, task: TaskWrapper): Promise<Artifact[]> {\n const context = compiler.context\n const metadata = MetadataStorage.get(compiler)!\n\n const rc = context.rc!\n // const matcher = context.matcher!\n const documents = context.documents!\n // .filter((document) => !matcher.isModuleIgnored(document.module))\n\n const operationDefinitions = documents.flatMap((document) => document.operations)\n\n const artifactMap = new Map<OperationDefinition, Artifact>(\n await Promise.all(\n operationDefinitions.map(async (operationDefinition) => (<const>[\n operationDefinition,\n await metadata.hooks.afterOperationDeclarationArtifactGenerated.promise(\n this.generateOperationDefinitionArtifact(operationDefinition, rc),\n operationDefinition,\n task,\n ),\n ])),\n ),\n )\n\n return Array.from(artifactMap.values())\n }\n\n\n private generateOperationDefinitionArtifact(operationDefinition: OperationDefinition, rc: RuntimeConfig): Artifact {\n const filepath = OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle)\n const dirpath = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: OperationDeclarationGenerator.getOperationDefinitionArtifactId(operationDefinition),\n filepath,\n content: OperationDefinitionTransformer.toDeclaration(\n operationDefinition,\n {\n esm: rc.esm,\n getDependentSchemaDefinitionFilepath(dependentSchemaDefinition) {\n const relativePath = path.relative(\n dirpath,\n SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(dependentSchemaDefinition, rc.fileNamingStyle),\n )\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n },\n },\n ),\n extensionName: '.type.ts',\n })\n\n return artifact\n }\n\n private generateEntrypointArtifact(moduleDefinition: ModuleDefinition, exports: Artifact[], rc: RuntimeConfig): Artifact {\n const filepath = OperationDeclarationGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle)\n const dirpath = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: OperationDeclarationGenerator.getEntrypointArtifactId(moduleDefinition),\n filepath,\n content: EntrypointTransformer.toTypescript(exports, { dirpath }),\n })\n\n return artifact\n }\n\n\n static getOperationDefinitionArtifactFilepath(operationDefinition: OperationDefinition, fileNamingStyle: FileNamingStyle): string {\n const filename = `${changeCase[fileNamingStyle](operationDefinition.operationId)}.type.ts`\n const filepath = [\n '.',\n changeCase[fileNamingStyle](operationDefinition.module.name),\n 'types',\n 'operations',\n filename,\n ].join('/')\n\n return filepath\n }\n\n static getOperationDefinitionArtifactId(operationDefinition: OperationDefinition): string {\n return `${operationDefinition.id}?generator=${OPERATION_GENERATOR}`\n }\n\n static getEntrypointArtifactFilepath(moduleDefinition: ModuleDefinition, fileNamingStyle: FileNamingStyle): string {\n return [\n '.',\n changeCase[fileNamingStyle](moduleDefinition.name),\n 'types',\n 'operations',\n 'index.ts',\n ].join('/')\n }\n\n static getEntrypointArtifactId(moduleDefinition: ModuleDefinition): string {\n return `${moduleDefinition.address}/paths/entrypoint?generator=${OPERATION_GENERATOR}`\n }\n}\n","import { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { Renderer } from '../types/renderer.js'\n\n\nexport class CommentRenderer implements Renderer {\n constructor(\n private readonly schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject,\n ) {}\n\n render(): string {\n const schema = this.schema\n\n const lines = ['/**']\n\n if (schema.description) {\n const description = schema.description.replace('*/', '*\\\\/')\n lines.push(...description.split('\\n').map((line) => ` * ${line}`))\n }\n\n if (schema.deprecated) {\n lines.push(' * @deprecated')\n }\n\n if (schema.readOnly) {\n lines.push(' * @readonly')\n }\n\n if (schema.format) {\n lines.push(` * @format ${schema.format}`)\n }\n\n lines.push(' */')\n\n if (lines.length === 2) return ''\n return lines.join('\\n')\n }\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\n\nimport * as R from 'ramda'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { MixedSchemaObject } from './types/mixed-schema-object.js'\nimport { JsonSchemaUtils } from '~/utils/json-schema-utils/index.js'\nimport { indent } from '~/utils/indent.js'\nimport { CommentRenderer } from './comment.renderer.js'\nimport { ReferenceTransformer } from './reference.transformer.js'\nimport { Renderer } from '../types/renderer.js'\n\n\nexport interface JsonSchemaDeclarationRendererOptions {\n referenceTransformer?: (schema: OpenAPIV3_1.ReferenceObject) => string\n}\n\nexport class DeclarationRenderer implements Renderer {\n constructor(\n private readonly schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject,\n private readonly options: JsonSchemaDeclarationRendererOptions = {},\n ) {\n }\n\n render(): string {\n return this.renderSchema(this.schema)\n }\n\n private renderSchema(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject): string {\n if (typeof schema === 'boolean') return 'unknown'\n\n if (JsonSchemaUtils.isRef(schema)) return this.renderReference(schema)\n if (JsonSchemaUtils.isMixed(schema)) return this.renderMixed(schema)\n if (JsonSchemaUtils.isArray(schema)) return this.renderArray(schema)\n\n if (schema.type === 'object') return this.renderObject(schema)\n if (schema.enum) return this.renderEnum(schema)\n if (schema.oneOf) return this.renderOneOf(schema)\n if (schema.anyOf) return this.renderAnyOf(schema)\n if (schema.allOf) return this.renderAllOf(schema)\n if (schema.type === 'string') return this.renderString(schema)\n if (schema.type === 'number') return this.renderNumber(schema)\n if (schema.type === 'boolean') return this.renderBoolean(schema)\n if (schema.type === 'null') return this.renderNull(schema)\n if (schema.type === 'integer') return this.renderInteger(schema)\n\n return 'unknown'\n }\n\n\n private renderMixed(schema: MixedSchemaObject): string {\n if (Array.isArray(schema.type)) {\n schema.type\n .map((type): (OpenAPIV3_1.ArraySchemaObject | OpenAPIV3_1.NonArraySchemaObject) => ({ ...schema, type }))\n .map((schema) => this.renderSchema(schema))\n .join(' | ')\n }\n\n return 'unknown'\n }\n\n private renderReference(schema: OpenAPIV3_1.ReferenceObject): string {\n if (!this.options.referenceTransformer) {\n return ReferenceTransformer.toDeclaration(schema)\n }\n\n return this.options.referenceTransformer(schema)\n }\n\n private renderArray(schema: OpenAPIV3_1.ArraySchemaObject): string {\n if (schema.items && Array.isArray(schema.items)) {\n const items = schema.items.map((s) => this.renderSchema(s)).join(', ')\n return `[${items}]`\n }\n\n if (schema.items && typeof schema.items === 'object') {\n return `${this.renderSchema(schema.items)}[]`\n }\n\n return 'any[]'\n }\n\n\n private renderObject(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n if (\n (!schema.properties || R.isEmpty(schema.properties))\n && (!schema.additionalProperties || R.isEmpty(schema.additionalProperties))\n ) {\n return 'object'\n }\n\n\n const $properties = Object.entries(schema.properties || {})\n .map(([propertyName, propertySchema]) => {\n let $comment = new CommentRenderer(propertySchema).render()\n if ($comment) $comment += '\\n'\n\n const $key = `\"${propertyName}\"${schema.required?.includes(propertyName) ? '' : '?'}`\n const $value = this.renderSchema(propertySchema)\n\n return indent(2, `${$comment}${$key}: ${$value}`)\n })\n\n if (schema.additionalProperties) {\n const $value = schema.additionalProperties === true\n ? 'any'\n : this.renderSchema(schema.additionalProperties)\n $properties.push(indent(2, `[key: string]: ${$value}`))\n }\n\n return [\n '{',\n ...$properties,\n '}',\n ].join('\\n')\n }\n\n private renderOneOf(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n if (!schema.oneOf) return 'unknown'\n\n return schema.oneOf.map((s) => this.renderSchema(s)).join(' | ')\n }\n\n private renderAnyOf(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n if (!schema.anyOf) return 'unknown'\n\n return schema.anyOf.map((s) => this.renderSchema(s)).join(' | ')\n }\n\n private renderAllOf(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n if (!schema.allOf) return 'unknown'\n\n return schema.allOf.map((s) => this.renderSchema(s)).join(' & ')\n }\n\n private renderEnum(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n if (!schema.enum) return 'unknown'\n return schema.enum.map((v) => JSON.stringify(v)).join(' | ')\n }\n\n private renderString(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n if (schema.contentMediaType === 'application/octet-stream') return 'Blob | Buffer'\n if (schema.format === 'binary') return 'Blob | Buffer'\n return 'string'\n }\n\n private renderNumber(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n return 'number'\n }\n\n private renderBoolean(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n return 'boolean'\n }\n\n private renderNull(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n return 'null'\n }\n\n private renderInteger(schema: OpenAPIV3_1.NonArraySchemaObject): string {\n return 'number'\n }\n}\n","export function indent(space: number, text: string): string {\n if (text === '') return ''\n\n const indentation = ' '.repeat(space)\n return text.split('\\n')\n .map((line) => (line ? `${indentation}${line}` : line))\n .join('\\n')\n}\n","import * as R from 'ramda'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\n\n\nexport class ReferenceTransformer {\n static toDeclaration(schema: OpenAPIV3_1.ReferenceObject, alias: (name: string) => string = R.identity): string {\n if (!schema.$ref || !schema.$ref.startsWith('#')) return `unknown /* ${schema.$ref.replace('*/', '*\\\\/')} */`\n\n const parts: string[] = schema.$ref.split('/')\n // return parts[parts.length - 1] || 'unknown'\n\n return alias(parts[parts.length - 1]) || 'unknown'\n }\n}\n","import { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { CommentRenderer } from './comment.renderer.js'\nimport { DeclarationRenderer, JsonSchemaDeclarationRendererOptions } from './declaration.renderer.js'\n\n\nexport class JsonSchemaTransformer {\n static toComment(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject): string {\n return new CommentRenderer(schema).render()\n }\n\n static toDeclaration(schema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject, options?: JsonSchemaDeclarationRendererOptions): string {\n return new DeclarationRenderer(schema, options).render()\n }\n}\n","import * as R from 'ramda'\nimport { SchemaDefinition } from '~/models/index.js'\nimport { JsonSchemaUtils } from '~/utils/json-schema-utils/index.js'\nimport { JsonSchemaTransformer } from '../json-schema/index.js'\n\n\ninterface SchemaDefinitionDeclarationRendererOptions {\n esm?: boolean\n\n getDependentSchemaDefinitionFilepath: (schemaDefinition: SchemaDefinition) => string\n}\n\nexport class SchemaDefinitionTransformer {\n static toDeclaration(schemaDefinition: SchemaDefinition, options: SchemaDefinitionDeclarationRendererOptions): string {\n const dependencies = schemaDefinition.getDependencies()\n let $dependencies = dependencies\n .filter((dep) => !SchemaDefinition.isUnknown(dep))\n .map((dep) => {\n const filepath = options.getDependentSchemaDefinitionFilepath(dep)\n return `import type { ${dep.name} } from \"${filepath}\"`\n })\n .map((str) => str.replace(/ from \"(\\.\\.?\\/.+?)(\\.ts|\\.mts|\\.cts|\\.js|\\.cjs|\\.mjs)?\"/, options.esm ? ' from \"$1.js\"' : ' from \"$1\"'))\n .join('\\n')\n\n if ($dependencies) $dependencies += '\\n'\n\n let $comment = JsonSchemaTransformer.toComment(schemaDefinition.schema)\n if ($comment) $comment += '\\n'\n\n if (typeof schemaDefinition.schema === 'boolean') {\n return [\n '/* @anchor:file:start */',\n '',\n $dependencies,\n $comment || undefined,\n `type ${schemaDefinition.name} = unknown`,\n '',\n '/* @anchor:file:end */',\n ].filter(R.isNotNil).join('\\n')\n }\n\n if (JsonSchemaUtils.isNonArray(schemaDefinition.schema) && schemaDefinition.schema.type === 'object') {\n const $schema = JsonSchemaTransformer.toDeclaration(schemaDefinition.schema)\n\n const $declaration = $schema.startsWith('{')\n ? `export interface ${schemaDefinition.name} ${$schema}`\n : `export type ${schemaDefinition.name} = ${$schema}`\n\n return [\n '/* @anchor:file:start */',\n '',\n $dependencies,\n $comment || undefined,\n $declaration,\n '',\n '/* @anchor:file:end */',\n ].filter(R.isNotNil).join('\\n')\n }\n\n return [\n '/* @anchor:file:start */',\n '',\n $dependencies,\n $comment || undefined,\n `export type ${schemaDefinition.name} = ${JsonSchemaTransformer.toDeclaration(schemaDefinition.schema)}`,\n '',\n '/* @anchor:file:end */',\n ].filter(R.isNotNil).join('\\n')\n }\n}\n","import * as R from 'ramda'\nimport { OperationDefinition } from '~/models/index.js'\nimport { Renderer } from '../types/renderer.js'\n\n\nexport class CommentRenderer implements Renderer {\n constructor(\n private readonly operationDefinition: OperationDefinition,\n ) {}\n\n render(): string {\n const operation = this.operationDefinition.operation\n if (!operation.summary && !operation.description) return ''\n\n const lines = ['/**']\n\n if (operation.summary && typeof operation.summary === 'string') {\n lines.push(` * ${R.trim(operation.summary)}`)\n lines.push(' *')\n }\n\n if (operation.description && typeof operation.description === 'string') {\n lines.push(` * @description ${R.trim(operation.description)}`)\n }\n\n lines.push(' */')\n\n return lines.join('\\n')\n }\n}\n","import * as R from 'ramda'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { OperationDefinition, SchemaDefinition } from '~/models/index.js'\nimport { typeNameFactory, TypeNameFn } from './utils/index.js'\nimport { JsonSchemaUtils } from '~/utils/json-schema-utils/index.js'\nimport { indent } from '~/utils/indent.js'\nimport { OpenapiUtils } from '~/utils/openapi-utils/index.js'\nimport { JsonSchemaTransformer, JsonSchemaDeclarationRendererOptions, ReferenceTransformer } from '../json-schema/index.js'\nimport { Renderer } from '../types/renderer.js'\n\n\nexport interface OperationDefinitionDeclarationRendererOptions {\n esm?: boolean\n\n getDependentSchemaDefinitionFilepath(dependentSchemaDefinition: SchemaDefinition): string\n}\n\nconst alias = (name: string): string => `${name}Schema`\n\nexport class DeclarationRenderer implements Renderer {\n private typeName: TypeNameFn\n\n constructor(\n private readonly operationDefinition: OperationDefinition,\n private readonly options: OperationDefinitionDeclarationRendererOptions,\n ) {\n this.typeName = typeNameFactory(operationDefinition)\n }\n\n private renderResponseBodies(operation: OpenAPIV3_1.OperationObject, options: JsonSchemaDeclarationRendererOptions): string {\n if (!operation.responses || R.isEmpty(operation.responses)) {\n return `export interface ${this.typeName('ResponseBodies')} {}`\n }\n\n const $responses = Object.entries(operation.responses)\n .map(([statusCode, response]) => {\n if (!JsonSchemaUtils.isRef(response)) {\n const $value = Object.entries(response.content || {})\n .map(([mediaType, mediaTypeObject]) => <const>[mediaType, mediaTypeObject.schema])\n .map(([mediaType, schema]) => {\n if (mediaType.includes('text/event-stream')) return 'ReadableStream<ServerSentEvent>'\n if (mediaType.includes('multipart/form-data')) return 'FormData'\n if (!schema) return 'unknown'\n\n return JsonSchemaTransformer.toDeclaration(schema, options)\n })\n .join(' | ')\n\n return indent(2, `${statusCode}: ${$value || 'void'}`)\n }\n })\n .join('\\n')\n\n return [\n `export interface ${this.typeName('ResponseBodies')} {`,\n $responses,\n '}',\n ].join('\\n')\n }\n\n private renderRequestBodies(operation: OpenAPIV3_1.OperationObject, options: JsonSchemaDeclarationRendererOptions): string {\n let $requestBodies = `export interface ${this.typeName('RequestBodies')} {}`\n\n if (operation.requestBody && !JsonSchemaUtils.isRef(operation.requestBody)) {\n const $mediaTypes = Object.entries(operation.requestBody.content || {})\n .map(([mediaType, mediaTypeObject]) => <const>[mediaType, mediaTypeObject.schema])\n .map(([mediaType, schema]) => {\n if (!schema) return `${JSON.stringify(mediaType)}: unknown`\n\n // if (mediaType === 'multipart/form-data') {\n // return `${JSON.stringify(mediaType)}: FormData | ${generateSchema(schema, alias)}`\n // } else if (mediaType === 'application/x-www-form-urlencoded') {\n // return `${JSON.stringify(mediaType)}: URLSearchParams | ${generateSchema(schema, alias)}`\n // }\n\n return `${JSON.stringify(mediaType)}: ${JsonSchemaTransformer.toDeclaration(schema, options)}`\n })\n .map((pair) => indent(2, pair))\n\n $requestBodies = [\n `export interface ${this.typeName('RequestBodies')} {`,\n ...$mediaTypes,\n '}',\n ].join('\\n')\n }\n\n return $requestBodies\n }\n\n private renderParameterBodies(operationDefinition: OperationDefinition, options: JsonSchemaDeclarationRendererOptions): string {\n const { operation } = operationDefinition\n let parameterBodies = ''\n // let parameterBodies = `interface ${typeName('ParameterBodies')} {}`\n\n if (operation.requestBody && !JsonSchemaUtils.isRef(operation.requestBody)) {\n const $mediaTypes = Object.entries(operation.requestBody.content || {})\n .map(([mediaType, mediaTypeObject]) => <const>[mediaType, mediaTypeObject.schema])\n // .filter((pair): pair is [string, OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject] => !!pair[1])\n .map(([mediaType, schemaOrRef]) => {\n if (!schemaOrRef) return `${JSON.stringify(mediaType)}: unknown`\n\n const schema = JsonSchemaUtils.isRef(schemaOrRef)\n ? OpenapiUtils.dereferenceDeep<OpenAPIV3_1.SchemaObject>(schemaOrRef.$ref, operationDefinition.document.specification)\n : schemaOrRef\n\n if (schema.type === 'object' || schema.properties) {\n return `${JSON.stringify(mediaType)}: ${JsonSchemaTransformer.toDeclaration(schemaOrRef, options)} & { [key: string]: any }`\n }\n\n return `${JSON.stringify(mediaType)}: { [key: string]: any }`\n })\n .map((pair) => indent(2, pair))\n\n // $requestBodies = `export type ${typeName('RequestBody')} = ${$value || 'unknown'}`\n parameterBodies = [\n `interface ${this.typeName('ParameterBodies')} {`,\n ...$mediaTypes,\n '}',\n '',\n ].join('\\n')\n }\n\n return parameterBodies\n }\n\n private renderRequestParameters(operation: OpenAPIV3_1.OperationObject, options: JsonSchemaDeclarationRendererOptions): string {\n const mediaTypes = operation.requestBody && !JsonSchemaUtils.isRef(operation.requestBody)\n ? Object.keys(operation.requestBody.content || {})\n : []\n\n const base = `${this.typeName('RequestQuery')} & ${this.typeName('RouteParameters')} & ${this.typeName('RequestHeaders')}`\n\n if (mediaTypes.length === 1) {\n return `export type ${this.typeName('RequestParameters')} = ${base} & ${this.typeName('RequestBodies')}[${JSON.stringify(mediaTypes[0])}]`\n }\n\n if (mediaTypes.length > 1) {\n const unions = mediaTypes\n .map((mediaType) => `(${base} & ${this.typeName('RequestBodies')}[${JSON.stringify(mediaType)}] & { \"content-type\": ${JSON.stringify(mediaType)} })`)\n .join('\\n| ')\n\n return `export type ${this.typeName('RequestParameters')} = ${unions}`\n }\n\n return `export type ${this.typeName('RequestParameters')} = ${base}`\n }\n\n private rendererParameters(name: string, parameters: OpenAPIV3_1.ParameterObject[], options: JsonSchemaDeclarationRendererOptions): string {\n if (parameters.length === 0) {\n return `export type ${name} = {}`\n }\n\n const $parameters = parameters.map((parameter) => {\n const parameterName = `\"${parameter.name}\"`\n const $key = parameter.required ? parameterName : `${parameterName}?`\n const $value = JsonSchemaTransformer.toDeclaration(parameter.schema || { type: 'any' }, options)\n\n return indent(2, `${$key}: ${$value}`)\n })\n .join('\\n')\n\n\n return [\n `export type ${name} = {`,\n $parameters,\n '}',\n ].filter(Boolean).join('\\n')\n }\n\n private renderDependencies(): string {\n const schemaDefinitions = this.operationDefinition.getDependencies()\n .filter((schemaDefinition) => !SchemaDefinition.isUnknown(schemaDefinition))\n\n const $schemaDefinitions = schemaDefinitions\n .map((schemaDefinition) => {\n const filepath = this.options.getDependentSchemaDefinitionFilepath(schemaDefinition)\n const schemaName = schemaDefinition.name\n\n return `import type { ${schemaName} as ${alias(schemaName)} } from \"${filepath}\"`\n })\n .map((str) => (str.replace(/ from \"(\\.\\.?\\/.+?)(\\.ts|\\.mts|\\.cts|\\.js|\\.cjs|\\.mjs)?\"/, this.options.esm ? ' from \"$1.js\"' : ' from \"$1\"')))\n\n return [\n 'import type { KeqOperation, KeqPathParameterInit, KeqQueryInit, ServerSentEvent } from \"keq\"',\n ...$schemaDefinitions,\n ].join('\\n')\n }\n\n render(): string {\n const { operation } = this.operationDefinition\n\n if (!operation.responses) return ''\n\n const jsonSchemaDeclarationRendererOptions: JsonSchemaDeclarationRendererOptions = {\n referenceTransformer: (schema: OpenAPIV3_1.ReferenceObject) => {\n return ReferenceTransformer.toDeclaration(schema, alias)\n },\n }\n\n const $dependencies = this.renderDependencies()\n\n const $responseBodies = this.renderResponseBodies(operation, jsonSchemaDeclarationRendererOptions)\n const $requestBodies = this.renderRequestBodies(operation, jsonSchemaDeclarationRendererOptions)\n const $parameterBodies = this.renderParameterBodies(this.operationDefinition, jsonSchemaDeclarationRendererOptions)\n const $requestParameters = this.renderRequestParameters(operation, jsonSchemaDeclarationRendererOptions)\n const $requestQuery = this.rendererParameters(\n `${this.typeName('RequestQuery')}`,\n operation.parameters?.filter((p) => !JsonSchemaUtils.isRef(p) && p.in === 'query') || [],\n jsonSchemaDeclarationRendererOptions,\n )\n const $routeParameters = this.rendererParameters(\n `${this.typeName('RouteParameters')}`,\n operation.parameters?.filter((p) => !JsonSchemaUtils.isRef(p) && p.in === 'path') || [],\n jsonSchemaDeclarationRendererOptions,\n )\n const $requestHeaders = this.rendererParameters(\n `${this.typeName('RequestHeaders')}`,\n operation.parameters?.filter((p) => !JsonSchemaUtils.isRef(p) && p.in === 'header') || [],\n jsonSchemaDeclarationRendererOptions,\n )\n\n return [\n '/* @anchor:file:start */',\n '',\n $dependencies,\n '',\n $responseBodies,\n '',\n $requestBodies,\n '',\n $requestQuery,\n '',\n $routeParameters,\n '',\n $requestHeaders,\n '',\n $parameterBodies || undefined,\n $requestParameters,\n '',\n `export interface ${this.typeName('Operation')}<STATUS extends keyof ${this.typeName('ResponseBodies')}, CONTENT_TYPE extends ${$parameterBodies ? `keyof ${this.typeName('ParameterBodies')}` : 'string'} > extends KeqOperation {`,\n ` requestParams: ${this.typeName('RouteParameters')} & { [key: string]: KeqPathParameterInit }`,\n ` requestQuery: ${this.typeName('RequestQuery')} & { [key: string]: KeqQueryInit }`,\n ` requestHeaders: ${this.typeName('RequestHeaders')} & { [key: string]: string | number }`,\n ` requestBody: ${$parameterBodies ? `${this.typeName('ParameterBodies')}[CONTENT_TYPE] | ` : 'object | '}BodyInit`,\n ` responseBody: ${this.typeName('ResponseBodies')}[STATUS]`,\n '}',\n '',\n '/* @anchor:file:end */',\n ].filter(R.isNotNil).join('\\n')\n }\n}\n","import * as changeCase from 'change-case'\nimport { OperationDefinition } from '~/models/index.js'\n\nexport type TypeNameFn = (name: string) => string\n\nexport function typeNameFactory(operationDefinition: OperationDefinition): TypeNameFn {\n const pascalCaseOperationId = changeCase.pascalCase(operationDefinition.operationId)\n return (name: string) => `${pascalCaseOperationId}${name}`\n}\n","import * as R from 'ramda'\nimport { OperationDefinition } from '~/models/index.js'\nimport { Renderer } from '../types/renderer.js'\nimport { typeNameFactory, TypeNameFn } from './utils/index.js'\nimport { indent } from '~/utils/indent.js'\nimport { Exception } from '~/exception.js'\nimport { CommentRenderer } from './comment.renderer.js'\nimport { OperationDefinitionSnippet, OperationDefinitionSnippetOptions } from './typescript-snippet.js'\n\n\nexport interface OperationDefinitionMicroFunctionRendererOptions extends OperationDefinitionSnippetOptions {\n getOperationDefinitionDeclarationFilepath(operationDefinition: OperationDefinition): string\n getRequestFilepath(): string\n}\n\nexport class OperationDefinitionMicroFunctionRenderer implements Renderer {\n helper: OperationDefinitionSnippet\n typeName: TypeNameFn\n\n constructor(\n private readonly operationDefinition: OperationDefinition,\n private readonly options: OperationDefinitionMicroFunctionRendererOptions,\n ) {\n this.typeName = typeNameFactory(operationDefinition)\n this.helper = new OperationDefinitionSnippet(operationDefinition, options)\n }\n\n render(): string {\n const { operation, operationId, method, pathname } = this.operationDefinition\n if (!operation.responses) return ''\n\n const $dependencies = this.renderDependencies()\n const $comment = new CommentRenderer(this.operationDefinition).render()\n\n const moduleName = this.operationDefinition.module.name\n\n const $method = method.toLowerCase()\n const $queryParameters = this.helper.renderRequestQuery()\n const $headerParameters = this.helper.renderRequestHeaders()\n const $pathParameters = this.helper.renderRequestPathParameters()\n\n const $mediaType = this.helper.renderMediaType()\n\n const $requestBody = this.helper.renderRequestBody()\n\n const $operationDeclaration = this.renderOperationDeclaration()\n\n return [\n '/* @anchor:file:start */',\n '',\n $dependencies,\n '',\n `const moduleName = \"${moduleName}\"`,\n `const method = \"${method}\"`,\n `const pathname = \"${pathname}\"`,\n '',\n $comment || undefined,\n `export ${$operationDeclaration} {`,\n ` const req = request.${$method}<${this.typeName('ResponseBodies')}[STATUS]>(\"${pathname}\")`,\n ' .option(\\'module\\', { name: moduleName, pathname, method })',\n '',\n $mediaType || undefined,\n ' /* @anchor:query:start */',\n $queryParameters ? indent(2, $queryParameters) : undefined,\n ' /* @anchor:query:end */',\n '',\n ' /* @anchor:headers:start */',\n $headerParameters ? indent(2, $headerParameters) : undefined,\n ' /* @anchor:headers:end */',\n '',\n ' /* @anchor:path-parameters:start */',\n $pathParameters ? indent(2, $pathParameters) : undefined,\n ' /* @anchor:path-parameters:end */',\n '',\n ' /* @anchor:body:start */',\n $requestBody ? indent(2, $requestBody) : undefined,\n ' /* @anchor:body:end */',\n '',\n ' /* @anchor:operation-return */',\n ` return req as ReturnType<typeof ${operationId}<STATUS${$operationDeclaration.includes('CONTENT_TYPE') ? ', CONTENT_TYPE' : ''}>>`,\n '}',\n '',\n `${operationId}.pathname = pathname`,\n `${operationId}.method = method`,\n '/* @anchor:file:end */',\n ].filter(R.isNotNil).join('\\n')\n }\n\n private renderDependencies(): string {\n const declarationFilepath = this.options.getOperationDefinitionDeclarationFilepath(this.operationDefinition)\n const requestFilepath = this.options.getRequestFilepath()\n\n return [\n 'import { Keq } from \"keq\"',\n `import { request } from \"${requestFilepath}\"`,\n `import type { ${this.typeName('Operation')}, ${this.typeName('ResponseBodies')}, ${this.typeName('RequestParameters')} } from \"${declarationFilepath}\"`,\n `export type { ${this.typeName('RequestQuery')}, ${this.typeName('RequestHeaders')}, ${this.typeName('RequestBodies')} } from \"${declarationFilepath}\"`,\n ]\n .map((str) => (str.replace(/ from \"(\\.\\.?\\/.+?)(\\.ts|\\.mts|\\.cts|\\.js|\\.cjs|\\.mjs)?\"/, this.options.esm ? ' from \"$1.js\"' : ' from \"$1\"')))\n .join('\\n')\n }\n\n private renderOperationDeclaration(): string {\n const { operationId } = this.operationDefinition\n\n const mediaTypes = this.helper.getRequestMediaTypes()\n\n if (mediaTypes.length === 0) {\n return `function ${operationId}<STATUS extends keyof ${this.typeName('ResponseBodies')}, CONTENT_TYPE extends never = never>(args?: ${this.typeName('RequestParameters')}): Keq<${this.typeName('Operation')}<STATUS, CONTENT_TYPE>>`\n } else if (mediaTypes.length === 1) {\n return `function ${operationId}<STATUS extends keyof ${this.typeName('ResponseBodies')}, CONTENT_TYPE extends ${JSON.stringify(mediaTypes[0])} = ${JSON.stringify(mediaTypes[0])}>(args?: ${this.typeName('RequestParameters')}): Keq<${this.typeName('Operation')}<STATUS, CONTENT_TYPE>>`\n } else if (mediaTypes.length > 1) {\n return `function ${operationId}<STATUS extends keyof ${this.typeName('ResponseBodies')}, CONTENT_TYPE extends ${this.typeName('RequestParameters')}[\"content-type\"]>(args?: Extract<${this.typeName('RequestParameters')}, { \"content-type\": CONTENT_TYPE }>): Keq<${this.typeName('Operation')}<STATUS, CONTENT_TYPE>>`\n }\n\n throw new Exception(this.operationDefinition.module, '[operationDeclarationRenderer] Unreachable')\n }\n}\n","import * as R from 'ramda'\nimport { KeqQueryOptions } from 'keq'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { OperationDefinition } from '~/models/index.js'\nimport { JsonSchemaUtils } from '~/utils/json-schema-utils/index.js'\nimport { OpenapiUtils } from '~/utils/openapi-utils/index.js'\nimport { QsArrayFormat } from '~/constants/index.js'\nimport { typeNameFactory, TypeNameFn } from './utils/index.js'\n\n\nexport interface OperationDefinitionSnippetOptions {\n esm?: boolean\n}\n\nexport class OperationDefinitionSnippet {\n typeName: TypeNameFn\n\n constructor(\n private readonly operationDefinition: OperationDefinition,\n private readonly options: OperationDefinitionSnippetOptions,\n ) {\n this.typeName = typeNameFactory(operationDefinition)\n }\n\n\n private getQsParameters(parameter: OpenAPIV3_1.ParameterObject): KeqQueryOptions | undefined {\n let arrayFormat: QsArrayFormat | undefined\n let allowDots: boolean | undefined\n let indices: boolean | undefined\n\n const style = parameter.style || 'form'\n const explode = parameter.explode ?? true\n\n if ('x-qs-array-format' in parameter) {\n arrayFormat = parameter['x-qs-array-format'] as QsArrayFormat\n } else {\n if (style === 'deepObject') {\n arrayFormat = QsArrayFormat.brackets\n } else if (explode) {\n arrayFormat = QsArrayFormat.repeat\n } else {\n if (style === 'form') {\n arrayFormat = QsArrayFormat.comma\n } else if (style === 'spaceDelimited') {\n arrayFormat = QsArrayFormat.space\n } else if (style === 'pipeDelimited') {\n arrayFormat = QsArrayFormat.pipe\n }\n }\n }\n\n if ('x-qs-allow-dots' in parameter) {\n allowDots = Boolean(parameter['x-qs-allow-dots'])\n }\n\n if ('x-qs-indices' in parameter) {\n indices = Boolean(parameter['x-qs-indices'])\n }\n\n\n if (arrayFormat || allowDots !== undefined || indices !== undefined) {\n return {\n ...(arrayFormat ? { arrayFormat } : {}),\n ...(allowDots !== undefined ? { allowDots } : {}),\n ...(indices !== undefined ? { indices } : {}),\n }\n }\n\n return undefined\n }\n\n\n // render: \"if (args && 'Authorization' in args) req.header('Authorization', args['Authorization'])\"\n renderRequestHeaders(): string {\n const { operation } = this.operationDefinition\n\n const $headers = (operation.parameters || [])\n .filter((p): p is OpenAPIV3_1.ParameterObject => !JsonSchemaUtils.isRef(p))\n .filter((p) => p.in === 'header')\n .map((p) => `if (args && ${JSON.stringify(p.name)} in args) req.header(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}])`)\n .join('\\n')\n\n return $headers\n }\n\n // render: \"if (args && 'id' in args) req.query('id', args['id'], options)\"\n renderRequestQuery(): string {\n const { operation } = this.operationDefinition\n\n const $query = (operation.parameters || [])\n .filter((p): p is OpenAPIV3_1.ParameterObject => !JsonSchemaUtils.isRef(p))\n .filter((p) => p.in === 'query')\n .map((p) => {\n const option = this.getQsParameters(p)\n const $option = (!option || R.isEmpty(option)) ? '' : `, ${JSON.stringify(option)}`\n\n return `if (args && ${JSON.stringify(p.name)} in args) req.query(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}]${$option})`\n })\n .join('\\n')\n\n return $query\n }\n\n // render: \"if (args && 'id' in args) req.params('id', args['id'])\"\n renderRequestPathParameters(): string {\n const { operation } = this.operationDefinition\n\n const $pathParameters = (operation.parameters || [])\n .filter((p): p is OpenAPIV3_1.ParameterObject => !JsonSchemaUtils.isRef(p))\n .filter((p) => p.in === 'path')\n .map((p) => `if (args && ${JSON.stringify(p.name)} in args) req.params(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}])`)\n .join('\\n')\n\n return $pathParameters\n }\n\n getRequestMediaTypes(): string[] {\n const { operation } = this.operationDefinition\n const requestBodyContent = (operation.requestBody?.content || {}) as Record<string, OpenAPIV3_1.MediaTypeObject>\n return Object.keys(requestBodyContent)\n }\n\n // render \"req.type(\"application/json\")\"\n renderMediaType(): string {\n const mediaTypes = this.getRequestMediaTypes()\n\n if (mediaTypes.length === 1 && !mediaTypes[0].endsWith('/*')) {\n return `req.type(\"${mediaTypes[0]}\")\\n`\n } else if (mediaTypes.some((mediaType) => mediaType === '*/*')) {\n // no-op\n } else if (mediaTypes.some((mediaType) => mediaType.endsWith('/*'))) {\n return 'if(args?.[\"content-type\"]) req.type(args[\"content-type\"])\\n'\n } else if (mediaTypes.length > 1) {\n return 'if(args?.[\"content-type\"]) req.type(args[\"content-type\"])\\n'\n }\n\n return ''\n }\n\n\n // render body\n\n private requestBodyFormDataPropertyRenderer(\n propertyName: string,\n propertySchema: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject,\n mediaType: string,\n ): string {\n try {\n const $propertyName = JSON.stringify(propertyName)\n\n const schema = JsonSchemaUtils.isRef(propertySchema)\n ? OpenapiUtils.dereferenceDeep<OpenAPIV3_1.SchemaObject>(propertySchema.$ref, this.operationDefinition.document.specification)\n : propertySchema\n\n if (\n (schema.type === 'string' && schema.format === 'binary')\n || schema.contentMediaType === 'application/octet-stream') {\n return `if (args && ${$propertyName} in args && args[${$propertyName}]) req.attach(${$propertyName}, args[${$propertyName}])`\n } else if (\n schema.type === 'string'\n || (schema.type === 'array' && schema.items && schema.items.type === 'string')\n ) {\n return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, args[${$propertyName}])`\n } else if (schema.type === 'number' || schema.type === 'integer') {\n return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, String(args[${$propertyName}]))`\n }\n\n return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, String(args[${$propertyName}]) /* type is non-string in schema; triggers type coercion here */)`\n } catch (err) {\n return this.renderErrorComment(err, mediaType)\n }\n }\n\n private requestBodyPropertyRenderer(\n propertyName: string,\n propertySchema: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject,\n mediaType: string,\n ): string {\n if (mediaType === 'application/json') {\n const $propertyName = JSON.stringify(propertyName)\n return `if (args && ${$propertyName} in args) req.send({ ${$propertyName}: args[${$propertyName}] })`\n } else if (mediaType === 'multipart/form-data') {\n return this.requestBodyFormDataPropertyRenderer(propertyName, propertySchema, mediaType)\n } else {\n throw new Error(`Unsupported media type: ${mediaType}`)\n }\n }\n\n renderRequestBody(): string {\n const { operation } = this.operationDefinition\n const requestBodyContent = (operation.requestBody?.content || {}) as Record<string, OpenAPIV3_1.MediaTypeObject>\n\n const $requestBody = Object.entries(requestBodyContent)\n .map(([mediaType, mediaTypeObject]): string | undefined => {\n if (!mediaTypeObject.schema) return\n\n try {\n const schema = JsonSchemaUtils.isRef(mediaTypeObject.schema)\n ? OpenapiUtils.dereferenceDeep<OpenAPIV3_1.SchemaObject>(mediaTypeObject.schema.$ref, this.operationDefinition.document.specification)\n : mediaTypeObject.schema\n\n if (schema.type !== 'object') return\n\n const properties = (schema.properties || {}) as OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject\n\n return Object.entries(properties)\n .map(([propertyName, propertySchema]) => this.requestBodyPropertyRenderer(propertyName, propertySchema, mediaType))\n .join('\\n')\n } catch (err) {\n return this.renderErrorComment(err, mediaType)\n }\n })\n .filter(R.isNotNil)\n .join('\\n')\n\n return $requestBody\n }\n\n private renderErrorComment(err: unknown, mediaType: string): string {\n const $err = String(err)\n .split('\\n')\n .map(((line) => ` * ${line}`))\n .join('\\n')\n\n return [\n '/**',\n ` * Unable to dereference schema for media type ${mediaType}`,\n $err,\n ' */',\n ].join('\\n')\n }\n}\n","export enum QsArrayFormat {\n brackets = 'brackets',\n indices = 'indices',\n repeat = 'repeat',\n comma = 'comma',\n space = 'space',\n pipe = 'pipe',\n}\n","import * as R from 'ramda'\nimport { TypeNameFn, typeNameFactory } from './utils/index.js'\nimport { OperationDefinition } from '~/models/index.js'\nimport { OperationDefinitionSnippet, OperationDefinitionSnippetOptions } from './typescript-snippet.js'\nimport { CommentRenderer } from './comment.renderer.js'\nimport { indent } from '~/utils/indent.js'\nimport { Renderer } from '../types/renderer.js'\nimport { Exception } from '~/exception.js'\n\n\nexport type OperationDefinitionNestjsMethodRendererOptions = OperationDefinitionSnippetOptions\n\nexport class OperationDefinitionNestjsMethodRenderer implements Renderer {\n helper: OperationDefinitionSnippet\n typeName: TypeNameFn\n\n constructor(\n private readonly operationDefinition: OperationDefinition,\n private readonly options: OperationDefinitionNestjsMethodRendererOptions,\n ) {\n this.typeName = typeNameFactory(operationDefinition)\n this.helper = new OperationDefinitionSnippet(operationDefinition, options)\n }\n\n\n render(): string {\n // const operationId = changeCase.camelCase(this.operationDefinition.operationId)\n const pathname = this.operationDefinition.pathname\n\n const $comment = new CommentRenderer(this.operationDefinition).render()\n const $method = this.operationDefinition.method.toLowerCase()\n const $mediaType = this.helper.renderMediaType()\n const $operationDeclaration = this.renderOperationDeclaration(this.operationDefinition)\n const $queryParameters = this.helper.renderRequestQuery()\n const $headerParameters = this.helper.renderRequestHeaders()\n const $pathParameters = this.helper.renderRequestPathParameters()\n const $requestBody = this.helper.renderRequestBody()\n\n return [\n $comment,\n `${$operationDeclaration} {`,\n ` const req = this.request.${$method}<${this.typeName('ResponseBodies')}[STATUS]>(${JSON.stringify(pathname)})`,\n ' .option(',\n ' \"module\",',\n ' {',\n ` name: ${JSON.stringify(this.operationDefinition.module.name)},`,\n ` pathname: ${JSON.stringify(pathname)},`,\n ` method: ${JSON.stringify($method)},`,\n ' },',\n ' )',\n '',\n $mediaType ? indent(2, $mediaType) : undefined,\n '',\n ' /* @anchor:query:start */',\n $queryParameters ? indent(2, $queryParameters) : undefined,\n ' /* @anchor:query:end */',\n '',\n ' /* @anchor:headers:start */',\n $headerParameters ? indent(2, $headerParameters) : undefined,\n ' /* @anchor:headers:end */',\n '',\n ' /* @anchor:path-parameters:start */',\n $pathParameters ? indent(2, $pathParameters) : undefined,\n ' /* @anchor:path-parameters:end */',\n '',\n ' /* @anchor:body:start */',\n $requestBody ? indent(2, $requestBody) : undefined,\n ' /* @anchor:body:end */',\n '',\n ' return req',\n '}',\n ].filter(R.isNotNil).join('\\n')\n }\n\n private renderOperationDeclaration(operationDefinition: OperationDefinition): string {\n const { operationId } = operationDefinition\n const typeName = typeNameFactory(operationDefinition)\n\n const mediaTypes = this.helper.getRequestMediaTypes()\n\n if (mediaTypes.length === 0) {\n return `${operationId}<STATUS extends keyof ${typeName('ResponseBodies')}, CONTENT_TYPE extends never = never>(args?: ${typeName('RequestParameters')}): Keq<${typeName('Operation')}<STATUS, CONTENT_TYPE>>`\n } else if (mediaTypes.length === 1) {\n return `${operationId}<STATUS extends keyof ${typeName('ResponseBodies')}, CONTENT_TYPE extends ${JSON.stringify(mediaTypes[0])} = ${JSON.stringify(mediaTypes[0])}>(args?: ${typeName('RequestParameters')}): Keq<${typeName('Operation')}<STATUS, CONTENT_TYPE>>`\n } else if (mediaTypes.length > 1) {\n return `${operationId}<STATUS extends keyof ${typeName('ResponseBodies')}, CONTENT_TYPE extends ${typeName('RequestParameters')}[\"content-type\"]>(args?: Extract<${typeName('RequestParameters')}, { \"content-type\": CONTENT_TYPE }>): Keq<${typeName('Operation')}<STATUS, CONTENT_TYPE>>`\n }\n\n throw new Exception(operationDefinition.module, '[operationDeclarationRenderer] Unreachable')\n }\n}\n","import * as R from 'ramda'\nimport { OperationDefinition } from '~/models/index.js'\nimport { CommentRenderer } from './comment.renderer.js'\nimport { DeclarationRenderer, OperationDefinitionDeclarationRendererOptions } from './declaration.renderer.js'\nimport { OperationDefinitionMicroFunctionRendererOptions, OperationDefinitionMicroFunctionRenderer } from './micro-function.renderer.js'\nimport { OperationDefinitionNestjsMethodRenderer, OperationDefinitionNestjsMethodRendererOptions } from './nestjs-method.renderer.js'\n\n\nexport class OperationDefinitionTransformer {\n static toDeclaration(operationDefinition: OperationDefinition, options: OperationDefinitionDeclarationRendererOptions): string {\n return new DeclarationRenderer(operationDefinition, options).render()\n }\n\n static toMicroFunction(operationDefinition: OperationDefinition, options: OperationDefinitionMicroFunctionRendererOptions): string {\n return new OperationDefinitionMicroFunctionRenderer(operationDefinition, options).render()\n }\n\n static toNestjsMethod(operationDefinition: OperationDefinition, options: OperationDefinitionNestjsMethodRendererOptions): string {\n return new OperationDefinitionNestjsMethodRenderer(operationDefinition, options).render()\n }\n\n static toComment(operationDefinition: OperationDefinition): string {\n return new CommentRenderer(operationDefinition).render()\n }\n}\n","import * as path from 'path'\nimport { Artifact } from '~/models/index.js'\n\n\ninterface EntrypointTypescriptRendererOptions {\n esm?: boolean\n\n // The directory path of the entrypoint file being generated\n dirpath: string\n}\n\nexport class EntrypointTransformer {\n static toTypescript(exports: Artifact[], options: EntrypointTypescriptRendererOptions): string {\n const $exports = exports.map((exportArtifact) => {\n const relativePath = path.relative(\n options.dirpath,\n exportArtifact.filepath,\n )\n .replace(/(\\.ts|\\.mts|\\.cts|\\.js|\\.cjs|\\.mjs)?$/, options.esm ? '.js' : '')\n\n return relativePath.startsWith('.')\n ? `export * from '${relativePath}'`\n : `export * from './${relativePath}'`\n })\n\n return [\n '/* @anchor:file:start */',\n '',\n ...$exports,\n '',\n '/* @anchor:file:end */',\n ].join('\\n')\n }\n}\n","import * as R from 'ramda'\nimport * as changeCase from 'change-case'\nimport { ApiDocumentV3_1, OperationDefinition } from '~/models/index.js'\nimport { Renderer } from '../types/renderer.js'\nimport { OperationDefinitionTransformer, typeNameFactory } from '../operation-definition/index.js'\nimport { indent } from '~/utils/indent.js'\n\n\nexport interface ApiDocumentNestjsClientRendererOptions {\n esm?: boolean\n\n getOperationDefinitionDeclarationFilepath(this: void, operationDefinition: OperationDefinition): string\n}\n\n\nexport class NestjsClientRenderer implements Renderer {\n constructor(\n private readonly document: ApiDocumentV3_1,\n private readonly options: ApiDocumentNestjsClientRendererOptions,\n ) {\n\n }\n\n private renderDependencies(): string {\n const $operations = this.document.operations\n .map((operationDefinition) => {\n const filepath = this.options.getOperationDefinitionDeclarationFilepath(operationDefinition)\n const typeName = typeNameFactory(operationDefinition)\n\n return `import type { ${typeName('Operation')}, ${typeName('ResponseBodies')}, ${typeName('RequestParameters')} } from \"${filepath}\"`\n })\n .map((str) => (str.replace(/ from \"(\\.\\.?\\/.+?)(\\.ts|\\.mts|\\.cts|\\.js|\\.cjs|\\.mjs)?\"/, this.options.esm ? ' from \"$1.js\"' : ' from \"$1\"')))\n\n return [\n 'import { Injectable, Logger } from \"@nestjs/common\"',\n 'import { Keq, KeqRequest } from \"keq\"',\n ...$operations,\n ]\n .join('\\n')\n }\n\n render(): string {\n const moduleName = changeCase.pascalCase(this.document.module.name)\n\n const $dependencies = this.renderDependencies()\n const $operations = this.document.operations\n .map((operation) => OperationDefinitionTransformer.toNestjsMethod(operation, {\n esm: this.options.esm,\n }))\n .join('\\n\\n')\n\n return [\n '/* @anchor:file:start */',\n '',\n $dependencies,\n '',\n '@Injectable()',\n `export class ${moduleName}Client {`,\n ` private readonly logger = new Logger(${moduleName}Client.name)`,\n '',\n ' constructor(',\n ' // @anchor:client-constructor-parameters:start',\n ' private readonly request: KeqRequest,',\n ' // @anchor:client-constructor-parameters:end',\n ' ) {}',\n '',\n indent(2, $operations),\n '}',\n '',\n '/* @anchor:file:end */',\n ].filter(R.isNotNil).join('\\n')\n }\n}\n","import * as changeCase from 'change-case'\nimport { ApiDocumentV3_1 } from '~/models/api-document_v3_1.js'\n\nexport interface ApiDocumentNestjsModuleRendererOptions {\n esm?: boolean\n\n getNestjsClientFilepath(document: ApiDocumentV3_1): string\n}\n\nexport class NestjsModuleRenderer {\n constructor(\n private readonly document: ApiDocumentV3_1,\n private readonly options: ApiDocumentNestjsModuleRendererOptions,\n ) {\n }\n\n render(): string {\n const moduleName = changeCase.pascalCase(this.document.module.name)\n const clientFilepath = this.options.getNestjsClientFilepath(this.document)\n .replace(/(\\.ts|\\.mts|\\.cts|\\.js|\\.cjs|\\.mjs)?$/, this.options.esm ? '.js' : '')\n\n return [\n '/* @anchor:file:start */',\n 'import { Module, Inject, ConfigurableModuleBuilder, Global } from \"@nestjs/common\"',\n 'import { KeqRequest } from \"keq\"',\n 'import { KeqModuleOptions } from \"@keq-request/nestjs\"',\n `import { ${moduleName}Client } from \"${clientFilepath}\"`,\n '',\n '',\n 'const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE, ASYNC_OPTIONS_TYPE } = new ConfigurableModuleBuilder<KeqModuleOptions>().build()',\n '',\n '@Global()',\n '@Module({',\n ' imports: [],',\n ' controllers: [],',\n ` providers: [${moduleName}Client],`,\n ` exports: [${moduleName}Client],`,\n '})',\n `export class ${moduleName}Module extends ConfigurableModuleClass {`,\n '',\n ' constructor(',\n ' @Inject(MODULE_OPTIONS_TOKEN) private readonly options: KeqModuleOptions,',\n ' private readonly request: KeqRequest,',\n ' ) {',\n ' super()',\n ' }',\n '',\n ' onModuleInit() {',\n ' if (this.options.middlewares) {',\n ' for (const middleware of this.options.middlewares) {',\n ' this.request.use(middleware)',\n ' }',\n ' }',\n ' }',\n '}',\n '',\n '/* @anchor:file:end */',\n ].join('\\n')\n }\n}\n","import { ApiDocumentV3_1 } from '~/models/index.js'\nimport { ApiDocumentNestjsClientRendererOptions, NestjsClientRenderer } from './nestjs-client.renderer.js'\nimport { ApiDocumentNestjsModuleRendererOptions, NestjsModuleRenderer } from './nestjs-module.renderer.js'\n\n\nexport class ApiDocumentTransformer {\n static toNestjsModule(document: ApiDocumentV3_1, options: ApiDocumentNestjsModuleRendererOptions): string {\n return new NestjsModuleRenderer(document, options).render()\n }\n\n static toNestjsClient(document: ApiDocumentV3_1, options: ApiDocumentNestjsClientRendererOptions): string {\n return new NestjsClientRenderer(document, options).render()\n }\n}\n","import * as R from 'ramda'\nimport * as path from 'path'\nimport { Artifact, ModuleDefinition, SchemaDefinition } from '~/models/index.js'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { SchemaDefinitionTransformer } from '~/transformers/index.js'\nimport { EntrypointTransformer } from '~/transformers/entrypoint/entrypoint.transformer.js'\nimport { FileNamingStyle } from '~/constants/file-naming-style.js'\nimport * as changeCase from 'change-case'\nimport type { Generator, RuntimeConfig } from '~/types/index.js'\nimport { MetadataStorage } from '../../constants/metadata-storage.js'\n\n\nexport const SCHEMA_GENERATOR = 'schemaGenerator'\n\nexport class SchemaDeclarationGenerator implements Generator {\n async compile(compiler: Compiler, task: TaskWrapper): Promise<Artifact[]> {\n const context = compiler.context\n const metadata = MetadataStorage.get(compiler)!\n\n const rc = context.rc!\n // const matcher = context.matcher!\n const documents = context.documents!\n // .filter((document) => !matcher.isModuleIgnored(document.module))\n\n const schemaDefinitions = documents.flatMap((document) => document.schemas)\n\n const artifactMap = new Map<SchemaDefinition, Artifact>(\n await Promise.all(\n schemaDefinitions.map(async (schemaDefinition) => (<const>[\n schemaDefinition,\n await metadata.hooks.afterSchemaDeclarationArtifactGenerated.promise(\n this.generateSchemaDefinitionsArtifact(schemaDefinition, rc),\n schemaDefinition,\n task,\n ),\n ])),\n ),\n )\n\n\n const entrypoints = R.collectBy(\n (schemaDefinition) => schemaDefinition.module.name,\n schemaDefinitions,\n )\n .map((schemaDefinitions) => <const>[\n schemaDefinitions[0].module,\n schemaDefinitions\n .map((schemaDefinition) => artifactMap.get(schemaDefinition))\n .filter((artifact): artifact is Artifact => Boolean(artifact)),\n ])\n\n .map(([moduleDefinition, artifacts]) => this.generateEntrypointArtifact(\n moduleDefinition,\n artifacts,\n rc,\n ))\n\n return [...artifactMap.values(), ...entrypoints]\n }\n\n private generateSchemaDefinitionsArtifact(schemaDefinition: SchemaDefinition, rc: RuntimeConfig): Artifact {\n const filepath = SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(schemaDefinition, rc.fileNamingStyle)\n const dirpath = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: SchemaDeclarationGenerator.getSchemaDefinitionArtifactId(schemaDefinition),\n filepath,\n content: SchemaDefinitionTransformer.toDeclaration(\n schemaDefinition,\n {\n esm: rc.esm,\n getDependentSchemaDefinitionFilepath(dependentSchemaDefinition: SchemaDefinition): string {\n const relativePath = path.relative(\n dirpath,\n SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(dependentSchemaDefinition, rc.fileNamingStyle),\n )\n\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n },\n },\n ),\n extensionName: '.schema.ts',\n })\n\n return artifact\n }\n\n private generateEntrypointArtifact(moduleDefinition: ModuleDefinition, exports: Artifact[], rc: RuntimeConfig): Artifact {\n const filepath = SchemaDeclarationGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle)\n const dirpath = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: SchemaDeclarationGenerator.getEntrypointArtifactId(moduleDefinition),\n filepath,\n content: EntrypointTransformer.toTypescript(exports, { dirpath }),\n })\n\n return artifact\n }\n\n static getEntrypointArtifactFilepath(moduleDefinition: ModuleDefinition, fileNamingStyle: FileNamingStyle): string {\n return [\n '.',\n changeCase[fileNamingStyle](moduleDefinition.name),\n 'types',\n 'components',\n 'schemas',\n 'index.ts',\n ].join('/')\n }\n\n static getEntrypointArtifactId(moduleDefinition: ModuleDefinition): string {\n return `${moduleDefinition.address}/components/schemas/entrypoint?generator=${SCHEMA_GENERATOR}`\n }\n\n static getSchemaDefinitionArtifactFilepath(schemaDefinition: SchemaDefinition, fileNamingStyle: FileNamingStyle): string {\n const filename = `${changeCase[fileNamingStyle](schemaDefinition.name)}.schema.ts`\n return [\n '.',\n changeCase[fileNamingStyle](schemaDefinition.module.name),\n 'types',\n 'components',\n 'schemas',\n filename,\n ].join('/')\n }\n\n static getSchemaDefinitionArtifactId(schemaDefinition: SchemaDefinition): string {\n return `${schemaDefinition.id}?generator=${SCHEMA_GENERATOR}`\n }\n}\n","import { AsyncSeriesWaterfallHook } from 'tapable'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { Artifact, OperationDefinition, SchemaDefinition } from '~/models/index.js'\n\n\nexport interface GenerateDeclarationPluginMetadata {\n hooks: {\n afterEntrypointArtifactGenerated: AsyncSeriesWaterfallHook<[Artifact, TaskWrapper]>\n afterSchemaDeclarationArtifactGenerated: AsyncSeriesWaterfallHook<[Artifact, SchemaDefinition, TaskWrapper]>\n afterOperationDeclarationArtifactGenerated: AsyncSeriesWaterfallHook<[Artifact, OperationDefinition, TaskWrapper]>\n }\n}\n\nexport const MetadataStorage = new WeakMap<Compiler, GenerateDeclarationPluginMetadata>()\n","import { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { Artifact } from '~/models/index.js'\nimport { Generator } from '~/types/index.js'\n\n\nexport const MICRO_FUNCTION_REQUEST_GENERATOR = 'microFunctionRequestGenerator'\n\nexport class RequestGenerator implements Generator {\n private generateRequestArtifact(): Artifact {\n const content = [\n '/* @anchor:file:start */',\n '',\n 'import { KeqRequest } from \"keq\"',\n '',\n '/* @anchor:request-declaration */',\n 'export const request = new KeqRequest()',\n '',\n '/* @anchor:file:end */',\n ].join('\\n')\n\n return new Artifact({\n id: RequestGenerator.getRequestArtifactId(),\n filepath: RequestGenerator.getRequestArtifactFilepath(),\n content,\n })\n }\n\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async compile(compiler: Compiler, task: TaskWrapper): Promise<Artifact[]> {\n return [\n this.generateRequestArtifact(),\n ]\n }\n\n static getRequestArtifactFilepath(): string {\n return './request.ts'\n }\n\n static getRequestArtifactId(): string {\n return `request?generator=${MICRO_FUNCTION_REQUEST_GENERATOR}`\n }\n}\n","import { AsyncSeriesWaterfallHook } from 'tapable'\nimport { Plugin } from '~/types/index.js'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { ApiDocumentV3_1, Artifact } from '~/models/index.js'\nimport { GenerateNestjsModulePluginMetadata, MetadataStorage } from './constants/index.js'\nimport { NestjsModuleGenerator } from './generators/nestjs-module.generator.js'\n\n\nexport class GenerateNestjsModulePlugin implements Plugin {\n private readonly nestjsModuleGenerator = new NestjsModuleGenerator()\n\n apply(compiler: Compiler): void {\n GenerateNestjsModulePlugin.register(compiler)\n\n compiler.hooks.compile.tapPromise(GenerateNestjsModulePlugin.name, async (task) => {\n const artifacts = await this.nestjsModuleGenerator.compile(compiler, task)\n compiler.context.artifacts!.push(...artifacts)\n })\n }\n\n static register(compiler: Compiler): GenerateNestjsModulePluginMetadata {\n if (!MetadataStorage.has(compiler)) {\n MetadataStorage.set(compiler, {\n hooks: {\n afterNestjsModuleArtifactGenerated: new AsyncSeriesWaterfallHook<[Artifact, ApiDocumentV3_1, TaskWrapper]>(['artifact', 'document', 'task']),\n },\n })\n }\n\n return MetadataStorage.get(compiler)!\n }\n\n static of(compiler: Compiler): GenerateNestjsModulePluginMetadata | undefined {\n return MetadataStorage.get(compiler)\n }\n}\n","import { AsyncSeriesWaterfallHook } from 'tapable'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { ApiDocumentV3_1, Artifact } from '~/models/index.js'\n\nexport interface GenerateNestjsModulePluginMetadata {\n hooks: {\n afterNestjsModuleArtifactGenerated: AsyncSeriesWaterfallHook<[Artifact, ApiDocumentV3_1, TaskWrapper]>\n }\n}\n\nexport const MetadataStorage = new WeakMap<Compiler, GenerateNestjsModulePluginMetadata>()\n","import * as path from 'path'\nimport * as changeCase from 'change-case'\nimport { Compiler, TaskWrapper } from '~/compiler/index.js'\nimport { ApiDocumentV3_1, Artifact } from '~/models/index.js'\nimport { MetadataStorage } from '../constants/metadata-storage.js'\nimport { FileNamingStyle } from '~/constants/index.js'\nimport { Generator, RuntimeConfig } from '~/types/index.js'\nimport { ApiDocumentTransformer } from '~/transformers/index.js'\nimport { OperationDeclarationGenerator } from '~/plugins/generate-declaration/index.js'\n\n\nconst NESTJS_MODULE_GENERATOR = 'nestjs-module-generator'\n\nexport class NestjsModuleGenerator implements Generator {\n private generateNestjsModuleArtifact(document: ApiDocumentV3_1, rc: RuntimeConfig): Artifact {\n const filepath = NestjsModuleGenerator.getNestjsModuleArtifactFilepath(document, rc.fileNamingStyle)\n const dirname = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: NestjsModuleGenerator.getNestjsModuleArtifactId(document),\n filepath,\n content: ApiDocumentTransformer.toNestjsModule(document, {\n esm: rc.esm,\n getNestjsClientFilepath(document) {\n const relativePath = path.relative(\n dirname,\n NestjsModuleGenerator.getNestjsClientArtifactFilepath(document, rc.fileNamingStyle),\n )\n\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n },\n }),\n })\n\n return artifact\n }\n\n private generateNestjsClientArtifact(document: ApiDocumentV3_1, rc: RuntimeConfig): Artifact {\n const filepath = NestjsModuleGenerator.getNestjsClientArtifactFilepath(document, rc.fileNamingStyle)\n const dirpath = path.dirname(filepath)\n\n const artifact = new Artifact({\n id: NestjsModuleGenerator.getNestjsClientArtifactId(document),\n filepath,\n content: ApiDocumentTransformer.toNestjsClient(document, {\n esm: rc.esm,\n getOperationDefinitionDeclarationFilepath(operationDefinition) {\n const relativePath = path.relative(\n dirpath,\n OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle),\n )\n\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n },\n }),\n })\n\n return artifact\n }\n\n async compile(compiler: Compiler, task: TaskWrapper): Promise<Artifact[]> {\n const metadata = MetadataStorage.get(compiler)!\n const rc = compiler.context.rc!\n const documents = compiler.context.documents!\n\n const nestjsModuleArtifacts = await Promise.all(\n documents.map((document) => metadata.hooks.afterNestjsModuleArtifactGenerated.promise(\n this.generateNestjsModuleArtifact(document, rc),\n document,\n task,\n )),\n )\n\n const nestjsClientArtifacts = await Promise.all(\n documents.map((document) => metadata.hooks.afterNestjsModuleArtifactGenerated.promise(\n this.generateNestjsClientArtifact(document, rc),\n document,\n task,\n )),\n )\n\n return [...nestjsModuleArtifacts, ...nestjsClientArtifacts]\n }\n\n static getNestjsModuleArtifactFilepath(document: ApiDocumentV3_1, fileNamingStyle: FileNamingStyle): string {\n const filename = `${changeCase[fileNamingStyle](document.module.name)}.module.ts`\n\n const filepath = [\n '.',\n changeCase[fileNamingStyle](document.module.name),\n filename,\n ]\n\n return filepath.join('/')\n }\n\n static getNestjsModuleArtifactId(document: ApiDocumentV3_1): string {\n return `${document.module.address}?generate=${NESTJS_MODULE_GENERATOR}`\n }\n\n static getNestjsClientArtifactFilepath(document: ApiDocumentV3_1, fileNamingStyle: FileNamingStyle): string {\n const filename = `${changeCase[fileNamingStyle](document.module.name)}.client.ts`\n\n const filepath = [\n '.',\n changeCase[fileNamingStyle](document.module.name),\n filename,\n ]\n\n return filepath.join('/')\n }\n\n static getNestjsClientArtifactId(document: ApiDocumentV3_1): string {\n return `${document.module.address}?generate=${NESTJS_MODULE_GENERATOR}-client`\n }\n}\n","\nimport { fixSwagger } from 'swagger-fix'\nimport { Compiler } from '~/compiler/index.js'\nimport { ApiDocumentV3_1 } from '~/models/index.js'\n\n\nexport class ChineseToPinyinPlugin {\n apply(compiler: Compiler): void {\n compiler.hooks.afterDownload.tap(ChineseToPinyinPlugin.name, (task) => {\n const documents = compiler.context.documents!\n\n compiler.context.documents = documents.map((doc) => {\n return new ApiDocumentV3_1(\n fixSwagger(doc.specification as any),\n doc.module,\n )\n })\n })\n }\n}\n","import * as validUrl from 'valid-url'\nimport { Compiler } from '~/compiler/index.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { OpenapiUtils } from '~/utils/openapi-utils/index.js'\n\n\nexport class DownloadHttpFilePlugin implements Plugin {\n apply(compiler: Compiler): void {\n compiler.hooks.download.tapPromise(DownloadHttpFilePlugin.name, async (address, task) => {\n if (!validUrl.isUri(address)) return undefined\n const content = await this.download(address)\n const spec = this.deserialize(content)\n return JSON.stringify(spec)\n })\n }\n\n async download(address): Promise<string> {\n try {\n const res = await fetch(address)\n if (res.status >= 400) throw new Error(`failed with status code ${res.status}`)\n\n return await res.text()\n } catch (e) {\n if (e instanceof Error) {\n e.message = `Unable get the openapi/swagger file from ${address}: ${e.message}`\n }\n\n throw e\n }\n }\n\n deserialize(content: string): object {\n const json = JSON.parse(content)\n const spec = OpenapiUtils.to3_1(json)\n return spec\n }\n}\n","import * as path from 'path'\nimport * as fs from 'fs/promises'\nimport * as yaml from 'js-yaml'\nimport { Compiler } from '~/compiler/index.js'\nimport { Plugin } from '~/types/index.js'\nimport { OpenapiUtils } from '~/utils/openapi-utils/index.js'\n\n\nexport class DownloadLocalFilePlugin implements Plugin {\n apply(compiler: Compiler): void {\n compiler.hooks.download.tapPromise(DownloadLocalFilePlugin.name, async (address, task) => {\n if (!address.startsWith('./') && !address.startsWith('/') && !address.startsWith('../')) return undefined\n\n const fileExt = path.extname(address)\n const content = await fs.readFile(address, 'utf8')\n\n if (['.yml', '.yaml'].includes(fileExt)) {\n const value = yaml.load(content)\n return JSON.stringify(OpenapiUtils.to3_1(value))\n } else if (fileExt === '.json') {\n return JSON.stringify(OpenapiUtils.to3_1(JSON.parse(content)))\n }\n })\n }\n}\n","import { Plugin } from '~/types/index.js'\nimport { Compiler } from '~/compiler/index.js'\nimport { ApiDocumentV3_1, ModuleDefinition, OperationDefinition } from '~/models/index.js'\nimport { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { SupportedMethods } from '~/constants/index.js'\nimport { openapiShakingSync } from '@opendoc/openapi-shaking'\n\nexport class ShakingPlugin implements Plugin {\n apply(compiler: Compiler): void {\n compiler.hooks.beforeCompile.tap(ShakingPlugin.name, (task) => {\n const matcher = compiler.context.matcher!\n const documents = compiler.context.documents!\n\n compiler.context.documents = documents\n .map((document) => this.shaking(compiler, document))\n .filter((document) => !document.isEmpty())\n .filter((document) => !matcher.isModuleIgnored(document.module))\n })\n }\n\n shaking(compiler: Compiler, document: ApiDocumentV3_1): ApiDocumentV3_1 {\n const rc = compiler.context.rc!\n const matcher = compiler.context.matcher!\n\n const isAccepted = (pathname: string, method: string, operation: OpenAPIV3_1.Document): boolean => {\n if (!SupportedMethods.includes(method)) return false\n\n return !matcher.isOperationIgnored(new OperationDefinition({\n method,\n pathname,\n operation,\n module: document.module,\n document: document,\n }))\n }\n\n\n const sharkedSwagger = openapiShakingSync(\n document.specification as any,\n isAccepted as any,\n { tolerant: rc.tolerant },\n ) as OpenAPIV3_1.Document\n\n return new ApiDocumentV3_1(\n sharkedSwagger,\n new ModuleDefinition(\n document.module.name,\n `file://${document.module.name}.v3_1.sharked.json`,\n ),\n )\n }\n}\n","import { ListrTaskWrapper } from 'listr2'\nimport { OperationDefinition } from '~/models/index.js'\nimport { select } from 'inquirer-select-pro'\nimport { ListrInquirerPromptAdapter } from '@listr2/prompt-adapter-inquirer'\nimport { CompilerContext } from '~/compiler/index.js'\n\nexport async function selectOperationDefinitions(\n task: ListrTaskWrapper<CompilerContext, any, any>,\n operationDefinitions: OperationDefinition[],\n): Promise<OperationDefinition[]> {\n const selectedOperationDefinitions = await task.prompt(ListrInquirerPromptAdapter).run(\n select<OperationDefinition>,\n {\n message: 'Select Pathname',\n defaultValue: [],\n options: (input) => {\n const items = operationDefinitions.map((op) => ({ name: `${op.module.name} ${op.method.toUpperCase()} ${op.pathname}`, value: op }))\n\n if (!input) return items\n const keys = input\n .trim()\n .toLowerCase()\n .split(/\\s+/)\n\n return items.filter((i) => {\n const name = i.name.toLowerCase()\n return keys.every((q) => name.includes(q))\n })\n },\n },\n )\n\n return selectedOperationDefinitions\n}\n","import { Compiler } from '~/compiler/index.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { selectOperationDefinitions } from './utils/select-operation-definitions.js'\nimport { IgnoreMode } from './types/index.js'\n\nexport interface TerminalSelectPluginOptions {\n mode: IgnoreMode\n\n persist?: boolean\n\n /**\n * Remove all previously matcher rules.\n * This means that all rules form `.keqignore` file will be removed.\n */\n clear?: boolean\n}\n\n\nexport class TerminalSelectPlugin implements Plugin {\n constructor(private options: TerminalSelectPluginOptions) {}\n\n apply(compiler: Compiler): void {\n compiler.hooks.afterDownload.tapPromise(TerminalSelectPlugin.name, async (task) => {\n const context = compiler.context\n\n const matcher = context.matcher!\n const documents = context.documents!\n const operationDefinitions = documents.flatMap((document) => document.operations)\n const selectedOperationDefinitions = await selectOperationDefinitions(task, operationDefinitions)\n\n if (this.options.clear) {\n matcher.append({\n persist: false,\n ignore: true,\n moduleName: '*',\n operationMethod: '*',\n operationPathname: '*',\n })\n }\n\n for (const op of selectedOperationDefinitions) {\n matcher.append({\n persist: !!this.options.persist,\n ignore: this.options.mode === 'add',\n moduleName: op.module.name,\n operationMethod: op.method,\n operationPathname: op.pathname,\n })\n }\n })\n }\n}\n","import * as R from 'ramda'\nimport { Compiler } from '~/compiler/index.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { DownloadHttpFilePlugin } from '../download-http-file/index.js'\nimport { DownloadLocalFilePlugin } from '../download-local-file/index.js'\nimport { GenerateDeclarationPlugin } from '../generate-declaration/index.js'\nimport { ShakingPlugin } from '../shaking/index.js'\nimport { TerminalSelectPlugin, TerminalSelectPluginOptions } from '../terminal-select/index.js'\nimport { GenerateMicroFunctionPlugin } from '../generate-micro-function/index.js'\nimport { GenerateNestjsModulePlugin } from '../generate-nestjs-module/index.js'\n\n\ninterface InitializePluginOptions {\n build?: boolean\n interactive?: boolean | TerminalSelectPluginOptions\n\n includes?: string[]\n}\n\nexport class InitializePlugin implements Plugin {\n constructor(private options: InitializePluginOptions) {\n }\n\n apply(compiler: Compiler): void {\n compiler.hooks.setup.tap(InitializePlugin.name, (task) => {\n new DownloadHttpFilePlugin().apply(compiler)\n new DownloadLocalFilePlugin().apply(compiler)\n\n new GenerateDeclarationPlugin().apply(compiler)\n\n if (this.options.build) {\n new ShakingPlugin().apply(compiler)\n }\n\n if (this.options.interactive) {\n new TerminalSelectPlugin(\n typeof this.options.interactive === 'object'\n ? this.options.interactive\n : { mode: 'except' },\n ).apply(compiler)\n }\n\n const rc = compiler.context.rc!\n\n if (rc.mode === 'micro-function') {\n new GenerateMicroFunctionPlugin().apply(compiler)\n } else if (rc.mode === 'nestjs-module') {\n new GenerateNestjsModulePlugin().apply(compiler)\n }\n\n // Apply Custom Plugins\n if (rc.plugins && rc.plugins.length) {\n for (const plugin of rc.plugins) {\n plugin.apply(compiler)\n }\n }\n })\n\n if (this.options.includes && this.options.includes.length) {\n const modulesIncludes = this.options.includes\n\n compiler.hooks.afterSetup.tap(InitializePlugin.name, (task) => {\n const rc = compiler.context.rc!\n const matcher = compiler.context.matcher!\n\n const notExistModules = modulesIncludes.filter((moduleName) => !(moduleName in rc.modules))\n if (notExistModules.length) {\n throw new Error(`Cannot find module(s) ${notExistModules.join(', ')} in config file.`)\n }\n\n const ignoredModules = R.difference(R.keys(rc.modules), modulesIncludes)\n for (const moduleName of ignoredModules) {\n matcher.append({\n persist: false,\n ignore: true,\n moduleName,\n operationMethod: '*',\n operationPathname: '*',\n })\n }\n })\n }\n }\n}\n","import { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { KeqQueryOptions } from 'keq'\nimport { Compiler } from '~/compiler/index.js'\nimport { QsArrayFormat } from '~/constants/qs-array-format.js'\nimport { Exception } from '~/exception.js'\nimport { ApiDocumentV3_1, ModuleDefinition } from '~/models/index.js'\nimport { Plugin } from '~/types/plugin.js'\nimport { OpenapiUtils } from '~/utils/openapi-utils/index.js'\n\n\nexport type OverwriteQueryOptionsFactory = (\n (options: {\n module: ModuleDefinition\n method: string\n pathname: string\n operation: OpenAPIV3_1.OperationObject\n parameter: OpenAPIV3_1.ParameterObject\n }) => KeqQueryOptions | undefined\n) | KeqQueryOptions\n\nconst QsArrayFormatUnion: string[] = Object.values(QsArrayFormat)\n\nexport class OverwriteQueryOptionsPlugin implements Plugin {\n constructor(private readonly factory: OverwriteQueryOptionsFactory) {}\n\n apply(compiler: Compiler): void {\n compiler.hooks.afterDownload.tap(OverwriteQueryOptionsPlugin.name, (task) => {\n const documents = compiler.context.documents!\n const factory = this.factory\n\n compiler.context.documents = documents.map((document) => {\n const specification = OpenapiUtils.mapParameter(\n document.specification,\n (method, pathname, operation, parameter) => {\n const qsOptions = typeof factory === 'function' ? factory({ parameter, operation, pathname, method, module: document.module }) : factory\n if (!qsOptions) return parameter\n\n if (qsOptions.arrayFormat) {\n if (!QsArrayFormatUnion.includes(qsOptions.arrayFormat)) {\n throw new Exception(document.module, `The 'arrayFormat' value '${qsOptions.arrayFormat}' for the query parameter '${parameter.name}' in [${method.toUpperCase()} ${pathname}] is invalid.`)\n }\n\n parameter['x-qs-array-format'] = qsOptions.arrayFormat\n }\n\n if (qsOptions.allowDots !== undefined) {\n if (typeof qsOptions.allowDots !== 'boolean') {\n throw new Exception(document.module, `The 'allowDots' value for the query parameter '${parameter.name}' in [${method.toUpperCase()} ${pathname}] must be a boolean.`)\n }\n\n parameter['x-qs-allow-dots'] = Boolean(qsOptions.allowDots)\n }\n\n if (qsOptions.indices !== undefined) {\n if (typeof qsOptions.indices !== 'boolean') {\n throw new Exception(document.module, `The 'indices' value for the query parameter '${parameter.name}' in [${method.toUpperCase()} ${pathname}] must be a boolean.`)\n }\n\n parameter['x-qs-indices'] = Boolean(qsOptions.indices)\n }\n\n return parameter\n },\n )\n\n return new ApiDocumentV3_1(\n specification,\n document.module,\n )\n })\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oBAAmB;AACnB,uBAA0C;;;ACFnC,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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H;AAEA,QAAM,SAAS,IAAI;AACrB,CAAC;AAEH,eAAeC,QAAsB;AACnC,UAAQ,GAAG,aAAa,SAAU,UAAU;AAC1C,UAAM,IAAI,MAAM,oBAAoB,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG;AAAA,EAC5D,CAAC;AAED,MAAI;AACF,UAAM,QAAQ,WAAW,QAAQ,IAAI;AAAA,EACvC,SAAS,KAAK;AACZ,QAAI,QAAQ,KAAK,SAAS,SAAS,GAAG;AACpC,cAAQ,MAAM,GAAG;AAAA,IACnB,OAAO;AACL,aAAO,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,IAC/D;AAAA,EACF;AACF;AAEA,KAAKA,MAAK;","names":["chalk","import_listr2","import_tapable","import_fs_extra","fs","FileNamingStyle","R","keys","validator","path","fs","path","message","fs","context","task","import_openapi_parser","path","R","R","import_jsonpath_plus","R","module","path","path","module","wrap","R","import_jsonpointer","import_jsonpath_plus","R","import_jsonpath_plus","R","path","jsonpointer","jsonpointer","last","R","main","task","path","import_fs_extra","fs","main","context","task","main","context","task","prop","R","R","import_tapable","R","path","changeCase","path","changeCase","R","R","alias","schema","R","R","CommentRenderer","R","DeclarationRenderer","R","R","QsArrayFormat","CommentRenderer","R","CommentRenderer","DeclarationRenderer","CommentRenderer","path","exports","R","changeCase","changeCase","R","path","changeCase","MetadataStorage","MetadataStorage","schemaDefinitions","exports","changeCase","MetadataStorage","exports","changeCase","MetadataStorage","operationDefinitions","operationDefinition","exports","changeCase","import_tapable","MetadataStorage","path","changeCase","dirname","document","MetadataStorage","changeCase","MetadataStorage","path","fs","keys","R","semver","moduleNames","main"]}
|