diff --git a/.changeset/little-books-reply.md b/.changeset/little-books-reply.md index ffbf1159bd..ba30b8ac16 100644 --- a/.changeset/little-books-reply.md +++ b/.changeset/little-books-reply.md @@ -4,7 +4,6 @@ "medusa-dev-cli": patch "@medusajs/medusa-oas-cli": patch "@medusajs/oas-github-ci": patch -"@medusajs/openapi-typescript-codegen": patch "@medusajs/core-flows": patch "medusa-test-utils": patch "@medusajs/modules-sdk": patch diff --git a/.eslintrc.js b/.eslintrc.js index 5c41a72f12..559d5f480e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -95,7 +95,6 @@ module.exports = { "./packages/cli/medusa-cli/tsconfig.spec/json", "./packages/cli/medusa-dev-cli/tsconfig.spec.json", "./packages/cli/oas/medusa-oas-cli/tsconfig.spec.json", - "./packages/cli/oas/openapi-typescript-codegen/tsconfig.spec.json", "./packages/core/orchestration/tsconfig.json", "./packages/core/workflows-sdk/tsconfig.spec.json", diff --git a/packages/cli/oas/medusa-oas-cli/README.md b/packages/cli/oas/medusa-oas-cli/README.md index 27038a0ec6..5b60916461 100644 --- a/packages/cli/oas/medusa-oas-cli/README.md +++ b/packages/cli/oas/medusa-oas-cli/README.md @@ -85,70 +85,6 @@ yarn medusa-oas oas --force --- -### Command - `client` - -Will generate API client files from a given OAS file. - -#### `--src-file ` - -Specify the path to the OAS JSON file. - -```bash -yarn medusa-oas client --src-file ./store.oas.json` -``` - -#### `--name ` - -Namespace for the generated client. Usually `admin` or `store`. - -```bash -yarn medusa-oas client --name admin` -``` - -#### `--out-dir ` - -Specify in which directory should the files be outputted. Accepts relative and absolute path. -If the directory doesn't exist, it will be created. Defaults to `./`. - -```bash -yarn medusa-oas client --out-dir ./client` -``` - -#### `--type ` - -Client component types to generate. Accepts `all`, `types`, `client`, `hooks`. -Defaults to `all`. - -```bash -yarn medusa-oas client --type types` -``` - -#### `--types-packages ` - -Replace relative import statements by types package name. Mandatory when using `--type client` or `--type hooks`. - -```bash -yarn medusa-oas client --types-packages @medusajs/client-types` -``` - -#### `--client-packages ` - -Replace relative import statements by client package name. Mandatory when using `--type hooks`. - -```bash -yarn medusa-oas client --client-packages @medusajs/medusa-js` -``` - -#### `--clean` - -Delete destination directory content before generating client. - -```bash -yarn medusa-oas client --clean -``` - ---- - ### Command - `docs` Will sanitize OAS for use with Redocly's API documentation viewer. @@ -188,7 +124,7 @@ yarn medusa-oas docs --src-file ./store.oas.json --dry-run #### `--clean` -Delete destination directory content before generating client. +Delete destination directory content before generating the docs. ```bash yarn medusa-oas docs --src-file ./store.oas.json --clean diff --git a/packages/cli/oas/medusa-oas-cli/package.json b/packages/cli/oas/medusa-oas-cli/package.json index bcc1f45607..ba94549a1b 100644 --- a/packages/cli/oas/medusa-oas-cli/package.json +++ b/packages/cli/oas/medusa-oas-cli/package.json @@ -37,7 +37,6 @@ }, "dependencies": { "@medusajs/medusa": "^1.20.4", - "@medusajs/openapi-typescript-codegen": "^0.2.1", "@medusajs/utils": "^1.11.8", "@readme/json-schema-ref-parser": "^1.2.0", "@readme/openapi-parser": "^2.4.0", diff --git a/packages/cli/oas/medusa-oas-cli/src/command-client.ts b/packages/cli/oas/medusa-oas-cli/src/command-client.ts deleted file mode 100644 index 00e699ac93..0000000000 --- a/packages/cli/oas/medusa-oas-cli/src/command-client.ts +++ /dev/null @@ -1,176 +0,0 @@ -import path from "path" -import { - generate, - HttpClient, - Indent, - PackageNames, -} from "@medusajs/openapi-typescript-codegen" -import { upperFirst } from "lodash" -import fs, { mkdir, readFile } from "fs/promises" -import { OpenAPIObject } from "openapi3-ts" -import { Command, Option, OptionValues } from "commander" - -/** - * CLI Command declaration - */ -export const commandName = "client" -export const commandDescription = "Generate API clients from OAS." -export const commandOptions: Option[] = [ - new Option( - "-t, --type ", - "Namespace for the generated client. Usually `admin` or `store`." - ).makeOptionMandatory(), - - new Option( - "-s, --src-file ", - "Path to source OAS JSON file." - ).makeOptionMandatory(), - - new Option( - "-o, --out-dir ", - "Output directory for generated client files." - ).default(path.resolve(process.cwd(), "client")), - - new Option( - "-c, --component ", - "Client component types to generate." - ) - .choices(["all", "types", "client", "hooks"]) - .default("all"), - - new Option( - "--types-package ", - "Replace relative import statements by types package name." - ), - - new Option( - "--client-package ", - "Replace relative import statements by client package name." - ), - - new Option( - "--clean", - "Delete destination directory content before generating client." - ), -] - -export function getCommand() { - const command = new Command(commandName) - command.description(commandDescription) - for (const opt of commandOptions) { - command.addOption(opt) - } - command.action(async (options) => await execute(options)) - command.showHelpAfterError(true) - return command -} - -/** - * Main - */ -export async function execute(cliParams: OptionValues) { - /** - * Process CLI options - */ - if ( - ["client", "hooks"].includes(cliParams.component) && - !cliParams.typesPackage - ) { - throw new Error( - `--types-package must be declared when using --component=${cliParams.component}` - ) - } - if (cliParams.component === "hooks" && !cliParams.clientPackage) { - throw new Error( - `--client-package must be declared when using --component=${cliParams.component}` - ) - } - - const shouldClean = !!cliParams.clean - const srcFile = path.resolve(cliParams.srcFile) - const outDir = path.resolve(cliParams.outDir) - const apiName = cliParams.type - const packageNames: PackageNames = { - models: cliParams.typesPackage, - client: cliParams.clientPackage, - } - const exportComponent = cliParams.component - - /** - * Command execution - */ - console.log(`🟣 Generating client - ${apiName} - ${exportComponent}`) - - if (shouldClean) { - console.log(`🟠 Cleaning output directory`) - await fs.rm(outDir, { recursive: true, force: true }) - } - await mkdir(outDir, { recursive: true }) - - const oas = await getOASFromFile(srcFile) - await generateClientSDK(oas, outDir, apiName, exportComponent, packageNames) - - console.log( - `⚫️ Client generated - ${apiName} - ${exportComponent} - ${outDir}` - ) -} - -/** - * Methods - */ -const getOASFromFile = async (jsonFile: string): Promise => { - const jsonString = await readFile(jsonFile, "utf8") - return JSON.parse(jsonString) -} - -const generateClientSDK = async ( - oas: OpenAPIObject, - targetDir: string, - apiName: string, - exportComponent: "all" | "types" | "client" | "hooks", - packageNames: PackageNames = {} -) => { - const exports = { - exportCore: false, - exportServices: false, - exportModels: false, - exportHooks: false, - } - - switch (exportComponent) { - case "types": - exports.exportModels = true - break - case "client": - exports.exportCore = true - exports.exportServices = true - break - case "hooks": - exports.exportHooks = true - break - default: - exports.exportCore = true - exports.exportServices = true - exports.exportModels = true - exports.exportHooks = true - } - - await generate({ - input: oas, - output: targetDir, - httpClient: HttpClient.AXIOS, - useOptions: true, - useUnionTypes: true, - exportCore: exports.exportCore, - exportServices: exports.exportServices, - exportModels: exports.exportModels, - exportHooks: exports.exportHooks, - exportSchemas: false, - indent: Indent.SPACE_2, - postfixServices: "Service", - postfixModels: "", - clientName: `Medusa${upperFirst(apiName)}`, - request: undefined, - packageNames, - }) -} diff --git a/packages/cli/oas/medusa-oas-cli/src/index.ts b/packages/cli/oas/medusa-oas-cli/src/index.ts index 2903353837..11544199b3 100644 --- a/packages/cli/oas/medusa-oas-cli/src/index.ts +++ b/packages/cli/oas/medusa-oas-cli/src/index.ts @@ -2,7 +2,6 @@ import { Command } from "commander" import { getCommand as oasGetCommand } from "./command-oas" -import { getCommand as clientGetCommand } from "./command-client" import { getCommand as docsGetCommand } from "./command-docs" const run = async () => { @@ -13,11 +12,6 @@ const run = async () => { */ program.addCommand(oasGetCommand()) - /** - * Alias to command-client.ts - */ - program.addCommand(clientGetCommand()) - /** * Alias to command-docs.ts */ diff --git a/packages/cli/oas/openapi-typescript-codegen/.gitignore b/packages/cli/oas/openapi-typescript-codegen/.gitignore deleted file mode 100644 index 1a8a9e80b9..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/dist -node_modules -.DS_store -.env* -.env -*.sql -/bin \ No newline at end of file diff --git a/packages/cli/oas/openapi-typescript-codegen/.prettierignore b/packages/cli/oas/openapi-typescript-codegen/.prettierignore deleted file mode 100644 index 5acb4c912f..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -*.hbs \ No newline at end of file diff --git a/packages/cli/oas/openapi-typescript-codegen/CHANGELOG.md b/packages/cli/oas/openapi-typescript-codegen/CHANGELOG.md deleted file mode 100644 index 267dc953e7..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/CHANGELOG.md +++ /dev/null @@ -1,33 +0,0 @@ -# @medusajs/openapi-typescript-codegen - -## 0.2.1 - -### Patch Changes - -- [#3675](https://github.com/medusajs/medusa/pull/3675) [`0b3c6fde3`](https://github.com/medusajs/medusa/commit/0b3c6fde30c9bac052a8e1aa641ef925b6937c0e) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - feat(codegen:test): coverage x-expanded-relation + x-codegen.queryParams - -## 0.2.0 - -### Minor Changes - -- [#3477](https://github.com/medusajs/medusa/pull/3477) [`826d4bedf`](https://github.com/medusajs/medusa/commit/826d4bedfe1b6459163711d5173eb8eadfdea26e) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - feat(codegen,types): SetRelation on expanded types - -- [#3442](https://github.com/medusajs/medusa/pull/3442) [`7b57695e0`](https://github.com/medusajs/medusa/commit/7b57695e00433e1d54f8cdc912ef7e5f28fc1071) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - feat(codegen): x-expanded-relations - -### Patch Changes - -- [#3272](https://github.com/medusajs/medusa/pull/3272) [`1c40346e9`](https://github.com/medusajs/medusa/commit/1c40346e9e56718de4a6e2d5c2d52abd388343e3) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - feat(codegen): openapi-typescript-codegen fork - -## 0.2.0-rc.0 - -### Minor Changes - -- [#3477](https://github.com/medusajs/medusa/pull/3477) [`826d4bedf`](https://github.com/medusajs/medusa/commit/826d4bedfe1b6459163711d5173eb8eadfdea26e) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - feat(codegen,types): SetRelation on expanded types - -- [#3442](https://github.com/medusajs/medusa/pull/3442) [`7b57695e0`](https://github.com/medusajs/medusa/commit/7b57695e00433e1d54f8cdc912ef7e5f28fc1071) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - feat(codegen): x-expanded-relations - -### Patch Changes - -- [#3272](https://github.com/medusajs/medusa/pull/3272) [`1c40346e9`](https://github.com/medusajs/medusa/commit/1c40346e9e56718de4a6e2d5c2d52abd388343e3) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - feat(codegen): openapi-typescript-codegen fork - -## 0.1.0 diff --git a/packages/cli/oas/openapi-typescript-codegen/README.md b/packages/cli/oas/openapi-typescript-codegen/README.md deleted file mode 100644 index e0d763158d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# OpenAPI Typescript Codegen - 0.1.0 - experimental - -Node.js library that generates Typescript clients based on the OpenAPI specification. - -## About this fork - -This package is a significantly customized fork of -the amazing npm [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen) package 💜. - -### Brief reasoning - -We wanted a level of customization that was not achievable through the source package's interface. -We started with a conventional fork but the development workflow was hindering our ability to iterate quickly. -We decided to fold the package within our monorepo to hopefully accelerate development and innovation. - -### Noteworthy differences - -* Added ability to generate React hooks in the style of `medusa-react`. -* Added access to the raw OAS on parsed element from the parser. -* Added access `operationId` from path. -* Added access `x-codegen` from path. -* Added renaming of service method when `x-codegen.method` is declared. -* Added bundling of query params into a typed object when `x-codegen.queryParams` is declared. -* Added parameterization of import path for the client and models. -* Added generated `index.ts` files in directories to simplify imports. -* Updated npm dependencies' version to match existing versions found in the monorepo. -* Updated coding style to match the convention of the monorepo. -* Removed support for Angular client generation. -* Removed support for OAS v2 parsing. -* Removed documentation. -* Removed tests (temporarily). - -## Install - -`yarn add --dev @medusajs/openapi-typescript-codegen` - -## How to use - -See `@medusajs/medusa-oas-cli` for usage. diff --git a/packages/cli/oas/openapi-typescript-codegen/babel.config.json b/packages/cli/oas/openapi-typescript-codegen/babel.config.json deleted file mode 100644 index ff5c1c77bc..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/babel.config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "presets": [ - [ - "@babel/preset-env", - { - "targets": { - "node": "12" - } - } - ], - [ - "@babel/preset-typescript", - { - "onlyRemoveTypeImports": true - } - ] - ] -} diff --git a/packages/cli/oas/openapi-typescript-codegen/jest.config.js b/packages/cli/oas/openapi-typescript-codegen/jest.config.js deleted file mode 100644 index 8fa6fb8c15..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/jest.config.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - globals: { - "ts-jest": { - tsconfig: "tsconfig.json", - isolatedModules: false, - }, - }, - transform: { - "^.+\\.[jt]s?$": "ts-jest", - }, - testEnvironment: `node`, - moduleFileExtensions: [`js`, `ts`], - testTimeout: 30000, -} diff --git a/packages/cli/oas/openapi-typescript-codegen/package.json b/packages/cli/oas/openapi-typescript-codegen/package.json deleted file mode 100644 index 959c7dd4a5..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@medusajs/openapi-typescript-codegen", - "version": "0.2.1", - "description": "Library that generates Typescript clients based on the OpenAPI specification.", - "main": "dist/index.js", - "types": "types/index.d.ts", - "files": [ - "dist/index.js", - "types/index.d.ts" - ], - "repository": { - "type": "git", - "url": "https://github.com/medusajs/medusa", - "directory": "packages/oas/openapi-typescript-codegen" - }, - "author": "Medusa", - "contributors": [ - "Ferdi Koomen" - ], - "license": "MIT", - "scripts": { - "prepare": "cross-env NODE_ENV=production yarn run release", - "build": "rollup --config --environment NODE_ENV:development", - "release": "rollup --config --environment NODE_ENV:production", - "test": "jest src --passWithNoTests" - }, - "dependencies": { - "camelcase": "^6.3.0", - "commander": "^9.4.1", - "fs-extra": "^10.1.0", - "handlebars": "^4.7.7", - "json-schema-ref-parser": "^9.0.9", - "pascalcase": "^2.0.0" - }, - "devDependencies": { - "@babel/cli": "7.14.3", - "@babel/core": "7.14.3", - "@babel/preset-env": "7.11.5", - "@babel/preset-typescript": "7.18.6", - "@rollup/plugin-commonjs": "24.0.0", - "@rollup/plugin-node-resolve": "15.0.1", - "@rollup/plugin-typescript": "9.0.2", - "@types/fs-extra": "^9.0.12", - "@types/jest": "27.5.0", - "@types/node": "18.11.9", - "@types/node-fetch": "2.6.2", - "@types/pascalcase": "^1.0.1", - "@types/qs": "6.9.7", - "abort-controller": "3.0.0", - "axios": "1.2.0", - "form-data": "4.0.0", - "jest": "^25.5.4", - "node-fetch": "2.6.7", - "qs": "6.10.3", - "rollup": "3.9.1", - "rollup-plugin-terser": "7.0.2", - "ts-jest": "^25.5.1", - "tslib": "2.3.1", - "typescript": "4.9.5" - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/rollup.config.mjs b/packages/cli/oas/openapi-typescript-codegen/rollup.config.mjs deleted file mode 100644 index 8236101b73..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/rollup.config.mjs +++ /dev/null @@ -1,83 +0,0 @@ -import commonjs from "@rollup/plugin-commonjs" -import { nodeResolve } from "@rollup/plugin-node-resolve" -import typescript from "@rollup/plugin-typescript" -import { readFileSync } from "fs" -import handlebars from "handlebars" -import { dirname, extname, resolve } from "path" -import { terser } from "rollup-plugin-terser" - -const { precompile } = handlebars - -/** - * Custom plugin to parse handlebar imports and precompile - * the template on the fly. This reduces runtime by about - * half on large projects. - */ -const handlebarsPlugin = () => ({ - resolveId: (file, importer) => { - if (extname(file) === ".hbs") { - return resolve(dirname(importer), file) - } - return null - }, - load: (file) => { - if (extname(file) === ".hbs") { - const template = readFileSync(file, "utf8").toString().trim() - const templateSpec = precompile(template, { - strict: true, - noEscape: true, - preventIndent: true, - knownHelpersOnly: true, - knownHelpers: { - ifdef: true, - equals: true, - notEquals: true, - containsSpaces: true, - union: true, - intersection: true, - enumerator: true, - escapeComment: true, - escapeDescription: true, - camelCase: true, - pascalCase: true, - }, - }) - return `export default ${templateSpec};` - } - return null - }, -}) - -const getPlugins = () => { - const plugins = [ - nodeResolve(), - commonjs({ - sourceMap: false, - }), - handlebarsPlugin(), - typescript({ - module: "esnext", - }), - ] - if (process.env.NODE_ENV === "development") { - return plugins - } - return [...plugins, terser()] -} - -export default { - input: "./src/index.ts", - output: { - exports: "named", - file: "./dist/index.js", - format: "cjs", - }, - external: [ - "camelcase", - "commander", - "fs-extra", - "handlebars", - "json-schema-ref-parser", - ], - plugins: getPlugins(), -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/HttpClient.ts b/packages/cli/oas/openapi-typescript-codegen/src/HttpClient.ts deleted file mode 100644 index 960d38677c..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/HttpClient.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum HttpClient { - FETCH = "fetch", - XHR = "xhr", - NODE = "node", - AXIOS = "axios", -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/Indent.ts b/packages/cli/oas/openapi-typescript-codegen/src/Indent.ts deleted file mode 100644 index 19b5fe093b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/Indent.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum Indent { - SPACE_4 = "4", - SPACE_2 = "2", - TAB = "tab", -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Client.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Client.d.ts deleted file mode 100644 index fb90e78bcc..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Client.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { Model } from "./Model" -import type { Service } from "./Service" - -export interface Client { - version: string - server: string - models: Model[] - services: Service[] -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Enum.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Enum.d.ts deleted file mode 100644 index 7f1fc0f79f..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Enum.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface Enum { - name: string - value: string - type: string - description: string | null -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Model.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Model.d.ts deleted file mode 100644 index cb3f71c3e7..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Model.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { Enum } from "./Enum" -import type { Schema } from "./Schema" - -export type NestedRelation = { - field: string - nestedRelations: NestedRelation[] - base?: string - isArray?: boolean - hasDepth?: boolean -} - -export interface Model extends Schema { - name: string - export: - | "reference" - | "generic" - | "enum" - | "array" - | "dictionary" - | "interface" - | "one-of" - | "any-of" - | "all-of" - type: string - base: string - template: string | null - link: Model | null - description: string | null - deprecated?: boolean - default?: string - imports: string[] - enum: Enum[] - enums: Model[] - properties: Model[] - nestedRelations?: NestedRelation[] -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/ModelComposition.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/ModelComposition.d.ts deleted file mode 100644 index e7a801a4a1..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/ModelComposition.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { Model } from "./Model" - -export interface ModelComposition { - type: "one-of" | "any-of" | "all-of" - imports: string[] - enums: Model[] - properties: Model[] -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Operation.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Operation.d.ts deleted file mode 100644 index 55e23a20a9..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Operation.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { OperationError } from "./OperationError" -import type { OperationParameters } from "./OperationParameters" -import type { OperationResponse } from "./OperationResponse" -import type { OperationCodegen } from "./OperationCodegen" - -export interface Operation extends OperationParameters { - service: string - name: string - operationId: string | null - summary: string | null - description: string | null - deprecated: boolean - method: string - path: string - errors: OperationError[] - results: OperationResponse[] - responseHeader: string | null - codegen: OperationCodegen -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationCodegen.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationCodegen.d.ts deleted file mode 100644 index 6fbf9734e7..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationCodegen.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface OperationCodegen { - method?: string - queryParams?: string -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationError.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationError.d.ts deleted file mode 100644 index 82639c1dce..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationError.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface OperationError { - code: number - description: string -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationParameter.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationParameter.d.ts deleted file mode 100644 index ac7a023a9c..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationParameter.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { Model } from "./Model" -import { OpenApiParameter } from "../../openApi/v3/interfaces/OpenApiParameter" -import { OpenApiRequestBody } from "../../openApi/v3/interfaces/OpenApiRequestBody" - -export interface OperationParameter extends Model { - spec: OpenApiParameter | OpenApiRequestBody - in: "path" | "query" | "header" | "formData" | "body" | "cookie" - prop: string - mediaType: string | null -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationParameters.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationParameters.d.ts deleted file mode 100644 index 7237be2ace..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationParameters.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { OperationParameter } from "./OperationParameter" - -export interface OperationParameters { - imports: string[] - parameters: OperationParameter[] - parametersPath: OperationParameter[] - parametersQuery: OperationParameter[] - parametersForm: OperationParameter[] - parametersCookie: OperationParameter[] - parametersHeader: OperationParameter[] - parametersBody: OperationParameter | null -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationResponse.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationResponse.d.ts deleted file mode 100644 index 5be335cd32..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/OperationResponse.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { Model } from "./Model" -import { OpenApiResponse } from "../../openApi/v3/interfaces/OpenApiResponse" - -export interface OperationResponse extends Model { - spec: OpenApiResponse - in: "response" | "header" - code: number -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Schema.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Schema.d.ts deleted file mode 100644 index bff11c4770..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Schema.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { OpenApiSchema } from "../../openApi/v3/interfaces/OpenApiSchema" - -export interface Schema { - spec: OpenApiSchema - isDefinition: boolean - isReadOnly: boolean - isRequired: boolean - isNullable: boolean - format?: - | "int32" - | "int64" - | "float" - | "double" - | "string" - | "boolean" - | "byte" - | "binary" - | "date" - | "date-time" - | "password" - maximum?: number - exclusiveMaximum?: boolean - minimum?: number - exclusiveMinimum?: boolean - multipleOf?: number - maxLength?: number - minLength?: number - pattern?: string - maxItems?: number - minItems?: number - uniqueItems?: boolean - maxProperties?: number - minProperties?: number -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Service.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Service.d.ts deleted file mode 100644 index b1ee601f50..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Service.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { Operation } from "./Operation" - -export interface Service { - name: string - operations: Operation[] - imports: string[] -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Type.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Type.d.ts deleted file mode 100644 index 6180b565d0..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/client/interfaces/Type.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface Type { - type: string - base: string - template: string | null - imports: string[] - isNullable: boolean -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/index.ts b/packages/cli/oas/openapi-typescript-codegen/src/index.ts deleted file mode 100644 index 446f834ba8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/index.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { HttpClient } from "./HttpClient" -import { Indent } from "./Indent" -import { parse } from "./openApi/v3" -import { getOpenApiSpec } from "./utils/getOpenApiSpec" -import { getOpenApiVersion } from "./utils/getOpenApiVersion" -import { isString } from "./utils/isString" -import { postProcessClient } from "./utils/postProcessClient" -import { registerHandlebarTemplates } from "./utils/registerHandlebarTemplates" -import { writeClient } from "./utils/writeClient" - -export { HttpClient } from "./HttpClient" -export { Indent } from "./Indent" - -export type PackageNames = { - models?: string - client?: string -} - -export type Options = { - input: string | Record - output: string - httpClient?: HttpClient - clientName?: string - useOptions?: boolean - useUnionTypes?: boolean - exportCore?: boolean - exportServices?: boolean - exportModels?: boolean - exportHooks?: boolean - exportSchemas?: boolean - indent?: Indent - packageNames?: PackageNames - postfixServices?: string - postfixModels?: string - request?: string - write?: boolean -} - -/** - * Generate the OpenAPI client. This method will read the OpenAPI specification and based on the - * given language it will generate the client, including the typed models, validation schemas, - * service layer, etc. - * @param input The relative location of the OpenAPI spec - * @param output The relative location of the output directory - * @param httpClient The selected httpClient (fetch, xhr, node or axios) - * @param clientName Custom client class name - * @param useOptions Use options or arguments functions - * @param useUnionTypes Use union types instead of enums - * @param exportCore Generate core client classes - * @param exportServices Generate services - * @param exportModels Generate models - * @param exportHooks Generate hooks - * @param exportSchemas Generate schemas - * @param indent Indentation options (4, 2 or tab) - * @param packageNames Package name to use in import statements. - * @param postfixServices Service name postfix - * @param postfixModels Model name postfix - * @param request Path to custom request file - * @param write Write the files to disk (true or false) - */ -export const generate = async ({ - input, - output, - httpClient = HttpClient.FETCH, - clientName, - useOptions = false, - useUnionTypes = false, - exportCore = true, - exportServices = true, - exportModels = true, - exportHooks = true, - exportSchemas = false, - indent = Indent.SPACE_4, - packageNames = {}, - postfixServices = "Service", - postfixModels = "", - request, - write = true, -}: Options): Promise => { - const openApi = isString(input) ? await getOpenApiSpec(input) : input - const openApiVersion = getOpenApiVersion(openApi) - const templates = registerHandlebarTemplates({ - httpClient, - useUnionTypes, - useOptions, - }) - - const client = parse(openApi) - const clientFinal = postProcessClient(client) - if (write) { - await writeClient( - clientFinal, - templates, - output, - httpClient, - useOptions, - useUnionTypes, - exportCore, - exportServices, - exportModels, - exportHooks, - exportSchemas, - indent, - packageNames, - postfixServices, - postfixModels, - clientName, - request - ) - } -} - -export default { - HttpClient, - generate, -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/index.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/index.ts deleted file mode 100644 index 01f47dccb1..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { Client } from "../../client/interfaces/Client" -import type { OpenApi } from "./interfaces/OpenApi" -import { getModels } from "./parser/getModels" -import { getServer } from "./parser/getServer" -import { getServices } from "./parser/getServices" -import { getServiceVersion } from "./parser/getServiceVersion" - -/** - * Parse the OpenAPI specification to a Client model that contains - * all the models, services and schema's we should output. - * @param openApi The OpenAPI spec that we have loaded from disk. - */ -export const parse = (openApi: OpenApi): Client => { - const version = getServiceVersion(openApi.info.version) - const server = getServer(openApi) - const models = getModels(openApi) - const services = getServices(openApi) - - return { version, server, models, services } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/Extensions/WithDefaultRelationsExtension.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/Extensions/WithDefaultRelationsExtension.d.ts deleted file mode 100644 index 9427a7ddc2..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/Extensions/WithDefaultRelationsExtension.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface WithExtendedRelationsExtension { - "x-expanded-relations"?: { - field: string - relations?: string[] - totals?: string[] - implicit?: string[] - eager?: string[] - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/Extensions/WithEnumExtension.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/Extensions/WithEnumExtension.d.ts deleted file mode 100644 index f11828f332..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/Extensions/WithEnumExtension.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface WithEnumExtension { - "x-enum-varnames"?: string[] - "x-enum-descriptions"?: string[] -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApi.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApi.d.ts deleted file mode 100644 index d5fb333dbb..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApi.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { OpenApiComponents } from "./OpenApiComponents" -import type { OpenApiExternalDocs } from "./OpenApiExternalDocs" -import type { OpenApiInfo } from "./OpenApiInfo" -import type { OpenApiPaths } from "./OpenApiPaths" -import type { OpenApiSecurityRequirement } from "./OpenApiSecurityRequirement" -import type { OpenApiServer } from "./OpenApiServer" -import type { OpenApiTag } from "./OpenApiTag" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md - */ -export interface OpenApi { - openapi: string - info: OpenApiInfo - servers?: OpenApiServer[] - paths: OpenApiPaths - components?: OpenApiComponents - security?: OpenApiSecurityRequirement[] - tags?: OpenApiTag[] - externalDocs?: OpenApiExternalDocs -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiCallback.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiCallback.d.ts deleted file mode 100644 index d3f8d0977d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiCallback.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { OpenApiPath } from "./OpenApiPath" -import type { OpenApiReference } from "./OpenApiReference" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#callbackObject - */ -export interface OpenApiCallback extends OpenApiReference { - [key: string]: OpenApiPath -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiComponents.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiComponents.d.ts deleted file mode 100644 index a1f9e8dc0d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiComponents.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Dictionary } from "../../../utils/types" -import type { OpenApiCallback } from "./OpenApiCallback" -import type { OpenApiExample } from "./OpenApiExample" -import type { OpenApiHeader } from "./OpenApiHeader" -import type { OpenApiLink } from "./OpenApiLink" -import type { OpenApiParameter } from "./OpenApiParameter" -import type { OpenApiRequestBody } from "./OpenApiRequestBody" -import type { OpenApiResponses } from "./OpenApiResponses" -import type { OpenApiSchema } from "./OpenApiSchema" -import type { OpenApiSecurityScheme } from "./OpenApiSecurityScheme" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#componentsObject - */ -export interface OpenApiComponents { - schemas?: Dictionary - responses?: Dictionary - parameters?: Dictionary - examples?: Dictionary - requestBodies?: Dictionary - headers?: Dictionary - securitySchemes?: Dictionary - links?: Dictionary - callbacks?: Dictionary -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiContact.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiContact.d.ts deleted file mode 100644 index a74658319b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiContact.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#contactObject - */ -export interface OpenApiContact { - name?: string - url?: string - email?: string -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiDiscriminator.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiDiscriminator.d.ts deleted file mode 100644 index 064e289e77..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiDiscriminator.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { Dictionary } from "../../../utils/types" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#discriminatorObject - */ -export interface OpenApiDiscriminator { - propertyName: string - mapping?: Dictionary -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiEncoding.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiEncoding.d.ts deleted file mode 100644 index eda5d4c0a4..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiEncoding.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Dictionary } from "../../../utils/types" -import type { OpenApiHeader } from "./OpenApiHeader" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#encodingObject - */ -export interface OpenApiEncoding { - contentType?: string - headers?: Dictionary - style?: string - explode?: boolean - allowReserved?: boolean -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiExample.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiExample.d.ts deleted file mode 100644 index 7f5f92db20..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiExample.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { OpenApiReference } from "./OpenApiReference" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#exampleObject - */ -export interface OpenApiExample extends OpenApiReference { - summary?: string - description?: string - value?: any - externalValue?: string -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiExternalDocs.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiExternalDocs.d.ts deleted file mode 100644 index b522ef272e..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiExternalDocs.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#externalDocumentationObject - */ -export interface OpenApiExternalDocs { - description?: string - url: string -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiHeader.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiHeader.d.ts deleted file mode 100644 index 470236351e..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiHeader.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { Dictionary } from "../../../utils/types" -import type { OpenApiExample } from "./OpenApiExample" -import type { OpenApiReference } from "./OpenApiReference" -import type { OpenApiSchema } from "./OpenApiSchema" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#headerObject - */ -export interface OpenApiHeader extends OpenApiReference { - description?: string - required?: boolean - deprecated?: boolean - allowEmptyValue?: boolean - style?: string - explode?: boolean - allowReserved?: boolean - schema?: OpenApiSchema - example?: any - examples?: Dictionary -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiInfo.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiInfo.d.ts deleted file mode 100644 index 25ace57a4e..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiInfo.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { OpenApiContact } from "./OpenApiContact" -import type { OpenApiLicense } from "./OpenApiLicense" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#infoObject - */ -export interface OpenApiInfo { - title: string - description?: string - termsOfService?: string - contact?: OpenApiContact - license?: OpenApiLicense - version: string -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiLicense.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiLicense.d.ts deleted file mode 100644 index e34ea2c14b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiLicense.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#licenseObject - */ -export interface OpenApiLicense { - name: string - url?: string -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiLink.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiLink.d.ts deleted file mode 100644 index 34428c5f84..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiLink.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { Dictionary } from "../../../utils/types" -import type { OpenApiReference } from "./OpenApiReference" -import type { OpenApiServer } from "./OpenApiServer" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#linkObject - */ -export interface OpenApiLink extends OpenApiReference { - operationRef?: string - operationId?: string - parameters?: Dictionary - requestBody?: any - description?: string - server?: OpenApiServer -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiMediaType.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiMediaType.d.ts deleted file mode 100644 index 5398c17cef..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiMediaType.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { Dictionary } from "../../../utils/types" -import type { OpenApiEncoding } from "./OpenApiEncoding" -import type { OpenApiExample } from "./OpenApiExample" -import type { OpenApiReference } from "./OpenApiReference" -import type { OpenApiSchema } from "./OpenApiSchema" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#mediaTypeObject - */ -export interface OpenApiMediaType extends OpenApiReference { - schema?: OpenApiSchema - example?: any - examples?: Dictionary - encoding?: Dictionary -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiOAuthFlow.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiOAuthFlow.d.ts deleted file mode 100644 index eaa7727bda..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiOAuthFlow.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { Dictionary } from "../../../utils/types" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#oauthFlowObject - */ -export interface OpenApiOAuthFlow { - authorizationUrl: string - tokenUrl: string - refreshUrl?: string - scopes: Dictionary -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiOAuthFlows.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiOAuthFlows.d.ts deleted file mode 100644 index f71f97976a..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiOAuthFlows.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { OpenApiOAuthFlow } from "./OpenApiOAuthFlow" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#oauthFlowsObject - */ -export interface OpenApiOAuthFlows { - implicit?: OpenApiOAuthFlow - password?: OpenApiOAuthFlow - clientCredentials?: OpenApiOAuthFlow - authorizationCode?: OpenApiOAuthFlow -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiOperation.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiOperation.d.ts deleted file mode 100644 index 8394025c68..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiOperation.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { Dictionary } from "../../../utils/types" -import type { OpenApiCallback } from "./OpenApiCallback" -import type { OpenApiExternalDocs } from "./OpenApiExternalDocs" -import type { OpenApiParameter } from "./OpenApiParameter" -import type { OpenApiRequestBody } from "./OpenApiRequestBody" -import type { OpenApiResponses } from "./OpenApiResponses" -import type { OpenApiSecurityRequirement } from "./OpenApiSecurityRequirement" -import type { OpenApiServer } from "./OpenApiServer" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#operationObject - */ -export interface OpenApiOperation { - tags?: string[] - summary?: string - description?: string - externalDocs?: OpenApiExternalDocs - operationId?: string - parameters?: OpenApiParameter[] - requestBody?: OpenApiRequestBody - responses: OpenApiResponses - callbacks?: Dictionary - deprecated?: boolean - security?: OpenApiSecurityRequirement[] - servers?: OpenApiServer[] - "x-codegen"?: Record -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiParameter.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiParameter.d.ts deleted file mode 100644 index cebe8a50e8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiParameter.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { Dictionary } from "../../../utils/types" -import type { OpenApiExample } from "./OpenApiExample" -import type { OpenApiReference } from "./OpenApiReference" -import type { OpenApiSchema } from "./OpenApiSchema" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterObject - */ -export interface OpenApiParameter extends OpenApiReference { - name: string - in: "path" | "query" | "header" | "formData" | "cookie" - description?: string - required?: boolean - nullable?: boolean - deprecated?: boolean - allowEmptyValue?: boolean - style?: string - explode?: boolean - allowReserved?: boolean - schema?: OpenApiSchema - example?: any - examples?: Dictionary -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiPath.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiPath.d.ts deleted file mode 100644 index 9b7cd5eaba..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiPath.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { OpenApiOperation } from "./OpenApiOperation" -import type { OpenApiParameter } from "./OpenApiParameter" -import type { OpenApiServer } from "./OpenApiServer" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#pathItemObject - */ -export interface OpenApiPath { - summary?: string - description?: string - get?: OpenApiOperation - put?: OpenApiOperation - post?: OpenApiOperation - delete?: OpenApiOperation - options?: OpenApiOperation - head?: OpenApiOperation - patch?: OpenApiOperation - trace?: OpenApiOperation - servers?: OpenApiServer[] - parameters?: OpenApiParameter[] -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiPaths.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiPaths.d.ts deleted file mode 100644 index 0e7f38e6d6..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiPaths.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { OpenApiPath } from "./OpenApiPath" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#pathsObject - */ -export interface OpenApiPaths { - [path: string]: OpenApiPath -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiReference.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiReference.d.ts deleted file mode 100644 index 86d809abb9..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiReference.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#referenceObject - */ -export interface OpenApiReference { - $ref?: string -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiRequestBody.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiRequestBody.d.ts deleted file mode 100644 index fe48187d2b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiRequestBody.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Dictionary } from "../../../utils/types" -import type { OpenApiMediaType } from "./OpenApiMediaType" -import type { OpenApiReference } from "./OpenApiReference" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#requestBodyObject - */ -export interface OpenApiRequestBody extends OpenApiReference { - description?: string - content: Dictionary - required?: boolean - nullable?: boolean -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiResponse.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiResponse.d.ts deleted file mode 100644 index 52e325c8f7..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiResponse.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { Dictionary } from "../../../utils/types" -import type { OpenApiHeader } from "./OpenApiHeader" -import type { OpenApiLink } from "./OpenApiLink" -import type { OpenApiMediaType } from "./OpenApiMediaType" -import type { OpenApiReference } from "./OpenApiReference" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responseObject - */ -export interface OpenApiResponse extends OpenApiReference { - description: string - headers?: Dictionary - content?: Dictionary - links?: Dictionary -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiResponses.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiResponses.d.ts deleted file mode 100644 index 6762ac6011..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiResponses.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { OpenApiReference } from "./OpenApiReference" -import type { OpenApiResponse } from "./OpenApiResponse" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responsesObject - */ -export interface OpenApiResponses extends OpenApiReference { - default?: OpenApiResponse - - [httpcode: string]: OpenApiResponse -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiSchema.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiSchema.d.ts deleted file mode 100644 index 279bc9ad5b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiSchema.d.ts +++ /dev/null @@ -1,62 +0,0 @@ -import type { Dictionary } from "../../../utils/types" -import type { WithEnumExtension } from "./Extensions/WithEnumExtension" -import type { OpenApiDiscriminator } from "./OpenApiDiscriminator" -import type { OpenApiExternalDocs } from "./OpenApiExternalDocs" -import type { OpenApiReference } from "./OpenApiReference" -import type { OpenApiXml } from "./OpenApiXml" -import { WithExtendedRelationsExtension } from "./Extensions/WithDefaultRelationsExtension" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schemaObject - */ -export interface OpenApiSchema - extends OpenApiReference, - WithEnumExtension, - WithExtendedRelationsExtension { - title?: string - multipleOf?: number - maximum?: number - exclusiveMaximum?: boolean - minimum?: number - exclusiveMinimum?: boolean - maxLength?: number - minLength?: number - pattern?: string - maxItems?: number - minItems?: number - uniqueItems?: boolean - maxProperties?: number - minProperties?: number - required?: string[] - enum?: (string | number)[] - type?: string | string[] - allOf?: OpenApiSchema[] - oneOf?: OpenApiSchema[] - anyOf?: OpenApiSchema[] - not?: OpenApiSchema[] - items?: OpenApiSchema - properties?: Dictionary - additionalProperties?: boolean | OpenApiSchema - description?: string - format?: - | "int32" - | "int64" - | "float" - | "double" - | "string" - | "boolean" - | "byte" - | "binary" - | "date" - | "date-time" - | "password" - default?: any - nullable?: boolean - discriminator?: OpenApiDiscriminator - readOnly?: boolean - writeOnly?: boolean - xml?: OpenApiXml - externalDocs?: OpenApiExternalDocs - example?: any - deprecated?: boolean -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiSecurityRequirement.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiSecurityRequirement.d.ts deleted file mode 100644 index a758cf9e0e..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiSecurityRequirement.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#securityRequirementObject - */ -export interface OpenApiSecurityRequirement { - [name: string]: string -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiSecurityScheme.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiSecurityScheme.d.ts deleted file mode 100644 index 99077dca74..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiSecurityScheme.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { OpenApiOAuthFlows } from "./OpenApiOAuthFlows" -import type { OpenApiReference } from "./OpenApiReference" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#securitySchemeObject - */ -export interface OpenApiSecurityScheme extends OpenApiReference { - type: "apiKey" | "http" | "oauth2" | "openIdConnect" - description?: string - name?: string - in?: "query" | "header" | "cookie" - scheme?: string - bearerFormat?: string - flows?: OpenApiOAuthFlows - openIdConnectUrl?: string -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiServer.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiServer.d.ts deleted file mode 100644 index 5c8dd73b30..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiServer.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { Dictionary } from "../../../utils/types" -import type { OpenApiServerVariable } from "./OpenApiServerVariable" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#serverObject - */ -export interface OpenApiServer { - url: string - description?: string - variables?: Dictionary -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiServerVariable.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiServerVariable.d.ts deleted file mode 100644 index 0daee96e55..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiServerVariable.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { WithEnumExtension } from "./Extensions/WithEnumExtension" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#serverVariableObject - */ -export interface OpenApiServerVariable extends WithEnumExtension { - enum?: (string | number)[] - default: string - description?: string -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiTag.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiTag.d.ts deleted file mode 100644 index e99dd6f7d8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiTag.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { OpenApiExternalDocs } from "./OpenApiExternalDocs" - -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#tagObject - */ -export interface OpenApiTag { - name: string - description?: string - externalDocs?: OpenApiExternalDocs -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiXml.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiXml.d.ts deleted file mode 100644 index 2e6ab8f8f2..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/interfaces/OpenApiXml.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#xmlObject - */ -export interface OpenApiXml { - name?: string - namespace?: string - prefix?: string - attribute?: boolean - wrapped?: boolean -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getModel.test.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getModel.test.ts deleted file mode 100644 index 1d8145e445..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getModel.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { getModel } from "../getModel" -import { OpenApi } from "../../interfaces/OpenApi" -import { Model } from "../../../../client/interfaces/Model" -import { OpenApiSchema } from "../../interfaces/OpenApiSchema" - -describe("getModel", () => { - let openApi: OpenApi - beforeEach(async () => { - openApi = { - openapi: "3.0.0", - info: { - title: "Test", - version: "1.0.0", - }, - paths: {}, - components: {}, - } - }) - - it("should set model spec with definition", () => { - const modelName = "OrderRes" - const definition: OpenApiSchema = { - type: "object", - properties: { - id: { - type: "string", - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - expect(model.spec).toEqual(definition) - }) - - it("should set property spec with definition", () => { - const modelName = "OrderRes" - const definition: OpenApiSchema = { - type: "object", - properties: { - order: { - type: "object", - properties: { - id: { - type: "string", - }, - }, - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - expect(model.properties[0].spec).toEqual(definition.properties!.order) - }) -}) diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getModels.test.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getModels.test.ts deleted file mode 100644 index cc0d1f20c9..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getModels.test.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { getModels } from "../getModels" -import { OpenApi } from "../../interfaces/OpenApi" - -describe("getModels", () => { - let openApi: OpenApi - beforeEach(async () => { - openApi = { - openapi: "3.0.0", - info: { - title: "Test", - version: "1.0.0", - }, - paths: {}, - components: {}, - } - }) - - it("should return an empty array if no models are found", () => { - const models = getModels(openApi) - expect(models).toEqual([]) - }) - - it("should return an array of models", () => { - openApi.components = { - schemas: { - OrderRes: { - type: "object", - properties: { - id: { - type: "string", - }, - }, - }, - }, - } - const models = getModels(openApi) - expect(models).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - name: "OrderRes", - properties: expect.arrayContaining([ - expect.objectContaining({ - name: "id", - type: "string", - }), - ]), - }), - ]) - ) - }) - - it("should return an array of models with expanded relations", () => { - openApi.components = { - schemas: { - OrderRes: { - type: "object", - "x-expanded-relations": { - field: "order", - relations: ["region", "region.country"], - }, - properties: { - order: { - $ref: "#/components/schemas/Order", - }, - }, - }, - Order: { - type: "object", - properties: { - region: { - $ref: "#/components/schemas/Region", - }, - }, - }, - Region: { - type: "object", - properties: { - country: { - $ref: "#/components/schemas/Country", - }, - }, - }, - Country: { - type: "object", - }, - }, - } - const models = getModels(openApi) - expect(models).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - name: "OrderRes", - properties: expect.arrayContaining([ - expect.objectContaining({ - name: "order", - base: "Order", - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - base: "Order", - field: "order", - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - field: "region", - base: "Region", - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - base: "Country", - field: "country", - nestedRelations: [], - }), - ]), - }), - ]), - }), - ]), - }), - ]), - }), - ]) - ) - }) - - it("should convert query parameters into a schema when x-codegen.queryParams is declared", () => { - openApi.paths = { - "/": { - get: { - operationId: "GetOrder", - "x-codegen": { - queryParams: "GetOrderQueryParams", - }, - parameters: [ - { - description: "Limit the number of results", - in: "query", - name: "limit", - schema: { - type: "integer", - }, - required: true, - deprecated: true, - }, - ], - responses: { - "200": { - description: "OK", - }, - }, - }, - }, - } - const models = getModels(openApi) - expect(models).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - name: "GetOrderQueryParams", - properties: expect.arrayContaining([ - expect.objectContaining({ - description: "Limit the number of results", - name: "limit", - type: "number", - isRequired: true, - deprecated: true, - }), - ]), - }), - ]) - ) - }) -}) diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getModelsExpandedRelations.test.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getModelsExpandedRelations.test.ts deleted file mode 100644 index 26e1530440..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getModelsExpandedRelations.test.ts +++ /dev/null @@ -1,436 +0,0 @@ -import { Model } from "../../../../client/interfaces/Model" -import { handleExpandedRelations } from "../getModelsExpandedRelations" -import { getModel } from "../getModel" -import { OpenApi } from "../../interfaces/OpenApi" -import { OpenApiSchema } from "../../interfaces/OpenApiSchema" -import { getType } from "../getType" - -function getModelsTest(openApi: OpenApi): Model[] { - const models: Model[] = [] - if (openApi.components) { - for (const definitionName in openApi.components.schemas) { - if (openApi.components.schemas.hasOwnProperty(definitionName)) { - const definition = openApi.components.schemas[definitionName] - const definitionType = getType(definitionName) - const model = getModel(openApi, definition, true, definitionType.base) - models.push(model) - } - } - } - return models -} - -describe("getModelsExpandedRelations", () => { - let openApi: OpenApi - beforeEach(async () => { - openApi = { - openapi: "3.0.0", - info: { - title: "Test", - version: "1.0.0", - }, - paths: {}, - components: { - schemas: { - Order: { - type: "object", - properties: { - region: { - $ref: "#/components/schemas/Region", - }, - total: { - type: "number", - }, - }, - }, - Region: { - type: "object", - properties: { - country: { - $ref: "#/components/schemas/Country", - }, - }, - }, - Country: { - type: "object", - }, - Customer: { - type: "object", - properties: { - orders: { - type: "array", - items: { - $ref: "#/components/schemas/Order", - }, - }, - }, - }, - }, - }, - } - }) - - describe("basic use cases", () => { - it("should find nested relation - model", () => { - const modelName: string = "OrderRes" - const definition: OpenApiSchema = { - type: "object", - "x-expanded-relations": { - field: "order", - relations: ["region"], - }, - properties: { - order: { - $ref: "#/components/schemas/Order", - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - const models: Model[] = [...getModelsTest(openApi), model] - - handleExpandedRelations(model, models) - - expect(model.properties[0].nestedRelations).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - field: "order", - base: "Order", - isArray: false, - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - field: "region", - base: "Region", - isArray: false, - nestedRelations: [], - }), - ]), - }), - ]) - ) - }) - - it("should find nested relation - shallow", () => { - const modelName: string = "OrderRes" - const definition: OpenApiSchema = { - type: "object", - "x-expanded-relations": { - field: "order", - relations: ["total"], - }, - properties: { - order: { - $ref: "#/components/schemas/Order", - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - const models: Model[] = [...getModelsTest(openApi), model] - - handleExpandedRelations(model, models) - - expect(model.properties[0].nestedRelations).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - field: "order", - base: "Order", - isArray: false, - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - field: "total", - nestedRelations: [], - }), - ]), - }), - ]) - ) - }) - - it("should find nested relation - array", () => { - const modelName: string = "CustomerRes" - const definition: OpenApiSchema = { - type: "object", - "x-expanded-relations": { - field: "customer", - relations: ["orders"], - }, - properties: { - customer: { - $ref: "#/components/schemas/Customer", - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - const models: Model[] = [...getModelsTest(openApi), model] - - handleExpandedRelations(model, models) - - expect(model.properties[0].nestedRelations).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - field: "customer", - base: "Customer", - isArray: false, - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - field: "orders", - base: "Order", - isArray: true, - nestedRelations: [], - }), - ]), - }), - ]) - ) - }) - }) - - describe("misc usage", () => { - it.each([["allOf"], ["anyOf"], ["oneOf"]])( - "should findPropInCombination - %s", - (combination) => { - openApi.components!.schemas!.ExpandedOrder = { - [combination]: [{ $ref: "#/components/schemas/Order" }], - } - const modelName: string = "OrderRes" - const definition: OpenApiSchema = { - type: "object", - "x-expanded-relations": { - field: "order", - relations: ["region"], - }, - properties: { - order: { - $ref: "#/components/schemas/ExpandedOrder", - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - const models: Model[] = [...getModelsTest(openApi), model] - - handleExpandedRelations(model, models) - - expect(model.properties[0].nestedRelations).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - field: "region", - }), - ]), - }), - ]) - ) - } - ) - - it.each([["relations"], ["totals"], ["implicit"], ["eager"]])( - "should find nested relation with relation type - %s", - (relationType) => { - const modelName: string = "OrderRes" - const definition: OpenApiSchema = { - type: "object", - "x-expanded-relations": { - field: "order", - [relationType]: ["region"], - }, - properties: { - order: { - $ref: "#/components/schemas/Order", - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - const models: Model[] = [...getModelsTest(openApi), model] - - handleExpandedRelations(model, models) - - expect(model.properties[0].nestedRelations).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - field: "region", - }), - ]), - }), - ]) - ) - } - ) - - it("should set field hasDepth - true", () => { - const modelName: string = "OrderRes" - const definition: OpenApiSchema = { - type: "object", - "x-expanded-relations": { - field: "order", - relations: ["region.country"], - }, - properties: { - order: { - $ref: "#/components/schemas/Order", - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - const models: Model[] = [...getModelsTest(openApi), model] - - handleExpandedRelations(model, models) - - expect(model.properties[0].nestedRelations).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - hasDepth: true, - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - field: "region", - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - field: "country", - }), - ]), - }), - ]), - }), - ]) - ) - }) - - it("should set relation hasDepth - true", () => { - const modelName: string = "CustomerRes" - const definition: OpenApiSchema = { - type: "object", - "x-expanded-relations": { - field: "customer", - relations: ["orders.region.country"], - }, - properties: { - customer: { - $ref: "#/components/schemas/Customer", - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - const models: Model[] = [...getModelsTest(openApi), model] - - handleExpandedRelations(model, models) - - expect(model.properties[0].nestedRelations).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - hasDepth: true, - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - field: "orders", - hasDepth: true, - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - field: "region", - nestedRelations: expect.arrayContaining([ - expect.objectContaining({ - field: "country", - nestedRelations: [], - }), - ]), - }), - ]), - }), - ]), - }), - ]) - ) - }) - - it("should add models with relation to root model imports, only once", () => { - const modelName: string = "OrderRes" - const definition: OpenApiSchema = { - type: "object", - "x-expanded-relations": { - field: "order", - relations: ["region", "region.country"], - }, - properties: { - order: { - $ref: "#/components/schemas/Order", - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - const models: Model[] = [...getModelsTest(openApi), model] - - handleExpandedRelations(model, models) - - expect(model.imports).toEqual(expect.arrayContaining(["Order", "Region"])) - }) - }) - - describe("errors", () => { - it("should throw if field is not found", () => { - const modelName: string = "OrderRes" - const definition: OpenApiSchema = { - type: "object", - "x-expanded-relations": { - field: "nope", - }, - properties: { - order: { - $ref: "#/components/schemas/Order", - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - const models: Model[] = [...getModelsTest(openApi), model] - - expect(() => handleExpandedRelations(model, models)).toThrow( - "x-expanded-relations - field not found" - ) - }) - - it("should throw if relation is not found", () => { - const modelName: string = "OrderRes" - const definition: OpenApiSchema = { - type: "object", - "x-expanded-relations": { - field: "order", - relations: ["nope"], - }, - properties: { - order: { - $ref: "#/components/schemas/Order", - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - const models: Model[] = [...getModelsTest(openApi), model] - - expect(() => handleExpandedRelations(model, models)).toThrow( - "x-expanded-relations - relation not found" - ) - }) - - it.each([["allOf"], ["anyOf"], ["oneOf"]])( - "should throw if field exports as a combination - %s", - (combination) => { - const modelName: string = "OrderRes" - const definition: OpenApiSchema = { - type: "object", - "x-expanded-relations": { - field: "order", - relations: ["region"], - }, - properties: { - order: { - [combination]: [{ $ref: "#/components/schemas/Order" }], - }, - }, - } - const model: Model = getModel(openApi, definition, true, modelName) - const models: Model[] = [...getModelsTest(openApi), model] - - expect(() => handleExpandedRelations(model, models)).toThrow( - "x-expanded-relations - unsupported - field referencing multiple models" - ) - } - ) - }) -}) diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getOperation.test.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getOperation.test.ts deleted file mode 100644 index e43767aa99..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getOperation.test.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { OpenApi } from "../../interfaces/OpenApi" -import { OpenApiOperation } from "../../interfaces/OpenApiOperation" -import { getOperation } from "../getOperation" -import { getOperationParameters } from "../getOperationParameters" - -describe("getOperation", () => { - let openApi: OpenApi - beforeEach(async () => { - openApi = { - openapi: "3.0.0", - info: { - title: "Test", - version: "1.0.0", - }, - paths: {}, - components: {}, - } - }) - - it("should parse x-codegen", () => { - const op: OpenApiOperation = { - "x-codegen": { - method: "list", - }, - responses: { - "200": { - description: "OK", - }, - }, - } - const pathParams = getOperationParameters(openApi, []) - const operation = getOperation( - openApi, - "/orders", - "get", - "Orders", - op, - pathParams - ) - expect(operation).toEqual( - expect.objectContaining({ - codegen: { method: "list" }, - }) - ) - }) - - it("should add x-codegen.queryParams to imports", () => { - const op: OpenApiOperation = { - "x-codegen": { - queryParams: "OrdersQueryParams", - }, - responses: { - "200": { - description: "OK", - }, - }, - } - const pathParams = getOperationParameters(openApi, []) - const operation = getOperation( - openApi, - "/orders", - "get", - "Orders", - op, - pathParams - ) - expect(operation.imports).toEqual( - expect.arrayContaining(["OrdersQueryParams"]) - ) - }) -}) diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getOperationParameter.test.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getOperationParameter.test.ts deleted file mode 100644 index 5dbee71fab..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getOperationParameter.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { OpenApi } from "../../interfaces/OpenApi" -import { getOperationParameter } from "../getOperationParameter" -import { OpenApiParameter } from "../../interfaces/OpenApiParameter" - -describe("getOperation", () => { - let openApi: OpenApi - beforeEach(async () => { - openApi = { - openapi: "3.0.0", - info: { - title: "Test", - version: "1.0.0", - }, - paths: {}, - components: {}, - } - }) - - it("should set spec with definition", () => { - const parameter: OpenApiParameter = { - name: "id", - in: "path", - } - const operationParameter = getOperationParameter(openApi, parameter) - expect(operationParameter.spec).toEqual(parameter) - }) -}) diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getOperationRequestBody.test.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getOperationRequestBody.test.ts deleted file mode 100644 index e36ace4014..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getOperationRequestBody.test.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { OpenApi } from "../../interfaces/OpenApi" -import { getOperationRequestBody } from "../getOperationRequestBody" -import { OpenApiRequestBody } from "../../interfaces/OpenApiRequestBody" - -describe("getOperation", () => { - let openApi: OpenApi - beforeEach(async () => { - openApi = { - openapi: "3.0.0", - info: { - title: "Test", - version: "1.0.0", - }, - paths: {}, - components: {}, - } - }) - - it("should set spec with definition", () => { - const body: OpenApiRequestBody = { - content: { - "application/json": { - schema: { - type: "object", - properties: { - id: { - type: "string", - }, - }, - }, - }, - }, - } - const operationRequestBody = getOperationRequestBody(openApi, body) - expect(operationRequestBody.spec).toEqual(body) - }) -}) diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getOperationResponse.test.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getOperationResponse.test.ts deleted file mode 100644 index da3f52b43d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/__tests__/getOperationResponse.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { OpenApi } from "../../interfaces/OpenApi" -import { getOperationResponse } from "../getOperationResponse" -import { OpenApiResponse } from "../../interfaces/OpenApiResponse" - -describe("getOperation", () => { - let openApi: OpenApi - beforeEach(async () => { - openApi = { - openapi: "3.0.0", - info: { - title: "Test", - version: "1.0.0", - }, - paths: {}, - components: {}, - } - }) - - it("should set spec with definition", () => { - const response: OpenApiResponse = { - description: "OK", - } - const operationResponse = getOperationResponse(openApi, response, 200) - expect(operationResponse.spec).toEqual(response) - }) -}) diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/escapeName.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/escapeName.ts deleted file mode 100644 index 0de7ab211b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/escapeName.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const escapeName = (value: string): string => { - if (value || value === "") { - const validName = /^[a-zA-Z_$][\w$]+$/g.test(value) - if (!validName) { - return `'${value}'` - } - } - return value -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/extendEnum.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/extendEnum.ts deleted file mode 100644 index 5f9c46da9c..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/extendEnum.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { Enum } from "../../../client/interfaces/Enum" -import { isString } from "../../../utils/isString" -import type { WithEnumExtension } from "../interfaces/Extensions/WithEnumExtension" - -/** - * Extend the enum with the x-enum properties. This adds the capability - * to use names and descriptions inside the generated enums. - * @param enumerators - * @param definition - */ -export const extendEnum = ( - enumerators: Enum[], - definition: WithEnumExtension -): Enum[] => { - const names = definition["x-enum-varnames"]?.filter(isString) - const descriptions = definition["x-enum-descriptions"]?.filter(isString) - - return enumerators.map((enumerator, index) => ({ - name: names?.[index] || enumerator.name, - description: descriptions?.[index] || enumerator.description, - value: enumerator.value, - type: enumerator.type, - })) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getContent.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getContent.ts deleted file mode 100644 index 83869c28c0..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getContent.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { isDefined } from "../../../utils/isDefined" -import type { Dictionary } from "../../../utils/types" -import type { OpenApi } from "../interfaces/OpenApi" -import type { OpenApiMediaType } from "../interfaces/OpenApiMediaType" -import type { OpenApiSchema } from "../interfaces/OpenApiSchema" - -export interface Content { - mediaType: string - schema: OpenApiSchema -} - -const BASIC_MEDIA_TYPES = [ - "application/json-patch+json", - "application/json", - "application/x-www-form-urlencoded", - "text/json", - "text/plain", - "multipart/form-data", - "multipart/mixed", - "multipart/related", - "multipart/batch", -] - -export const getContent = ( - openApi: OpenApi, - content: Dictionary -): Content | null => { - const basicMediaTypeWithSchema = Object.keys(content) - .filter((mediaType) => { - const cleanMediaType = mediaType.split(";")[0].trim() - return BASIC_MEDIA_TYPES.includes(cleanMediaType) - }) - .find((mediaType) => isDefined(content[mediaType]?.schema)) - if (basicMediaTypeWithSchema) { - return { - mediaType: basicMediaTypeWithSchema, - schema: content[basicMediaTypeWithSchema].schema as OpenApiSchema, - } - } - - const firstMediaTypeWithSchema = Object.keys(content).find((mediaType) => - isDefined(content[mediaType]?.schema) - ) - if (firstMediaTypeWithSchema) { - return { - mediaType: firstMediaTypeWithSchema, - schema: content[firstMediaTypeWithSchema].schema as OpenApiSchema, - } - } - return null -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getEnum.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getEnum.ts deleted file mode 100644 index 7c7942a5d6..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getEnum.ts +++ /dev/null @@ -1,34 +0,0 @@ -import type { Enum } from "../../../client/interfaces/Enum" - -export const getEnum = (values?: (string | number)[]): Enum[] => { - if (Array.isArray(values)) { - return values - .filter((value, index, arr) => { - return arr.indexOf(value) === index - }) - .filter((value: any) => { - return typeof value === "number" || typeof value === "string" - }) - .map((value) => { - if (typeof value === "number") { - return { - name: `'_${value}'`, - value: String(value), - type: "number", - description: null, - } - } - return { - name: String(value) - .replace(/\W+/g, "_") - .replace(/^(\d+)/g, "_$1") - .replace(/([a-z])([A-Z]+)/g, "$1_$2") - .toUpperCase(), - value: `'${value.replace(/'/g, "\\'")}'`, - type: "string", - description: null, - } - }) - } - return [] -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getMappedType.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getMappedType.ts deleted file mode 100644 index 38f5cf5fab..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getMappedType.ts +++ /dev/null @@ -1,35 +0,0 @@ -const TYPE_MAPPINGS = new Map([ - ["file", "binary"], - ["any", "any"], - ["object", "any"], - ["array", "any[]"], - ["boolean", "boolean"], - ["byte", "number"], - ["int", "number"], - ["integer", "number"], - ["float", "number"], - ["double", "number"], - ["short", "number"], - ["long", "number"], - ["number", "number"], - ["char", "string"], - ["date", "string"], - ["date-time", "string"], - ["password", "string"], - ["string", "string"], - ["void", "void"], - ["null", "null"], -]) - -/** - * Get mapped type for given type to any basic Typescript/Javascript type. - */ -export const getMappedType = ( - type: string, - format?: string -): string | undefined => { - if (format === "binary") { - return "binary" - } - return TYPE_MAPPINGS.get(type) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModel.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModel.ts deleted file mode 100644 index 88867dd38a..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModel.ts +++ /dev/null @@ -1,224 +0,0 @@ -import type { Model } from "../../../client/interfaces/Model" -import { getPattern } from "../../../utils/getPattern" -import type { OpenApi } from "../interfaces/OpenApi" -import type { OpenApiSchema } from "../interfaces/OpenApiSchema" -import { extendEnum } from "./extendEnum" -import { getEnum } from "./getEnum" -import { getModelComposition } from "./getModelComposition" -import { getModelDefault } from "./getModelDefault" -import { getModelProperties } from "./getModelProperties" -import { getType } from "./getType" - -export const getModel = ( - openApi: OpenApi, - definition: OpenApiSchema, - isDefinition: boolean = false, - name: string = "" -): Model => { - const model: Model = { - spec: definition, - name, - export: "interface", - type: "any", - base: "any", - template: null, - link: null, - description: definition.description || null, - deprecated: definition.deprecated === true, - isDefinition, - isReadOnly: definition.readOnly === true, - isNullable: definition.nullable === true, - isRequired: false, - format: definition.format, - maximum: definition.maximum, - exclusiveMaximum: definition.exclusiveMaximum, - minimum: definition.minimum, - exclusiveMinimum: definition.exclusiveMinimum, - multipleOf: definition.multipleOf, - maxLength: definition.maxLength, - minLength: definition.minLength, - maxItems: definition.maxItems, - minItems: definition.minItems, - uniqueItems: definition.uniqueItems, - maxProperties: definition.maxProperties, - minProperties: definition.minProperties, - pattern: getPattern(definition.pattern), - imports: [], - enum: [], - enums: [], - properties: [], - } - - if (definition.$ref) { - const definitionRef = getType(definition.$ref) - model.export = "reference" - model.type = definitionRef.type - model.base = definitionRef.base - model.template = definitionRef.template - model.imports.push(...definitionRef.imports) - model.default = getModelDefault(definition, model) - return model - } - - if (definition.enum && definition.type !== "boolean") { - const enumerators = getEnum(definition.enum) - const extendedEnumerators = extendEnum(enumerators, definition) - if (extendedEnumerators.length) { - model.export = "enum" - model.type = "string" - model.base = "string" - model.enum.push(...extendedEnumerators) - model.default = getModelDefault(definition, model) - return model - } - } - - if (definition.type === "array" && definition.items) { - if (definition.items.$ref) { - const arrayItems = getType(definition.items.$ref) - model.export = "array" - model.type = arrayItems.type - model.base = arrayItems.base - model.template = arrayItems.template - model.imports.push(...arrayItems.imports) - model.default = getModelDefault(definition, model) - return model - } else { - const arrayItems = getModel(openApi, definition.items) - model.export = "array" - model.type = arrayItems.type - model.base = arrayItems.base - model.template = arrayItems.template - model.link = arrayItems - model.imports.push(...arrayItems.imports) - model.default = getModelDefault(definition, model) - return model - } - } - - if ( - definition.type === "object" && - (typeof definition.additionalProperties === "object" || - definition.additionalProperties === true) - ) { - const ap = - typeof definition.additionalProperties === "object" - ? definition.additionalProperties - : {} - if (ap.$ref) { - const additionalProperties = getType(ap.$ref) - model.export = "dictionary" - model.type = additionalProperties.type - model.base = additionalProperties.base - model.template = additionalProperties.template - model.imports.push(...additionalProperties.imports) - model.default = getModelDefault(definition, model) - return model - } else { - const additionalProperties = getModel(openApi, ap) - model.export = "dictionary" - model.type = additionalProperties.type - model.base = additionalProperties.base - model.template = additionalProperties.template - model.link = additionalProperties - model.imports.push(...additionalProperties.imports) - model.default = getModelDefault(definition, model) - return model - } - } - - if (definition.oneOf?.length) { - const composition = getModelComposition( - openApi, - definition, - definition.oneOf, - "one-of", - getModel - ) - model.export = composition.type - model.imports.push(...composition.imports) - model.properties.push(...composition.properties) - model.enums.push(...composition.enums) - return model - } - - if (definition.anyOf?.length) { - const composition = getModelComposition( - openApi, - definition, - definition.anyOf, - "any-of", - getModel - ) - model.export = composition.type - model.imports.push(...composition.imports) - model.properties.push(...composition.properties) - model.enums.push(...composition.enums) - return model - } - - if (definition.allOf?.length) { - const composition = getModelComposition( - openApi, - definition, - definition.allOf, - "all-of", - getModel - ) - model.export = composition.type - model.imports.push(...composition.imports) - model.properties.push(...composition.properties) - model.enums.push(...composition.enums) - return model - } - - if (definition.type === "object") { - if (definition.properties) { - model.export = "interface" - model.type = "any" - model.base = "any" - model.default = getModelDefault(definition, model) - - const modelProperties = getModelProperties( - openApi, - definition, - getModel, - model - ) - modelProperties.forEach((modelProperty) => { - model.imports.push(...modelProperty.imports) - model.enums.push(...modelProperty.enums) - model.properties.push(modelProperty) - if (modelProperty.export === "enum") { - model.enums.push(modelProperty) - } - }) - return model - } else { - const additionalProperties = getModel(openApi, {}) - model.export = "dictionary" - model.type = additionalProperties.type - model.base = additionalProperties.base - model.template = additionalProperties.template - model.link = additionalProperties - model.imports.push(...additionalProperties.imports) - model.default = getModelDefault(definition, model) - return model - } - } - - // If the schema has a type than it can be a basic or generic type. - if (definition.type) { - const definitionType = getType(definition.type, definition.format) - model.export = "generic" - model.type = definitionType.type - model.base = definitionType.base - model.template = definitionType.template - model.isNullable = definitionType.isNullable || model.isNullable - model.imports.push(...definitionType.imports) - model.default = getModelDefault(definition, model) - return model - } - - return model -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelComposition.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelComposition.ts deleted file mode 100644 index 2ff0f9cd4f..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelComposition.ts +++ /dev/null @@ -1,92 +0,0 @@ -import type { Model } from "../../../client/interfaces/Model" -import type { ModelComposition } from "../../../client/interfaces/ModelComposition" -import type { OpenApi } from "../interfaces/OpenApi" -import type { OpenApiSchema } from "../interfaces/OpenApiSchema" -import type { getModel } from "./getModel" -import { getModelProperties } from "./getModelProperties" -import { getRequiredPropertiesFromComposition } from "./getRequiredPropertiesFromComposition" - -// Fix for circular dependency -export type GetModelFn = typeof getModel - -export const getModelComposition = ( - openApi: OpenApi, - definition: OpenApiSchema, - definitions: OpenApiSchema[], - type: "one-of" | "any-of" | "all-of", - getModel: GetModelFn -): ModelComposition => { - const composition: ModelComposition = { - type, - imports: [], - enums: [], - properties: [], - } - - const properties: Model[] = [] - - definitions - .map((definition) => getModel(openApi, definition)) - .filter((model) => { - const hasProperties = model.properties.length - const hasEnums = model.enums.length - const isObject = model.type === "any" - const isDictionary = model.export === "dictionary" - const isEmpty = isObject && !hasProperties && !hasEnums - return !isEmpty || isDictionary - }) - .forEach((model) => { - composition.imports.push(...model.imports) - composition.enums.push(...model.enums) - composition.properties.push(model) - }) - - if (definition.required) { - const requiredProperties = getRequiredPropertiesFromComposition( - openApi, - definition.required, - definitions, - getModel - ) - requiredProperties.forEach((requiredProperty) => { - composition.imports.push(...requiredProperty.imports) - composition.enums.push(...requiredProperty.enums) - }) - properties.push(...requiredProperties) - } - - if (definition.properties) { - const modelProperties = getModelProperties(openApi, definition, getModel) - modelProperties.forEach((modelProperty) => { - composition.imports.push(...modelProperty.imports) - composition.enums.push(...modelProperty.enums) - if (modelProperty.export === "enum") { - composition.enums.push(modelProperty) - } - }) - properties.push(...modelProperties) - } - - if (properties.length) { - composition.properties.push({ - spec: definition, - name: "properties", - export: "interface", - type: "any", - base: "any", - template: null, - link: null, - description: "", - isDefinition: false, - isReadOnly: false, - isNullable: false, - isRequired: false, - imports: [], - enum: [], - enums: [], - properties, - }) - } - - return composition -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelDefault.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelDefault.ts deleted file mode 100644 index 55e1b79c8b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelDefault.ts +++ /dev/null @@ -1,42 +0,0 @@ -import type { Model } from "../../../client/interfaces/Model" -import type { OpenApiSchema } from "../interfaces/OpenApiSchema" - -export const getModelDefault = ( - definition: OpenApiSchema, - model?: Model -): string | undefined => { - if (definition.default === undefined) { - return undefined - } - - if (definition.default === null) { - return "null" - } - - const type = definition.type || typeof definition.default - - switch (type) { - case "int": - case "integer": - case "number": - if (model?.export === "enum" && model.enum?.[definition.default]) { - return model.enum[definition.default].value - } - return definition.default - - case "boolean": - return JSON.stringify(definition.default) - - case "string": - return `'${definition.default}'` - - case "object": - try { - return JSON.stringify(definition.default, null, 4) - } catch (e) { - // Ignore - } - } - - return undefined -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelProperties.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelProperties.ts deleted file mode 100644 index 90916458d3..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelProperties.ts +++ /dev/null @@ -1,112 +0,0 @@ -import type { Model } from "../../../client/interfaces/Model" -import { - findOneOfParentDiscriminator, - mapPropertyValue, -} from "../../../utils/discriminator" -import { getPattern } from "../../../utils/getPattern" -import type { OpenApi } from "../interfaces/OpenApi" -import type { OpenApiSchema } from "../interfaces/OpenApiSchema" -import { escapeName } from "./escapeName" -import type { getModel } from "./getModel" -import { getType } from "./getType" - -// Fix for circular dependency -export type GetModelFn = typeof getModel - -export const getModelProperties = ( - openApi: OpenApi, - definition: OpenApiSchema, - getModel: GetModelFn, - parent?: Model -): Model[] => { - const models: Model[] = [] - const discriminator = findOneOfParentDiscriminator(openApi, parent) - for (const propertyName in definition.properties) { - if (definition.properties.hasOwnProperty(propertyName)) { - const property = definition.properties[propertyName] - const propertyRequired = !!definition.required?.includes(propertyName) - const propertyValues: Omit< - Model, - | "export" - | "type" - | "base" - | "template" - | "link" - | "isNullable" - | "imports" - | "enum" - | "enums" - | "properties" - > = { - spec: property, - name: escapeName(propertyName), - description: property.description || null, - deprecated: property.deprecated === true, - isDefinition: false, - isReadOnly: property.readOnly === true, - isRequired: propertyRequired, - format: property.format, - maximum: property.maximum, - exclusiveMaximum: property.exclusiveMaximum, - minimum: property.minimum, - exclusiveMinimum: property.exclusiveMinimum, - multipleOf: property.multipleOf, - maxLength: property.maxLength, - minLength: property.minLength, - maxItems: property.maxItems, - minItems: property.minItems, - uniqueItems: property.uniqueItems, - maxProperties: property.maxProperties, - minProperties: property.minProperties, - pattern: getPattern(property.pattern), - } - if (parent && discriminator?.propertyName == propertyName) { - models.push({ - export: "reference", - type: "string", - base: `'${mapPropertyValue(discriminator, parent)}'`, - template: null, - isNullable: property.nullable === true, - link: null, - imports: [], - enum: [], - enums: [], - properties: [], - ...propertyValues, - }) - } else if (property.$ref) { - const model = getType(property.$ref) - models.push({ - export: "reference", - type: model.type, - base: model.base, - template: model.template, - link: null, - isNullable: model.isNullable || property.nullable === true, - imports: model.imports, - enum: [], - enums: [], - properties: [], - ...propertyValues, - }) - } else { - const model = getModel(openApi, property) - models.push({ - export: model.export, - type: model.type, - base: model.base, - template: model.template, - link: model.link, - isNullable: model.isNullable || property.nullable === true, - imports: model.imports, - enum: model.enum, - enums: model.enums, - properties: model.properties, - ...propertyValues, - }) - } - } - } - - return models -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelTemplate.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelTemplate.ts deleted file mode 100644 index 85a5f5b8ce..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelTemplate.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { Type } from "../../../client/interfaces/Type" - -/** - * If our model has a template type, then we want to generalize that! - * In that case we should return "" as our template type. - * @param modelClass The parsed model class type. - * @returns The model template type ( or empty). - */ -export const getModelTemplate = (modelClass: Type): string => { - return modelClass.template ? "" : "" -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModels.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModels.ts deleted file mode 100644 index 4c37dd8a1c..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModels.ts +++ /dev/null @@ -1,117 +0,0 @@ -import type { Model } from "../../../client/interfaces/Model" -import type { OpenApi } from "../interfaces/OpenApi" -import { getModel } from "./getModel" -import { reservedWords } from "./getOperationParameterName" -import { getType } from "./getType" -import { OperationParameter } from "../../../client/interfaces/OperationParameter" -import { OpenApiSchema } from "../interfaces/OpenApiSchema" -import { Dictionary } from "../../../utils/types" -import { OpenApiParameter } from "../interfaces/OpenApiParameter" -import { listOperations } from "./listOperations" -import { handleExpandedRelations } from "./getModelsExpandedRelations" - -export const getModels = (openApi: OpenApi): Model[] => { - const models: Model[] = [] - if (openApi.components) { - for (const definitionName in openApi.components.schemas) { - if (openApi.components.schemas.hasOwnProperty(definitionName)) { - const definition = openApi.components.schemas[definitionName] - const definitionType = getType(definitionName) - const model = getModel( - openApi, - definition, - true, - definitionType.base.replace(reservedWords, "_$1") - ) - models.push(model) - } - } - } - - for (const model of models) { - handleExpandedRelations(model, models) - } - - /** - * Bundle all query parameters in a single typed object - * when x-codegen.queryParams is declared on the operation. - */ - const operations = listOperations(openApi) - for (const operation of operations) { - if (operation.codegen.queryParams) { - const definition = getDefinitionFromParametersQuery( - operation.parametersQuery - ) - const model = getModel( - openApi, - definition, - true, - operation.codegen.queryParams - ) - models.push(model) - } - } - - return models -} - -/** - * Combines and converts query parameters into schema properties. - * Given a typical parameter OAS: - * ``` - * parameters: - * - in: query - * name: limit - * schema: - * type: integer - * default: 10 - * required: true - * description: Limit the number of results returned. - * ``` - * Convert into a schema property: - * ``` - * UnnamedSchema: - * type: object - * required: - * - limit - * properties: - * limit: - * description: Limit the number of results returned. - * type: integer - * default: 10 - * ``` - */ -const getDefinitionFromParametersQuery = ( - parametersQuery: OperationParameter[] -): OpenApiSchema => { - /** - * Identify query parameters that are required (non-optional). - */ - const required = parametersQuery - .filter((parameter) => (parameter.spec as OpenApiParameter).required) - .map((parameter) => (parameter.spec as OpenApiParameter).name) - - const properties: Dictionary = {} - for (const parameter of parametersQuery) { - const spec = parameter.spec as OpenApiParameter - /** - * Augment a copy of schema with description and deprecated - * and assign it as a named property on the schema. - */ - properties[spec.name] = Object.assign( - { ...spec.schema }, - { - description: spec.description, - deprecated: spec.deprecated, - } - ) - } - /** - * Return an unnamed schema definition. - */ - return { - type: "object", - required, - properties, - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelsExpandedRelations.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelsExpandedRelations.ts deleted file mode 100644 index c790789d7c..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getModelsExpandedRelations.ts +++ /dev/null @@ -1,156 +0,0 @@ -import { Model, NestedRelation } from "../../../client/interfaces/Model" - -export const handleExpandedRelations = (model: Model, allModels: Model[]) => { - const xExpandedRelation = model.spec["x-expanded-relations"] - if (!xExpandedRelation) { - return - } - const field = xExpandedRelation.field - const relations = xExpandedRelation.relations ?? [] - const totals = xExpandedRelation.totals ?? [] - const implicit = xExpandedRelation.implicit ?? [] - const eager = xExpandedRelation.eager ?? [] - - const nestedRelation: NestedRelation = { - field, - nestedRelations: [], - } - - for (const relation of [...relations, ...totals, ...implicit, ...eager]) { - const splitRelation = relation.split(".") - walkSplitRelations(nestedRelation, splitRelation, 0) - } - - const prop = getPropertyByName(nestedRelation.field, model) - if (!prop) { - throw new Error(`x-expanded-relations - field not found - Schema: ${model.name} - NestedRelation: ${JSON.stringify(nestedRelation, null, 2)} - Model: ${JSON.stringify(model.spec, null, 2)}`) - } - - walkNestedRelations(allModels, model, model, nestedRelation) - model.imports = [...new Set(model.imports)] - /** - * To reduce complexity in the exportInterface template, nestedRelations is - * set on the property that is the root of the nested relations instead of - * setting it on the model. - */ - prop.nestedRelations = [nestedRelation] -} - -const walkSplitRelations = ( - parentNestedRelation: NestedRelation, - splitRelation: string[], - depthIndex: number -) => { - const field = splitRelation[depthIndex] - let nestedRelation: NestedRelation | undefined = - parentNestedRelation.nestedRelations.find( - (nestedRelation) => nestedRelation.field === field - ) - if (!nestedRelation) { - nestedRelation = { - field, - nestedRelations: [], - } - parentNestedRelation.nestedRelations.push(nestedRelation) - } - depthIndex++ - if (depthIndex < splitRelation.length) { - walkSplitRelations(nestedRelation, splitRelation, depthIndex) - } -} - -const walkNestedRelations = ( - allModels: Model[], - rootModel: Model, - model: Model, - nestedRelation: NestedRelation, - parentNestedRelation?: NestedRelation -): void => { - const prop = ["all-of", "any-of", "one-of"].includes(model.export) - ? findPropInCombination(nestedRelation.field, model, allModels) - : getPropertyByName(nestedRelation.field, model) - if (!prop) { - throw new Error(`x-expanded-relations - relation not found - Schema: ${rootModel.name} - NestedRelation: ${JSON.stringify(nestedRelation, null, 2)} - Model: ${JSON.stringify(model.spec, null, 2)}`) - } - if (["all-of", "any-of", "one-of"].includes(prop.export)) { - /** - * Root property for nested relations can not use combination strategies. - * To use combination, they must be defined in referenced models instead. - */ - throw new Error(`x-expanded-relations - unsupported - field referencing multiple models - Schema: ${rootModel.name} - NestedRelation: ${JSON.stringify(nestedRelation, null, 2)} - Model: ${JSON.stringify(model.spec, null, 2)}`) - } - if (!["reference", "array"].includes(prop.export)) { - return - } - - nestedRelation.base = prop.type - nestedRelation.isArray = prop.export === "array" - - if (!nestedRelation.nestedRelations.length) { - return - } - const childModel = getModelByName(prop.type, allModels) - if (!childModel) { - throw new Error(`x-expanded-relations - field referencing unknown model - Schema: ${rootModel.name} - NestedRelation: ${JSON.stringify(nestedRelation, null, 2)} - Model: ${JSON.stringify(model.spec, null, 2)}`) - } - rootModel.imports.push(prop.type) - if (parentNestedRelation) { - parentNestedRelation.hasDepth = true - } - for (const childNestedRelation of nestedRelation.nestedRelations) { - walkNestedRelations( - allModels, - rootModel, - childModel, - childNestedRelation, - nestedRelation - ) - } -} - -const findPropInCombination = ( - fieldName: string, - model: Model, - allModels: Model[] -) => { - for (const property of model.properties) { - switch (property.export) { - case "interface": - return getPropertyByName(fieldName, model) - case "reference": - const tmpModel = getModelByName(property.type, allModels) - if (tmpModel) { - return getPropertyByName(fieldName, tmpModel) - } - break - } - } -} - -function getModelByName(name: string, models: Model[]): Model | void { - for (const model of models) { - if (model.name === name) { - return model - } - } -} - -function getPropertyByName(name: string, model: Model): Model | void { - for (const property of model.properties) { - if (property.name === name) { - return property - } - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperation.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperation.ts deleted file mode 100644 index 42abec5dfc..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperation.ts +++ /dev/null @@ -1,95 +0,0 @@ -import type { Operation } from "../../../client/interfaces/Operation" -import type { OperationParameters } from "../../../client/interfaces/OperationParameters" -import type { OperationCodegen } from "../../../client/interfaces/OperationCodegen" -import type { OpenApi } from "../interfaces/OpenApi" -import type { OpenApiOperation } from "../interfaces/OpenApiOperation" -import type { OpenApiRequestBody } from "../interfaces/OpenApiRequestBody" -import { getOperationErrors } from "./getOperationErrors" -import { getOperationName } from "./getOperationName" -import { getOperationParameters } from "./getOperationParameters" -import { getOperationRequestBody } from "./getOperationRequestBody" -import { getOperationResponseHeader } from "./getOperationResponseHeader" -import { getOperationResponses } from "./getOperationResponses" -import { getOperationResults } from "./getOperationResults" -import { getRef } from "./getRef" -import { getServiceName } from "./getServiceName" -import { sortByRequired } from "./sortByRequired" - -export const getOperation = ( - openApi: OpenApi, - url: string, - method: string, - tag: string, - op: OpenApiOperation, - pathParams: OperationParameters -): Operation => { - const serviceName = getServiceName(tag) - const operationName = getOperationName(url, method, op.operationId) - const codegen: OperationCodegen = op["x-codegen"] || {} - - // Create a new operation object for this method. - const operation: Operation = { - service: serviceName, - name: codegen.method || operationName, - operationId: op.operationId || null, - summary: op.summary || null, - description: op.description || null, - deprecated: op.deprecated === true, - method: method.toUpperCase(), - path: url, - parameters: [...pathParams.parameters], - parametersPath: [...pathParams.parametersPath], - parametersQuery: [...pathParams.parametersQuery], - parametersForm: [...pathParams.parametersForm], - parametersHeader: [...pathParams.parametersHeader], - parametersCookie: [...pathParams.parametersCookie], - parametersBody: pathParams.parametersBody, - imports: [], - errors: [], - results: [], - responseHeader: null, - codegen, - } - - // Parse the operation parameters (path, query, body, etc). - if (op.parameters) { - const parameters = getOperationParameters(openApi, op.parameters) - operation.imports.push(...parameters.imports) - operation.parameters.push(...parameters.parameters) - operation.parametersPath.push(...parameters.parametersPath) - operation.parametersQuery.push(...parameters.parametersQuery) - operation.parametersForm.push(...parameters.parametersForm) - operation.parametersHeader.push(...parameters.parametersHeader) - operation.parametersCookie.push(...parameters.parametersCookie) - operation.parametersBody = parameters.parametersBody - } - - if (op.requestBody) { - const requestBodyDef = getRef(openApi, op.requestBody) - const requestBody = getOperationRequestBody(openApi, requestBodyDef) - operation.imports.push(...requestBody.imports) - operation.parameters.push(requestBody) - operation.parametersBody = requestBody - } - - // Parse the operation responses. - if (op.responses) { - const operationResponses = getOperationResponses(openApi, op.responses) - const operationResults = getOperationResults(operationResponses) - operation.errors = getOperationErrors(operationResponses) - operation.responseHeader = getOperationResponseHeader(operationResults) - - operationResults.forEach((operationResult) => { - operation.results.push(operationResult) - operation.imports.push(...operationResult.imports) - }) - } - - if (codegen.queryParams) { - operation.imports.push(codegen.queryParams) - } - - operation.parameters = operation.parameters.sort(sortByRequired) - - return operation -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationErrors.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationErrors.ts deleted file mode 100644 index c877333e2f..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationErrors.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { OperationError } from "../../../client/interfaces/OperationError" -import type { OperationResponse } from "../../../client/interfaces/OperationResponse" - -export const getOperationErrors = ( - operationResponses: OperationResponse[] -): OperationError[] => { - return operationResponses - .filter((operationResponse) => { - return operationResponse.code >= 300 && operationResponse.description - }) - .map((response) => ({ - code: response.code, - description: response.description!, - })) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationName.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationName.ts deleted file mode 100644 index 742997f7f9..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationName.ts +++ /dev/null @@ -1,28 +0,0 @@ -import camelCase from "camelcase" - -/** - * Convert the input value to a correct operation (method) classname. - * This will use the operation ID - if available - and otherwise fallback - * on a generated name from the URL - */ -export const getOperationName = ( - url: string, - method: string, - operationId?: string -): string => { - if (operationId) { - return camelCase( - operationId - .replace(/^[^a-zA-Z]+/g, "") - .replace(/[^\w\-]+/g, "-") - .trim() - ) - } - - const urlWithoutPlaceholders = url - .replace(/[^/]*?{api-version}.*?\//g, "") - .replace(/{(.*?)}/g, "") - .replace(/\//g, "-") - - return camelCase(`${method}-${urlWithoutPlaceholders}`) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationParameter.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationParameter.ts deleted file mode 100644 index c04a3d6ae2..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationParameter.ts +++ /dev/null @@ -1,99 +0,0 @@ -import type { OperationParameter } from "../../../client/interfaces/OperationParameter" -import { getPattern } from "../../../utils/getPattern" -import type { OpenApi } from "../interfaces/OpenApi" -import type { OpenApiParameter } from "../interfaces/OpenApiParameter" -import type { OpenApiSchema } from "../interfaces/OpenApiSchema" -import { getModel } from "./getModel" -import { getModelDefault } from "./getModelDefault" -import { getOperationParameterName } from "./getOperationParameterName" -import { getRef } from "./getRef" -import { getType } from "./getType" - -export const getOperationParameter = ( - openApi: OpenApi, - parameter: OpenApiParameter -): OperationParameter => { - const operationParameter: OperationParameter = { - spec: parameter, - in: parameter.in, - prop: parameter.name, - export: "interface", - name: getOperationParameterName(parameter.name), - type: "any", - base: "any", - template: null, - link: null, - description: parameter.description || null, - deprecated: parameter.deprecated === true, - isDefinition: false, - isReadOnly: false, - isRequired: parameter.required === true, - isNullable: parameter.nullable === true, - imports: [], - enum: [], - enums: [], - properties: [], - mediaType: null, - } - - if (parameter.$ref) { - const definitionRef = getType(parameter.$ref) - operationParameter.export = "reference" - operationParameter.type = definitionRef.type - operationParameter.base = definitionRef.base - operationParameter.template = definitionRef.template - operationParameter.imports.push(...definitionRef.imports) - return operationParameter - } - - let schema = parameter.schema - if (schema) { - if (schema.$ref?.startsWith("#/components/parameters/")) { - schema = getRef(openApi, schema) - } - if (schema.$ref) { - const model = getType(schema.$ref) - operationParameter.export = "reference" - operationParameter.type = model.type - operationParameter.base = model.base - operationParameter.template = model.template - operationParameter.imports.push(...model.imports) - operationParameter.default = getModelDefault(schema) - return operationParameter - } else { - const model = getModel(openApi, schema) - operationParameter.export = model.export - operationParameter.type = model.type - operationParameter.base = model.base - operationParameter.template = model.template - operationParameter.link = model.link - operationParameter.isReadOnly = model.isReadOnly - operationParameter.isRequired = - operationParameter.isRequired || model.isRequired - operationParameter.isNullable = - operationParameter.isNullable || model.isNullable - operationParameter.format = model.format - operationParameter.maximum = model.maximum - operationParameter.exclusiveMaximum = model.exclusiveMaximum - operationParameter.minimum = model.minimum - operationParameter.exclusiveMinimum = model.exclusiveMinimum - operationParameter.multipleOf = model.multipleOf - operationParameter.maxLength = model.maxLength - operationParameter.minLength = model.minLength - operationParameter.maxItems = model.maxItems - operationParameter.minItems = model.minItems - operationParameter.uniqueItems = model.uniqueItems - operationParameter.maxProperties = model.maxProperties - operationParameter.minProperties = model.minProperties - operationParameter.pattern = getPattern(model.pattern) - operationParameter.default = model.default - operationParameter.imports.push(...model.imports) - operationParameter.enum.push(...model.enum) - operationParameter.enums.push(...model.enums) - operationParameter.properties.push(...model.properties) - return operationParameter - } - } - - return operationParameter -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationParameterName.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationParameterName.ts deleted file mode 100644 index f550547154..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationParameterName.ts +++ /dev/null @@ -1,16 +0,0 @@ -import camelCase from "camelcase" - -export const reservedWords = - /^(arguments|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g - -/** - * Replaces any invalid characters from a parameter name. - * For example: 'filter.someProperty' becomes 'filterSomeProperty'. - */ -export const getOperationParameterName = (value: string): string => { - const clean = value - .replace(/^[^a-zA-Z]+/g, "") - .replace(/[^\w\-]+/g, "-") - .trim() - return camelCase(clean).replace(reservedWords, "_$1") -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationParameters.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationParameters.ts deleted file mode 100644 index e9dc91ccba..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationParameters.ts +++ /dev/null @@ -1,64 +0,0 @@ -import type { OperationParameters } from "../../../client/interfaces/OperationParameters" -import type { OpenApi } from "../interfaces/OpenApi" -import type { OpenApiParameter } from "../interfaces/OpenApiParameter" -import { getOperationParameter } from "./getOperationParameter" -import { getRef } from "./getRef" - -export const getOperationParameters = ( - openApi: OpenApi, - parameters: OpenApiParameter[] -): OperationParameters => { - const operationParameters: OperationParameters = { - imports: [], - parameters: [], - parametersPath: [], - parametersQuery: [], - parametersForm: [], - parametersCookie: [], - parametersHeader: [], - parametersBody: null, // Not used in V3 -> @see requestBody - } - - // Iterate over the parameters - parameters.forEach((parameterOrReference) => { - const parameterDef = getRef(openApi, parameterOrReference) - const parameter = getOperationParameter(openApi, parameterDef) - - // We ignore the "api-version" param, since we do not want to add this - // as the first / default parameter for each of the service calls. - if (parameter.prop !== "api-version") { - switch (parameterDef.in) { - case "path": - operationParameters.parametersPath.push(parameter) - operationParameters.parameters.push(parameter) - operationParameters.imports.push(...parameter.imports) - break - - case "query": - operationParameters.parametersQuery.push(parameter) - operationParameters.parameters.push(parameter) - operationParameters.imports.push(...parameter.imports) - break - - case "formData": - operationParameters.parametersForm.push(parameter) - operationParameters.parameters.push(parameter) - operationParameters.imports.push(...parameter.imports) - break - - case "cookie": - operationParameters.parametersCookie.push(parameter) - operationParameters.parameters.push(parameter) - operationParameters.imports.push(...parameter.imports) - break - - case "header": - operationParameters.parametersHeader.push(parameter) - operationParameters.parameters.push(parameter) - operationParameters.imports.push(...parameter.imports) - break - } - } - }) - return operationParameters -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationRequestBody.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationRequestBody.ts deleted file mode 100644 index 80dd9ee5f6..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationRequestBody.ts +++ /dev/null @@ -1,90 +0,0 @@ -import type { OperationParameter } from "../../../client/interfaces/OperationParameter" -import { getPattern } from "../../../utils/getPattern" -import type { OpenApi } from "../interfaces/OpenApi" -import type { OpenApiRequestBody } from "../interfaces/OpenApiRequestBody" -import { getContent } from "./getContent" -import { getModel } from "./getModel" -import { getType } from "./getType" - -export const getOperationRequestBody = ( - openApi: OpenApi, - body: OpenApiRequestBody -): OperationParameter => { - const requestBody: OperationParameter = { - spec: body, - in: "body", - export: "interface", - prop: "requestBody", - name: "requestBody", - type: "any", - base: "any", - template: null, - link: null, - description: body.description || null, - default: undefined, - isDefinition: false, - isReadOnly: false, - isRequired: body.required === true, - isNullable: body.nullable === true, - imports: [], - enum: [], - enums: [], - properties: [], - mediaType: null, - } - - if (body.content) { - const content = getContent(openApi, body.content) - if (content) { - requestBody.mediaType = content.mediaType - switch (requestBody.mediaType) { - case "application/x-www-form-urlencoded": - case "multipart/form-data": - requestBody.in = "formData" - requestBody.name = "formData" - requestBody.prop = "formData" - break - } - if (content.schema.$ref) { - const model = getType(content.schema.$ref) - requestBody.export = "reference" - requestBody.type = model.type - requestBody.base = model.base - requestBody.template = model.template - requestBody.imports.push(...model.imports) - return requestBody - } else { - const model = getModel(openApi, content.schema) - requestBody.export = model.export - requestBody.type = model.type - requestBody.base = model.base - requestBody.template = model.template - requestBody.link = model.link - requestBody.isReadOnly = model.isReadOnly - requestBody.isRequired = requestBody.isRequired || model.isRequired - requestBody.isNullable = requestBody.isNullable || model.isNullable - requestBody.format = model.format - requestBody.maximum = model.maximum - requestBody.exclusiveMaximum = model.exclusiveMaximum - requestBody.minimum = model.minimum - requestBody.exclusiveMinimum = model.exclusiveMinimum - requestBody.multipleOf = model.multipleOf - requestBody.maxLength = model.maxLength - requestBody.minLength = model.minLength - requestBody.maxItems = model.maxItems - requestBody.minItems = model.minItems - requestBody.uniqueItems = model.uniqueItems - requestBody.maxProperties = model.maxProperties - requestBody.minProperties = model.minProperties - requestBody.pattern = getPattern(model.pattern) - requestBody.imports.push(...model.imports) - requestBody.enum.push(...model.enum) - requestBody.enums.push(...model.enums) - requestBody.properties.push(...model.properties) - return requestBody - } - } - } - - return requestBody -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResponse.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResponse.ts deleted file mode 100644 index 5d84a1716d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResponse.ts +++ /dev/null @@ -1,99 +0,0 @@ -import type { OperationResponse } from "../../../client/interfaces/OperationResponse" -import { getPattern } from "../../../utils/getPattern" -import type { OpenApi } from "../interfaces/OpenApi" -import type { OpenApiResponse } from "../interfaces/OpenApiResponse" -import type { OpenApiSchema } from "../interfaces/OpenApiSchema" -import { getContent } from "./getContent" -import { getModel } from "./getModel" -import { getRef } from "./getRef" -import { getType } from "./getType" - -export const getOperationResponse = ( - openApi: OpenApi, - response: OpenApiResponse, - responseCode: number -): OperationResponse => { - const operationResponse: OperationResponse = { - spec: response, - in: "response", - name: "", - code: responseCode, - description: response.description || null, - export: "generic", - type: "any", - base: "any", - template: null, - link: null, - isDefinition: false, - isReadOnly: false, - isRequired: false, - isNullable: false, - imports: [], - enum: [], - enums: [], - properties: [], - } - - if (response.content) { - const content = getContent(openApi, response.content) - if (content) { - if (content.schema.$ref?.startsWith("#/components/responses/")) { - content.schema = getRef(openApi, content.schema) - } - if (content.schema.$ref) { - const model = getType(content.schema.$ref) - operationResponse.export = "reference" - operationResponse.type = model.type - operationResponse.base = model.base - operationResponse.template = model.template - operationResponse.imports.push(...model.imports) - return operationResponse - } else { - const model = getModel(openApi, content.schema) - operationResponse.export = model.export - operationResponse.type = model.type - operationResponse.base = model.base - operationResponse.template = model.template - operationResponse.link = model.link - operationResponse.isReadOnly = model.isReadOnly - operationResponse.isRequired = model.isRequired - operationResponse.isNullable = model.isNullable - operationResponse.format = model.format - operationResponse.maximum = model.maximum - operationResponse.exclusiveMaximum = model.exclusiveMaximum - operationResponse.minimum = model.minimum - operationResponse.exclusiveMinimum = model.exclusiveMinimum - operationResponse.multipleOf = model.multipleOf - operationResponse.maxLength = model.maxLength - operationResponse.minLength = model.minLength - operationResponse.maxItems = model.maxItems - operationResponse.minItems = model.minItems - operationResponse.uniqueItems = model.uniqueItems - operationResponse.maxProperties = model.maxProperties - operationResponse.minProperties = model.minProperties - operationResponse.pattern = getPattern(model.pattern) - operationResponse.imports.push(...model.imports) - operationResponse.enum.push(...model.enum) - operationResponse.enums.push(...model.enums) - operationResponse.properties.push(...model.properties) - return operationResponse - } - } - } - - // We support basic properties from response headers, since both - // fetch and XHR client just support string types. - if (response.headers) { - for (const name in response.headers) { - if (response.headers.hasOwnProperty(name)) { - operationResponse.in = "header" - operationResponse.name = name - operationResponse.type = "string" - operationResponse.base = "string" - return operationResponse - } - } - } - - return operationResponse -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResponseCode.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResponseCode.ts deleted file mode 100644 index 09d8ef3369..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResponseCode.ts +++ /dev/null @@ -1,18 +0,0 @@ -export const getOperationResponseCode = ( - value: string | "default" -): number | null => { - // You can specify a "default" response, this is treated as HTTP code 200 - if (value === "default") { - return 200 - } - - // Check if we can parse the code and return of successful. - if (/[0-9]+/g.test(value)) { - const code = parseInt(value) - if (Number.isInteger(code)) { - return Math.abs(code) - } - } - - return null -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResponseHeader.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResponseHeader.ts deleted file mode 100644 index 0860e10a7a..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResponseHeader.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { OperationResponse } from "../../../client/interfaces/OperationResponse" - -export const getOperationResponseHeader = ( - operationResponses: OperationResponse[] -): string | null => { - const header = operationResponses.find((operationResponses) => { - return operationResponses.in === "header" - }) - if (header) { - return header.name - } - return null -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResponses.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResponses.ts deleted file mode 100644 index 8ef8ad0cfe..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResponses.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { OperationResponse } from "../../../client/interfaces/OperationResponse" -import type { OpenApi } from "../interfaces/OpenApi" -import type { OpenApiResponse } from "../interfaces/OpenApiResponse" -import type { OpenApiResponses } from "../interfaces/OpenApiResponses" -import { getOperationResponse } from "./getOperationResponse" -import { getOperationResponseCode } from "./getOperationResponseCode" -import { getRef } from "./getRef" - -export const getOperationResponses = ( - openApi: OpenApi, - responses: OpenApiResponses -): OperationResponse[] => { - const operationResponses: OperationResponse[] = [] - - // Iterate over each response code and get the - // status code and response message (if any). - for (const code in responses) { - if (responses.hasOwnProperty(code)) { - const responseOrReference = responses[code] - const response = getRef(openApi, responseOrReference) - const responseCode = getOperationResponseCode(code) - - if (responseCode) { - const operationResponse = getOperationResponse( - openApi, - response, - responseCode - ) - operationResponses.push(operationResponse) - } - } - } - - // Sort the responses to 2XX success codes come before 4XX and 5XX error codes. - return operationResponses.sort((a, b): number => { - return a.code < b.code ? -1 : a.code > b.code ? 1 : 0 - }) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResults.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResults.ts deleted file mode 100644 index d93f501072..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getOperationResults.ts +++ /dev/null @@ -1,56 +0,0 @@ -import type { Model } from "../../../client/interfaces/Model" -import type { OperationResponse } from "../../../client/interfaces/OperationResponse" - -const areEqual = (a: Model, b: Model): boolean => { - const equal = - a.type === b.type && a.base === b.base && a.template === b.template - if (equal && a.link && b.link) { - return areEqual(a.link, b.link) - } - return equal -} - -export const getOperationResults = ( - operationResponses: OperationResponse[] -): OperationResponse[] => { - const operationResults: OperationResponse[] = [] - - // Filter out success response codes, but skip "204 No Content" - operationResponses.forEach((operationResponse) => { - const { code } = operationResponse - if (code && code !== 204 && code >= 200 && code < 300) { - operationResults.push(operationResponse) - } - }) - - if (!operationResults.length) { - operationResults.push({ - spec: { description: "" }, - in: "response", - name: "", - code: 200, - description: "", - export: "generic", - type: "void", - base: "void", - template: null, - link: null, - isDefinition: false, - isReadOnly: false, - isRequired: false, - isNullable: false, - imports: [], - enum: [], - enums: [], - properties: [], - }) - } - - return operationResults.filter((operationResult, index, arr) => { - return ( - arr.findIndex((item) => { - return areEqual(item, operationResult) - }) === index - ) - }) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getRef.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getRef.ts deleted file mode 100644 index 40657bf866..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getRef.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { OpenApi } from "../interfaces/OpenApi" -import type { OpenApiReference } from "../interfaces/OpenApiReference" - -const ESCAPED_REF_SLASH = /~1/g -const ESCAPED_REF_TILDE = /~0/g - -export const getRef = (openApi: OpenApi, item: T & OpenApiReference): T => { - if (item.$ref) { - // Fetch the paths to the definitions, this converts: - // "#/components/schemas/Form" to ["components", "schemas", "Form"] - const paths = item.$ref - .replace(/^#/g, "") - .split("/") - .filter((item) => item) - - // Try to find the reference by walking down the path, - // if we cannot find it, then we throw an error. - let result: any = openApi - paths.forEach((path) => { - const decodedPath = decodeURIComponent( - path.replace(ESCAPED_REF_SLASH, "/").replace(ESCAPED_REF_TILDE, "~") - ) - if (result.hasOwnProperty(decodedPath)) { - result = result[decodedPath] - } else { - throw new Error(`Could not find reference: "${item.$ref}"`) - } - }) - return result as T - } - return item as T -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getRequiredPropertiesFromComposition.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getRequiredPropertiesFromComposition.ts deleted file mode 100644 index d9912d8da2..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getRequiredPropertiesFromComposition.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { Model } from "../../../client/interfaces/Model" -import type { OpenApi } from "../interfaces/OpenApi" -import type { OpenApiSchema } from "../interfaces/OpenApiSchema" -import type { getModel } from "./getModel" -import { getRef } from "./getRef" - -// Fix for circular dependency -export type GetModelFn = typeof getModel - -export const getRequiredPropertiesFromComposition = ( - openApi: OpenApi, - required: string[], - definitions: OpenApiSchema[], - getModel: GetModelFn -): Model[] => { - return definitions - .reduce((properties, definition) => { - if (definition.$ref) { - const schema = getRef(openApi, definition) - return [...properties, ...getModel(openApi, schema).properties] - } - return [...properties, ...getModel(openApi, definition).properties] - }, [] as Model[]) - .filter((property) => { - return !property.isRequired && required.includes(property.name) - }) - .map((property) => { - return { - ...property, - isRequired: true, - } - }) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getServer.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getServer.ts deleted file mode 100644 index 45cba010d6..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getServer.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { OpenApi } from "../interfaces/OpenApi" - -export const getServer = (openApi: OpenApi): string => { - const server = openApi.servers?.[0] - const variables = server?.variables || {} - let url = server?.url || "" - for (const variable in variables) { - if (variables.hasOwnProperty(variable)) { - url = url.replace(`{${variable}}`, variables[variable].default) - } - } - return url.replace(/\/$/g, "") -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getServiceName.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getServiceName.ts deleted file mode 100644 index bc25d3aa73..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getServiceName.ts +++ /dev/null @@ -1,13 +0,0 @@ -import camelCase from "camelcase" - -/** - * Convert the input value to a correct service name. This converts - * the input string to PascalCase. - */ -export const getServiceName = (value: string): string => { - const clean = value - .replace(/^[^a-zA-Z]+/g, "") - .replace(/[^\w\-]+/g, "-") - .trim() - return camelCase(clean, { pascalCase: true }) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getServiceVersion.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getServiceVersion.ts deleted file mode 100644 index d4ba5fefd1..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getServiceVersion.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Convert the service version to 'normal' version. - * This basically removes any "v" prefix from the version string. - * @param version - */ -export const getServiceVersion = (version = "1.0"): string => { - return String(version).replace(/^v/gi, "") -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getServices.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getServices.ts deleted file mode 100644 index b255107584..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getServices.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { Service } from "../../../client/interfaces/Service" -import type { OpenApi } from "../interfaces/OpenApi" -import { listOperations } from "./listOperations" - -/** - * Get the OpenAPI services - */ -export const getServices = (openApi: OpenApi): Service[] => { - const services = new Map() - const operations = listOperations(openApi) - for (const operation of operations) { - // If we have already declared a service, then we should fetch that and - // append the new method to it. Otherwise we should create a new service object. - const service: Service = services.get(operation.service) || { - name: operation.service, - operations: [], - imports: [], - } - - // Push the operation in the service - service.operations.push(operation) - service.imports.push(...operation.imports) - services.set(operation.service, service) - } - return Array.from(services.values()) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getType.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getType.ts deleted file mode 100644 index 597d8bbf89..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/getType.ts +++ /dev/null @@ -1,85 +0,0 @@ -import type { Type } from "../../../client/interfaces/Type" -import { isDefined } from "../../../utils/isDefined" -import { getMappedType } from "./getMappedType" -import { stripNamespace } from "./stripNamespace" - -const encode = (value: string): string => { - return value.replace(/^[^a-zA-Z_$]+/g, "").replace(/[^\w$]+/g, "_") -} - -/** - * Parse any string value into a type object. - * @param type String or String[] value like "integer", "Link[Model]" or ["string", "null"]. - * @param format String value like "binary" or "date". - */ -export const getType = ( - type: string | string[] = "any", - format?: string -): Type => { - const result: Type = { - type: "any", - base: "any", - template: null, - imports: [], - isNullable: false, - } - - // Special case for JSON Schema spec (december 2020, page 17), - // that allows type to be an array of primitive types... - if (Array.isArray(type)) { - const joinedType = type - .filter((value) => value !== "null") - .map((value) => getMappedType(value, format)) - .filter(isDefined) - .join(" | ") - result.type = joinedType - result.base = joinedType - result.isNullable = type.includes("null") - return result - } - - const mapped = getMappedType(type, format) - if (mapped) { - result.type = mapped - result.base = mapped - return result - } - - const typeWithoutNamespace = decodeURIComponent(stripNamespace(type)) - - if (/\[.*\]$/g.test(typeWithoutNamespace)) { - const matches = typeWithoutNamespace.match(/(.*?)\[(.*)\]$/) - if (matches?.length) { - const match1 = getType(encode(matches[1])) - const match2 = getType(encode(matches[2])) - - if (match1.type === "any[]") { - result.type = `${match2.type}[]` - result.base = `${match2.type}` - match1.imports = [] - } else if (match2.type) { - result.type = `${match1.type}<${match2.type}>` - result.base = match1.type - result.template = match2.type - } else { - result.type = match1.type - result.base = match1.type - result.template = match1.type - } - - result.imports.push(...match1.imports) - result.imports.push(...match2.imports) - return result - } - } - - if (typeWithoutNamespace) { - const type = encode(typeWithoutNamespace) - result.type = type - result.base = type - result.imports.push(type) - return result - } - - return result -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/listOperations.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/listOperations.ts deleted file mode 100644 index 83d410a38f..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/listOperations.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { OpenApi } from "../interfaces/OpenApi" -import { Operation } from "../../../client/interfaces/Operation" -import { getOperationParameters } from "./getOperationParameters" -import { unique } from "../../../utils/unique" -import { getOperation } from "./getOperation" - -export const listOperations = (openApi: OpenApi): Operation[] => { - const operations: Operation[] = [] - for (const url in openApi.paths) { - if (openApi.paths.hasOwnProperty(url)) { - // Grab path and parse any global path parameters - const path = openApi.paths[url] - const pathParams = getOperationParameters(openApi, path.parameters || []) - - // Parse all the methods for this path - for (const method in path) { - if (path.hasOwnProperty(method)) { - switch (method) { - case "get": - case "put": - case "post": - case "delete": - case "options": - case "head": - case "patch": - // Each method contains an OpenAPI operation, we parse the operation - const op = path[method]! - const tags = op.tags?.length - ? op.tags.filter(unique) - : ["Default"] - tags.forEach((tag) => { - const operation = getOperation( - openApi, - url, - method, - tag, - op, - pathParams - ) - operations.push(operation) - }) - break - } - } - } - } - } - return operations -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/sortByRequired.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/sortByRequired.ts deleted file mode 100644 index a79b90c46d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/sortByRequired.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { OperationParameter } from "../../../client/interfaces/OperationParameter" - -export const sortByRequired = ( - a: OperationParameter, - b: OperationParameter -): number => { - const aNeedsValue = a.isRequired && a.default === undefined - const bNeedsValue = b.isRequired && b.default === undefined - if (aNeedsValue && !bNeedsValue) return -1 - if (bNeedsValue && !aNeedsValue) return 1 - return 0 -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/stripNamespace.ts b/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/stripNamespace.ts deleted file mode 100644 index f59aa5d47e..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/openApi/v3/parser/stripNamespace.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Strip (OpenAPI) namespaces fom values. - * @param value - */ -export const stripNamespace = (value: string): string => { - return value - .trim() - .replace(/^#\/components\/schemas\//, "") - .replace(/^#\/components\/responses\//, "") - .replace(/^#\/components\/parameters\//, "") - .replace(/^#\/components\/examples\//, "") - .replace(/^#\/components\/requestBodies\//, "") - .replace(/^#\/components\/headers\//, "") - .replace(/^#\/components\/securitySchemes\//, "") - .replace(/^#\/components\/links\//, "") - .replace(/^#\/components\/callbacks\//, "") -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/client.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/client.hbs deleted file mode 100644 index 0408c59307..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/client.hbs +++ /dev/null @@ -1,40 +0,0 @@ -{{>header}} - -import type { BaseHttpRequest } from './core/BaseHttpRequest'; -import type { OpenAPIConfig } from './core/OpenAPI'; -import { {{{httpRequest}}} } from './core/{{{httpRequest}}}'; - -{{#if services}} -{{#each services}} -import { {{{name}}}{{{@root.postfix}}} } from './services/{{{name}}}{{{@root.postfix}}}'; -{{/each}} -{{/if}} - -type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest; - -export class {{{clientName}}} { - - {{#each services}} - public readonly {{{camelCase name}}}: {{{name}}}{{{@root.postfix}}}; - {{/each}} - - public readonly request: BaseHttpRequest; - - constructor(config?: Partial, HttpRequest: HttpRequestConstructor = {{{httpRequest}}}) { - this.request = new HttpRequest({ - BASE: config?.BASE ?? '{{{server}}}', - VERSION: config?.VERSION ?? '{{{version}}}', - WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false, - CREDENTIALS: config?.CREDENTIALS ?? 'include', - TOKEN: config?.TOKEN, - USERNAME: config?.USERNAME, - PASSWORD: config?.PASSWORD, - HEADERS: config?.HEADERS, - ENCODE_PATH: config?.ENCODE_PATH, - }); - - {{#each services}} - this.{{{camelCase name}}} = new {{{name}}}{{{@root.postfix}}}(this.request); - {{/each}} - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/ApiError.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/ApiError.hbs deleted file mode 100644 index ab6849d189..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/ApiError.hbs +++ /dev/null @@ -1,23 +0,0 @@ -{{>header}} - -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; - -export class ApiError extends Error { - public readonly url: string; - public readonly status: number; - public readonly statusText: string; - public readonly body: any; - public readonly request: ApiRequestOptions; - - constructor(request: ApiRequestOptions, response: ApiResult, message: string) { - super(message); - - this.name = 'ApiError'; - this.url = response.url; - this.status = response.status; - this.statusText = response.statusText; - this.body = response.body; - this.request = request; - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/ApiRequestOptions.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/ApiRequestOptions.hbs deleted file mode 100644 index 355929a712..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/ApiRequestOptions.hbs +++ /dev/null @@ -1,15 +0,0 @@ -{{>header}} - -export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; - readonly cookies?: Record; - readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; - readonly mediaType?: string; - readonly responseHeader?: string; - readonly errors?: Record; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/ApiResult.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/ApiResult.hbs deleted file mode 100644 index a768b8c5ae..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/ApiResult.hbs +++ /dev/null @@ -1,9 +0,0 @@ -{{>header}} - -export type ApiResult = { - readonly url: string; - readonly ok: boolean; - readonly status: number; - readonly statusText: string; - readonly body: any; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/BaseHttpRequest.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/BaseHttpRequest.hbs deleted file mode 100644 index c4c992a825..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/BaseHttpRequest.hbs +++ /dev/null @@ -1,12 +0,0 @@ -{{>header}} - -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { CancelablePromise } from './CancelablePromise'; -import type { OpenAPIConfig } from './OpenAPI'; - -export abstract class BaseHttpRequest { - - constructor(public readonly config: OpenAPIConfig) {} - - public abstract request(options: ApiRequestOptions): CancelablePromise; -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/CancelablePromise.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/CancelablePromise.hbs deleted file mode 100644 index b708b4edc4..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/CancelablePromise.hbs +++ /dev/null @@ -1,127 +0,0 @@ -{{>header}} - -export class CancelError extends Error { - - constructor(message: string) { - super(message); - this.name = 'CancelError'; - } - - public get isCancelled(): boolean { - return true; - } -} - -export interface OnCancel { - readonly isResolved: boolean; - readonly isRejected: boolean; - readonly isCancelled: boolean; - - (cancelHandler: () => void): void; -} - -export class CancelablePromise implements Promise { - readonly [Symbol.toStringTag]!: string; - - private _isResolved: boolean; - private _isRejected: boolean; - private _isCancelled: boolean; - private readonly _cancelHandlers: (() => void)[]; - private readonly _promise: Promise; - private _resolve?: (value: T | PromiseLike) => void; - private _reject?: (reason?: any) => void; - - constructor( - executor: ( - resolve: (value: T | PromiseLike) => void, - reject: (reason?: any) => void, - onCancel: OnCancel - ) => void - ) { - this._isResolved = false; - this._isRejected = false; - this._isCancelled = false; - this._cancelHandlers = []; - this._promise = new Promise((resolve, reject) => { - this._resolve = resolve; - this._reject = reject; - - const onResolve = (value: T | PromiseLike): void => { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._isResolved = true; - this._resolve?.(value); - }; - - const onReject = (reason?: any): void => { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._isRejected = true; - this._reject?.(reason); - }; - - const onCancel = (cancelHandler: () => void): void => { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._cancelHandlers.push(cancelHandler); - }; - - Object.defineProperty(onCancel, 'isResolved', { - get: (): boolean => this._isResolved, - }); - - Object.defineProperty(onCancel, 'isRejected', { - get: (): boolean => this._isRejected, - }); - - Object.defineProperty(onCancel, 'isCancelled', { - get: (): boolean => this._isCancelled, - }); - - return executor(onResolve, onReject, onCancel as OnCancel); - }); - } - - public then( - onFulfilled?: ((value: T) => TResult1 | PromiseLike) | null, - onRejected?: ((reason: any) => TResult2 | PromiseLike) | null - ): Promise { - return this._promise.then(onFulfilled, onRejected); - } - - public catch( - onRejected?: ((reason: any) => TResult | PromiseLike) | null - ): Promise { - return this._promise.catch(onRejected); - } - - public finally(onFinally?: (() => void) | null): Promise { - return this._promise.finally(onFinally); - } - - public cancel(): void { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._isCancelled = true; - if (this._cancelHandlers.length) { - try { - for (const cancelHandler of this._cancelHandlers) { - cancelHandler(); - } - } catch (error) { - console.warn('Cancellation threw an error', error); - return; - } - } - this._cancelHandlers.length = 0; - this._reject?.(new CancelError('Request aborted')); - } - - public get isCancelled(): boolean { - return this._isCancelled; - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/HookUtils.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/HookUtils.hbs deleted file mode 100644 index 266a94ef6d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/HookUtils.hbs +++ /dev/null @@ -1,23 +0,0 @@ -{{>header}} - -import { UseQueryOptions, UseMutationOptions, QueryKey } from "react-query" - -export type UseQueryOptionsWrapper< - TQueryFnData = unknown, - TError = unknown, - TData = TQueryFnData, - TQueryKey extends QueryKey = QueryKey -> = Omit< - UseQueryOptions, - "queryKey" | "queryFn" -> - -export type UseMutationOptionsWrapper< - TData = unknown, - TError = unknown, - TVariables = void, - TContext = unknown -> = Omit< - UseMutationOptions, - 'mutationKey' | 'mutationFn' -> diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/HttpRequest.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/HttpRequest.hbs deleted file mode 100644 index 1e19036ea2..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/HttpRequest.hbs +++ /dev/null @@ -1,24 +0,0 @@ -{{>header}} - -import type { ApiRequestOptions } from './ApiRequestOptions'; -import { BaseHttpRequest } from './BaseHttpRequest'; -import type { CancelablePromise } from './CancelablePromise'; -import type { OpenAPIConfig } from './OpenAPI'; -import { request as __request } from './request'; - -export class {{httpRequest}} extends BaseHttpRequest { - - constructor(config: OpenAPIConfig) { - super(config); - } - - /** - * Request method - * @param options The request options from the service - * @returns CancelablePromise - * @throws ApiError - */ - public override request(options: ApiRequestOptions): CancelablePromise { - return __request(this.config, options); - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/ModelUtils.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/ModelUtils.hbs deleted file mode 100644 index 2939ce82fd..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/ModelUtils.hbs +++ /dev/null @@ -1,101 +0,0 @@ -{{>header}} - -/** - * Typing utilities from https://github.com/sindresorhus/type-fest - */ - -/** - * private methods for exportable dependencies -*/ -// https://github.com/sindresorhus/type-fest/blob/main/source/except.d.ts -type Filter = IsEqual extends true ? never : (KeyType extends ExcludeType ? never : KeyType); - -// https://github.com/sindresorhus/type-fest/blob/main/source/enforce-optional.d.ts -type RequiredFilter = undefined extends Type[Key] - ? Type[Key] extends undefined - ? Key - : never - : Key; - -type OptionalFilter = undefined extends Type[Key] - ? Type[Key] extends undefined - ? never - : Key - : never; - -// https://github.com/sindresorhus/type-fest/blob/main/source/merge.d.ts -type SimpleMerge = { - [Key in keyof Destination | keyof Source]: Key extends keyof Source - ? Source[Key] - : Key extends keyof Destination - ? Destination[Key] - : never; -}; - -/** - * optional exportable dependencies - */ -export type Simplify = {[KeyType in keyof T]: T[KeyType]} & {}; - -export type IsEqual = - (() => G extends A ? 1 : 2) extends - (() => G extends B ? 1 : 2) - ? true - : false; - -export type Except = { - [KeyType in keyof ObjectType as Filter]: ObjectType[KeyType]; -}; - -export type OmitIndexSignature = { - [KeyType in keyof ObjectType as {} extends Record - ? never - : KeyType]: ObjectType[KeyType]; -}; - -export type PickIndexSignature = { - [KeyType in keyof ObjectType as {} extends Record - ? KeyType - : never]: ObjectType[KeyType]; -}; - -export type EnforceOptional = Simplify<{ - [Key in keyof ObjectType as RequiredFilter]: ObjectType[Key] -} & { - [Key in keyof ObjectType as OptionalFilter]?: Exclude -}>; - -/** - * SetRequired - */ -export type SetRequired = - Simplify< - // Pick just the keys that are optional from the base type. - Except & - // Pick the keys that should be required from the base type and make them required. - Required> - >; - -/** - * SetNonNullable - */ -export type SetNonNullable = { - [Key in keyof BaseType]: Key extends Keys - ? NonNullable - : BaseType[Key]; -}; - -/** - * Merge - */ -export type Merge = EnforceOptional< - SimpleMerge, PickIndexSignature> - & SimpleMerge, OmitIndexSignature> ->; - -/** - * SetRelation - * Alias combining SetRequire and SetNonNullable. - */ -export type SetRelation = - SetRequired, Keys>; \ No newline at end of file diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/OpenAPI.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/OpenAPI.hbs deleted file mode 100644 index 19e66fbf18..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/OpenAPI.hbs +++ /dev/null @@ -1,30 +0,0 @@ -{{>header}} - -import type { ApiRequestOptions } from './ApiRequestOptions'; - -type Resolver = (options: ApiRequestOptions) => Promise; -type Headers = Record; - -export type OpenAPIConfig = { - BASE: string; - VERSION: string; - WITH_CREDENTIALS: boolean; - CREDENTIALS: 'include' | 'omit' | 'same-origin'; - TOKEN?: string | Resolver; - USERNAME?: string | Resolver; - PASSWORD?: string | Resolver; - HEADERS?: Headers | Resolver; - ENCODE_PATH?: (path: string) => string; -}; - -export const OpenAPI: OpenAPIConfig = { - BASE: '{{{server}}}', - VERSION: '{{{version}}}', - WITH_CREDENTIALS: false, - CREDENTIALS: 'include', - TOKEN: undefined, - USERNAME: undefined, - PASSWORD: undefined, - HEADERS: undefined, - ENCODE_PATH: undefined, -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/getHeaders.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/getHeaders.hbs deleted file mode 100644 index e8a4afa382..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/getHeaders.hbs +++ /dev/null @@ -1,42 +0,0 @@ -const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions, formData?: FormData): Promise> => { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const additionalHeaders = await resolve(options, config.HEADERS); - const formHeaders = typeof formData?.getHeaders === 'function' && formData?.getHeaders() || {} - - const headers = Object.entries({ - Accept: 'application/json', - ...additionalHeaders, - ...options.headers, - ...formHeaders, - }) - .filter(([_, value]) => isDefined(value)) - .reduce((headers, [key, value]) => ({ - ...headers, - [key]: String(value), - }), {} as Record); - - if (isStringWithValue(token)) { - headers['Authorization'] = `Bearer ${token}`; - } - - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = base64(`${username}:${password}`); - headers['Authorization'] = `Basic ${credentials}`; - } - - if (options.body) { - if (options.mediaType) { - headers['Content-Type'] = options.mediaType; - } else if (isBlob(options.body)) { - headers['Content-Type'] = options.body.type || 'application/octet-stream'; - } else if (isString(options.body)) { - headers['Content-Type'] = 'text/plain'; - } else if (!isFormData(options.body)) { - headers['Content-Type'] = 'application/json'; - } - } - - return headers; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/getRequestBody.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/getRequestBody.hbs deleted file mode 100644 index 78abe5dfae..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/getRequestBody.hbs +++ /dev/null @@ -1,6 +0,0 @@ -const getRequestBody = (options: ApiRequestOptions): any => { - if (options.body) { - return options.body; - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/getResponseBody.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/getResponseBody.hbs deleted file mode 100644 index 0d0287882c..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/getResponseBody.hbs +++ /dev/null @@ -1,6 +0,0 @@ -const getResponseBody = (response: AxiosResponse): any => { - if (response.status !== 204) { - return response.data; - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/getResponseHeader.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/getResponseHeader.hbs deleted file mode 100644 index ba83fd2e0b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/getResponseHeader.hbs +++ /dev/null @@ -1,9 +0,0 @@ -const getResponseHeader = (response: AxiosResponse, responseHeader?: string): string | undefined => { - if (responseHeader) { - const content = response.headers[responseHeader]; - if (isString(content)) { - return content; - } - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/request.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/request.hbs deleted file mode 100644 index 19ebd5fb96..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/request.hbs +++ /dev/null @@ -1,101 +0,0 @@ -{{>header}} - -import axios from 'axios'; -import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'; -import FormData from 'form-data'; - -import { ApiError } from './ApiError'; -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; -import { CancelablePromise } from './CancelablePromise'; -import type { OnCancel } from './CancelablePromise'; -import type { OpenAPIConfig } from './OpenAPI'; - -{{>functions/isDefined}} - - -{{>functions/isString}} - - -{{>functions/isStringWithValue}} - - -{{>functions/isBlob}} - - -{{>functions/isFormData}} - - -{{>functions/isSuccess}} - - -{{>functions/base64}} - - -{{>functions/getQueryString}} - - -{{>functions/getUrl}} - - -{{>functions/getFormData}} - - -{{>functions/resolve}} - - -{{>axios/getHeaders}} - - -{{>axios/getRequestBody}} - - -{{>axios/sendRequest}} - - -{{>axios/getResponseHeader}} - - -{{>axios/getResponseBody}} - - -{{>functions/catchErrorCodes}} - - -/** - * Request method - * @param config The OpenAPI configuration object - * @param options The request options from the service - * @returns CancelablePromise - * @throws ApiError - */ -export const request = (config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise => { - return new CancelablePromise(async (resolve, reject, onCancel) => { - try { - const url = getUrl(config, options); - const formData = getFormData(options); - const body = getRequestBody(options); - const headers = await getHeaders(config, options, formData); - - if (!onCancel.isCancelled) { - const response = await sendRequest(config, options, url, body, formData, headers, onCancel); - const responseBody = getResponseBody(response); - const responseHeader = getResponseHeader(response, options.responseHeader); - - const result: ApiResult = { - url, - ok: isSuccess(response.status), - status: response.status, - statusText: response.statusText, - body: responseHeader ?? responseBody, - }; - - catchErrorCodes(options, result); - - resolve(result.body); - } - } catch (error) { - reject(error); - } - }); -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/sendRequest.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/sendRequest.hbs deleted file mode 100644 index 0b871ea366..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/axios/sendRequest.hbs +++ /dev/null @@ -1,32 +0,0 @@ -const sendRequest = async ( - config: OpenAPIConfig, - options: ApiRequestOptions, - url: string, - body: any, - formData: FormData | undefined, - headers: Record, - onCancel: OnCancel -): Promise> => { - const source = axios.CancelToken.source(); - - const requestConfig: AxiosRequestConfig = { - url, - headers, - data: body ?? formData, - method: options.method, - withCredentials: config.WITH_CREDENTIALS, - cancelToken: source.token, - }; - - onCancel(() => source.cancel('The user aborted a request.')); - - try { - return await axios.request(requestConfig); - } catch (error) { - const axiosError = error as AxiosError; - if (axiosError.response) { - return axiosError.response; - } - throw error; - } -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/getHeaders.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/getHeaders.hbs deleted file mode 100644 index 41a65005c0..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/getHeaders.hbs +++ /dev/null @@ -1,40 +0,0 @@ -const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise => { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const additionalHeaders = await resolve(options, config.HEADERS); - - const headers = Object.entries({ - Accept: 'application/json', - ...additionalHeaders, - ...options.headers, - }) - .filter(([_, value]) => isDefined(value)) - .reduce((headers, [key, value]) => ({ - ...headers, - [key]: String(value), - }), {} as Record); - - if (isStringWithValue(token)) { - headers['Authorization'] = `Bearer ${token}`; - } - - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = base64(`${username}:${password}`); - headers['Authorization'] = `Basic ${credentials}`; - } - - if (options.body) { - if (options.mediaType) { - headers['Content-Type'] = options.mediaType; - } else if (isBlob(options.body)) { - headers['Content-Type'] = options.body.type || 'application/octet-stream'; - } else if (isString(options.body)) { - headers['Content-Type'] = 'text/plain'; - } else if (!isFormData(options.body)) { - headers['Content-Type'] = 'application/json'; - } - } - - return new Headers(headers); -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/getRequestBody.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/getRequestBody.hbs deleted file mode 100644 index b2fc7e21cd..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/getRequestBody.hbs +++ /dev/null @@ -1,12 +0,0 @@ -const getRequestBody = (options: ApiRequestOptions): any => { - if (options.body !== undefined) { - if (options.mediaType?.includes('/json')) { - return JSON.stringify(options.body) - } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) { - return options.body; - } else { - return JSON.stringify(options.body); - } - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/getResponseBody.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/getResponseBody.hbs deleted file mode 100644 index 556c1f03f8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/getResponseBody.hbs +++ /dev/null @@ -1,19 +0,0 @@ -const getResponseBody = async (response: Response): Promise => { - if (response.status !== 204) { - try { - const contentType = response.headers.get('Content-Type'); - if (contentType) { - const jsonTypes = ['application/json', 'application/problem+json'] - const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type)); - if (isJSON) { - return await response.json(); - } else { - return await response.text(); - } - } - } catch (error) { - console.error(error); - } - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/getResponseHeader.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/getResponseHeader.hbs deleted file mode 100644 index 531fb84f1f..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/getResponseHeader.hbs +++ /dev/null @@ -1,9 +0,0 @@ -const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => { - if (responseHeader) { - const content = response.headers.get(responseHeader); - if (isString(content)) { - return content; - } - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/request.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/request.hbs deleted file mode 100644 index 4af6f9440a..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/request.hbs +++ /dev/null @@ -1,94 +0,0 @@ -{{>header}} - -import { ApiError } from './ApiError'; -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; -import { CancelablePromise } from './CancelablePromise'; -import type { OnCancel } from './CancelablePromise'; -import type { OpenAPIConfig } from './OpenAPI'; - -{{>functions/isDefined}} - - -{{>functions/isString}} - - -{{>functions/isStringWithValue}} - - -{{>functions/isBlob}} - - -{{>functions/isFormData}} - - -{{>functions/base64}} - - -{{>functions/getQueryString}} - - -{{>functions/getUrl}} - - -{{>functions/getFormData}} - - -{{>functions/resolve}} - - -{{>fetch/getHeaders}} - - -{{>fetch/getRequestBody}} - - -{{>fetch/sendRequest}} - - -{{>fetch/getResponseHeader}} - - -{{>fetch/getResponseBody}} - - -{{>functions/catchErrorCodes}} - - -/** - * Request method - * @param config The OpenAPI configuration object - * @param options The request options from the service - * @returns CancelablePromise - * @throws ApiError - */ -export const request = (config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise => { - return new CancelablePromise(async (resolve, reject, onCancel) => { - try { - const url = getUrl(config, options); - const formData = getFormData(options); - const body = getRequestBody(options); - const headers = await getHeaders(config, options); - - if (!onCancel.isCancelled) { - const response = await sendRequest(config, options, url, body, formData, headers, onCancel); - const responseBody = await getResponseBody(response); - const responseHeader = getResponseHeader(response, options.responseHeader); - - const result: ApiResult = { - url, - ok: response.ok, - status: response.status, - statusText: response.statusText, - body: responseHeader ?? responseBody, - }; - - catchErrorCodes(options, result); - - resolve(result.body); - } - } catch (error) { - reject(error); - } - }); -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/sendRequest.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/sendRequest.hbs deleted file mode 100644 index 73f71f428d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/fetch/sendRequest.hbs +++ /dev/null @@ -1,26 +0,0 @@ -export const sendRequest = async ( - config: OpenAPIConfig, - options: ApiRequestOptions, - url: string, - body: any, - formData: FormData | undefined, - headers: Headers, - onCancel: OnCancel -): Promise => { - const controller = new AbortController(); - - const request: RequestInit = { - headers, - body: body ?? formData, - method: options.method, - signal: controller.signal, - }; - - if (config.WITH_CREDENTIALS) { - request.credentials = config.CREDENTIALS; - } - - onCancel(() => controller.abort()); - - return await fetch(url, request); -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/base64.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/base64.hbs deleted file mode 100644 index be275b8510..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/base64.hbs +++ /dev/null @@ -1,8 +0,0 @@ -const base64 = (str: string): string => { - try { - return btoa(str); - } catch (err) { - // @ts-ignore - return Buffer.from(str).toString('base64'); - } -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/catchErrorCodes.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/catchErrorCodes.hbs deleted file mode 100644 index 8e87583a54..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/catchErrorCodes.hbs +++ /dev/null @@ -1,21 +0,0 @@ -const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => { - const errors: Record = { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Forbidden', - 404: 'Not Found', - 500: 'Internal Server Error', - 502: 'Bad Gateway', - 503: 'Service Unavailable', - ...options.errors, - } - - const error = errors[result.status]; - if (error) { - throw new ApiError(options, result, error); - } - - if (!result.ok) { - throw new ApiError(options, result, 'Generic Error'); - } -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/getFormData.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/getFormData.hbs deleted file mode 100644 index 3a74b8f3af..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/getFormData.hbs +++ /dev/null @@ -1,26 +0,0 @@ -const getFormData = (options: ApiRequestOptions): FormData | undefined => { - if (options.formData) { - const formData = new FormData(); - - const process = (key: string, value: any) => { - if (isString(value) || isBlob(value)) { - formData.append(key, value); - } else { - formData.append(key, JSON.stringify(value)); - } - }; - - Object.entries(options.formData) - .filter(([_, value]) => isDefined(value)) - .forEach(([key, value]) => { - if (Array.isArray(value)) { - value.forEach(v => process(key, v)); - } else { - process(key, value); - } - }); - - return formData; - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/getQueryString.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/getQueryString.hbs deleted file mode 100644 index eac37f5e47..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/getQueryString.hbs +++ /dev/null @@ -1,33 +0,0 @@ -const getQueryString = (params: Record): string => { - const qs: string[] = []; - - const append = (key: string, value: any) => { - qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); - }; - - const process = (key: string, value: any) => { - if (isDefined(value)) { - if (Array.isArray(value)) { - value.forEach(v => { - process(key, v); - }); - } else if (typeof value === 'object') { - Object.entries(value).forEach(([k, v]) => { - process(`${key}[${k}]`, v); - }); - } else { - append(key, value); - } - } - }; - - Object.entries(params).forEach(([key, value]) => { - process(key, value); - }); - - if (qs.length > 0) { - return `?${qs.join('&')}`; - } - - return ''; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/getUrl.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/getUrl.hbs deleted file mode 100644 index fe181ab2e7..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/getUrl.hbs +++ /dev/null @@ -1,18 +0,0 @@ -const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => { - const encoder = config.ENCODE_PATH || encodeURI; - - const path = options.url - .replace('{api-version}', config.VERSION) - .replace(/{(.*?)}/g, (substring: string, group: string) => { - if (options.path?.hasOwnProperty(group)) { - return encoder(String(options.path[group])); - } - return substring; - }); - - const url = `${config.BASE}${path}`; - if (options.query) { - return `${url}${getQueryString(options.query)}`; - } - return url; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isBlob.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isBlob.hbs deleted file mode 100644 index caf44dddaf..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isBlob.hbs +++ /dev/null @@ -1,12 +0,0 @@ -const isBlob = (value: any): value is Blob => { - return ( - typeof value === 'object' && - typeof value.type === 'string' && - typeof value.stream === 'function' && - typeof value.arrayBuffer === 'function' && - typeof value.constructor === 'function' && - typeof value.constructor.name === 'string' && - /^(Blob|File)$/.test(value.constructor.name) && - /^(Blob|File)$/.test(value[Symbol.toStringTag]) - ); -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isDefined.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isDefined.hbs deleted file mode 100644 index ef6d0fc79b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isDefined.hbs +++ /dev/null @@ -1,3 +0,0 @@ -const isDefined = (value: T | null | undefined): value is Exclude => { - return value !== undefined && value !== null; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isFormData.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isFormData.hbs deleted file mode 100644 index 8bcbed6b48..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isFormData.hbs +++ /dev/null @@ -1,3 +0,0 @@ -const isFormData = (value: any): value is FormData => { - return value instanceof FormData; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isString.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isString.hbs deleted file mode 100644 index b9888d56b8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isString.hbs +++ /dev/null @@ -1,3 +0,0 @@ -const isString = (value: any): value is string => { - return typeof value === 'string'; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isStringWithValue.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isStringWithValue.hbs deleted file mode 100644 index b1659067c5..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isStringWithValue.hbs +++ /dev/null @@ -1,3 +0,0 @@ -const isStringWithValue = (value: any): value is string => { - return isString(value) && value !== ''; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isSuccess.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isSuccess.hbs deleted file mode 100644 index 318af1241c..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/isSuccess.hbs +++ /dev/null @@ -1,3 +0,0 @@ -const isSuccess = (status: number): boolean => { - return status >= 200 && status < 300; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/resolve.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/resolve.hbs deleted file mode 100644 index 40dbed816d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/functions/resolve.hbs +++ /dev/null @@ -1,8 +0,0 @@ -type Resolver = (options: ApiRequestOptions) => Promise; - -const resolve = async (options: ApiRequestOptions, resolver?: T | Resolver): Promise => { - if (typeof resolver === 'function') { - return (resolver as Resolver)(options); - } - return resolver; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/getHeaders.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/getHeaders.hbs deleted file mode 100644 index 80f2cbcce7..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/getHeaders.hbs +++ /dev/null @@ -1,40 +0,0 @@ -const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise => { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const additionalHeaders = await resolve(options, config.HEADERS); - - const headers = Object.entries({ - Accept: 'application/json', - ...additionalHeaders, - ...options.headers, - }) - .filter(([_, value]) => isDefined(value)) - .reduce((headers, [key, value]) => ({ - ...headers, - [key]: String(value), - }), {} as Record); - - if (isStringWithValue(token)) { - headers['Authorization'] = `Bearer ${token}`; - } - - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = base64(`${username}:${password}`); - headers['Authorization'] = `Basic ${credentials}`; - } - - if (options.body) { - if (options.mediaType) { - headers['Content-Type'] = options.mediaType; - } else if (isBlob(options.body)) { - headers['Content-Type'] = 'application/octet-stream'; - } else if (isString(options.body)) { - headers['Content-Type'] = 'text/plain'; - } else if (!isFormData(options.body)) { - headers['Content-Type'] = 'application/json'; - } - } - - return new Headers(headers); -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/getRequestBody.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/getRequestBody.hbs deleted file mode 100644 index d04d210cd6..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/getRequestBody.hbs +++ /dev/null @@ -1,12 +0,0 @@ -const getRequestBody = (options: ApiRequestOptions): any => { - if (options.body !== undefined) { - if (options.mediaType?.includes('/json')) { - return JSON.stringify(options.body) - } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) { - return options.body as any; - } else { - return JSON.stringify(options.body); - } - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/getResponseBody.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/getResponseBody.hbs deleted file mode 100644 index 556c1f03f8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/getResponseBody.hbs +++ /dev/null @@ -1,19 +0,0 @@ -const getResponseBody = async (response: Response): Promise => { - if (response.status !== 204) { - try { - const contentType = response.headers.get('Content-Type'); - if (contentType) { - const jsonTypes = ['application/json', 'application/problem+json'] - const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type)); - if (isJSON) { - return await response.json(); - } else { - return await response.text(); - } - } - } catch (error) { - console.error(error); - } - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/getResponseHeader.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/getResponseHeader.hbs deleted file mode 100644 index 531fb84f1f..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/getResponseHeader.hbs +++ /dev/null @@ -1,9 +0,0 @@ -const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => { - if (responseHeader) { - const content = response.headers.get(responseHeader); - if (isString(content)) { - return content; - } - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/request.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/request.hbs deleted file mode 100644 index 8e6f6110e1..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/request.hbs +++ /dev/null @@ -1,99 +0,0 @@ -{{>header}} - -import FormData from 'form-data'; -import fetch, { Headers } from 'node-fetch'; -import type { RequestInit, Response } from 'node-fetch'; -import type { AbortSignal } from 'node-fetch/externals'; - -import { ApiError } from './ApiError'; -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; -import { CancelablePromise } from './CancelablePromise'; -import type { OnCancel } from './CancelablePromise'; -import type { OpenAPIConfig } from './OpenAPI'; - -{{>functions/isDefined}} - - -{{>functions/isString}} - - -{{>functions/isStringWithValue}} - - -{{>functions/isBlob}} - - -{{>functions/isFormData}} - - -{{>functions/base64}} - - -{{>functions/getQueryString}} - - -{{>functions/getUrl}} - - -{{>functions/getFormData}} - - -{{>functions/resolve}} - - -{{>node/getHeaders}} - - -{{>node/getRequestBody}} - - -{{>node/sendRequest}} - - -{{>node/getResponseHeader}} - - -{{>node/getResponseBody}} - - -{{>functions/catchErrorCodes}} - - -/** - * Request method - * @param config The OpenAPI configuration object - * @param options The request options from the service - * @returns CancelablePromise - * @throws ApiError - */ -export const request = (config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise => { - return new CancelablePromise(async (resolve, reject, onCancel) => { - try { - const url = getUrl(config, options); - const formData = getFormData(options); - const body = getRequestBody(options); - const headers = await getHeaders(config, options); - - if (!onCancel.isCancelled) { - const response = await sendRequest(options, url, body, formData, headers, onCancel); - const responseBody = await getResponseBody(response); - const responseHeader = getResponseHeader(response, options.responseHeader); - - const result: ApiResult = { - url, - ok: response.ok, - status: response.status, - statusText: response.statusText, - body: responseHeader ?? responseBody, - }; - - catchErrorCodes(options, result); - - resolve(result.body); - } - } catch (error) { - reject(error); - } - }); -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/sendRequest.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/sendRequest.hbs deleted file mode 100644 index a2ebf86d44..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/node/sendRequest.hbs +++ /dev/null @@ -1,21 +0,0 @@ -export const sendRequest = async ( - options: ApiRequestOptions, - url: string, - body: any, - formData: FormData | undefined, - headers: Headers, - onCancel: OnCancel -): Promise => { - const controller = new AbortController(); - - const request: RequestInit = { - headers, - method: options.method, - body: body ?? formData, - signal: controller.signal as AbortSignal, - }; - - onCancel(() => controller.abort()); - - return await fetch(url, request); -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/request.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/request.hbs deleted file mode 100644 index 4c472b500d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/request.hbs +++ /dev/null @@ -1,4 +0,0 @@ -{{~#equals @root.httpClient 'fetch'}}{{>fetch/request}}{{/equals~}} -{{~#equals @root.httpClient 'xhr'}}{{>xhr/request}}{{/equals~}} -{{~#equals @root.httpClient 'axios'}}{{>axios/request}}{{/equals~}} -{{~#equals @root.httpClient 'node'}}{{>node/request}}{{/equals~}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/getHeaders.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/getHeaders.hbs deleted file mode 100644 index 41a65005c0..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/getHeaders.hbs +++ /dev/null @@ -1,40 +0,0 @@ -const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise => { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const additionalHeaders = await resolve(options, config.HEADERS); - - const headers = Object.entries({ - Accept: 'application/json', - ...additionalHeaders, - ...options.headers, - }) - .filter(([_, value]) => isDefined(value)) - .reduce((headers, [key, value]) => ({ - ...headers, - [key]: String(value), - }), {} as Record); - - if (isStringWithValue(token)) { - headers['Authorization'] = `Bearer ${token}`; - } - - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = base64(`${username}:${password}`); - headers['Authorization'] = `Basic ${credentials}`; - } - - if (options.body) { - if (options.mediaType) { - headers['Content-Type'] = options.mediaType; - } else if (isBlob(options.body)) { - headers['Content-Type'] = options.body.type || 'application/octet-stream'; - } else if (isString(options.body)) { - headers['Content-Type'] = 'text/plain'; - } else if (!isFormData(options.body)) { - headers['Content-Type'] = 'application/json'; - } - } - - return new Headers(headers); -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/getRequestBody.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/getRequestBody.hbs deleted file mode 100644 index b2fc7e21cd..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/getRequestBody.hbs +++ /dev/null @@ -1,12 +0,0 @@ -const getRequestBody = (options: ApiRequestOptions): any => { - if (options.body !== undefined) { - if (options.mediaType?.includes('/json')) { - return JSON.stringify(options.body) - } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) { - return options.body; - } else { - return JSON.stringify(options.body); - } - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/getResponseBody.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/getResponseBody.hbs deleted file mode 100644 index 84a662ef7c..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/getResponseBody.hbs +++ /dev/null @@ -1,19 +0,0 @@ -const getResponseBody = (xhr: XMLHttpRequest): any => { - if (xhr.status !== 204) { - try { - const contentType = xhr.getResponseHeader('Content-Type'); - if (contentType) { - const jsonTypes = ['application/json', 'application/problem+json'] - const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type)); - if (isJSON) { - return JSON.parse(xhr.responseText); - } else { - return xhr.responseText; - } - } - } catch (error) { - console.error(error); - } - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/getResponseHeader.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/getResponseHeader.hbs deleted file mode 100644 index b117d09ddc..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/getResponseHeader.hbs +++ /dev/null @@ -1,9 +0,0 @@ -const getResponseHeader = (xhr: XMLHttpRequest, responseHeader?: string): string | undefined => { - if (responseHeader) { - const content = xhr.getResponseHeader(responseHeader); - if (isString(content)) { - return content; - } - } - return undefined; -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/request.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/request.hbs deleted file mode 100644 index 47f92870b0..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/request.hbs +++ /dev/null @@ -1,97 +0,0 @@ -{{>header}} - -import { ApiError } from './ApiError'; -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; -import { CancelablePromise } from './CancelablePromise'; -import type { OnCancel } from './CancelablePromise'; -import type { OpenAPIConfig } from './OpenAPI'; - -{{>functions/isDefined}} - - -{{>functions/isString}} - - -{{>functions/isStringWithValue}} - - -{{>functions/isBlob}} - - -{{>functions/isFormData}} - - -{{>functions/isSuccess}} - - -{{>functions/base64}} - - -{{>functions/getQueryString}} - - -{{>functions/getUrl}} - - -{{>functions/getFormData}} - - -{{>functions/resolve}} - - -{{>fetch/getHeaders}} - - -{{>xhr/getRequestBody}} - - -{{>xhr/sendRequest}} - - -{{>xhr/getResponseHeader}} - - -{{>xhr/getResponseBody}} - - -{{>functions/catchErrorCodes}} - - -/** - * Request method - * @param config The OpenAPI configuration object - * @param options The request options from the service - * @returns CancelablePromise - * @throws ApiError - */ -export const request = (config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise => { - return new CancelablePromise(async (resolve, reject, onCancel) => { - try { - const url = getUrl(config, options); - const formData = getFormData(options); - const body = getRequestBody(options); - const headers = await getHeaders(config, options); - - if (!onCancel.isCancelled) { - const response = await sendRequest(config, options, url, body, formData, headers, onCancel); - const responseBody = getResponseBody(response); - const responseHeader = getResponseHeader(response, options.responseHeader); - - const result: ApiResult = { - url, - ok: isSuccess(response.status), - status: response.status, - statusText: response.statusText, - body: responseHeader ?? responseBody, - }; - - catchErrorCodes(options, result); - - resolve(result.body); - } - } catch (error) { - reject(error); - } - }); -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/sendRequest.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/sendRequest.hbs deleted file mode 100644 index 0badf8daaa..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/core/xhr/sendRequest.hbs +++ /dev/null @@ -1,26 +0,0 @@ -export const sendRequest = async ( - config: OpenAPIConfig, - options: ApiRequestOptions, - url: string, - body: any, - formData: FormData | undefined, - headers: Headers, - onCancel: OnCancel -): Promise => { - const xhr = new XMLHttpRequest(); - xhr.open(options.method, url, true); - xhr.withCredentials = config.WITH_CREDENTIALS; - - headers.forEach((value, key) => { - xhr.setRequestHeader(key, value); - }); - - return new Promise((resolve, reject) => { - xhr.onload = () => resolve(xhr); - xhr.onabort = () => reject(new Error('Request aborted')); - xhr.onerror = () => reject(new Error('Network error')); - xhr.send(body ?? formData); - - onCancel(() => xhr.abort()); - }); -}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/exportHook.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/exportHook.hbs deleted file mode 100644 index 099ce1a278..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/exportHook.hbs +++ /dev/null @@ -1,54 +0,0 @@ -{{>header}} - -import { useQuery, useMutation, useQueryClient } from 'react-query'; -import { UseQueryOptionsWrapper, UseMutationOptionsWrapper} from '../core/HookUtils'; -import { use{{{pascalCase clientName}}} } from '../use{{pascalCase clientName}}'; -{{#if imports}} - {{#each imports}} - {{#if @root.packageNames.models}} -import type { {{{this}}} } from '{{{@root.packageNames.models}}}'; - {{else}} -import type { {{{this}}} } from '../models/{{{this}}}'; - {{/if}} - {{/each}} -{{/if}} - -const { client } = use{{{pascalCase clientName}}}() - -{{#each operations}} - export const use{{{service}}}{{{pascalCase name}}} = ( - {{~#if parameters}}{{~>parameters~}},{{/if}} - {{#equals method 'GET'}} - options: UseQueryOptionsWrapper>> = {} - {{else}} - options: UseMutationOptionsWrapper>, unknown, - {{~#if parametersBody}} {{parametersBody.type}}{{else}} void{{/if~}} - > = {} - {{/equals}} - ) => { - {{#equals method 'GET'}} - const { data, ...rest } = useQuery>>( - ['{{camelCase service}}', '{{ camelCase name }}'{{#if parameters}}, {{>parametersUntyped}}{{/if}}], - () => client.{{camelCase service}}.{{name}}({{#if parameters}}{{>parametersUntyped}}{{/if}}), - options - ); - return { ...data, ...rest } as const - {{else}} - if (!options?.onSuccess) { - const queryClient = useQueryClient() - options.onSuccess = async () => { - await queryClient.invalidateQueries('{{camelCase service}}') - } - } - return useMutation>, unknown, - {{~#if parametersBody}} {{parametersBody.type}}{{else}} void{{/if~}} - >( - ['{{camelCase service}}', '{{ camelCase name }}'{{#if parameters}}, {{>parametersUntyped}}{{/if}}], - () => client.{{camelCase service}}.{{name}}({{#if parameters}}{{>parametersUntyped}}{{/if}}), - options - ); - {{/equals}} - }; - -{{/each}} - diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/exportModel.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/exportModel.hbs deleted file mode 100644 index bb602822e6..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/exportModel.hbs +++ /dev/null @@ -1,27 +0,0 @@ -{{>header}} - -import { SetRelation, Merge } from '../core/ModelUtils'; -{{#if imports}} - -{{#each imports}} -import type { {{{this}}} } from './{{{this}}}'; -{{/each}} -{{/if}} - -{{#equals export 'interface'}} -{{>exportInterface}} -{{else equals export 'one-of'}} -{{>exportComposition}} -{{else equals export 'any-of'}} -{{>exportComposition}} -{{else equals export 'all-of'}} -{{>exportComposition}} -{{else equals export 'enum'}} -{{#if @root.useUnionTypes}} -{{>exportType}} -{{else}} -{{>exportEnum}} -{{/if}} -{{else}} -{{>exportType}} -{{/equals}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/exportSchema.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/exportSchema.hbs deleted file mode 100644 index f54c25fd9d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/exportSchema.hbs +++ /dev/null @@ -1,3 +0,0 @@ -{{>header}} - -export const ${{{name}}} = {{>schema}} as const; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/exportService.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/exportService.hbs deleted file mode 100644 index 708a29d25a..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/exportService.hbs +++ /dev/null @@ -1,119 +0,0 @@ -{{>header}} - -{{#if imports}} - import { - {{#each imports}} - {{{this}}}, - {{/each}} - } {{#if @root.packageNames.models~}} - from '{{{@root.packageNames.models}}}'; - {{else~}} - from '../models'; - {{/if}} -{{/if}} -import type { CancelablePromise } from '../core/CancelablePromise'; -{{#if @root.exportClient}} -import type { BaseHttpRequest } from '../core/BaseHttpRequest'; -{{else}} -import { OpenAPI } from '../core/OpenAPI'; -import { request as __request } from '../core/request'; -{{/if}} - -export class {{{name}}}{{{@root.postfix}}} { - {{#if @root.exportClient}} - - constructor(public readonly httpRequest: BaseHttpRequest) {} - {{/if}} - - {{#each operations}} - /** - {{#if deprecated}} - * @deprecated - {{/if}} - {{#if operationId}} - * {{{escapeComment operationId}}} - {{/if}} - {{#if summary}} - * {{{escapeComment summary}}} - {{/if}} - {{#if description}} - * {{{escapeComment description}}} - {{/if}} - {{#unless @root.useOptions}} - {{#if parameters}} - {{#each parameters}} - * @param {{{name}}} {{#if description}}{{{escapeComment description}}}{{/if}} - {{/each}} - {{/if}} - {{/unless}} - {{#each results}} - * @returns {{{type}}} {{#if description}}{{{escapeComment description}}}{{/if}} - {{/each}} - * @throws ApiError - */ - {{#if @root.exportClient}} - public {{{name}}}( - {{~#if parameters}}{{~>parameters~}},{{/if}} - customHeaders: Record = {} - ): CancelablePromise<{{>result}}> { - return this.httpRequest.request({ - {{else}} - public static {{{name}}}( - {{#if parameters}}{{~>parameters~}},{{/if}} - customHeaders: Record = {} - ): CancelablePromise<{{>result}}> { - return __request(OpenAPI, { - {{/if}} - method: '{{{method}}}', - url: '{{{path}}}', - {{#if parametersPath}} - path: { - {{#each parametersPath}} - '{{{prop}}}': {{{name}}}, - {{/each}} - }, - {{/if}} - {{#if parametersCookie}} - cookies: { - {{#each parametersCookie}} - '{{{prop}}}': {{{name}}}, - {{/each}} - }, - {{/if}} - headers: customHeaders, - {{#if parametersQuery}} - query: queryParams, - {{/if}} - {{#if parametersForm}} - formData: { - {{#each parametersForm}} - '{{{prop}}}': {{{name}}}, - {{/each}} - }, - {{/if}} - {{#if parametersBody}} - {{#equals parametersBody.in 'formData'}} - formData: {{{parametersBody.name}}}, - {{/equals}} - {{#equals parametersBody.in 'body'}} - body: {{{parametersBody.name}}}, - {{/equals}} - {{#if parametersBody.mediaType}} - mediaType: '{{{parametersBody.mediaType}}}', - {{/if}} - {{/if}} - {{#if responseHeader}} - responseHeader: '{{{responseHeader}}}', - {{/if}} - {{#if errors}} - errors: { - {{#each errors}} - {{{code}}}: `{{{escapeDescription description}}}`, - {{/each}} - }, - {{/if}} - }); - } - - {{/each}} -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/indexes/index.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/indexes/index.hbs deleted file mode 100644 index 73d3905707..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/indexes/index.hbs +++ /dev/null @@ -1,38 +0,0 @@ -{{>header}} - -{{#if @root.exportClient}} -export { {{{clientName}}} } from './{{{clientName}}}'; -{{#if @root.exportHooks}} -export { use{{{pascalCase clientName}}}, {{{pascalCase clientName}}}Provider } from './use{{{pascalCase clientName}}}'; -{{/if}} -{{/if}} - -{{#if @root.exportCore}} -export { ApiError } from './core/ApiError'; -{{#if @root.exportClient}} -export { BaseHttpRequest } from './core/BaseHttpRequest'; -{{/if}} -export { CancelablePromise, CancelError } from './core/CancelablePromise'; -export { OpenAPI } from './core/OpenAPI'; -export type { OpenAPIConfig } from './core/OpenAPI'; -{{/if}} - -{{#if @root.exportModels}} -{{#if models}} -export * from './models'; -{{/if}} -{{/if}} - -{{#if @root.exportSchemas}} -{{#if models}} -{{#each models}} -export { ${{{name}}} } from './schemas/${{{name}}}'; -{{/each}} -{{/if}} -{{/if}} - -{{#if @root.exportServices}} -{{#if services}} -export * from './services'; -{{/if}} -{{/if}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/indexes/indexHooks.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/indexes/indexHooks.hbs deleted file mode 100644 index e67d7578a3..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/indexes/indexHooks.hbs +++ /dev/null @@ -1,7 +0,0 @@ -{{>header}} - -{{#if services}} -{{#each services}} -export * from './use{{{pascalCase name}}}'; -{{/each}} -{{/if}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/indexes/indexModels.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/indexes/indexModels.hbs deleted file mode 100644 index 6bd6e02576..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/indexes/indexModels.hbs +++ /dev/null @@ -1,17 +0,0 @@ -{{>header}} - -{{#if @root.exportModels}} -{{#if models}} -{{#each models}} -{{#if @root.useUnionTypes}} -export type { {{{name}}}{{#if @root.postfixModels}} as {{{name}}}{{{@root.postfixModels}}}{{/if}} } from './{{{name}}}'; -{{else if enum}} -export { {{{name}}}{{#if @root.postfixModels}} as {{{name}}}{{{@root.postfixModels}}}{{/if}} } from './{{{name}}}'; -{{else if enums}} -export { {{{name}}}{{#if @root.postfixModels}} as {{{name}}}{{{@root.postfixModels}}}{{/if}} } from './{{{name}}}'; -{{else}} -export type { {{{name}}}{{#if @root.postfixModels}} as {{{name}}}{{{@root.postfixModels}}}{{/if}} } from './{{{name}}}'; -{{/if}} -{{/each}} -{{/if}} -{{/if}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/indexes/indexServices.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/indexes/indexServices.hbs deleted file mode 100644 index 2eac59892d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/indexes/indexServices.hbs +++ /dev/null @@ -1,7 +0,0 @@ -{{>header}} - -{{#if services}} -{{#each services}} -export * from './{{{name}}}{{{@root.postfixServices}}}'; -{{/each}} -{{/if}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/base.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/base.hbs deleted file mode 100644 index 0981843097..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/base.hbs +++ /dev/null @@ -1,8 +0,0 @@ -{{~#equals base 'binary'~}} -{{~#equals @root.httpClient 'fetch'}}Blob{{/equals~}} -{{~#equals @root.httpClient 'xhr'}}Blob{{/equals~}} -{{~#equals @root.httpClient 'axios'}}Blob{{/equals~}} -{{~#equals @root.httpClient 'node'}}Blob{{/equals~}} -{{~else~}} -{{{base}}} -{{~/equals~}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/exportComposition.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/exportComposition.hbs deleted file mode 100644 index 15bf6f65c4..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/exportComposition.hbs +++ /dev/null @@ -1,38 +0,0 @@ -{{#ifdef description deprecated}} -/** -{{#if description}} - * {{{escapeComment description}}} -{{/if}} -{{#if deprecated}} - * @deprecated -{{/if}} - */ -{{/ifdef}} -export type {{{name}}} = {{>type parent=name}}; -{{#if enums}} -{{#unless @root.useUnionTypes}} - -export namespace {{{name}}} { - - {{#each enums}} - {{#ifdef description deprecated}} - /** - {{#if description}} - * {{{escapeComment description}}} - {{/if}} - {{#if deprecated}} - * @deprecated - {{/if}} - */ - {{/ifdef}} - export enum {{{name}}} { - {{#each enum}} - {{{name}}} = {{{value}}}, - {{/each}} - } - - {{/each}} - -} -{{/unless}} -{{/if}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/exportEnum.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/exportEnum.hbs deleted file mode 100644 index f47622ef9e..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/exportEnum.hbs +++ /dev/null @@ -1,24 +0,0 @@ -{{#ifdef description deprecated}} -/** -{{#if description}} - * {{{escapeComment description}}} -{{/if}} -{{#if deprecated}} - * @deprecated -{{/if}} - */ -{{/ifdef}} -export enum {{{name}}} { - {{#each enum}} - {{#if description}} - /** - * {{{escapeComment description}}} - */ - {{/if}} - {{#containsSpaces name}} - '{{{name}}}' = {{{value}}}, - {{else}} - {{{name}}} = {{{value}}}, - {{/containsSpaces}} - {{/each}} -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/exportInterface.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/exportInterface.hbs deleted file mode 100644 index d62fbe251a..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/exportInterface.hbs +++ /dev/null @@ -1,54 +0,0 @@ -{{#ifdef description deprecated}} -/** -{{#if description}} - * {{{escapeComment description}}} -{{/if}} -{{#if deprecated}} - * @deprecated -{{/if}} - */ -{{/ifdef}} -export interface {{{name}}} { - {{#each properties}} - {{#ifdef description deprecated}} - /** - {{#if description}} - * {{{escapeComment description}}} - {{/if}} - {{#if deprecated}} - * @deprecated - {{/if}} - */ - {{/ifdef}} - {{~#if nestedRelations}} - {{#each nestedRelations}} - {{>isReadOnly}}{{{../name}}}: {{>typeWithRelation}}; - {{/each}} - {{else}} - {{>isReadOnly}}{{{name}}}{{>isRequired}}: {{>type parent=../name}}; - {{/if}} - {{/each}} -}; - -{{#if enums}} -{{#unless @root.useUnionTypes}} - -export namespace {{{name}}} { - - {{#each enums}} - {{#if description}} - /** - * {{{escapeComment description}}} - */ - {{/if}} - export enum {{{name}}} { - {{#each enum}} - {{{name}}} = {{{value}}}, - {{/each}} - } - - {{/each}} - -} -{{/unless}} -{{/if}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/exportType.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/exportType.hbs deleted file mode 100644 index b57790a0ba..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/exportType.hbs +++ /dev/null @@ -1,11 +0,0 @@ -{{#ifdef description deprecated}} -/** -{{#if description}} - * {{{escapeComment description}}} -{{/if}} -{{#if deprecated}} - * @deprecated -{{/if}} - */ -{{/ifdef}} -export type {{{name}}} = {{>type}}; diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/header.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/header.hbs deleted file mode 100644 index d592379e7b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/header.hbs +++ /dev/null @@ -1,3 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/isNullable.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/isNullable.hbs deleted file mode 100644 index 7ef73e3d00..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/isNullable.hbs +++ /dev/null @@ -1 +0,0 @@ -{{#if isNullable}} | null{{/if}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/isReadOnly.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/isReadOnly.hbs deleted file mode 100644 index 7ab3bdbf6b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/isReadOnly.hbs +++ /dev/null @@ -1 +0,0 @@ -{{#if isReadOnly}}readonly {{/if}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/isRequired.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/isRequired.hbs deleted file mode 100644 index b829272b96..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/isRequired.hbs +++ /dev/null @@ -1,5 +0,0 @@ -{{~#if @root.useOptions~}} -{{#unless isRequired}}?{{else if default}}?{{/unless}} -{{~else~}} -{{#unless isRequired}}{{#unless default}}?{{/unless}}{{/unless}} -{{~/if~}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/parameters.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/parameters.hbs deleted file mode 100644 index 964d55b2a2..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/parameters.hbs +++ /dev/null @@ -1,38 +0,0 @@ -{{~#if parameters}} - {{~#if parametersPath}} - - {{#each parametersPath}} - {{{name}}}{{>isRequired}}: {{>type}}{{#if default}} = {{{default}}}{{/if}}{{#unless @last}}, - {{/unless}} - {{~/each}} - {{~/if}} - {{~#if parametersBody}} - {{~#if parametersPath}},{{/if}} - {{#with parametersBody}} - {{{name}}}: {{>type}} - {{~/with}} - {{~#if parametersQuery}},{{/if}} - {{~/if}} - {{~#if parametersQuery}} - {{~#if parametersPath}}{{#unless parametersBody}},{{/unless}}{{/if}} - {{#if codegen.queryParams}} - queryParams: {{codegen.queryParams}} - {{~else~}} - queryParams: { - {{#each parametersQuery}} - {{#ifdef description deprecated}} - /** - {{#if description}} - * {{{escapeComment description}}} - {{/if}} - {{#if deprecated}} - * @deprecated - {{/if}} - */ - {{/ifdef}} - {{{prop}}}{{>isRequired}}: {{>type}}, - {{/each}} - } - {{~/if}} - {{~/if}} -{{~/if}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/parametersUntyped.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/parametersUntyped.hbs deleted file mode 100644 index 4523aed472..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/parametersUntyped.hbs +++ /dev/null @@ -1,18 +0,0 @@ -{{~#if parameters}} - {{~#if parametersPath}} - {{~#each parametersPath}} - {{~{name}}}{{#unless @last}},{{/unless}} - {{~/each}} - {{~/if}} - {{~#if parametersBody}} - {{~#if parametersPath}},{{/if}} - {{~#with parametersBody}} - {{~{name}}} - {{~/with}} - {{~#if parametersQuery}},{{/if}} - {{~/if}} - {{~#if parametersQuery}} - {{~#if parametersPath}}{{#unless parametersBody}},{{/unless}}{{/if~}} - queryParams - {{~/if}} -{{~/if}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/result.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/result.hbs deleted file mode 100644 index c8f4770fdc..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/result.hbs +++ /dev/null @@ -1,5 +0,0 @@ -{{~#if results~}} -{{#each results}}{{>type}}{{#unless @last}} | {{/unless}}{{/each}} -{{~else~}} -void -{{~/if~}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schema.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schema.hbs deleted file mode 100644 index 14b9156b05..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schema.hbs +++ /dev/null @@ -1,17 +0,0 @@ -{{#equals export 'interface'}} -{{>schemaInterface}} -{{else equals export 'enum'}} -{{>schemaEnum}} -{{else equals export 'array'}} -{{>schemaArray}} -{{else equals export 'dictionary'}} -{{>schemaDictionary}} -{{else equals export 'any-of'}} -{{>schemaComposition}} -{{else equals export 'all-of'}} -{{>schemaComposition}} -{{else equals export 'one-of'}} -{{>schemaComposition}} -{{else}} -{{>schemaGeneric}} -{{/equals}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaArray.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaArray.hbs deleted file mode 100644 index 44871265b8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaArray.hbs +++ /dev/null @@ -1,19 +0,0 @@ -{ - type: 'array', -{{#if link}} - contains: {{>schema link}}, -{{else}} - contains: { - type: '{{{base}}}', - }, -{{/if}} -{{#if isReadOnly}} - isReadOnly: {{{isReadOnly}}}, -{{/if}} -{{#if isRequired}} - isRequired: {{{isRequired}}}, -{{/if}} -{{#if isNullable}} - isNullable: {{{isNullable}}}, -{{/if}} -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaComposition.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaComposition.hbs deleted file mode 100644 index 050f6696d5..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaComposition.hbs +++ /dev/null @@ -1,16 +0,0 @@ -{ - type: '{{export}}', -{{#if description}} - description: `{{{escapeDescription description}}}`, -{{/if}} - contains: [{{#each properties}}{{>schema}}{{#unless @last}}, {{/unless}}{{/each}}], -{{#if isReadOnly}} - isReadOnly: {{{isReadOnly}}}, -{{/if}} -{{#if isRequired}} - isRequired: {{{isRequired}}}, -{{/if}} -{{#if isNullable}} - isNullable: {{{isNullable}}}, -{{/if}} -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaDictionary.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaDictionary.hbs deleted file mode 100644 index 1e755f7af9..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaDictionary.hbs +++ /dev/null @@ -1,19 +0,0 @@ -{ - type: 'dictionary', -{{#if link}} - contains: {{>schema link}}, -{{else}} - contains: { - type: '{{{base}}}', - }, -{{/if}} -{{#if isReadOnly}} - isReadOnly: {{{isReadOnly}}}, -{{/if}} -{{#if isRequired}} - isRequired: {{{isRequired}}}, -{{/if}} -{{#if isNullable}} - isNullable: {{{isNullable}}}, -{{/if}} -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaEnum.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaEnum.hbs deleted file mode 100644 index eaba3fc5f8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaEnum.hbs +++ /dev/null @@ -1,12 +0,0 @@ -{ - type: 'Enum', -{{#if isReadOnly}} - isReadOnly: {{{isReadOnly}}}, -{{/if}} -{{#if isRequired}} - isRequired: {{{isRequired}}}, -{{/if}} -{{#if isNullable}} - isNullable: {{{isNullable}}}, -{{/if}} -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaGeneric.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaGeneric.hbs deleted file mode 100644 index 23580a6734..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaGeneric.hbs +++ /dev/null @@ -1,59 +0,0 @@ -{ -{{#if type}} - type: '{{{type}}}', -{{/if}} -{{#if description}} - description: `{{{escapeDescription description}}}`, -{{/if}} -{{#if isReadOnly}} - isReadOnly: {{{isReadOnly}}}, -{{/if}} -{{#if isRequired}} - isRequired: {{{isRequired}}}, -{{/if}} -{{#if isNullable}} - isNullable: {{{isNullable}}}, -{{/if}} -{{#if format}} - format: '{{{format}}}', -{{/if}} -{{#if maximum}} - maximum: {{{maximum}}}, -{{/if}} -{{#if exclusiveMaximum}} - exclusiveMaximum: {{{exclusiveMaximum}}}, -{{/if}} -{{#if minimum}} - minimum: {{{minimum}}}, -{{/if}} -{{#if exclusiveMinimum}} - exclusiveMinimum: {{{exclusiveMinimum}}}, -{{/if}} -{{#if multipleOf}} - multipleOf: {{{multipleOf}}}, -{{/if}} -{{#if maxLength}} - maxLength: {{{maxLength}}}, -{{/if}} -{{#if minLength}} - minLength: {{{minLength}}}, -{{/if}} -{{#if pattern}} - pattern: '{{{pattern}}}', -{{/if}} -{{#if maxItems}} - maxItems: {{{maxItems}}}, -{{/if}} -{{#if minItems}} - minItems: {{{minItems}}}, -{{/if}} -{{#if uniqueItems}} - uniqueItems: {{{uniqueItems}}}, -{{/if}} -{{#if maxProperties}} - maxProperties: {{{maxProperties}}}, -{{/if}} -{{#if minProperties}} - minProperties: {{{minProperties}}}, -{{/if}} -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaInterface.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaInterface.hbs deleted file mode 100644 index 3417c5fb94..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/schemaInterface.hbs +++ /dev/null @@ -1,21 +0,0 @@ -{ -{{#if description}} - description: `{{{escapeDescription description}}}`, -{{/if}} - properties: { -{{#if properties}} - {{#each properties}} - {{{name}}}: {{>schema}}, - {{/each}} -{{/if}} - }, -{{#if isReadOnly}} - isReadOnly: {{{isReadOnly}}}, -{{/if}} -{{#if isRequired}} - isRequired: {{{isRequired}}}, -{{/if}} -{{#if isNullable}} - isNullable: {{{isNullable}}}, -{{/if}} -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/type.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/type.hbs deleted file mode 100644 index b6b4834bd1..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/type.hbs +++ /dev/null @@ -1,19 +0,0 @@ -{{#equals export 'interface'}} -{{>typeInterface}} -{{else equals export 'reference'}} -{{>typeReference}} -{{else equals export 'enum'}} -{{>typeEnum}} -{{else equals export 'array'}} -{{>typeArray}} -{{else equals export 'dictionary'}} -{{>typeDictionary}} -{{else equals export 'one-of'}} -{{>typeUnion}} -{{else equals export 'any-of'}} -{{>typeUnion}} -{{else equals export 'all-of'}} -{{>typeIntersection}} -{{else}} -{{>typeGeneric}} -{{/equals}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeArray.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeArray.hbs deleted file mode 100644 index c3d44374f4..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeArray.hbs +++ /dev/null @@ -1,5 +0,0 @@ -{{~#if link~}} -Array<{{>type link}}>{{>isNullable}} -{{~else~}} -Array<{{>base}}>{{>isNullable}} -{{~/if~}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeDictionary.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeDictionary.hbs deleted file mode 100644 index 12d57036c8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeDictionary.hbs +++ /dev/null @@ -1,5 +0,0 @@ -{{~#if link~}} -Recordtype link}}>{{>isNullable}} -{{~else~}} -Recordbase}}>{{>isNullable}} -{{~/if~}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeEnum.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeEnum.hbs deleted file mode 100644 index 781fd5ec58..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeEnum.hbs +++ /dev/null @@ -1,2 +0,0 @@ -{{#enumerator enum parent name}}{{this}}{{/enumerator}}{{>isNullable}} - diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeGeneric.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeGeneric.hbs deleted file mode 100644 index 0ac6aea3b8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeGeneric.hbs +++ /dev/null @@ -1 +0,0 @@ -{{>base}}{{>isNullable}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeInterface.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeInterface.hbs deleted file mode 100644 index 3d5acad072..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeInterface.hbs +++ /dev/null @@ -1,23 +0,0 @@ -{{~#if properties~}} -{ -{{#each properties}} -{{#ifdef description deprecated}} -/** -{{#if description}} - * {{{escapeComment description}}} -{{/if}} -{{#if deprecated}} - * @deprecated -{{/if}} - */ -{{/ifdef}} -{{#if ../parent}} -{{>isReadOnly}}{{{name}}}{{>isRequired}}: {{>type parent=../parent}}; -{{else}} -{{>isReadOnly}}{{{name}}}{{>isRequired}}: {{>type}}; -{{/if}} -{{/each}} -}{{>isNullable}} -{{~else~}} -any -{{~/if~}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeIntersection.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeIntersection.hbs deleted file mode 100644 index 031896f7c5..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeIntersection.hbs +++ /dev/null @@ -1 +0,0 @@ -{{#intersection properties parent}}{{this}}{{/intersection}}{{>isNullable}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeReference.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeReference.hbs deleted file mode 100644 index 0ac6aea3b8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeReference.hbs +++ /dev/null @@ -1 +0,0 @@ -{{>base}}{{>isNullable}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeUnion.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeUnion.hbs deleted file mode 100644 index 59371dfe43..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeUnion.hbs +++ /dev/null @@ -1 +0,0 @@ -{{#union properties parent}}{{this}}{{/union}}{{>isNullable}} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeWithRelation.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeWithRelation.hbs deleted file mode 100644 index 380194d93f..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/partials/typeWithRelation.hbs +++ /dev/null @@ -1,11 +0,0 @@ -{{~#if isArray}}Array<{{/if~}} -{{~#if hasDepth}}Merge<{{/if~}} -SetRelation<{{>base}}, {{#each nestedRelations}}'{{{field}}}'{{#unless @last}} | {{/unless}}{{/each}}>{{#if hasDepth}}, { -{{/if}} -{{~#each nestedRelations~}} - {{#if nestedRelations~}} - {{{field}}}: {{>typeWithRelation}}, - {{/if~}} -{{~/each~}} -{{~#if hasDepth~}} }>{{/if~}} -{{~#if isArray}}>{{/if~}} \ No newline at end of file diff --git a/packages/cli/oas/openapi-typescript-codegen/src/templates/useClient.hbs b/packages/cli/oas/openapi-typescript-codegen/src/templates/useClient.hbs deleted file mode 100644 index e99f26e731..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/templates/useClient.hbs +++ /dev/null @@ -1,58 +0,0 @@ -{{>header}} - -import React from 'react'; -import { createContext, useContext, ReactNode } from 'react'; -import { QueryClientProvider, QueryClientProviderProps } from 'react-query'; -{{#if packageNames.client}} -import { {{{clientName}}} } from '{{{packageNames.client}}}'; -{{else}} -import { {{{clientName}}} } from './{{{clientName}}}'; -{{/if}} - -interface {{{pascalCase clientName}}}ContextState { - client: {{{clientName}}} -} -const {{{pascalCase clientName}}}Context = createContext<{{{pascalCase clientName}}}ContextState | null>(null) - -export const use{{{pascalCase clientName}}} = () => { - const context = useContext({{{pascalCase clientName}}}Context) - if (!context) { - throw new Error("use{{{pascalCase clientName}}} must be used within a {{{pascalCase clientName}}}Provider") - } - return context -} - -interface {{{pascalCase clientName}}}ProviderProps { - baseUrl: string - queryClientProviderProps: QueryClientProviderProps - children: ReactNode - /** - * Authentication token - */ - apiKey?: string - /** - * PublishableApiKey identifier that defines the scope of resources - * available within the request - */ - publishableApiKey?: string -} - -export const {{{pascalCase clientName}}}Provider = ({ - queryClientProviderProps, - baseUrl, - {{!-- apiKey, - publishableApiKey,--}} - children, -}: {{{pascalCase clientName}}}ProviderProps) => { - const client = new {{{clientName}}}({ - BASE: baseUrl, - WITH_CREDENTIALS: true, - }) - return ( - - <{{{pascalCase clientName}}}Context.Provider value={ { client } }> - {children} - - - ) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/typings/hbs.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/typings/hbs.d.ts deleted file mode 100644 index baf6131250..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/typings/hbs.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * We precompile the handlebar templates during the build process, - * however in the source code we want to reference these templates - * by importing the hbs files directly. Of course this is not allowed - * by Typescript, so we need to provide some declaration for these - * types. - * @see: build.js for more information - */ -declare module "*.hbs" { - const template: { - compiler: [number, string] - useData: true - main: () => void - } - export default template -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/discriminator.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/discriminator.ts deleted file mode 100644 index 56aff288f3..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/discriminator.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type { Model } from "../client/interfaces/Model" -import type { OpenApi } from "../openApi/v3/interfaces/OpenApi" -import type { OpenApiDiscriminator } from "../openApi/v3/interfaces/OpenApiDiscriminator" -import { stripNamespace } from "../openApi/v3/parser/stripNamespace" -import type { Dictionary } from "./types" - -const inverseDictionary = (map: Dictionary): Dictionary => { - const m2: Dictionary = {} - for (const key in map) { - m2[map[key]] = key - } - return m2 -} - -export const findOneOfParentDiscriminator = ( - openApi: OpenApi, - parent?: Model -): OpenApiDiscriminator | undefined => { - if (openApi.components && parent) { - for (const definitionName in openApi.components.schemas) { - if (openApi.components.schemas.hasOwnProperty(definitionName)) { - const schema = openApi.components.schemas[definitionName] - if ( - schema.discriminator && - schema.oneOf?.length && - schema.oneOf.some( - (definition) => - definition.$ref && stripNamespace(definition.$ref) == parent.name - ) - ) { - return schema.discriminator - } - } - } - } - return undefined -} - -export const mapPropertyValue = ( - discriminator: OpenApiDiscriminator, - parent: Model -): string => { - if (discriminator.mapping) { - const mapping = inverseDictionary(discriminator.mapping) - const key = Object.keys(mapping).find( - (item) => stripNamespace(item) == parent.name - ) - if (key && mapping[key]) { - return mapping[key] - } - } - return parent.name -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/fileSystem.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/fileSystem.ts deleted file mode 100644 index 5827442a6f..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/fileSystem.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { - copyFile as __copyFile, - mkdirp as __mkdirp, - pathExists as __pathExists, - readFile as __readFile, - remove as __remove, - writeFile as __writeFile, -} from "fs-extra" - -// Export calls (needed for mocking) -export const readFile = __readFile -export const writeFile = __writeFile -export const copyFile = __copyFile -export const exists = __pathExists -export const mkdir = __mkdirp -export const rmdir = __remove diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/flatMap.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/flatMap.ts deleted file mode 100644 index b0af3be8d6..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/flatMap.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Calls a defined callback on each element of an array. - * Then, flattens the result into a new array. - */ -export const flatMap = ( - array: T[], - callback: (value: T, index: number, array: T[]) => U[] -): U[] => { - const result: U[] = [] - array.map(callback).forEach((arr) => { - result.push(...arr) - }) - return result -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/formatCode.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/formatCode.ts deleted file mode 100644 index 26a682729b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/formatCode.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { EOL } from "os" - -export const formatCode = (s: string): string => { - let indent: number = 0 - let lines = s.split(EOL) - lines = lines.map((line) => { - line = line.trim().replace(/^\*/g, " *") - let i = indent - if (line.endsWith("(") || line.endsWith("{") || line.endsWith("[")) { - indent++ - } - if ( - (line.startsWith(")") || line.startsWith("}") || line.startsWith("]")) && - i - ) { - indent-- - i-- - } - const result = `${"\t".repeat(i)}${line}` - if (result.trim() === "") { - return "" - } - return result - }) - return lines.join(EOL) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/formatIndentation.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/formatIndentation.ts deleted file mode 100644 index d0b3650974..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/formatIndentation.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { EOL } from "os" - -import { Indent } from "../Indent" - -export const formatIndentation = (s: string, indent: Indent): string => { - let lines = s.split(EOL) - lines = lines.map((line) => { - switch (indent) { - case Indent.SPACE_4: - return line.replace(/\t/g, " ") - case Indent.SPACE_2: - return line.replace(/\t/g, " ") - case Indent.TAB: - return line // Default output is tab formatted - } - }) - // Make sure we have a blank line at the end - const content = lines.join(EOL) - return `${content}${EOL}` -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/getHttpRequestName.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/getHttpRequestName.ts deleted file mode 100644 index 131516f399..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/getHttpRequestName.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { HttpClient } from "../HttpClient" - -/** - * Generate the HttpRequest filename based on the selected client - * @param httpClient The selected httpClient (fetch, xhr, node or axios) - */ -export const getHttpRequestName = (httpClient: HttpClient): string => { - switch (httpClient) { - case HttpClient.FETCH: - return "FetchHttpRequest" - case HttpClient.XHR: - return "XHRHttpRequest" - case HttpClient.NODE: - return "NodeHttpRequest" - case HttpClient.AXIOS: - return "AxiosHttpRequest" - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/getModelNames.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/getModelNames.ts deleted file mode 100644 index 3db3f84c28..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/getModelNames.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { Model } from "../client/interfaces/Model" -import { sort } from "./sort" - -export const getModelNames = (models: Model[]): string[] => { - return models.map((model) => model.name).sort(sort) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/getOpenApiSpec.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/getOpenApiSpec.ts deleted file mode 100644 index db7d6a2dc4..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/getOpenApiSpec.ts +++ /dev/null @@ -1,11 +0,0 @@ -import RefParser from "json-schema-ref-parser" - -/** - * Load and parse te open api spec. If the file extension is ".yml" or ".yaml" - * we will try to parse the file as a YAML spec, otherwise we will fall back - * on parsing the file as JSON. - * @param location: Path or url - */ -export const getOpenApiSpec = async (location: string): Promise => { - return await RefParser.bundle(location, location, {}) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/getOpenApiVersion.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/getOpenApiVersion.ts deleted file mode 100644 index cc0d7866d4..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/getOpenApiVersion.ts +++ /dev/null @@ -1,22 +0,0 @@ -export enum OpenApiVersion { - V2 = 2, - V3 = 3, -} - -/** - * Get the Open API specification version (V2 or V3). This generator only supports - * version 2 and 3 of the specification, so we will alert the user if we encounter - * an incompatible type. Or if the type is missing... - * @param openApi The loaded spec (can be any object) - */ -export const getOpenApiVersion = (openApi: any): OpenApiVersion => { - const info: any = openApi.swagger || openApi.openapi - if (typeof info === "string") { - const c = info.charAt(0) - const v = Number.parseInt(c) - if (v === OpenApiVersion.V2 || v === OpenApiVersion.V3) { - return v as OpenApiVersion - } - } - throw new Error(`Unsupported Open API version: "${String(info)}"`) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/getPattern.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/getPattern.ts deleted file mode 100644 index 3a6cf6ab6a..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/getPattern.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * The spec generates a pattern like this '^\d{3}-\d{2}-\d{4}$' - * However, to use it in HTML or inside new RegExp() we need to - * escape the pattern to become: '^\\d{3}-\\d{2}-\\d{4}$' in order - * to make it a valid regexp string. - * - * Also, escape single quote characters, because the output uses single quotes for strings - * - * @param pattern - */ -export const getPattern = (pattern?: string): string | undefined => { - // eslint-disable-next-line prettier/prettier - return pattern?.replace(/\\/g, "\\\\").replace(/'/g, "\\'") -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/getServiceNames.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/getServiceNames.ts deleted file mode 100644 index e9a5e3b734..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/getServiceNames.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { Service } from "../client/interfaces/Service" -import { sort } from "./sort" - -export const getServiceNames = (services: Service[]): string[] => { - return services.map((service) => service.name).sort(sort) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/isDefined.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/isDefined.ts deleted file mode 100644 index b450b60f7f..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/isDefined.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Check if a value is defined - * @param value - */ -export const isDefined = ( - value: T | undefined | null | "" -): value is Exclude => { - return value !== undefined && value !== null && value !== "" -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/isEqual.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/isEqual.ts deleted file mode 100644 index a18e2d36d8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/isEqual.ts +++ /dev/null @@ -1,38 +0,0 @@ -export const isEqual = (a: any, b: any): boolean => { - if (a === b) { - return true - } - - if (a && b && typeof a === "object" && typeof b === "object") { - if (Array.isArray(a) && Array.isArray(b)) { - if (a.length !== b.length) { - return false - } - for (let i = 0; i < a.length; i++) { - if (!isEqual(a[i], b[i])) { - return false - } - } - return true - } - - const keysA = Object.keys(a) - const keysB = Object.keys(b) - if (keysA.length !== keysB.length) { - return false - } - - for (let i = 0; i < keysA.length; i++) { - const key = keysA[i] - if (!Object.prototype.hasOwnProperty.call(b, key)) { - return false - } - if (!isEqual(a[key], b[key])) { - return false - } - } - return true - } - - return a !== a && b !== b -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/isString.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/isString.ts deleted file mode 100644 index 6e38486b54..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/isString.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const isString = (val: any): val is string => { - return typeof val === "string" -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/isSubdirectory.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/isSubdirectory.ts deleted file mode 100644 index 96aa666d27..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/isSubdirectory.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { relative } from "path" - -export const isSubDirectory = (parent: string, child: string) => { - return relative(child, parent).startsWith("..") -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessClient.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessClient.ts deleted file mode 100644 index 2bb5b005e3..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessClient.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { Client } from "../client/interfaces/Client" -import { postProcessModel } from "./postProcessModel" -import { postProcessService } from "./postProcessService" - -/** - * Post process client - * @param client Client object with all the models, services, etc. - */ -export const postProcessClient = (client: Client): Client => { - return { - ...client, - models: client.models.map((model) => postProcessModel(model)), - services: client.services.map((service) => postProcessService(service)), - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessModel.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessModel.ts deleted file mode 100644 index 2558c92c38..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessModel.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type { Model } from "../client/interfaces/Model" -import { postProcessModelEnum } from "./postProcessModelEnum" -import { postProcessModelEnums } from "./postProcessModelEnums" -import { postProcessModelImports } from "./postProcessModelImports" - -/** - * Post processes the model. - * This will clean up any double imports or enum values. - * @param model - */ -export const postProcessModel = (model: Model): Model => { - return { - ...model, - imports: postProcessModelImports(model), - enums: postProcessModelEnums(model), - enum: postProcessModelEnum(model), - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessModelEnum.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessModelEnum.ts deleted file mode 100644 index a4352ea577..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessModelEnum.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { Enum } from "../client/interfaces/Enum" -import type { Model } from "../client/interfaces/Model" - -/** - * Set unique enum values for the model - * @param model - */ -export const postProcessModelEnum = (model: Model): Enum[] => { - return model.enum.filter((property, index, arr) => { - return arr.findIndex((item) => item.name === property.name) === index - }) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessModelEnums.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessModelEnums.ts deleted file mode 100644 index 53df1a100b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessModelEnums.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { Model } from "../client/interfaces/Model" - -/** - * Set unique enum values for the model - * @param model The model that is post-processed - */ -export const postProcessModelEnums = (model: Model): Model[] => { - return model.enums.filter((property, index, arr) => { - return arr.findIndex((item) => item.name === property.name) === index - }) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessModelImports.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessModelImports.ts deleted file mode 100644 index 753ffd6f2d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessModelImports.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { Model } from "../client/interfaces/Model" -import { sort } from "./sort" -import { unique } from "./unique" - -/** - * Set unique imports, sorted by name - * @param model The model that is post-processed - */ -export const postProcessModelImports = (model: Model): string[] => { - return model.imports - .filter(unique) - .sort(sort) - .filter((name) => model.name !== name) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessService.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessService.ts deleted file mode 100644 index c6487feef7..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessService.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Service } from "../client/interfaces/Service" -import { postProcessServiceImports } from "./postProcessServiceImports" -import { postProcessServiceOperations } from "./postProcessServiceOperations" - -export const postProcessService = (service: Service): Service => { - const clone = { ...service } - clone.operations = postProcessServiceOperations(clone) - clone.operations.forEach((operation) => { - clone.imports.push(...operation.imports) - }) - clone.imports = postProcessServiceImports(clone) - return clone -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessServiceImports.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessServiceImports.ts deleted file mode 100644 index f1a6609169..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessServiceImports.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { Service } from "../client/interfaces/Service" -import { sort } from "./sort" -import { unique } from "./unique" - -/** - * Set unique imports, sorted by name - * @param service - */ -export const postProcessServiceImports = (service: Service): string[] => { - return service.imports.filter(unique).sort(sort) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessServiceOperations.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessServiceOperations.ts deleted file mode 100644 index 0288db9414..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/postProcessServiceOperations.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type { Operation } from "../client/interfaces/Operation" -import type { Service } from "../client/interfaces/Service" -import { flatMap } from "./flatMap" - -export const postProcessServiceOperations = (service: Service): Operation[] => { - const names = new Map() - - return service.operations.map((operation) => { - const clone = { ...operation } - - // Parse the service parameters and results, very similar to how we parse - // properties of models. These methods will extend the type if needed. - clone.imports.push( - ...flatMap(clone.parameters, (parameter) => parameter.imports) - ) - clone.imports.push(...flatMap(clone.results, (result) => result.imports)) - - // Check if the operation name is unique, if not then prefix this with a number - const name = clone.name - const index = names.get(name) || 0 - if (index > 0) { - clone.name = `${name}${index}` - } - names.set(name, index + 1) - - return clone - }) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/readSpec.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/readSpec.ts deleted file mode 100644 index 87c1f40122..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/readSpec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { readSpecFromDisk } from "./readSpecFromDisk" -import { readSpecFromHttp } from "./readSpecFromHttp" -import { readSpecFromHttps } from "./readSpecFromHttps" - -export const readSpec = async (input: string): Promise => { - if (input.startsWith("https://")) { - return await readSpecFromHttps(input) - } - if (input.startsWith("http://")) { - return await readSpecFromHttp(input) - } - return await readSpecFromDisk(input) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/readSpecFromDisk.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/readSpecFromDisk.ts deleted file mode 100644 index 03759d7c7f..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/readSpecFromDisk.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { resolve } from "path" - -import { exists, readFile } from "./fileSystem" - -/** - * Check if given file exists and try to read the content as string. - * @param input - */ -export const readSpecFromDisk = async (input: string): Promise => { - const filePath = resolve(process.cwd(), input) - const fileExists = await exists(filePath) - if (fileExists) { - try { - const content = await readFile(filePath, "utf8") - return content.toString() - } catch (e) { - throw new Error(`Could not read OpenApi spec: "${filePath}"`) - } - } - throw new Error(`Could not find OpenApi spec: "${filePath}"`) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/readSpecFromHttp.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/readSpecFromHttp.ts deleted file mode 100644 index 35dc5c9637..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/readSpecFromHttp.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { get } from "http" - -/** - * Download the spec file from a HTTP resource - * @param url - */ -export const readSpecFromHttp = async (url: string): Promise => { - return new Promise((resolve, reject) => { - get(url, (response) => { - let body = "" - response.on("data", (chunk) => { - body += chunk - }) - response.on("end", () => { - resolve(body) - }) - response.on("error", () => { - reject(`Could not read OpenApi spec: "${url}"`) - }) - }) - }) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/readSpecFromHttps.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/readSpecFromHttps.ts deleted file mode 100644 index 54bbb25eff..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/readSpecFromHttps.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { get } from "https" - -/** - * Download the spec file from a HTTPS resource - * @param url - */ -export const readSpecFromHttps = async (url: string): Promise => { - return new Promise((resolve, reject) => { - get(url, (response) => { - let body = "" - response.on("data", (chunk) => { - body += chunk - }) - response.on("end", () => { - resolve(body) - }) - response.on("error", () => { - reject(`Could not read OpenApi spec: "${url}"`) - }) - }) - }) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/registerHandlebarHelpers.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/registerHandlebarHelpers.ts deleted file mode 100644 index e8c7b79ee4..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/registerHandlebarHelpers.ts +++ /dev/null @@ -1,146 +0,0 @@ -import camelCase from "camelcase" -import pascalCase from "pascalcase" -import Handlebars from "handlebars/runtime" -import { EOL } from "os" - -import type { Enum } from "../client/interfaces/Enum" -import type { Model } from "../client/interfaces/Model" -import type { HttpClient } from "../HttpClient" -import { unique } from "./unique" - -export const registerHandlebarHelpers = (root: { - httpClient: HttpClient - useOptions: boolean - useUnionTypes: boolean -}): void => { - Handlebars.registerHelper("ifdef", function (this: any, ...args): string { - const options = args.pop() - if (!args.every((value) => !value)) { - return options.fn(this) - } - return options.inverse(this) - }) - - Handlebars.registerHelper( - "equals", - function ( - this: any, - a: string, - b: string, - options: Handlebars.HelperOptions - ): string { - return a === b ? options.fn(this) : options.inverse(this) - } - ) - - Handlebars.registerHelper( - "notEquals", - function ( - this: any, - a: string, - b: string, - options: Handlebars.HelperOptions - ): string { - return a !== b ? options.fn(this) : options.inverse(this) - } - ) - - Handlebars.registerHelper( - "containsSpaces", - function ( - this: any, - value: string, - options: Handlebars.HelperOptions - ): string { - return /\s+/.test(value) ? options.fn(this) : options.inverse(this) - } - ) - - Handlebars.registerHelper( - "union", - function ( - this: any, - properties: Model[], - parent: string | undefined, - options: Handlebars.HelperOptions - ) { - const type = Handlebars.partials["type"] - const types = properties.map((property) => - type({ ...root, ...property, parent }) - ) - const uniqueTypes = types.filter(unique) - let uniqueTypesString = uniqueTypes.join(" | ") - if (uniqueTypes.length > 1) { - uniqueTypesString = `(${uniqueTypesString})` - } - return options.fn(uniqueTypesString) - } - ) - - Handlebars.registerHelper( - "intersection", - function ( - this: any, - properties: Model[], - parent: string | undefined, - options: Handlebars.HelperOptions - ) { - const type = Handlebars.partials["type"] - const types = properties.map((property) => - type({ ...root, ...property, parent }) - ) - const uniqueTypes = types.filter(unique) - let uniqueTypesString = uniqueTypes.join(" & ") - if (uniqueTypes.length > 1) { - uniqueTypesString = `(${uniqueTypesString})` - } - return options.fn(uniqueTypesString) - } - ) - - Handlebars.registerHelper( - "enumerator", - function ( - this: any, - enumerators: Enum[], - parent: string | undefined, - name: string | undefined, - options: Handlebars.HelperOptions - ) { - if (!root.useUnionTypes && parent && name) { - return `${parent}.${name}` - } - return options.fn( - enumerators - .map((enumerator) => enumerator.value) - .filter(unique) - .join(" | ") - ) - } - ) - - Handlebars.registerHelper("escapeComment", function (value: string): string { - return value - .replace(/\*\//g, "*") - .replace(/\/\*/g, "*") - .replace(/\r?\n(.*)/g, (_, w) => `${EOL} * ${w.trim()}`) - }) - - Handlebars.registerHelper( - "escapeDescription", - function (value: string): string { - return value - .replace(/\\/g, "\\\\") - .replace(/`/g, "\\`") - .replace(/\${/g, "\\${") - } - ) - - Handlebars.registerHelper("camelCase", function (value: string): string { - return camelCase(value) - }) - - Handlebars.registerHelper("pascalCase", function (value: string): string { - return pascalCase(value) - }) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/registerHandlebarTemplates.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/registerHandlebarTemplates.ts deleted file mode 100644 index d541e3124b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/registerHandlebarTemplates.ts +++ /dev/null @@ -1,398 +0,0 @@ -import Handlebars from "handlebars/runtime" - -import { HttpClient } from "../HttpClient" -import templateClient from "../templates/client.hbs" -import templateUseClient from "../templates/useClient.hbs" -import templateCoreApiError from "../templates/core/ApiError.hbs" -import templateCoreApiRequestOptions from "../templates/core/ApiRequestOptions.hbs" -import templateCoreApiResult from "../templates/core/ApiResult.hbs" -import templateCoreHookUtils from "../templates/core/HookUtils.hbs" -import templateCoreModelUtils from "../templates/core/ModelUtils.hbs" -import axiosGetHeaders from "../templates/core/axios/getHeaders.hbs" -import axiosGetRequestBody from "../templates/core/axios/getRequestBody.hbs" -import axiosGetResponseBody from "../templates/core/axios/getResponseBody.hbs" -import axiosGetResponseHeader from "../templates/core/axios/getResponseHeader.hbs" -import axiosRequest from "../templates/core/axios/request.hbs" -import axiosSendRequest from "../templates/core/axios/sendRequest.hbs" -import templateCoreBaseHttpRequest from "../templates/core/BaseHttpRequest.hbs" -import templateCancelablePromise from "../templates/core/CancelablePromise.hbs" -import fetchGetHeaders from "../templates/core/fetch/getHeaders.hbs" -import fetchGetRequestBody from "../templates/core/fetch/getRequestBody.hbs" -import fetchGetResponseBody from "../templates/core/fetch/getResponseBody.hbs" -import fetchGetResponseHeader from "../templates/core/fetch/getResponseHeader.hbs" -import fetchRequest from "../templates/core/fetch/request.hbs" -import fetchSendRequest from "../templates/core/fetch/sendRequest.hbs" -import functionBase64 from "../templates/core/functions/base64.hbs" -import functionCatchErrorCodes from "../templates/core/functions/catchErrorCodes.hbs" -import functionGetFormData from "../templates/core/functions/getFormData.hbs" -import functionGetQueryString from "../templates/core/functions/getQueryString.hbs" -import functionGetUrl from "../templates/core/functions/getUrl.hbs" -import functionIsBlob from "../templates/core/functions/isBlob.hbs" -import functionIsDefined from "../templates/core/functions/isDefined.hbs" -import functionIsFormData from "../templates/core/functions/isFormData.hbs" -import functionIsString from "../templates/core/functions/isString.hbs" -import functionIsStringWithValue from "../templates/core/functions/isStringWithValue.hbs" -import functionIsSuccess from "../templates/core/functions/isSuccess.hbs" -import functionResolve from "../templates/core/functions/resolve.hbs" -import templateCoreHttpRequest from "../templates/core/HttpRequest.hbs" -import nodeGetHeaders from "../templates/core/node/getHeaders.hbs" -import nodeGetRequestBody from "../templates/core/node/getRequestBody.hbs" -import nodeGetResponseBody from "../templates/core/node/getResponseBody.hbs" -import nodeGetResponseHeader from "../templates/core/node/getResponseHeader.hbs" -import nodeRequest from "../templates/core/node/request.hbs" -import nodeSendRequest from "../templates/core/node/sendRequest.hbs" -import templateCoreSettings from "../templates/core/OpenAPI.hbs" -import templateCoreRequest from "../templates/core/request.hbs" -import xhrGetHeaders from "../templates/core/xhr/getHeaders.hbs" -import xhrGetRequestBody from "../templates/core/xhr/getRequestBody.hbs" -import xhrGetResponseBody from "../templates/core/xhr/getResponseBody.hbs" -import xhrGetResponseHeader from "../templates/core/xhr/getResponseHeader.hbs" -import xhrRequest from "../templates/core/xhr/request.hbs" -import xhrSendRequest from "../templates/core/xhr/sendRequest.hbs" -import templateExportModel from "../templates/exportModel.hbs" -import templateExportSchema from "../templates/exportSchema.hbs" -import templateExportService from "../templates/exportService.hbs" -import templateExportHook from "../templates/exportHook.hbs" -import templateIndex from "../templates/indexes/index.hbs" -import templateIndexModels from "../templates/indexes/indexModels.hbs" -import templateIndexServices from "../templates/indexes/indexServices.hbs" -import templateIndexHooks from "../templates/indexes/indexHooks.hbs" -import partialBase from "../templates/partials/base.hbs" -import partialExportComposition from "../templates/partials/exportComposition.hbs" -import partialExportEnum from "../templates/partials/exportEnum.hbs" -import partialExportInterface from "../templates/partials/exportInterface.hbs" -import partialExportType from "../templates/partials/exportType.hbs" -import partialHeader from "../templates/partials/header.hbs" -import partialIsNullable from "../templates/partials/isNullable.hbs" -import partialIsReadOnly from "../templates/partials/isReadOnly.hbs" -import partialIsRequired from "../templates/partials/isRequired.hbs" -import partialParameters from "../templates/partials/parameters.hbs" -import partialParametersUntyped from "../templates/partials/parametersUntyped.hbs" -import partialResult from "../templates/partials/result.hbs" -import partialSchema from "../templates/partials/schema.hbs" -import partialSchemaArray from "../templates/partials/schemaArray.hbs" -import partialSchemaComposition from "../templates/partials/schemaComposition.hbs" -import partialSchemaDictionary from "../templates/partials/schemaDictionary.hbs" -import partialSchemaEnum from "../templates/partials/schemaEnum.hbs" -import partialSchemaGeneric from "../templates/partials/schemaGeneric.hbs" -import partialSchemaInterface from "../templates/partials/schemaInterface.hbs" -import partialType from "../templates/partials/type.hbs" -import partialTypeArray from "../templates/partials/typeArray.hbs" -import partialTypeDictionary from "../templates/partials/typeDictionary.hbs" -import partialTypeEnum from "../templates/partials/typeEnum.hbs" -import partialTypeGeneric from "../templates/partials/typeGeneric.hbs" -import partialTypeInterface from "../templates/partials/typeInterface.hbs" -import partialTypeIntersection from "../templates/partials/typeIntersection.hbs" -import partialTypeReference from "../templates/partials/typeReference.hbs" -import partialTypeUnion from "../templates/partials/typeUnion.hbs" -import partialTypeWithRelation from "../templates/partials/typeWithRelation.hbs" -import { registerHandlebarHelpers } from "./registerHandlebarHelpers" - -export interface Templates { - indexes: { - index: Handlebars.TemplateDelegate - indexModels: Handlebars.TemplateDelegate - indexServices: Handlebars.TemplateDelegate - indexHooks: Handlebars.TemplateDelegate - } - client: Handlebars.TemplateDelegate - useClient: Handlebars.TemplateDelegate - exports: { - model: Handlebars.TemplateDelegate - schema: Handlebars.TemplateDelegate - service: Handlebars.TemplateDelegate - hook: Handlebars.TemplateDelegate - } - core: { - settings: Handlebars.TemplateDelegate - apiError: Handlebars.TemplateDelegate - apiRequestOptions: Handlebars.TemplateDelegate - apiResult: Handlebars.TemplateDelegate - cancelablePromise: Handlebars.TemplateDelegate - request: Handlebars.TemplateDelegate - baseHttpRequest: Handlebars.TemplateDelegate - httpRequest: Handlebars.TemplateDelegate - hookUtils: Handlebars.TemplateDelegate - modelUtils: Handlebars.TemplateDelegate - } -} - -/** - * Read all the Handlebar templates that we need and return on wrapper object - * so we can easily access the templates in out generator / write functions. - */ -export const registerHandlebarTemplates = (root: { - httpClient: HttpClient - useOptions: boolean - useUnionTypes: boolean -}): Templates => { - registerHandlebarHelpers(root) - - // Main templates (entry points for the files we write to disk) - const templates: Templates = { - indexes: { - index: Handlebars.template(templateIndex), - indexModels: Handlebars.template(templateIndexModels), - indexServices: Handlebars.template(templateIndexServices), - indexHooks: Handlebars.template(templateIndexHooks), - }, - client: Handlebars.template(templateClient), - useClient: Handlebars.template(templateUseClient), - exports: { - model: Handlebars.template(templateExportModel), - schema: Handlebars.template(templateExportSchema), - service: Handlebars.template(templateExportService), - hook: Handlebars.template(templateExportHook), - }, - core: { - settings: Handlebars.template(templateCoreSettings), - apiError: Handlebars.template(templateCoreApiError), - apiRequestOptions: Handlebars.template(templateCoreApiRequestOptions), - apiResult: Handlebars.template(templateCoreApiResult), - cancelablePromise: Handlebars.template(templateCancelablePromise), - request: Handlebars.template(templateCoreRequest), - baseHttpRequest: Handlebars.template(templateCoreBaseHttpRequest), - httpRequest: Handlebars.template(templateCoreHttpRequest), - hookUtils: Handlebars.template(templateCoreHookUtils), - modelUtils: Handlebars.template(templateCoreModelUtils), - }, - } - - // Partials for the generations of the models, services, etc. - Handlebars.registerPartial( - "exportEnum", - Handlebars.template(partialExportEnum) - ) - Handlebars.registerPartial( - "exportInterface", - Handlebars.template(partialExportInterface) - ) - Handlebars.registerPartial( - "exportComposition", - Handlebars.template(partialExportComposition) - ) - Handlebars.registerPartial( - "exportType", - Handlebars.template(partialExportType) - ) - Handlebars.registerPartial("header", Handlebars.template(partialHeader)) - Handlebars.registerPartial( - "isNullable", - Handlebars.template(partialIsNullable) - ) - Handlebars.registerPartial( - "isReadOnly", - Handlebars.template(partialIsReadOnly) - ) - Handlebars.registerPartial( - "isRequired", - Handlebars.template(partialIsRequired) - ) - Handlebars.registerPartial( - "parameters", - Handlebars.template(partialParameters) - ) - Handlebars.registerPartial( - "parametersUntyped", - Handlebars.template(partialParametersUntyped) - ) - Handlebars.registerPartial("result", Handlebars.template(partialResult)) - Handlebars.registerPartial("schema", Handlebars.template(partialSchema)) - Handlebars.registerPartial( - "schemaArray", - Handlebars.template(partialSchemaArray) - ) - Handlebars.registerPartial( - "schemaDictionary", - Handlebars.template(partialSchemaDictionary) - ) - Handlebars.registerPartial( - "schemaEnum", - Handlebars.template(partialSchemaEnum) - ) - Handlebars.registerPartial( - "schemaGeneric", - Handlebars.template(partialSchemaGeneric) - ) - Handlebars.registerPartial( - "schemaInterface", - Handlebars.template(partialSchemaInterface) - ) - Handlebars.registerPartial( - "schemaComposition", - Handlebars.template(partialSchemaComposition) - ) - Handlebars.registerPartial("type", Handlebars.template(partialType)) - Handlebars.registerPartial("typeArray", Handlebars.template(partialTypeArray)) - Handlebars.registerPartial( - "typeDictionary", - Handlebars.template(partialTypeDictionary) - ) - Handlebars.registerPartial("typeEnum", Handlebars.template(partialTypeEnum)) - Handlebars.registerPartial( - "typeGeneric", - Handlebars.template(partialTypeGeneric) - ) - Handlebars.registerPartial( - "typeInterface", - Handlebars.template(partialTypeInterface) - ) - Handlebars.registerPartial( - "typeReference", - Handlebars.template(partialTypeReference) - ) - Handlebars.registerPartial("typeUnion", Handlebars.template(partialTypeUnion)) - Handlebars.registerPartial( - "typeIntersection", - Handlebars.template(partialTypeIntersection) - ) - Handlebars.registerPartial( - "typeWithRelation", - Handlebars.template(partialTypeWithRelation) - ) - Handlebars.registerPartial("base", Handlebars.template(partialBase)) - - // Generic functions used in 'request' file @see src/templates/core/request.hbs for more info - Handlebars.registerPartial( - "functions/catchErrorCodes", - Handlebars.template(functionCatchErrorCodes) - ) - Handlebars.registerPartial( - "functions/getFormData", - Handlebars.template(functionGetFormData) - ) - Handlebars.registerPartial( - "functions/getQueryString", - Handlebars.template(functionGetQueryString) - ) - Handlebars.registerPartial( - "functions/getUrl", - Handlebars.template(functionGetUrl) - ) - Handlebars.registerPartial( - "functions/isBlob", - Handlebars.template(functionIsBlob) - ) - Handlebars.registerPartial( - "functions/isDefined", - Handlebars.template(functionIsDefined) - ) - Handlebars.registerPartial( - "functions/isFormData", - Handlebars.template(functionIsFormData) - ) - Handlebars.registerPartial( - "functions/isString", - Handlebars.template(functionIsString) - ) - Handlebars.registerPartial( - "functions/isStringWithValue", - Handlebars.template(functionIsStringWithValue) - ) - Handlebars.registerPartial( - "functions/isSuccess", - Handlebars.template(functionIsSuccess) - ) - Handlebars.registerPartial( - "functions/base64", - Handlebars.template(functionBase64) - ) - Handlebars.registerPartial( - "functions/resolve", - Handlebars.template(functionResolve) - ) - - // Specific files for the fetch client implementation - Handlebars.registerPartial( - "fetch/getHeaders", - Handlebars.template(fetchGetHeaders) - ) - Handlebars.registerPartial( - "fetch/getRequestBody", - Handlebars.template(fetchGetRequestBody) - ) - Handlebars.registerPartial( - "fetch/getResponseBody", - Handlebars.template(fetchGetResponseBody) - ) - Handlebars.registerPartial( - "fetch/getResponseHeader", - Handlebars.template(fetchGetResponseHeader) - ) - Handlebars.registerPartial( - "fetch/sendRequest", - Handlebars.template(fetchSendRequest) - ) - Handlebars.registerPartial("fetch/request", Handlebars.template(fetchRequest)) - - // Specific files for the xhr client implementation - Handlebars.registerPartial( - "xhr/getHeaders", - Handlebars.template(xhrGetHeaders) - ) - Handlebars.registerPartial( - "xhr/getRequestBody", - Handlebars.template(xhrGetRequestBody) - ) - Handlebars.registerPartial( - "xhr/getResponseBody", - Handlebars.template(xhrGetResponseBody) - ) - Handlebars.registerPartial( - "xhr/getResponseHeader", - Handlebars.template(xhrGetResponseHeader) - ) - Handlebars.registerPartial( - "xhr/sendRequest", - Handlebars.template(xhrSendRequest) - ) - Handlebars.registerPartial("xhr/request", Handlebars.template(xhrRequest)) - - // Specific files for the node client implementation - Handlebars.registerPartial( - "node/getHeaders", - Handlebars.template(nodeGetHeaders) - ) - Handlebars.registerPartial( - "node/getRequestBody", - Handlebars.template(nodeGetRequestBody) - ) - Handlebars.registerPartial( - "node/getResponseBody", - Handlebars.template(nodeGetResponseBody) - ) - Handlebars.registerPartial( - "node/getResponseHeader", - Handlebars.template(nodeGetResponseHeader) - ) - Handlebars.registerPartial( - "node/sendRequest", - Handlebars.template(nodeSendRequest) - ) - Handlebars.registerPartial("node/request", Handlebars.template(nodeRequest)) - - // Specific files for the axios client implementation - Handlebars.registerPartial( - "axios/getHeaders", - Handlebars.template(axiosGetHeaders) - ) - Handlebars.registerPartial( - "axios/getRequestBody", - Handlebars.template(axiosGetRequestBody) - ) - Handlebars.registerPartial( - "axios/getResponseBody", - Handlebars.template(axiosGetResponseBody) - ) - Handlebars.registerPartial( - "axios/getResponseHeader", - Handlebars.template(axiosGetResponseHeader) - ) - Handlebars.registerPartial( - "axios/sendRequest", - Handlebars.template(axiosSendRequest) - ) - Handlebars.registerPartial("axios/request", Handlebars.template(axiosRequest)) - - return templates -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/sort.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/sort.ts deleted file mode 100644 index 18d2ecaddd..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/sort.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const sort = (a: string, b: string): number => { - const nameA = a.toLowerCase() - const nameB = b.toLowerCase() - return nameA.localeCompare(nameB, "en") -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/sortModelsByName.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/sortModelsByName.ts deleted file mode 100644 index 9d3e915b72..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/sortModelsByName.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { Model } from "../client/interfaces/Model" - -export const sortModelsByName = (models: Model[]): Model[] => { - return models.sort((a, b) => { - const nameA = a.name.toLowerCase() - const nameB = b.name.toLowerCase() - return nameA.localeCompare(nameB, "en") - }) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/sortServicesByName.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/sortServicesByName.ts deleted file mode 100644 index 14a9d0faf8..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/sortServicesByName.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { Service } from "../client/interfaces/Service" - -export const sortServicesByName = (services: Service[]): Service[] => { - return services.sort((a, b) => { - const nameA = a.name.toLowerCase() - const nameB = b.name.toLowerCase() - return nameA.localeCompare(nameB, "en") - }) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/types.d.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/types.d.ts deleted file mode 100644 index a3c299913b..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/types.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface Dictionary { - [key: string]: T -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/unique.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/unique.ts deleted file mode 100644 index 9705cdb55d..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/unique.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const unique = (val: T, index: number, arr: T[]): boolean => { - return arr.indexOf(val) === index -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClient.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClient.ts deleted file mode 100644 index 0245de5544..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClient.ts +++ /dev/null @@ -1,252 +0,0 @@ -import { resolve } from "path" - -import type { Client } from "../client/interfaces/Client" -import type { HttpClient } from "../HttpClient" -import type { Indent } from "../Indent" -import { mkdir, rmdir, writeFile } from "./fileSystem" -import { isDefined } from "./isDefined" -import { isSubDirectory } from "./isSubdirectory" -import type { Templates } from "./registerHandlebarTemplates" -import { writeClientClass } from "./writeClientClass" -import { writeClientCore } from "./writeClientCore" -import { writeClientHooks } from "./writeClientHooks" -import { - writeClientIndex, - writeClientIndexHooks, - writeClientIndexModels, - writeClientIndexServices, -} from "./writeClientIndex" -import { writeClientModels } from "./writeClientModels" -import { writeClientSchemas } from "./writeClientSchemas" -import { writeClientServices } from "./writeClientServices" -import { writeUseClient } from "./writeUseClient" -import { PackageNames } from "../index" -import { formatIndentation as i } from "./formatIndentation" - -/** - * Write our OpenAPI client, using the given templates at the given output - * @param client Client object with all the models, services, etc. - * @param templates Templates wrapper with all loaded Handlebars templates - * @param output The relative location of the output directory - * @param httpClient The selected httpClient (fetch, xhr, node or axios) - * @param useOptions Use options or arguments functions - * @param useUnionTypes Use union types instead of enums - * @param exportCore Generate core client classes - * @param exportServices Generate services - * @param exportModels Generate models - * @param exportHooks Generate hooks - * @param exportSchemas Generate schemas - * @param exportSchemas Generate schemas - * @param indent Indentation options (4, 2 or tab) - * @param packageNames Package name to use in import statements. - * @param postfixServices Service name postfix - * @param postfixModels Model name postfix - * @param clientName Custom client class name - * @param request Path to custom request file - */ -export const writeClient = async ( - client: Client, - templates: Templates, - output: string, - httpClient: HttpClient, - useOptions: boolean, - useUnionTypes: boolean, - exportCore: boolean, - exportServices: boolean, - exportModels: boolean, - exportHooks: boolean, - exportSchemas: boolean, - indent: Indent, - packageNames: PackageNames, - postfixServices: string, - postfixModels: string, - clientName?: string, - request?: string -): Promise => { - const outputPath = resolve(process.cwd(), output) - const outputPathCore = resolve(outputPath, "core") - const outputPathModels = resolve(outputPath, "models") - const outputPathSchemas = resolve(outputPath, "schemas") - const outputPathServices = resolve(outputPath, "services") - const outputPathHooks = resolve(outputPath, "hooks") - - if (!isSubDirectory(process.cwd(), output)) { - throw new Error( - `Output folder is not a subdirectory of the current working directory` - ) - } - - if (exportCore) { - await rmdir(outputPathCore) - await mkdir(outputPathCore) - await writeClientCore( - client, - templates, - outputPathCore, - httpClient, - indent, - clientName, - request - ) - } - - if (exportServices) { - await rmdir(outputPathServices) - await mkdir(outputPathServices) - await writeClientServices( - client.services, - templates, - outputPathServices, - httpClient, - useUnionTypes, - useOptions, - indent, - postfixServices, - clientName, - packageNames - ) - await writeClientIndexServices( - client, - templates, - outputPathServices, - useUnionTypes, - exportCore, - exportServices, - exportModels, - exportHooks, - exportSchemas, - postfixServices, - postfixModels, - clientName - ) - } - - if (exportHooks) { - await rmdir(outputPathHooks) - await mkdir(outputPathHooks) - await writeClientHooks( - client.services, - templates, - outputPathHooks, - httpClient, - useUnionTypes, - useOptions, - indent, - postfixServices, - clientName, - packageNames - ) - await writeClientIndexHooks( - client, - templates, - outputPathHooks, - useUnionTypes, - exportCore, - exportServices, - exportModels, - exportHooks, - exportSchemas, - postfixServices, - postfixModels, - clientName - ) - } - - /** - * Deprecate. To remove. - */ - if (exportSchemas) { - await rmdir(outputPathSchemas) - await mkdir(outputPathSchemas) - await writeClientSchemas( - client.models, - templates, - outputPathSchemas, - httpClient, - useUnionTypes, - indent - ) - } - - if (exportModels) { - await rmdir(outputPathModels) - await mkdir(outputPathModels) - await mkdir(outputPathCore) - await writeFile( - resolve(outputPathCore, "ModelUtils.ts"), - i(templates.core.modelUtils({}), indent) - ) - await writeClientModels( - client.models, - templates, - outputPathModels, - httpClient, - useUnionTypes, - indent - ) - await writeClientIndexModels( - client, - templates, - outputPathModels, - useUnionTypes, - exportCore, - exportServices, - exportModels, - exportHooks, - exportSchemas, - postfixServices, - postfixModels, - clientName - ) - } - - if (isDefined(clientName) && exportServices) { - await mkdir(outputPath) - await writeClientClass( - client, - templates, - outputPath, - httpClient, - clientName, - indent, - postfixServices - ) - } - - if (isDefined(clientName) && exportHooks) { - await mkdir(outputPath) - await mkdir(outputPathCore) - await writeFile( - resolve(outputPathCore, "HookUtils.ts"), - i(templates.core.hookUtils({}), indent) - ) - await writeUseClient( - client, - templates, - outputPath, - httpClient, - clientName, - indent, - postfixServices, - packageNames - ) - } - - if (exportCore || exportServices || exportSchemas || exportModels) { - await mkdir(outputPath) - await writeClientIndex( - client, - templates, - outputPath, - useUnionTypes, - exportCore, - exportServices, - exportModels, - exportHooks, - exportSchemas, - postfixServices, - postfixModels, - clientName - ) - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientClass.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientClass.ts deleted file mode 100644 index 685ab185c3..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientClass.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { resolve } from "path" - -import type { Client } from "../client/interfaces/Client" -import type { HttpClient } from "../HttpClient" -import type { Indent } from "../Indent" -import { writeFile } from "./fileSystem" -import { formatCode as f } from "./formatCode" -import { formatIndentation as i } from "./formatIndentation" -import { getHttpRequestName } from "./getHttpRequestName" -import type { Templates } from "./registerHandlebarTemplates" -import { sortModelsByName } from "./sortModelsByName" -import { sortServicesByName } from "./sortServicesByName" - -/** - * Generate the OpenAPI client index file using the Handlebar template and write it to disk. - * The index file just contains all the exports you need to use the client as a standalone - * library. But yuo can also import individual models and services directly. - * @param client Client object, containing, models, schemas and services - * @param templates The loaded handlebar templates - * @param outputPath Directory to write the generated files to - * @param httpClient The selected httpClient (fetch, xhr, node or axios) - * @param clientName Custom client class name - * @param indent Indentation options (4, 2 or tab) - * @param postfix Service name postfix - */ -export const writeClientClass = async ( - client: Client, - templates: Templates, - outputPath: string, - httpClient: HttpClient, - clientName: string, - indent: Indent, - postfix: string -): Promise => { - const templateResult = templates.client({ - clientName, - httpClient, - postfix, - server: client.server, - version: client.version, - models: sortModelsByName(client.models), - services: sortServicesByName(client.services), - httpRequest: getHttpRequestName(httpClient), - }) - - await writeFile( - resolve(outputPath, `${clientName}.ts`), - i(f(templateResult), indent) - ) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientCore.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientCore.ts deleted file mode 100644 index 3e17ef8349..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientCore.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { resolve } from "path" - -import type { Client } from "../client/interfaces/Client" -import type { HttpClient } from "../HttpClient" -import type { Indent } from "../Indent" -import { copyFile, exists, writeFile } from "./fileSystem" -import { formatIndentation as i } from "./formatIndentation" -import { getHttpRequestName } from "./getHttpRequestName" -import { isDefined } from "./isDefined" -import type { Templates } from "./registerHandlebarTemplates" - -/** - * Generate OpenAPI core files, this includes the basic boilerplate code to handle requests. - * @param client Client object, containing, models, schemas and services - * @param templates The loaded handlebar templates - * @param outputPath Directory to write the generated files to - * @param httpClient The selected httpClient (fetch, xhr, node or axios) - * @param indent Indentation options (4, 2 or tab) - * @param clientName Custom client class name - * @param request Path to custom request file - */ -export const writeClientCore = async ( - client: Client, - templates: Templates, - outputPath: string, - httpClient: HttpClient, - indent: Indent, - clientName?: string, - request?: string -): Promise => { - const httpRequest = getHttpRequestName(httpClient) - const context = { - httpClient, - clientName, - httpRequest, - server: client.server, - version: client.version, - } - - await writeFile( - resolve(outputPath, "OpenAPI.ts"), - i(templates.core.settings(context), indent) - ) - await writeFile( - resolve(outputPath, "ApiError.ts"), - i(templates.core.apiError(context), indent) - ) - await writeFile( - resolve(outputPath, "ApiRequestOptions.ts"), - i(templates.core.apiRequestOptions(context), indent) - ) - await writeFile( - resolve(outputPath, "ApiResult.ts"), - i(templates.core.apiResult(context), indent) - ) - await writeFile( - resolve(outputPath, "CancelablePromise.ts"), - i(templates.core.cancelablePromise(context), indent) - ) - await writeFile( - resolve(outputPath, "request.ts"), - i(templates.core.request(context), indent) - ) - - if (isDefined(clientName)) { - await writeFile( - resolve(outputPath, "BaseHttpRequest.ts"), - i(templates.core.baseHttpRequest(context), indent) - ) - await writeFile( - resolve(outputPath, `${httpRequest}.ts`), - i(templates.core.httpRequest(context), indent) - ) - } - - if (request) { - const requestFile = resolve(process.cwd(), request) - const requestFileExists = await exists(requestFile) - if (!requestFileExists) { - throw new Error(`Custom request file "${requestFile}" does not exists`) - } - await copyFile(requestFile, resolve(outputPath, "request.ts")) - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientHooks.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientHooks.ts deleted file mode 100644 index 7c9f2f15d1..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientHooks.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { resolve } from "path" - -import type { Service } from "../client/interfaces/Service" -import type { HttpClient } from "../HttpClient" -import type { Indent } from "../Indent" -import { writeFile } from "./fileSystem" -import { formatCode as f } from "./formatCode" -import { formatIndentation as i } from "./formatIndentation" -import type { Templates } from "./registerHandlebarTemplates" -import { PackageNames } from "../index" - -/** - * Generate Services using the Handlebar template and write to disk. - * @param services Array of Services to write - * @param templates The loaded handlebar templates - * @param outputPath Directory to write the generated files to - * @param httpClient The selected httpClient (fetch, xhr, node or axios) - * @param useUnionTypes Use union types instead of enums - * @param useOptions Use options or arguments functions - * @param indent Indentation options (4, 2 or tab) - * @param postfixServices Service name postfix - * @param clientName Custom client class name - * @param packageNames Package name to use in import statements. - */ -export const writeClientHooks = async ( - services: Service[], - templates: Templates, - outputPath: string, - httpClient: HttpClient, - useUnionTypes: boolean, - useOptions: boolean, - indent: Indent, - postfixServices: string, - clientName?: string, - packageNames: PackageNames = {} -): Promise => { - for (const service of services) { - const file = resolve(outputPath, `use${service.name}.ts`) - const templateResult = templates.exports.hook({ - ...service, - httpClient, - useUnionTypes, - useOptions, - postfixServices, - clientName, - packageNames, - }) - await writeFile(file, i(f(templateResult), indent)) - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientIndex.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientIndex.ts deleted file mode 100644 index 485675ec74..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientIndex.ts +++ /dev/null @@ -1,161 +0,0 @@ -import { resolve } from "path" - -import type { Client } from "../client/interfaces/Client" -import { writeFile } from "./fileSystem" -import { isDefined } from "./isDefined" -import { Templates } from "./registerHandlebarTemplates" -import { sortModelsByName } from "./sortModelsByName" -import { sortServicesByName } from "./sortServicesByName" - -/** - * Generate the OpenAPI client index file using the Handlebar template and write it to disk. - * The index file just contains all the exports you need to use the client as a standalone - * library. But yuo can also import individual models and services directly. - * @param client Client object, containing, models, schemas and services - * @param templates The loaded handlebar templates - * @param outputPath Directory to write the generated files to - * @param useUnionTypes Use union types instead of enums - * @param exportCore Generate core - * @param exportServices Generate services - * @param exportModels Generate models - * @param exportHooks Generate hooks - * @param exportSchemas Generate schemas - * @param postfixServices Service name postfix - * @param postfixModels Model name postfix - * @param clientName Custom client class name - */ -export const writeClientIndex = async ( - client: Client, - templates: Templates, - outputPath: string, - useUnionTypes: boolean, - exportCore: boolean, - exportServices: boolean, - exportModels: boolean, - exportHooks: boolean, - exportSchemas: boolean, - postfixServices: string, - postfixModels: string, - clientName?: string -): Promise => { - const templateResult = templates.indexes.index({ - exportCore, - exportServices, - exportModels, - exportHooks, - exportSchemas, - useUnionTypes, - postfixServices, - postfixModels, - clientName, - server: client.server, - version: client.version, - models: sortModelsByName(client.models), - services: sortServicesByName(client.services), - exportClient: isDefined(clientName) && exportServices, - }) - - await writeFile(resolve(outputPath, "index.ts"), templateResult) -} - -export const writeClientIndexModels = async ( - client: Client, - templates: Templates, - outputPath: string, - useUnionTypes: boolean, - exportCore: boolean, - exportServices: boolean, - exportModels: boolean, - exportHooks: boolean, - exportSchemas: boolean, - postfixServices: string, - postfixModels: string, - clientName?: string -): Promise => { - const templateResult = templates.indexes.indexModels({ - exportCore, - exportServices, - exportModels, - exportHooks, - exportSchemas, - useUnionTypes, - postfixServices, - postfixModels, - clientName, - server: client.server, - version: client.version, - models: sortModelsByName(client.models), - services: sortServicesByName(client.services), - exportClient: isDefined(clientName), - }) - - await writeFile(resolve(outputPath, "index.ts"), templateResult) -} - -export const writeClientIndexServices = async ( - client: Client, - templates: Templates, - outputPath: string, - useUnionTypes: boolean, - exportCore: boolean, - exportServices: boolean, - exportModels: boolean, - exportHooks: boolean, - exportSchemas: boolean, - postfixServices: string, - postfixModels: string, - clientName?: string -): Promise => { - const templateResult = templates.indexes.indexServices({ - exportCore, - exportServices, - exportModels, - exportHooks, - exportSchemas, - useUnionTypes, - postfixServices, - postfixModels, - clientName, - server: client.server, - version: client.version, - models: sortModelsByName(client.models), - services: sortServicesByName(client.services), - exportClient: isDefined(clientName), - }) - - await writeFile(resolve(outputPath, "index.ts"), templateResult) -} - -export const writeClientIndexHooks = async ( - client: Client, - templates: Templates, - outputPath: string, - useUnionTypes: boolean, - exportCore: boolean, - exportServices: boolean, - exportModels: boolean, - exportHooks: boolean, - exportSchemas: boolean, - postfixServices: string, - postfixModels: string, - clientName?: string -): Promise => { - const templateResult = templates.indexes.indexHooks({ - exportCore, - exportServices, - exportModels, - exportHooks, - exportSchemas, - useUnionTypes, - postfixServices, - postfixModels, - clientName, - server: client.server, - version: client.version, - models: sortModelsByName(client.models), - services: sortServicesByName(client.services), - exportClient: isDefined(clientName), - }) - - await writeFile(resolve(outputPath, "index.ts"), templateResult) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientModels.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientModels.ts deleted file mode 100644 index 7a8707a6aa..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientModels.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { resolve } from "path" - -import type { Model } from "../client/interfaces/Model" -import type { HttpClient } from "../HttpClient" -import type { Indent } from "../Indent" -import { writeFile } from "./fileSystem" -import { formatCode as f } from "./formatCode" -import { formatIndentation as i } from "./formatIndentation" -import type { Templates } from "./registerHandlebarTemplates" - -/** - * Generate Models using the Handlebar template and write to disk. - * @param models Array of Models to write - * @param templates The loaded handlebar templates - * @param outputPath Directory to write the generated files to - * @param httpClient The selected httpClient (fetch, xhr, node or axios) - * @param useUnionTypes Use union types instead of enums - * @param indent Indentation options (4, 2 or tab) - */ -export const writeClientModels = async ( - models: Model[], - templates: Templates, - outputPath: string, - httpClient: HttpClient, - useUnionTypes: boolean, - indent: Indent -): Promise => { - for (const model of models) { - const file = resolve(outputPath, `${model.name}.ts`) - const templateResult = templates.exports.model({ - ...model, - httpClient, - useUnionTypes, - }) - await writeFile(file, i(f(templateResult), indent)) - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientSchemas.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientSchemas.ts deleted file mode 100644 index 111df7851a..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientSchemas.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { resolve } from "path" - -import type { Model } from "../client/interfaces/Model" -import type { HttpClient } from "../HttpClient" -import type { Indent } from "../Indent" -import { writeFile } from "./fileSystem" -import { formatCode as f } from "./formatCode" -import { formatIndentation as i } from "./formatIndentation" -import type { Templates } from "./registerHandlebarTemplates" - -/** - * Generate Schemas using the Handlebar template and write to disk. - * @param models Array of Models to write - * @param templates The loaded handlebar templates - * @param outputPath Directory to write the generated files to - * @param httpClient The selected httpClient (fetch, xhr, node or axios) - * @param useUnionTypes Use union types instead of enums - * @param indent Indentation options (4, 2 or tab) - */ -export const writeClientSchemas = async ( - models: Model[], - templates: Templates, - outputPath: string, - httpClient: HttpClient, - useUnionTypes: boolean, - indent: Indent -): Promise => { - for (const model of models) { - const file = resolve(outputPath, `$${model.name}.ts`) - const templateResult = templates.exports.schema({ - ...model, - httpClient, - useUnionTypes, - }) - await writeFile(file, i(f(templateResult), indent)) - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientServices.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientServices.ts deleted file mode 100644 index 4e055038e5..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeClientServices.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { resolve } from "path" - -import type { Service } from "../client/interfaces/Service" -import type { HttpClient } from "../HttpClient" -import type { Indent } from "../Indent" -import { writeFile } from "./fileSystem" -import { formatCode as f } from "./formatCode" -import { formatIndentation as i } from "./formatIndentation" -import { isDefined } from "./isDefined" -import type { Templates } from "./registerHandlebarTemplates" -import { PackageNames } from "../index" - -/** - * Generate Services using the Handlebar template and write to disk. - * @param services Array of Services to write - * @param templates The loaded handlebar templates - * @param outputPath Directory to write the generated files to - * @param httpClient The selected httpClient (fetch, xhr, node or axios) - * @param useUnionTypes Use union types instead of enums - * @param useOptions Use options or arguments functions - * @param indent Indentation options (4, 2 or tab) - * @param postfix Service name postfix - * @param clientName Custom client class name - * @param packageNames Package name to use in import statements. - */ -export const writeClientServices = async ( - services: Service[], - templates: Templates, - outputPath: string, - httpClient: HttpClient, - useUnionTypes: boolean, - useOptions: boolean, - indent: Indent, - postfix: string, - clientName?: string, - packageNames: PackageNames = {} -): Promise => { - for (const service of services) { - const file = resolve(outputPath, `${service.name}${postfix}.ts`) - const templateResult = templates.exports.service({ - ...service, - httpClient, - useUnionTypes, - useOptions, - postfix, - exportClient: isDefined(clientName), - packageNames, - }) - await writeFile(file, i(f(templateResult), indent)) - } -} diff --git a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeUseClient.ts b/packages/cli/oas/openapi-typescript-codegen/src/utils/writeUseClient.ts deleted file mode 100644 index 76491d76e6..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/src/utils/writeUseClient.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { resolve } from "path" - -import type { Client } from "../client/interfaces/Client" -import type { HttpClient } from "../HttpClient" -import type { Indent } from "../Indent" -import { writeFile } from "./fileSystem" -import { formatCode as f } from "./formatCode" -import { formatIndentation as i } from "./formatIndentation" -import { getHttpRequestName } from "./getHttpRequestName" -import type { Templates } from "./registerHandlebarTemplates" -import { sortModelsByName } from "./sortModelsByName" -import { sortServicesByName } from "./sortServicesByName" -import camelCase from "camelcase" -import { PackageNames } from "../index" - -/** - * Generate context for hooks. - * @param client Client object, containing, models, schemas and services - * @param templates The loaded handlebar templates - * @param outputPath Directory to write the generated files to - * @param httpClient The selected httpClient (fetch, xhr, node or axios) - * @param clientName Custom client class name - * @param indent Indentation options (4, 2 or tab) - * @param postfix Service name postfix - * @param packageNames Package name to use in import statements. - */ -export const writeUseClient = async ( - client: Client, - templates: Templates, - outputPath: string, - httpClient: HttpClient, - clientName: string, - indent: Indent, - postfix: string, - packageNames: PackageNames = {} -): Promise => { - const templateResult = templates.useClient({ - clientName, - httpClient, - postfix, - server: client.server, - version: client.version, - models: sortModelsByName(client.models), - services: sortServicesByName(client.services), - httpRequest: getHttpRequestName(httpClient), - packageNames, - }) - - const filename = `use${camelCase(clientName, { pascalCase: true })}.tsx` - await writeFile(resolve(outputPath, filename), i(f(templateResult), indent)) -} diff --git a/packages/cli/oas/openapi-typescript-codegen/tsconfig.json b/packages/cli/oas/openapi-typescript-codegen/tsconfig.json deleted file mode 100644 index 293c548bdd..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "outDir": "./dist", - "target": "es2019", - "module": "commonjs", - "moduleResolution": "node", - "lib": ["es2019", "dom"], - "types": ["jest", "node"], - "declaration": false, - "declarationMap": false, - "sourceMap": false, - "noImplicitReturns": true, - "noImplicitThis": true, - "noImplicitAny": true, - "strict": true, - "skipLibCheck": true, - "allowSyntheticDefaultImports": true, - "experimentalDecorators": true - }, - - "files": ["./src/typings/hbs.d.ts"], - - "include": ["./src/**/*.ts"], - - "exclude": ["node_modules", "**/__mocks__"] -} diff --git a/packages/cli/oas/openapi-typescript-codegen/tsconfig.spec.json b/packages/cli/oas/openapi-typescript-codegen/tsconfig.spec.json deleted file mode 100644 index 9b62409191..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/tsconfig.spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/packages/cli/oas/openapi-typescript-codegen/types/index.d.ts b/packages/cli/oas/openapi-typescript-codegen/types/index.d.ts deleted file mode 100644 index 62cd066e76..0000000000 --- a/packages/cli/oas/openapi-typescript-codegen/types/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -export declare enum HttpClient { - FETCH = "fetch", - XHR = "xhr", - NODE = "node", - AXIOS = "axios", - ANGULAR = "angular", -} - -export declare enum Indent { - SPACE_4 = "4", - SPACE_2 = "2", - TAB = "tab", -} - -export type PackageNames = { - models?: string - client?: string -} - -export type Options = { - input: string | Record - output: string - httpClient?: HttpClient | "fetch" | "xhr" | "node" | "axios" | "angular" - clientName?: string - useOptions?: boolean - useUnionTypes?: boolean - exportCore?: boolean - exportServices?: boolean - exportModels?: boolean - exportHooks?: boolean - exportSchemas?: boolean - indent?: Indent | "4" | "2" | "tab" - packageNames?: PackageNames - postfixServices?: string - postfixModels?: string - request?: string - write?: boolean -} - -export declare function generate(options: Options): Promise - -declare type OpenAPI = { - HttpClient: HttpClient - Indent: Indent - generate: typeof generate -} - -export default OpenAPI diff --git a/packages/generated/client-types/src/lib/models/AdminPostCampaignsReq.ts b/packages/generated/client-types/src/lib/models/AdminPostCampaignsReq.ts deleted file mode 100644 index e9828672f5..0000000000 --- a/packages/generated/client-types/src/lib/models/AdminPostCampaignsReq.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { SetRelation, Merge } from "../core/ModelUtils" - -import type { CampaignBudget } from "./CampaignBudget" - -/** - * The promotion's campaign. - */ -export interface AdminPostCampaignsReq { - /** - * The campaign's name. - */ - name: string - /** - * The campaign's campaign identifier. - */ - campaign_identifier?: string - /** - * The campaign's description. - */ - description?: string - /** - * The campaign's currency. - */ - currency?: string - budget?: CampaignBudget - /** - * The campaign's starts at. - */ - starts_at?: string - /** - * The campaign's ends at. - */ - ends_at?: string - /** - * The campaign's promotions. - */ - promotions?: Array<{ - /** - * The promotion's ID. - */ - id: string - }> -} diff --git a/packages/generated/client-types/src/lib/models/ApplicationMethod.ts b/packages/generated/client-types/src/lib/models/ApplicationMethod.ts deleted file mode 100644 index 99707bbba8..0000000000 --- a/packages/generated/client-types/src/lib/models/ApplicationMethod.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { SetRelation, Merge } from "../core/ModelUtils" - -/** - * The promotion's application method. - */ -export interface ApplicationMethod {} diff --git a/packages/generated/client-types/src/lib/models/ApplicationMethodsMethodPostReq.ts b/packages/generated/client-types/src/lib/models/ApplicationMethodsMethodPostReq.ts deleted file mode 100644 index 2d743c6548..0000000000 --- a/packages/generated/client-types/src/lib/models/ApplicationMethodsMethodPostReq.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { SetRelation, Merge } from "../core/ModelUtils" - -/** - * The promotion's application method. - */ -export interface ApplicationMethodsMethodPostReq { - /** - * The application method's description. - */ - description?: string - /** - * The application method's value. - */ - value?: string - /** - * The application method's max quantity. - */ - max_quantity?: number - type?: "fixed" | "percentage" - target_type?: "order" | "shipping_methods" | "items" - allocation?: "each" | "across" - /** - * The application method's target rules. - */ - target_rules?: Array<{ - operator: "gte" | "lte" | "gt" | "lt" | "eq" | "ne" | "in" - /** - * The target rule's description. - */ - description?: string - /** - * The target rule's attribute. - */ - attribute: string - /** - * The target rule's values. - */ - values: Array - }> - /** - * The application method's buy rules. - */ - buy_rules?: Array<{ - operator: "gte" | "lte" | "gt" | "lt" | "eq" | "ne" | "in" - /** - * The buy rule's description. - */ - description?: string - /** - * The buy rule's attribute. - */ - attribute: string - /** - * The buy rule's values. - */ - values: Array - }> - /** - * The application method's apply to quantity. - */ - apply_to_quantity?: number - /** - * The application method's buy rules min quantity. - */ - buy_rules_min_quantity?: number -} diff --git a/packages/generated/client-types/src/lib/models/Campaign.ts b/packages/generated/client-types/src/lib/models/Campaign.ts deleted file mode 100644 index 809274e05d..0000000000 --- a/packages/generated/client-types/src/lib/models/Campaign.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { SetRelation, Merge } from "../core/ModelUtils" - -/** - * The promotion's campaign. - */ -export interface Campaign {} diff --git a/packages/generated/client-types/src/lib/models/CampaignBudget.ts b/packages/generated/client-types/src/lib/models/CampaignBudget.ts deleted file mode 100644 index beeef8dd53..0000000000 --- a/packages/generated/client-types/src/lib/models/CampaignBudget.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { SetRelation, Merge } from "../core/ModelUtils" - -/** - * The campaign's budget. - */ -export interface CampaignBudget { - type?: "spend" | "usage" - /** - * The budget's limit. - */ - limit?: number -} diff --git a/packages/generated/client-types/src/lib/models/CreateApplicationMethod.ts b/packages/generated/client-types/src/lib/models/CreateApplicationMethod.ts deleted file mode 100644 index 79436e2b3c..0000000000 --- a/packages/generated/client-types/src/lib/models/CreateApplicationMethod.ts +++ /dev/null @@ -1,85 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { SetRelation, Merge } from "../core/ModelUtils" - -import type { ApplicationMethod } from "./ApplicationMethod" -import type { Campaign } from "./Campaign" - -/** - * The promotion's application method. - */ -export interface CreateApplicationMethod { - type: "fixed" | "percentage" - target_type: "order" | "shipping_methods" | "items" - allocation?: "each" | "across" - /** - * The application method's value. - */ - value?: number - /** - * The application method's max quantity. - */ - max_quantity?: number - /** - * The application method's buy rules min quantity. - */ - buy_rules_min_quantity?: number - /** - * The application method's apply to quantity. - */ - apply_to_quantity?: number - promotion?: - | string - | { - /** - * The promotion's ID. - */ - id: string - /** - * The promotion's code. - */ - code?: string - type?: "standard" | "buyget" - /** - * The promotion's is automatic. - */ - is_automatic?: boolean - application_method?: ApplicationMethod - /** - * The promotion's rules. - */ - rules?: Array - campaign?: Campaign - } - /** - * The application method's target rules. - */ - target_rules?: Array<{ - /** - * The target rule's description. - */ - description?: string - /** - * The target rule's attribute. - */ - attribute: string - operator: "gt" | "lt" | "eq" | "ne" | "in" | "lte" | "gte" - values: string | Array - }> - /** - * The application method's buy rules. - */ - buy_rules?: Array<{ - /** - * The buy rule's description. - */ - description?: string - /** - * The buy rule's attribute. - */ - attribute: string - operator: "gt" | "lt" | "eq" | "ne" | "in" | "lte" | "gte" - values: string | Array - }> -} diff --git a/packages/generated/client-types/src/lib/models/CreateCampaign.ts b/packages/generated/client-types/src/lib/models/CreateCampaign.ts deleted file mode 100644 index 49d3a696c2..0000000000 --- a/packages/generated/client-types/src/lib/models/CreateCampaign.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { SetRelation, Merge } from "../core/ModelUtils" - -import type { CreateCampaignBudget } from "./CreateCampaignBudget" - -/** - * The promotion's campaign. - */ -export interface CreateCampaign { - /** - * The campaign's name. - */ - name: string - /** - * The campaign's description. - */ - description?: string - /** - * The campaign's currency. - */ - currency?: string - /** - * The campaign's campaign identifier. - */ - campaign_identifier: string - /** - * The campaign's starts at. - */ - starts_at: string - /** - * The campaign's ends at. - */ - ends_at: string - budget?: CreateCampaignBudget - /** - * The campaign's promotions. - */ - promotions?: Array<{ - /** - * The promotion's ID. - */ - id: string - }> -} diff --git a/packages/generated/client-types/src/lib/models/CreateCampaignBudget.ts b/packages/generated/client-types/src/lib/models/CreateCampaignBudget.ts deleted file mode 100644 index dae531a4ed..0000000000 --- a/packages/generated/client-types/src/lib/models/CreateCampaignBudget.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { SetRelation, Merge } from "../core/ModelUtils" - -/** - * The campaign's budget. - */ -export interface CreateCampaignBudget { - type: "spend" | "usage" - /** - * The budget's limit. - */ - limit: number - /** - * The budget's used. - */ - used?: number -} diff --git a/packages/generated/client-types/src/lib/models/CreateDefaultTaxRate.ts b/packages/generated/client-types/src/lib/models/CreateDefaultTaxRate.ts deleted file mode 100644 index 2d6cd5ebaf..0000000000 --- a/packages/generated/client-types/src/lib/models/CreateDefaultTaxRate.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { SetRelation, Merge } from "../core/ModelUtils" - -/** - * The tax region's default tax rate. - */ -export interface CreateDefaultTaxRate { - /** - * The default tax rate's rate. - */ - rate?: number - /** - * The default tax rate's code. - */ - code?: string - /** - * The default tax rate's name. - */ - name: string - /** - * The default tax rate's metadata. - */ - metadata?: any -} diff --git a/packages/generated/client-types/src/lib/models/CreateProductType.ts b/packages/generated/client-types/src/lib/models/CreateProductType.ts deleted file mode 100644 index 99fd5258e9..0000000000 --- a/packages/generated/client-types/src/lib/models/CreateProductType.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { SetRelation, Merge } from "../core/ModelUtils" - -/** - * The product's type. - */ -export interface CreateProductType { - /** - * The type's ID. - */ - id?: string - /** - * The type's value. - */ - value: string - /** - * The type's metadata. - */ - metadata?: any -} diff --git a/packages/generated/client-types/src/lib/models/StockLocationAddress.ts b/packages/generated/client-types/src/lib/models/StockLocationAddress.ts deleted file mode 100644 index b659b6676b..0000000000 --- a/packages/generated/client-types/src/lib/models/StockLocationAddress.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { SetRelation, Merge } from "../core/ModelUtils" - -/** - * The stock location's address. - */ -export interface StockLocationAddress { - /** - * The address's address 1. - */ - address_1: string - /** - * The address's address 2. - */ - address_2?: string - /** - * The address's company. - */ - company?: string - /** - * The address's city. - */ - city?: string - /** - * The address's country code. - */ - country_code: string - /** - * The address's phone. - */ - phone?: string - /** - * The address's postal code. - */ - postal_code?: string - /** - * The address's province. - */ - province?: string -} diff --git a/packages/generated/client-types/src/lib/models/StorePostPaymentCollectionsPaymentSessionReq.ts b/packages/generated/client-types/src/lib/models/StorePostPaymentCollectionsPaymentSessionReq.ts deleted file mode 100644 index 11a0ebe236..0000000000 --- a/packages/generated/client-types/src/lib/models/StorePostPaymentCollectionsPaymentSessionReq.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { SetRelation, Merge } from "../core/ModelUtils" - -/** - * SUMMARY - */ -export interface StorePostPaymentCollectionsPaymentSessionReq { - /** - * The payment collection's provider id. - */ - provider_id: string - context?: any - /** - * The payment collection's data. - */ - data?: any -} diff --git a/yarn.lock b/yarn.lock index c40ab21e01..989dab6f89 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,18 +29,6 @@ __metadata: languageName: node linkType: hard -"@apidevtools/json-schema-ref-parser@npm:9.0.9": - version: 9.0.9 - resolution: "@apidevtools/json-schema-ref-parser@npm:9.0.9" - dependencies: - "@jsdevtools/ono": ^7.1.3 - "@types/json-schema": ^7.0.6 - call-me-maybe: ^1.0.1 - js-yaml: ^4.1.0 - checksum: d1457e57ca12abcd3da25b9a2cb2982267102c65aefeaf284a3321b818090b9032d6b7a3ad9625abc00d07f5b1432d643f79aa6f515c1a787523d40563ef85e4 - languageName: node - linkType: hard - "@apidevtools/openapi-schemas@npm:^2.1.0": version: 2.1.0 resolution: "@apidevtools/openapi-schemas@npm:2.1.0" @@ -843,33 +831,6 @@ __metadata: languageName: node linkType: hard -"@babel/cli@npm:7.14.3": - version: 7.14.3 - resolution: "@babel/cli@npm:7.14.3" - dependencies: - "@nicolo-ribaudo/chokidar-2": 2.1.8-no-fsevents - chokidar: ^3.4.0 - commander: ^4.0.1 - convert-source-map: ^1.1.0 - fs-readdir-recursive: ^1.1.0 - glob: ^7.0.0 - make-dir: ^2.1.0 - slash: ^2.0.0 - source-map: ^0.5.0 - peerDependencies: - "@babel/core": ^7.0.0-0 - dependenciesMeta: - "@nicolo-ribaudo/chokidar-2": - optional: true - chokidar: - optional: true - bin: - babel: ./bin/babel.js - babel-external-helpers: ./bin/babel-external-helpers.js - checksum: fb314827536ac00d22516c376d5ec36c14219c615406dd35ea3326034675ac90f86a52a9a7ca03901cf3e3cd5c902902894a4ecaa1de1204542f69dca8074f8e - languageName: node - linkType: hard - "@babel/code-frame@npm:7.12.11": version: 7.12.11 resolution: "@babel/code-frame@npm:7.12.11" @@ -889,36 +850,13 @@ __metadata: languageName: node linkType: hard -"@babel/compat-data@npm:^7.11.0, @babel/compat-data@npm:^7.20.5, @babel/compat-data@npm:^7.22.6, @babel/compat-data@npm:^7.23.5, @babel/compat-data@npm:^7.24.4": +"@babel/compat-data@npm:^7.22.6, @babel/compat-data@npm:^7.23.5, @babel/compat-data@npm:^7.24.4": version: 7.24.4 resolution: "@babel/compat-data@npm:7.24.4" checksum: 9cd8a9cd28a5ca6db5d0e27417d609f95a8762b655e8c9c97fd2de08997043ae99f0139007083c5e607601c6122e8432c85fe391731b19bf26ad458fa0c60dd3 languageName: node linkType: hard -"@babel/core@npm:7.14.3": - version: 7.14.3 - resolution: "@babel/core@npm:7.14.3" - dependencies: - "@babel/code-frame": ^7.12.13 - "@babel/generator": ^7.14.3 - "@babel/helper-compilation-targets": ^7.13.16 - "@babel/helper-module-transforms": ^7.14.2 - "@babel/helpers": ^7.14.0 - "@babel/parser": ^7.14.3 - "@babel/template": ^7.12.13 - "@babel/traverse": ^7.14.2 - "@babel/types": ^7.14.2 - convert-source-map: ^1.7.0 - debug: ^4.1.0 - gensync: ^1.0.0-beta.2 - json5: ^2.1.2 - semver: ^6.3.0 - source-map: ^0.5.0 - checksum: c6bdfc5a76149de34ba414b327c1f69fb9b5902f4e999a4a6e21488585758365c94b1384c81e207baec743cfc07bbd139ca07f95c7dd4a831116e32d98121d1f - languageName: node - linkType: hard - "@babel/core@npm:^7.1.0, @babel/core@npm:^7.11.6, @babel/core@npm:^7.12.10, @babel/core@npm:^7.12.3, @babel/core@npm:^7.18.9, @babel/core@npm:^7.20.12, @babel/core@npm:^7.21.3, @babel/core@npm:^7.23.0, @babel/core@npm:^7.23.2, @babel/core@npm:^7.23.5, @babel/core@npm:^7.23.9, @babel/core@npm:^7.7.5": version: 7.24.5 resolution: "@babel/core@npm:7.24.5" @@ -942,7 +880,7 @@ __metadata: languageName: node linkType: hard -"@babel/generator@npm:^7.14.3, @babel/generator@npm:^7.23.0, @babel/generator@npm:^7.23.5, @babel/generator@npm:^7.24.5, @babel/generator@npm:^7.7.2": +"@babel/generator@npm:^7.23.0, @babel/generator@npm:^7.23.5, @babel/generator@npm:^7.24.5, @babel/generator@npm:^7.7.2": version: 7.24.5 resolution: "@babel/generator@npm:7.24.5" dependencies: @@ -972,7 +910,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-compilation-targets@npm:^7.10.4, @babel/helper-compilation-targets@npm:^7.13.16, @babel/helper-compilation-targets@npm:^7.20.7, @babel/helper-compilation-targets@npm:^7.22.6, @babel/helper-compilation-targets@npm:^7.23.6": +"@babel/helper-compilation-targets@npm:^7.22.6, @babel/helper-compilation-targets@npm:^7.23.6": version: 7.23.6 resolution: "@babel/helper-compilation-targets@npm:7.23.6" dependencies: @@ -985,7 +923,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-create-class-features-plugin@npm:^7.12.1, @babel/helper-create-class-features-plugin@npm:^7.18.6, @babel/helper-create-class-features-plugin@npm:^7.24.1, @babel/helper-create-class-features-plugin@npm:^7.24.4, @babel/helper-create-class-features-plugin@npm:^7.24.5": +"@babel/helper-create-class-features-plugin@npm:^7.12.1, @babel/helper-create-class-features-plugin@npm:^7.24.1, @babel/helper-create-class-features-plugin@npm:^7.24.4, @babel/helper-create-class-features-plugin@npm:^7.24.5": version: 7.24.5 resolution: "@babel/helper-create-class-features-plugin@npm:7.24.5" dependencies: @@ -1032,7 +970,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-environment-visitor@npm:^7.18.9, @babel/helper-environment-visitor@npm:^7.22.20": +"@babel/helper-environment-visitor@npm:^7.22.20": version: 7.22.20 resolution: "@babel/helper-environment-visitor@npm:7.22.20" checksum: e762c2d8f5d423af89bd7ae9abe35bd4836d2eb401af868a63bbb63220c513c783e25ef001019418560b3fdc6d9a6fb67e6c0b650bcdeb3a2ac44b5c3d2bdd94 @@ -1076,7 +1014,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-module-transforms@npm:^7.14.2, @babel/helper-module-transforms@npm:^7.23.3, @babel/helper-module-transforms@npm:^7.24.5": +"@babel/helper-module-transforms@npm:^7.23.3, @babel/helper-module-transforms@npm:^7.24.5": version: 7.24.5 resolution: "@babel/helper-module-transforms@npm:7.24.5" dependencies: @@ -1100,14 +1038,14 @@ __metadata: languageName: node linkType: hard -"@babel/helper-plugin-utils@npm:^7.0.0, @babel/helper-plugin-utils@npm:^7.10.4, @babel/helper-plugin-utils@npm:^7.12.13, @babel/helper-plugin-utils@npm:^7.14.5, @babel/helper-plugin-utils@npm:^7.18.6, @babel/helper-plugin-utils@npm:^7.18.9, @babel/helper-plugin-utils@npm:^7.20.2, @babel/helper-plugin-utils@npm:^7.22.5, @babel/helper-plugin-utils@npm:^7.24.0, @babel/helper-plugin-utils@npm:^7.24.5, @babel/helper-plugin-utils@npm:^7.8.0, @babel/helper-plugin-utils@npm:^7.8.3": +"@babel/helper-plugin-utils@npm:^7.0.0, @babel/helper-plugin-utils@npm:^7.10.4, @babel/helper-plugin-utils@npm:^7.12.13, @babel/helper-plugin-utils@npm:^7.14.5, @babel/helper-plugin-utils@npm:^7.18.6, @babel/helper-plugin-utils@npm:^7.22.5, @babel/helper-plugin-utils@npm:^7.24.0, @babel/helper-plugin-utils@npm:^7.24.5, @babel/helper-plugin-utils@npm:^7.8.0, @babel/helper-plugin-utils@npm:^7.8.3": version: 7.24.5 resolution: "@babel/helper-plugin-utils@npm:7.24.5" checksum: 4ae40094e6a2f183281213344f4df60c66b16b19a2bc38d2bb11810a6dc0a0e7ec638957d0e433ff8b615775b8f3cd1b7edbf59440d1b50e73c389fc22913377 languageName: node linkType: hard -"@babel/helper-remap-async-to-generator@npm:^7.18.9, @babel/helper-remap-async-to-generator@npm:^7.22.20": +"@babel/helper-remap-async-to-generator@npm:^7.22.20": version: 7.22.20 resolution: "@babel/helper-remap-async-to-generator@npm:7.22.20" dependencies: @@ -1142,7 +1080,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-skip-transparent-expression-wrappers@npm:^7.20.0, @babel/helper-skip-transparent-expression-wrappers@npm:^7.22.5": +"@babel/helper-skip-transparent-expression-wrappers@npm:^7.22.5": version: 7.22.5 resolution: "@babel/helper-skip-transparent-expression-wrappers@npm:7.22.5" dependencies: @@ -1174,7 +1112,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-validator-option@npm:^7.18.6, @babel/helper-validator-option@npm:^7.23.5": +"@babel/helper-validator-option@npm:^7.23.5": version: 7.23.5 resolution: "@babel/helper-validator-option@npm:7.23.5" checksum: af45d5c0defb292ba6fd38979e8f13d7da63f9623d8ab9ededc394f67eb45857d2601278d151ae9affb6e03d5d608485806cd45af08b4468a0515cf506510e94 @@ -1192,7 +1130,7 @@ __metadata: languageName: node linkType: hard -"@babel/helpers@npm:^7.14.0, @babel/helpers@npm:^7.24.5": +"@babel/helpers@npm:^7.24.5": version: 7.24.5 resolution: "@babel/helpers@npm:7.24.5" dependencies: @@ -1224,7 +1162,7 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.3, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.23.0, @babel/parser@npm:^7.23.5, @babel/parser@npm:^7.23.9, @babel/parser@npm:^7.24.0, @babel/parser@npm:^7.24.5, @babel/parser@npm:^7.3.3": +"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.23.0, @babel/parser@npm:^7.23.5, @babel/parser@npm:^7.23.9, @babel/parser@npm:^7.24.0, @babel/parser@npm:^7.24.5, @babel/parser@npm:^7.3.3": version: 7.24.5 resolution: "@babel/parser@npm:7.24.5" bin: @@ -1281,20 +1219,6 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-proposal-async-generator-functions@npm:^7.10.4": - version: 7.20.7 - resolution: "@babel/plugin-proposal-async-generator-functions@npm:7.20.7" - dependencies: - "@babel/helper-environment-visitor": ^7.18.9 - "@babel/helper-plugin-utils": ^7.20.2 - "@babel/helper-remap-async-to-generator": ^7.18.9 - "@babel/plugin-syntax-async-generators": ^7.8.4 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: 0f4bc01805704ae4840536acc9888c50a32250e9188d025063bd17fe77ed171a12361c3dc83ce99664dcd73aec612accb8da95b0d8b825c854931b2860c0bfb5 - languageName: node - linkType: hard - "@babel/plugin-proposal-class-properties@npm:7.12.1": version: 7.12.1 resolution: "@babel/plugin-proposal-class-properties@npm:7.12.1" @@ -1307,142 +1231,6 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-proposal-class-properties@npm:^7.10.4": - version: 7.18.6 - resolution: "@babel/plugin-proposal-class-properties@npm:7.18.6" - dependencies: - "@babel/helper-create-class-features-plugin": ^7.18.6 - "@babel/helper-plugin-utils": ^7.18.6 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: d5172ac6c9948cdfc387e94f3493ad86cb04035cf7433f86b5d358270b1b9752dc25e176db0c5d65892a246aca7bdb4636672e15626d7a7de4bc0bd0040168d9 - languageName: node - linkType: hard - -"@babel/plugin-proposal-dynamic-import@npm:^7.10.4": - version: 7.18.6 - resolution: "@babel/plugin-proposal-dynamic-import@npm:7.18.6" - dependencies: - "@babel/helper-plugin-utils": ^7.18.6 - "@babel/plugin-syntax-dynamic-import": ^7.8.3 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: 99be9865edfd65a46afb97d877ea247a8e881b4d0246a1ea0adf6db04c92f4f0959bd2f6f706d73248a2a7167c34f2464c4863137ddb94deadc5c7cc8bfc3e72 - languageName: node - linkType: hard - -"@babel/plugin-proposal-export-namespace-from@npm:^7.10.4": - version: 7.18.9 - resolution: "@babel/plugin-proposal-export-namespace-from@npm:7.18.9" - dependencies: - "@babel/helper-plugin-utils": ^7.18.9 - "@babel/plugin-syntax-export-namespace-from": ^7.8.3 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: b90346bd3628ebd44138d0628a5aba1e6b11748893fb48e87008cac30f3bc7cd3161362e49433156737350318174164436357a66fbbfdbe952606b460bd8a0e4 - languageName: node - linkType: hard - -"@babel/plugin-proposal-json-strings@npm:^7.10.4": - version: 7.18.6 - resolution: "@babel/plugin-proposal-json-strings@npm:7.18.6" - dependencies: - "@babel/helper-plugin-utils": ^7.18.6 - "@babel/plugin-syntax-json-strings": ^7.8.3 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: 83f2ce41262a538ee43450044b9b0de320002473e4849421a7318c0500f9b0385c03d228f1be777ad71fd358aef13392e3551f0be52b5c423b0c34f7c9e5a06d - languageName: node - linkType: hard - -"@babel/plugin-proposal-logical-assignment-operators@npm:^7.11.0": - version: 7.20.7 - resolution: "@babel/plugin-proposal-logical-assignment-operators@npm:7.20.7" - dependencies: - "@babel/helper-plugin-utils": ^7.20.2 - "@babel/plugin-syntax-logical-assignment-operators": ^7.10.4 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: 436c1ee9f983813fc52788980a7231414351bd34d80b16b83bddb09115386292fe4912cc6d172304eabbaf0c4813625331b9b5bc798acb0e8925cf0d2b394d4d - languageName: node - linkType: hard - -"@babel/plugin-proposal-nullish-coalescing-operator@npm:^7.10.4": - version: 7.18.6 - resolution: "@babel/plugin-proposal-nullish-coalescing-operator@npm:7.18.6" - dependencies: - "@babel/helper-plugin-utils": ^7.18.6 - "@babel/plugin-syntax-nullish-coalescing-operator": ^7.8.3 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: f6629158196ee9f16295d16db75825092ef543f8b98f4dfdd516e642a0430c7b1d69319ee676d35485d9b86a53ade6de0b883490d44de6d4336d38cdeccbe0bf - languageName: node - linkType: hard - -"@babel/plugin-proposal-numeric-separator@npm:^7.10.4": - version: 7.18.6 - resolution: "@babel/plugin-proposal-numeric-separator@npm:7.18.6" - dependencies: - "@babel/helper-plugin-utils": ^7.18.6 - "@babel/plugin-syntax-numeric-separator": ^7.10.4 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: a83a65c6ec0d2293d830e9db61406d246f22d8ea03583d68460cb1b6330c6699320acce1b45f66ba3c357830720e49267e3d99f95088be457c66e6450fbfe3fa - languageName: node - linkType: hard - -"@babel/plugin-proposal-object-rest-spread@npm:^7.11.0": - version: 7.20.7 - resolution: "@babel/plugin-proposal-object-rest-spread@npm:7.20.7" - dependencies: - "@babel/compat-data": ^7.20.5 - "@babel/helper-compilation-targets": ^7.20.7 - "@babel/helper-plugin-utils": ^7.20.2 - "@babel/plugin-syntax-object-rest-spread": ^7.8.3 - "@babel/plugin-transform-parameters": ^7.20.7 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: b9818749bb49d8095df64c45db682448d04743d96722984cbfd375733b2585c26d807f84b4fdb28474f2d614be6a6ffe3d96ffb121840e9e5345b2ccc0438bd8 - languageName: node - linkType: hard - -"@babel/plugin-proposal-optional-catch-binding@npm:^7.10.4": - version: 7.18.6 - resolution: "@babel/plugin-proposal-optional-catch-binding@npm:7.18.6" - dependencies: - "@babel/helper-plugin-utils": ^7.18.6 - "@babel/plugin-syntax-optional-catch-binding": ^7.8.3 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: ab20153d9e95e0b73004fdf86b6a2d219be2a0ace9ca76cd9eccddb680c913fec173bca54d761b1bc6044edde0a53811f3e515908c3b16d2d81cfec1e2e17391 - languageName: node - linkType: hard - -"@babel/plugin-proposal-optional-chaining@npm:^7.11.0": - version: 7.21.0 - resolution: "@babel/plugin-proposal-optional-chaining@npm:7.21.0" - dependencies: - "@babel/helper-plugin-utils": ^7.20.2 - "@babel/helper-skip-transparent-expression-wrappers": ^7.20.0 - "@babel/plugin-syntax-optional-chaining": ^7.8.3 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: b524a61b1de3f3ad287cd1e98c2a7f662178d21cd02205b0d615512e475f0159fa1b569fa7e34c8ed67baef689c0136fa20ba7d1bf058d186d30736a581a723f - languageName: node - linkType: hard - -"@babel/plugin-proposal-private-methods@npm:^7.10.4": - version: 7.18.6 - resolution: "@babel/plugin-proposal-private-methods@npm:7.18.6" - dependencies: - "@babel/helper-create-class-features-plugin": ^7.18.6 - "@babel/helper-plugin-utils": ^7.18.6 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: 1c273d0ec3d49d0fe80bd754ec0191016e5b3ab4fb1e162ac0c014e9d3c1517a5d973afbf8b6dc9f9c98a8605c79e5f9e8b5ee158a4313fa68d1ff7b02084b6a - languageName: node - linkType: hard - "@babel/plugin-proposal-private-property-in-object@npm:7.21.0-placeholder-for-preset-env.2": version: 7.21.0-placeholder-for-preset-env.2 resolution: "@babel/plugin-proposal-private-property-in-object@npm:7.21.0-placeholder-for-preset-env.2" @@ -1452,19 +1240,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-proposal-unicode-property-regex@npm:^7.10.4, @babel/plugin-proposal-unicode-property-regex@npm:^7.4.4": - version: 7.18.6 - resolution: "@babel/plugin-proposal-unicode-property-regex@npm:7.18.6" - dependencies: - "@babel/helper-create-regexp-features-plugin": ^7.18.6 - "@babel/helper-plugin-utils": ^7.18.6 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: c68feae57d9b1f4d98ecc2da63bda1993980deb509ccb08f6eace712ece8081032eb6532c304524b544c2dd577e2f9c2fe5c5bfd73d1955c946300def6fc7493 - languageName: node - linkType: hard - -"@babel/plugin-syntax-async-generators@npm:^7.8.0, @babel/plugin-syntax-async-generators@npm:^7.8.4": +"@babel/plugin-syntax-async-generators@npm:^7.8.4": version: 7.8.4 resolution: "@babel/plugin-syntax-async-generators@npm:7.8.4" dependencies: @@ -1486,7 +1262,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-class-properties@npm:^7.10.4, @babel/plugin-syntax-class-properties@npm:^7.12.13, @babel/plugin-syntax-class-properties@npm:^7.8.3": +"@babel/plugin-syntax-class-properties@npm:^7.12.13, @babel/plugin-syntax-class-properties@npm:^7.8.3": version: 7.12.13 resolution: "@babel/plugin-syntax-class-properties@npm:7.12.13" dependencies: @@ -1508,7 +1284,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-dynamic-import@npm:^7.8.0, @babel/plugin-syntax-dynamic-import@npm:^7.8.3": +"@babel/plugin-syntax-dynamic-import@npm:^7.8.3": version: 7.8.3 resolution: "@babel/plugin-syntax-dynamic-import@npm:7.8.3" dependencies: @@ -1574,7 +1350,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-json-strings@npm:^7.8.0, @babel/plugin-syntax-json-strings@npm:^7.8.3": +"@babel/plugin-syntax-json-strings@npm:^7.8.3": version: 7.8.3 resolution: "@babel/plugin-syntax-json-strings@npm:7.8.3" dependencies: @@ -1607,7 +1383,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-nullish-coalescing-operator@npm:^7.8.0, @babel/plugin-syntax-nullish-coalescing-operator@npm:^7.8.3": +"@babel/plugin-syntax-nullish-coalescing-operator@npm:^7.8.3": version: 7.8.3 resolution: "@babel/plugin-syntax-nullish-coalescing-operator@npm:7.8.3" dependencies: @@ -1629,7 +1405,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-object-rest-spread@npm:^7.8.0, @babel/plugin-syntax-object-rest-spread@npm:^7.8.3": +"@babel/plugin-syntax-object-rest-spread@npm:^7.8.3": version: 7.8.3 resolution: "@babel/plugin-syntax-object-rest-spread@npm:7.8.3" dependencies: @@ -1640,7 +1416,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-optional-catch-binding@npm:^7.8.0, @babel/plugin-syntax-optional-catch-binding@npm:^7.8.3": +"@babel/plugin-syntax-optional-catch-binding@npm:^7.8.3": version: 7.8.3 resolution: "@babel/plugin-syntax-optional-catch-binding@npm:7.8.3" dependencies: @@ -1651,7 +1427,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-optional-chaining@npm:^7.8.0, @babel/plugin-syntax-optional-chaining@npm:^7.8.3": +"@babel/plugin-syntax-optional-chaining@npm:^7.8.3": version: 7.8.3 resolution: "@babel/plugin-syntax-optional-chaining@npm:7.8.3" dependencies: @@ -1673,7 +1449,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-top-level-await@npm:^7.10.4, @babel/plugin-syntax-top-level-await@npm:^7.14.5, @babel/plugin-syntax-top-level-await@npm:^7.8.3": +"@babel/plugin-syntax-top-level-await@npm:^7.14.5, @babel/plugin-syntax-top-level-await@npm:^7.8.3": version: 7.14.5 resolution: "@babel/plugin-syntax-top-level-await@npm:7.14.5" dependencies: @@ -1707,7 +1483,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-arrow-functions@npm:^7.10.4, @babel/plugin-transform-arrow-functions@npm:^7.24.1": +"@babel/plugin-transform-arrow-functions@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-arrow-functions@npm:7.24.1" dependencies: @@ -1732,7 +1508,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-async-to-generator@npm:^7.10.4, @babel/plugin-transform-async-to-generator@npm:^7.24.1": +"@babel/plugin-transform-async-to-generator@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-async-to-generator@npm:7.24.1" dependencies: @@ -1745,7 +1521,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-block-scoped-functions@npm:^7.10.4, @babel/plugin-transform-block-scoped-functions@npm:^7.24.1": +"@babel/plugin-transform-block-scoped-functions@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-block-scoped-functions@npm:7.24.1" dependencies: @@ -1756,7 +1532,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-block-scoping@npm:^7.10.4, @babel/plugin-transform-block-scoping@npm:^7.24.5": +"@babel/plugin-transform-block-scoping@npm:^7.24.5": version: 7.24.5 resolution: "@babel/plugin-transform-block-scoping@npm:7.24.5" dependencies: @@ -1792,7 +1568,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-classes@npm:^7.10.4, @babel/plugin-transform-classes@npm:^7.24.5": +"@babel/plugin-transform-classes@npm:^7.24.5": version: 7.24.5 resolution: "@babel/plugin-transform-classes@npm:7.24.5" dependencies: @@ -1810,7 +1586,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-computed-properties@npm:^7.10.4, @babel/plugin-transform-computed-properties@npm:^7.24.1": +"@babel/plugin-transform-computed-properties@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-computed-properties@npm:7.24.1" dependencies: @@ -1822,7 +1598,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-destructuring@npm:^7.10.4, @babel/plugin-transform-destructuring@npm:^7.24.5": +"@babel/plugin-transform-destructuring@npm:^7.24.5": version: 7.24.5 resolution: "@babel/plugin-transform-destructuring@npm:7.24.5" dependencies: @@ -1833,7 +1609,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-dotall-regex@npm:^7.10.4, @babel/plugin-transform-dotall-regex@npm:^7.24.1, @babel/plugin-transform-dotall-regex@npm:^7.4.4": +"@babel/plugin-transform-dotall-regex@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-dotall-regex@npm:7.24.1" dependencies: @@ -1845,7 +1621,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-duplicate-keys@npm:^7.10.4, @babel/plugin-transform-duplicate-keys@npm:^7.24.1": +"@babel/plugin-transform-duplicate-keys@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-duplicate-keys@npm:7.24.1" dependencies: @@ -1868,7 +1644,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-exponentiation-operator@npm:^7.10.4, @babel/plugin-transform-exponentiation-operator@npm:^7.24.1": +"@babel/plugin-transform-exponentiation-operator@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-exponentiation-operator@npm:7.24.1" dependencies: @@ -1904,7 +1680,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-for-of@npm:^7.10.4, @babel/plugin-transform-for-of@npm:^7.24.1": +"@babel/plugin-transform-for-of@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-for-of@npm:7.24.1" dependencies: @@ -1916,7 +1692,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-function-name@npm:^7.10.4, @babel/plugin-transform-function-name@npm:^7.24.1": +"@babel/plugin-transform-function-name@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-function-name@npm:7.24.1" dependencies: @@ -1941,7 +1717,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-literals@npm:^7.10.4, @babel/plugin-transform-literals@npm:^7.24.1": +"@babel/plugin-transform-literals@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-literals@npm:7.24.1" dependencies: @@ -1964,7 +1740,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-member-expression-literals@npm:^7.10.4, @babel/plugin-transform-member-expression-literals@npm:^7.24.1": +"@babel/plugin-transform-member-expression-literals@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-member-expression-literals@npm:7.24.1" dependencies: @@ -1975,7 +1751,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-modules-amd@npm:^7.10.4, @babel/plugin-transform-modules-amd@npm:^7.24.1": +"@babel/plugin-transform-modules-amd@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-modules-amd@npm:7.24.1" dependencies: @@ -1987,7 +1763,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-modules-commonjs@npm:^7.10.4, @babel/plugin-transform-modules-commonjs@npm:^7.23.0, @babel/plugin-transform-modules-commonjs@npm:^7.24.1": +"@babel/plugin-transform-modules-commonjs@npm:^7.23.0, @babel/plugin-transform-modules-commonjs@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-modules-commonjs@npm:7.24.1" dependencies: @@ -2000,7 +1776,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-modules-systemjs@npm:^7.10.4, @babel/plugin-transform-modules-systemjs@npm:^7.24.1": +"@babel/plugin-transform-modules-systemjs@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-modules-systemjs@npm:7.24.1" dependencies: @@ -2014,7 +1790,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-modules-umd@npm:^7.10.4, @babel/plugin-transform-modules-umd@npm:^7.24.1": +"@babel/plugin-transform-modules-umd@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-modules-umd@npm:7.24.1" dependencies: @@ -2026,7 +1802,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-named-capturing-groups-regex@npm:^7.10.4, @babel/plugin-transform-named-capturing-groups-regex@npm:^7.22.5": +"@babel/plugin-transform-named-capturing-groups-regex@npm:^7.22.5": version: 7.22.5 resolution: "@babel/plugin-transform-named-capturing-groups-regex@npm:7.22.5" dependencies: @@ -2038,7 +1814,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-new-target@npm:^7.10.4, @babel/plugin-transform-new-target@npm:^7.24.1": +"@babel/plugin-transform-new-target@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-new-target@npm:7.24.1" dependencies: @@ -2087,7 +1863,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-object-super@npm:^7.10.4, @babel/plugin-transform-object-super@npm:^7.24.1": +"@babel/plugin-transform-object-super@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-object-super@npm:7.24.1" dependencies: @@ -2124,7 +1900,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-parameters@npm:^7.10.4, @babel/plugin-transform-parameters@npm:^7.20.7, @babel/plugin-transform-parameters@npm:^7.24.5": +"@babel/plugin-transform-parameters@npm:^7.24.5": version: 7.24.5 resolution: "@babel/plugin-transform-parameters@npm:7.24.5" dependencies: @@ -2161,7 +1937,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-property-literals@npm:^7.10.4, @babel/plugin-transform-property-literals@npm:^7.24.1": +"@babel/plugin-transform-property-literals@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-property-literals@npm:7.24.1" dependencies: @@ -2243,7 +2019,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-regenerator@npm:^7.10.4, @babel/plugin-transform-regenerator@npm:^7.12.1, @babel/plugin-transform-regenerator@npm:^7.24.1": +"@babel/plugin-transform-regenerator@npm:^7.12.1, @babel/plugin-transform-regenerator@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-regenerator@npm:7.24.1" dependencies: @@ -2255,7 +2031,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-reserved-words@npm:^7.10.4, @babel/plugin-transform-reserved-words@npm:^7.24.1": +"@babel/plugin-transform-reserved-words@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-reserved-words@npm:7.24.1" dependencies: @@ -2266,7 +2042,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-shorthand-properties@npm:^7.10.4, @babel/plugin-transform-shorthand-properties@npm:^7.24.1": +"@babel/plugin-transform-shorthand-properties@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-shorthand-properties@npm:7.24.1" dependencies: @@ -2277,7 +2053,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-spread@npm:^7.11.0, @babel/plugin-transform-spread@npm:^7.24.1": +"@babel/plugin-transform-spread@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-spread@npm:7.24.1" dependencies: @@ -2289,7 +2065,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-sticky-regex@npm:^7.10.4, @babel/plugin-transform-sticky-regex@npm:^7.24.1": +"@babel/plugin-transform-sticky-regex@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-sticky-regex@npm:7.24.1" dependencies: @@ -2300,7 +2076,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-template-literals@npm:^7.10.4, @babel/plugin-transform-template-literals@npm:^7.24.1": +"@babel/plugin-transform-template-literals@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-template-literals@npm:7.24.1" dependencies: @@ -2311,7 +2087,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-typeof-symbol@npm:^7.10.4, @babel/plugin-transform-typeof-symbol@npm:^7.24.5": +"@babel/plugin-transform-typeof-symbol@npm:^7.24.5": version: 7.24.5 resolution: "@babel/plugin-transform-typeof-symbol@npm:7.24.5" dependencies: @@ -2322,7 +2098,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-typescript@npm:^7.18.6, @babel/plugin-transform-typescript@npm:^7.24.1": +"@babel/plugin-transform-typescript@npm:^7.24.1": version: 7.24.5 resolution: "@babel/plugin-transform-typescript@npm:7.24.5" dependencies: @@ -2336,7 +2112,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-unicode-escapes@npm:^7.10.4, @babel/plugin-transform-unicode-escapes@npm:^7.24.1": +"@babel/plugin-transform-unicode-escapes@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-unicode-escapes@npm:7.24.1" dependencies: @@ -2359,7 +2135,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-unicode-regex@npm:^7.10.4, @babel/plugin-transform-unicode-regex@npm:^7.24.1": +"@babel/plugin-transform-unicode-regex@npm:^7.24.1": version: 7.24.1 resolution: "@babel/plugin-transform-unicode-regex@npm:7.24.1" dependencies: @@ -2383,84 +2159,6 @@ __metadata: languageName: node linkType: hard -"@babel/preset-env@npm:7.11.5": - version: 7.11.5 - resolution: "@babel/preset-env@npm:7.11.5" - dependencies: - "@babel/compat-data": ^7.11.0 - "@babel/helper-compilation-targets": ^7.10.4 - "@babel/helper-module-imports": ^7.10.4 - "@babel/helper-plugin-utils": ^7.10.4 - "@babel/plugin-proposal-async-generator-functions": ^7.10.4 - "@babel/plugin-proposal-class-properties": ^7.10.4 - "@babel/plugin-proposal-dynamic-import": ^7.10.4 - "@babel/plugin-proposal-export-namespace-from": ^7.10.4 - "@babel/plugin-proposal-json-strings": ^7.10.4 - "@babel/plugin-proposal-logical-assignment-operators": ^7.11.0 - "@babel/plugin-proposal-nullish-coalescing-operator": ^7.10.4 - "@babel/plugin-proposal-numeric-separator": ^7.10.4 - "@babel/plugin-proposal-object-rest-spread": ^7.11.0 - "@babel/plugin-proposal-optional-catch-binding": ^7.10.4 - "@babel/plugin-proposal-optional-chaining": ^7.11.0 - "@babel/plugin-proposal-private-methods": ^7.10.4 - "@babel/plugin-proposal-unicode-property-regex": ^7.10.4 - "@babel/plugin-syntax-async-generators": ^7.8.0 - "@babel/plugin-syntax-class-properties": ^7.10.4 - "@babel/plugin-syntax-dynamic-import": ^7.8.0 - "@babel/plugin-syntax-export-namespace-from": ^7.8.3 - "@babel/plugin-syntax-json-strings": ^7.8.0 - "@babel/plugin-syntax-logical-assignment-operators": ^7.10.4 - "@babel/plugin-syntax-nullish-coalescing-operator": ^7.8.0 - "@babel/plugin-syntax-numeric-separator": ^7.10.4 - "@babel/plugin-syntax-object-rest-spread": ^7.8.0 - "@babel/plugin-syntax-optional-catch-binding": ^7.8.0 - "@babel/plugin-syntax-optional-chaining": ^7.8.0 - "@babel/plugin-syntax-top-level-await": ^7.10.4 - "@babel/plugin-transform-arrow-functions": ^7.10.4 - "@babel/plugin-transform-async-to-generator": ^7.10.4 - "@babel/plugin-transform-block-scoped-functions": ^7.10.4 - "@babel/plugin-transform-block-scoping": ^7.10.4 - "@babel/plugin-transform-classes": ^7.10.4 - "@babel/plugin-transform-computed-properties": ^7.10.4 - "@babel/plugin-transform-destructuring": ^7.10.4 - "@babel/plugin-transform-dotall-regex": ^7.10.4 - "@babel/plugin-transform-duplicate-keys": ^7.10.4 - "@babel/plugin-transform-exponentiation-operator": ^7.10.4 - "@babel/plugin-transform-for-of": ^7.10.4 - "@babel/plugin-transform-function-name": ^7.10.4 - "@babel/plugin-transform-literals": ^7.10.4 - "@babel/plugin-transform-member-expression-literals": ^7.10.4 - "@babel/plugin-transform-modules-amd": ^7.10.4 - "@babel/plugin-transform-modules-commonjs": ^7.10.4 - "@babel/plugin-transform-modules-systemjs": ^7.10.4 - "@babel/plugin-transform-modules-umd": ^7.10.4 - "@babel/plugin-transform-named-capturing-groups-regex": ^7.10.4 - "@babel/plugin-transform-new-target": ^7.10.4 - "@babel/plugin-transform-object-super": ^7.10.4 - "@babel/plugin-transform-parameters": ^7.10.4 - "@babel/plugin-transform-property-literals": ^7.10.4 - "@babel/plugin-transform-regenerator": ^7.10.4 - "@babel/plugin-transform-reserved-words": ^7.10.4 - "@babel/plugin-transform-shorthand-properties": ^7.10.4 - "@babel/plugin-transform-spread": ^7.11.0 - "@babel/plugin-transform-sticky-regex": ^7.10.4 - "@babel/plugin-transform-template-literals": ^7.10.4 - "@babel/plugin-transform-typeof-symbol": ^7.10.4 - "@babel/plugin-transform-unicode-escapes": ^7.10.4 - "@babel/plugin-transform-unicode-regex": ^7.10.4 - "@babel/preset-modules": ^0.1.3 - "@babel/types": ^7.11.5 - browserslist: ^4.12.0 - core-js-compat: ^3.6.2 - invariant: ^2.2.2 - levenary: ^1.1.1 - semver: ^5.5.0 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: bfff5f36df8e14df3afdb09af141a6b6283fe38f122f58c46a356dfbb4f15a86c7e6b01f9615e72fa95b13b4ccef1fc1a8419657ffd5bb73e06b9ec2617326bf - languageName: node - linkType: hard - "@babel/preset-env@npm:^7.12.11, @babel/preset-env@npm:^7.23.2": version: 7.24.5 resolution: "@babel/preset-env@npm:7.24.5" @@ -2578,21 +2276,6 @@ __metadata: languageName: node linkType: hard -"@babel/preset-modules@npm:^0.1.3": - version: 0.1.6 - resolution: "@babel/preset-modules@npm:0.1.6" - dependencies: - "@babel/helper-plugin-utils": ^7.0.0 - "@babel/plugin-proposal-unicode-property-regex": ^7.4.4 - "@babel/plugin-transform-dotall-regex": ^7.4.4 - "@babel/types": ^7.4.4 - esutils: ^2.0.2 - peerDependencies: - "@babel/core": ^7.0.0-0 || ^8.0.0-0 <8.0.0 - checksum: 6397d196dec1ca91f0f28ea4fbd0e599e5724b7f783f27979e1e9de30a4693f8c1fa98495d542fe5a774b5d0d9b52c6effd2ed15900e879ebcb0488c4bf0eed9 - languageName: node - linkType: hard - "@babel/preset-react@npm:^7.12.10": version: 7.24.1 resolution: "@babel/preset-react@npm:7.24.1" @@ -2609,19 +2292,6 @@ __metadata: languageName: node linkType: hard -"@babel/preset-typescript@npm:7.18.6": - version: 7.18.6 - resolution: "@babel/preset-typescript@npm:7.18.6" - dependencies: - "@babel/helper-plugin-utils": ^7.18.6 - "@babel/helper-validator-option": ^7.18.6 - "@babel/plugin-transform-typescript": ^7.18.6 - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: 2314e0c1fd5d188ca4bdc35f8ab1e9caec3c662673949cf16ae5b29ed27855a5f354a19b736b50e54e099d580f825e39b58db7fd8f8e2c2d38eb22c9fa5910ea - languageName: node - linkType: hard - "@babel/preset-typescript@npm:^7.23.0": version: 7.24.1 resolution: "@babel/preset-typescript@npm:7.24.1" @@ -2668,7 +2338,7 @@ __metadata: languageName: node linkType: hard -"@babel/template@npm:^7.12.13, @babel/template@npm:^7.20.7, @babel/template@npm:^7.22.15, @babel/template@npm:^7.24.0, @babel/template@npm:^7.3.3": +"@babel/template@npm:^7.20.7, @babel/template@npm:^7.22.15, @babel/template@npm:^7.24.0, @babel/template@npm:^7.3.3": version: 7.24.0 resolution: "@babel/template@npm:7.24.0" dependencies: @@ -2697,7 +2367,7 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.1.0, @babel/traverse@npm:^7.14.2, @babel/traverse@npm:^7.18.9, @babel/traverse@npm:^7.23.2, @babel/traverse@npm:^7.24.5": +"@babel/traverse@npm:^7.1.0, @babel/traverse@npm:^7.18.9, @babel/traverse@npm:^7.23.2, @babel/traverse@npm:^7.24.5": version: 7.24.5 resolution: "@babel/traverse@npm:7.24.5" dependencies: @@ -2726,7 +2396,7 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:^7.0.0, @babel/types@npm:^7.11.5, @babel/types@npm:^7.14.2, @babel/types@npm:^7.18.9, @babel/types@npm:^7.20.7, @babel/types@npm:^7.21.3, @babel/types@npm:^7.21.5, @babel/types@npm:^7.22.15, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.23.4, @babel/types@npm:^7.23.5, @babel/types@npm:^7.24.0, @babel/types@npm:^7.24.5, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3": +"@babel/types@npm:^7.0.0, @babel/types@npm:^7.18.9, @babel/types@npm:^7.20.7, @babel/types@npm:^7.21.3, @babel/types@npm:^7.21.5, @babel/types@npm:^7.22.15, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.23.4, @babel/types@npm:^7.23.5, @babel/types@npm:^7.24.0, @babel/types@npm:^7.24.5, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3": version: 7.24.5 resolution: "@babel/types@npm:7.24.5" dependencies: @@ -5508,7 +5178,6 @@ __metadata: resolution: "@medusajs/medusa-oas-cli@workspace:packages/cli/oas/medusa-oas-cli" dependencies: "@medusajs/medusa": ^1.20.4 - "@medusajs/openapi-typescript-codegen": ^0.2.1 "@medusajs/types": ^1.11.15 "@medusajs/utils": ^1.11.8 "@readme/json-schema-ref-parser": ^1.2.0 @@ -5676,43 +5345,6 @@ __metadata: languageName: unknown linkType: soft -"@medusajs/openapi-typescript-codegen@^0.2.1, @medusajs/openapi-typescript-codegen@workspace:packages/cli/oas/openapi-typescript-codegen": - version: 0.0.0-use.local - resolution: "@medusajs/openapi-typescript-codegen@workspace:packages/cli/oas/openapi-typescript-codegen" - dependencies: - "@babel/cli": 7.14.3 - "@babel/core": 7.14.3 - "@babel/preset-env": 7.11.5 - "@babel/preset-typescript": 7.18.6 - "@rollup/plugin-commonjs": 24.0.0 - "@rollup/plugin-node-resolve": 15.0.1 - "@rollup/plugin-typescript": 9.0.2 - "@types/fs-extra": ^9.0.12 - "@types/jest": 27.5.0 - "@types/node": 18.11.9 - "@types/node-fetch": 2.6.2 - "@types/pascalcase": ^1.0.1 - "@types/qs": 6.9.7 - abort-controller: 3.0.0 - axios: 1.2.0 - camelcase: ^6.3.0 - commander: ^9.4.1 - form-data: 4.0.0 - fs-extra: ^10.1.0 - handlebars: ^4.7.7 - jest: ^25.5.4 - json-schema-ref-parser: ^9.0.9 - node-fetch: 2.6.7 - pascalcase: ^2.0.0 - qs: 6.10.3 - rollup: 3.9.1 - rollup-plugin-terser: 7.0.2 - ts-jest: ^25.5.1 - tslib: 2.3.1 - typescript: 4.9.5 - languageName: unknown - linkType: soft - "@medusajs/orchestration@^0.5.7, @medusajs/orchestration@workspace:packages/core/orchestration": version: 0.0.0-use.local resolution: "@medusajs/orchestration@workspace:packages/core/orchestration" @@ -6521,25 +6153,6 @@ __metadata: languageName: node linkType: hard -"@nicolo-ribaudo/chokidar-2@npm:2.1.8-no-fsevents": - version: 2.1.8-no-fsevents - resolution: "@nicolo-ribaudo/chokidar-2@npm:2.1.8-no-fsevents" - dependencies: - anymatch: ^2.0.0 - async-each: ^1.0.1 - braces: ^2.3.2 - glob-parent: ^3.1.0 - inherits: ^2.0.3 - is-binary-path: ^1.0.0 - is-glob: ^4.0.0 - normalize-path: ^3.0.0 - path-is-absolute: ^1.0.0 - readdirp: ^2.2.1 - upath: ^1.1.1 - checksum: 8ca958d7763d73a7fc63b208b865bf656d5970c7161014c71ef190aa0e30e14766f286ecb6c856f7fa2e2b5da7252788baab1382e96ed2a07f5c3d65131947f9 - languageName: node - linkType: hard - "@nodelib/fs.scandir@npm:2.1.5": version: 2.1.5 resolution: "@nodelib/fs.scandir@npm:2.1.5" @@ -8576,25 +8189,6 @@ __metadata: languageName: node linkType: hard -"@rollup/plugin-commonjs@npm:24.0.0": - version: 24.0.0 - resolution: "@rollup/plugin-commonjs@npm:24.0.0" - dependencies: - "@rollup/pluginutils": ^5.0.1 - commondir: ^1.0.1 - estree-walker: ^2.0.2 - glob: ^8.0.3 - is-reference: 1.2.1 - magic-string: ^0.27.0 - peerDependencies: - rollup: ^2.68.0||^3.0.0 - peerDependenciesMeta: - rollup: - optional: true - checksum: ae2ed1d49722fad55f7ef7629baad5fb31bc389e6042912fb5cb9623c2c9c0def27c66bbd1aea72f1fcd65caa1410a9de80a0377f85d8cd8068f97c0adeaf3da - languageName: node - linkType: hard - "@rollup/plugin-commonjs@npm:^17.0.0": version: 17.1.0 resolution: "@rollup/plugin-commonjs@npm:17.1.0" @@ -8623,25 +8217,6 @@ __metadata: languageName: node linkType: hard -"@rollup/plugin-node-resolve@npm:15.0.1": - version: 15.0.1 - resolution: "@rollup/plugin-node-resolve@npm:15.0.1" - dependencies: - "@rollup/pluginutils": ^5.0.1 - "@types/resolve": 1.20.2 - deepmerge: ^4.2.2 - is-builtin-module: ^3.2.0 - is-module: ^1.0.0 - resolve: ^1.22.1 - peerDependencies: - rollup: ^2.78.0||^3.0.0 - peerDependenciesMeta: - rollup: - optional: true - checksum: 82af7876281e9459ea86cedf571816b61883055f98d3ecd9306e869674b344b5e38d57d589f409d255fe22021dd81f4a65702e9e8c859eded45bebccb8644e1b - languageName: node - linkType: hard - "@rollup/plugin-node-resolve@npm:^11.0.1": version: 11.2.1 resolution: "@rollup/plugin-node-resolve@npm:11.2.1" @@ -8692,25 +8267,6 @@ __metadata: languageName: node linkType: hard -"@rollup/plugin-typescript@npm:9.0.2": - version: 9.0.2 - resolution: "@rollup/plugin-typescript@npm:9.0.2" - dependencies: - "@rollup/pluginutils": ^5.0.1 - resolve: ^1.22.1 - peerDependencies: - rollup: ^2.14.0||^3.0.0 - tslib: "*" - typescript: ">=3.7.0" - peerDependenciesMeta: - rollup: - optional: true - tslib: - optional: true - checksum: 799387ede61c1bd34f6822e9f65dffd465eaa7ed9b3d8797f61497d8ee693bca10c7ec8b664d9f7e47fdf70b9304af12f45a27a8d3f39546001e17f31cf69d93 - languageName: node - linkType: hard - "@rollup/pluginutils@npm:^3.0.8, @rollup/pluginutils@npm:^3.1.0": version: 3.1.0 resolution: "@rollup/pluginutils@npm:3.1.0" @@ -11296,15 +10852,6 @@ __metadata: languageName: node linkType: hard -"@types/fs-extra@npm:^9.0.12": - version: 9.0.13 - resolution: "@types/fs-extra@npm:9.0.13" - dependencies: - "@types/node": "*" - checksum: 576d4e9d382393316ed815c593f7f5c157408ec5e184521d077fcb15d514b5a985245f153ef52142b9b976cb9bd8f801850d51238153ebd0dc9e96b7a7548588 - languageName: node - linkType: hard - "@types/glob@npm:^7.1.3": version: 7.2.0 resolution: "@types/glob@npm:7.2.0" @@ -11402,16 +10949,6 @@ __metadata: languageName: node linkType: hard -"@types/jest@npm:27.5.0": - version: 27.5.0 - resolution: "@types/jest@npm:27.5.0" - dependencies: - jest-matcher-utils: ^27.0.0 - pretty-format: ^27.0.0 - checksum: bb26b293210827c1d65efde9bf72feb0d2b7c2816911e086fd9a9fb7690cfa9416e10f4ddcfbc8e5017442a682da6273781b8b0f78951e0bb7e40993f6a52e7b - languageName: node - linkType: hard - "@types/js-yaml@npm:^4.0.9": version: 4.0.9 resolution: "@types/js-yaml@npm:4.0.9" @@ -11441,7 +10978,7 @@ __metadata: languageName: node linkType: hard -"@types/json-schema@npm:^7.0.12, @types/json-schema@npm:^7.0.6, @types/json-schema@npm:^7.0.7, @types/json-schema@npm:^7.0.9": +"@types/json-schema@npm:^7.0.12, @types/json-schema@npm:^7.0.7, @types/json-schema@npm:^7.0.9": version: 7.0.15 resolution: "@types/json-schema@npm:7.0.15" checksum: a996a745e6c5d60292f36731dd41341339d4eeed8180bb09226e5c8d23759067692b1d88e5d91d72ee83dfc00d3aca8e7bd43ea120516c17922cbcb7c3e252db @@ -11542,16 +11079,6 @@ __metadata: languageName: node linkType: hard -"@types/node-fetch@npm:2.6.2": - version: 2.6.2 - resolution: "@types/node-fetch@npm:2.6.2" - dependencies: - "@types/node": "*" - form-data: ^3.0.0 - checksum: bd2ce7621905f9d80cd2fbe003d32a8d304f4aa53c12eb01a498255a1fc570d82216cff9a7ed38ff32570c78e46c924a8e23187a011ecfcfec4c530c7bdecdbb - languageName: node - linkType: hard - "@types/node-fetch@npm:^2.6.4": version: 2.6.11 resolution: "@types/node-fetch@npm:2.6.11" @@ -11571,13 +11098,6 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:18.11.9": - version: 18.11.9 - resolution: "@types/node@npm:18.11.9" - checksum: aeaa925406f841c41679b32def9391a9892171e977105e025050e9f66e2830b4c50d0d974a1af0077ead3337a1f3bdf49ee7e7f402ebf2e034a3f97d9d240dba - languageName: node - linkType: hard - "@types/node@npm:^12.7.1": version: 12.20.55 resolution: "@types/node@npm:12.20.55" @@ -11631,13 +11151,6 @@ __metadata: languageName: node linkType: hard -"@types/pascalcase@npm:^1.0.1": - version: 1.0.3 - resolution: "@types/pascalcase@npm:1.0.3" - checksum: 4bc93fee5a7e3ea63a1c92f66cc72462dc557430c705ecefd834181950a779cf188f24e9afac15687ff9fdf360cb5f233130c6fc92d4bb94772551557adb8281 - languageName: node - linkType: hard - "@types/pg@npm:^8.6.6": version: 8.11.6 resolution: "@types/pg@npm:8.11.6" @@ -11691,13 +11204,6 @@ __metadata: languageName: node linkType: hard -"@types/qs@npm:6.9.7": - version: 6.9.7 - resolution: "@types/qs@npm:6.9.7" - checksum: 157eb05f4c75790b0ebdcf7b0547ff117feabc8cda03c3cac3d3ea82bb19a1912e76a411df3eb0bdd01026a9770f07bc0e7e3fbe39ebb31c1be4564c16be35f1 - languageName: node - linkType: hard - "@types/range-parser@npm:*": version: 1.2.7 resolution: "@types/range-parser@npm:1.2.7" @@ -12397,7 +11903,7 @@ __metadata: languageName: node linkType: hard -"abort-controller@npm:3.0.0, abort-controller@npm:^3.0.0": +"abort-controller@npm:^3.0.0": version: 3.0.0 resolution: "abort-controller@npm:3.0.0" dependencies: @@ -13100,13 +12606,6 @@ __metadata: languageName: node linkType: hard -"async-each@npm:^1.0.1": - version: 1.0.6 - resolution: "async-each@npm:1.0.6" - checksum: d4e45e8f077e20e015952c065ceae75f82b30ee2d4a8e56a5c454ae44331aaa009d8c94fe043ba254c177bffae9f6ebeefebb7daf9f7ce4d27fac0274dc328ae - languageName: node - linkType: hard - "async-limiter@npm:~1.0.0": version: 1.0.1 resolution: "async-limiter@npm:1.0.1" @@ -13238,17 +12737,6 @@ __metadata: languageName: node linkType: hard -"axios@npm:1.2.0": - version: 1.2.0 - resolution: "axios@npm:1.2.0" - dependencies: - follow-redirects: ^1.15.0 - form-data: ^4.0.0 - proxy-from-env: ^1.1.0 - checksum: 2a9a73ca55010cab987b612b358a0bf128ebc572c5d63cdb66fb9c336a5718752749f2ba8b38b9745a6e33edb83ffec2dd65c5a7118ce94e5cae1a9ea6fc74c2 - languageName: node - linkType: hard - "axios@npm:^0.21.4": version: 0.21.4 resolution: "axios@npm:0.21.4" @@ -13625,13 +13113,6 @@ __metadata: languageName: node linkType: hard -"binary-extensions@npm:^1.0.0": - version: 1.13.1 - resolution: "binary-extensions@npm:1.13.1" - checksum: 2d616938ac23d828ec3fbe0dea429b566fd2c137ddc38f166f16561ccd58029deac3fa9fddb489ab13d679c8fb5f1bd0e82824041299e5e39d8dd3cc68fbb9f9 - languageName: node - linkType: hard - "binary-extensions@npm:^2.0.0": version: 2.3.0 resolution: "binary-extensions@npm:2.3.0" @@ -13757,7 +13238,7 @@ __metadata: languageName: node linkType: hard -"braces@npm:^2.3.1, braces@npm:^2.3.2": +"braces@npm:^2.3.1": version: 2.3.2 resolution: "braces@npm:2.3.2" dependencies: @@ -13852,7 +13333,7 @@ __metadata: languageName: node linkType: hard -"browserslist@npm:^4.0.0, browserslist@npm:^4.12.0, browserslist@npm:^4.21.10, browserslist@npm:^4.21.4, browserslist@npm:^4.22.2, browserslist@npm:^4.23.0": +"browserslist@npm:^4.0.0, browserslist@npm:^4.21.10, browserslist@npm:^4.21.4, browserslist@npm:^4.22.2, browserslist@npm:^4.23.0": version: 4.23.0 resolution: "browserslist@npm:4.23.0" dependencies: @@ -14155,7 +13636,7 @@ __metadata: languageName: node linkType: hard -"camelcase@npm:^6.0.0, camelcase@npm:^6.2.0, camelcase@npm:^6.2.1, camelcase@npm:^6.3.0": +"camelcase@npm:^6.0.0, camelcase@npm:^6.2.0": version: 6.3.0 resolution: "camelcase@npm:6.3.0" checksum: 0d701658219bd3116d12da3eab31acddb3f9440790c0792e0d398f0a520a6a4058018e546862b6fba89d7ae990efaeb97da71e1913e9ebf5a8b5621a3d55c710 @@ -14324,7 +13805,7 @@ __metadata: languageName: node linkType: hard -"chokidar@npm:^3.4.0, chokidar@npm:^3.4.2, chokidar@npm:^3.5.1, chokidar@npm:^3.5.2, chokidar@npm:^3.5.3, chokidar@npm:^3.6.0": +"chokidar@npm:^3.4.2, chokidar@npm:^3.5.1, chokidar@npm:^3.5.2, chokidar@npm:^3.5.3, chokidar@npm:^3.6.0": version: 3.6.0 resolution: "chokidar@npm:3.6.0" dependencies: @@ -14833,7 +14314,7 @@ __metadata: languageName: node linkType: hard -"commander@npm:^4.0.0, commander@npm:^4.0.1": +"commander@npm:^4.0.0": version: 4.1.1 resolution: "commander@npm:4.1.1" checksum: 84a76c08fe6cc08c9c93f62ac573d2907d8e79138999312c92d4155bc2325d487d64d13f669b2000c9f8caf70493c1be2dac74fec3c51d5a04f8bc3ae1830bab @@ -15034,7 +14515,7 @@ __metadata: languageName: node linkType: hard -"convert-source-map@npm:^1.1.0, convert-source-map@npm:^1.4.0, convert-source-map@npm:^1.6.0, convert-source-map@npm:^1.7.0": +"convert-source-map@npm:^1.4.0, convert-source-map@npm:^1.6.0, convert-source-map@npm:^1.7.0": version: 1.9.0 resolution: "convert-source-map@npm:1.9.0" checksum: 281da55454bf8126cbc6625385928c43479f2060984180c42f3a86c8b8c12720a24eac260624a7d1e090004028d2dee78602330578ceec1a08e27cb8bb0a8a5b @@ -15151,7 +14632,7 @@ __metadata: languageName: node linkType: hard -"core-js-compat@npm:^3.31.0, core-js-compat@npm:^3.36.1, core-js-compat@npm:^3.6.2": +"core-js-compat@npm:^3.31.0, core-js-compat@npm:^3.36.1": version: 3.37.0 resolution: "core-js-compat@npm:3.37.0" dependencies: @@ -16226,13 +15707,6 @@ __metadata: languageName: node linkType: hard -"diff-sequences@npm:^27.5.1": - version: 27.5.1 - resolution: "diff-sequences@npm:27.5.1" - checksum: a52566d891b89a666f48ba69f54262fa8293ae6264ae04da82c7bf3b6661cba75561de0729f18463179d56003cc0fd69aa09845f2c2cd7a353b1ec1e1a96beb9 - languageName: node - linkType: hard - "diff-sequences@npm:^29.4.3, diff-sequences@npm:^29.6.3": version: 29.6.3 resolution: "diff-sequences@npm:29.6.3" @@ -18360,7 +17834,7 @@ __metadata: languageName: node linkType: hard -"follow-redirects@npm:^1.14.0, follow-redirects@npm:^1.14.4, follow-redirects@npm:^1.15.0, follow-redirects@npm:^1.15.6": +"follow-redirects@npm:^1.14.0, follow-redirects@npm:^1.14.4, follow-redirects@npm:^1.15.6": version: 1.15.6 resolution: "follow-redirects@npm:1.15.6" peerDependenciesMeta: @@ -18410,17 +17884,6 @@ __metadata: languageName: node linkType: hard -"form-data@npm:4.0.0, form-data@npm:^4.0.0": - version: 4.0.0 - resolution: "form-data@npm:4.0.0" - dependencies: - asynckit: ^0.4.0 - combined-stream: ^1.0.8 - mime-types: ^2.1.12 - checksum: cb6f3ac49180be03ff07ba3ff125f9eba2ff0b277fb33c7fc47569fc5e616882c5b1c69b9904c4c4187e97dd0419dd03b134174756f296dec62041e6527e2c6e - languageName: node - linkType: hard - "form-data@npm:^2.3.1": version: 2.5.1 resolution: "form-data@npm:2.5.1" @@ -18443,6 +17906,17 @@ __metadata: languageName: node linkType: hard +"form-data@npm:^4.0.0": + version: 4.0.0 + resolution: "form-data@npm:4.0.0" + dependencies: + asynckit: ^0.4.0 + combined-stream: ^1.0.8 + mime-types: ^2.1.12 + checksum: cb6f3ac49180be03ff07ba3ff125f9eba2ff0b277fb33c7fc47569fc5e616882c5b1c69b9904c4c4187e97dd0419dd03b134174756f296dec62041e6527e2c6e + languageName: node + linkType: hard + "form-data@npm:~2.3.2": version: 2.3.3 resolution: "form-data@npm:2.3.3" @@ -18556,7 +18030,7 @@ __metadata: languageName: node linkType: hard -"fs-extra@npm:^10.0.0, fs-extra@npm:^10.1.0": +"fs-extra@npm:^10.0.0": version: 10.1.0 resolution: "fs-extra@npm:10.1.0" dependencies: @@ -18619,13 +18093,6 @@ __metadata: languageName: node linkType: hard -"fs-readdir-recursive@npm:^1.1.0": - version: 1.1.0 - resolution: "fs-readdir-recursive@npm:1.1.0" - checksum: 7e190393952143e674b6d1ad4abcafa1b5d3e337fcc21b0cb051079a7140a54617a7df193d562ef9faf21bd7b2148a38601b3d5c16261fa76f278d88dc69989c - languageName: node - linkType: hard - "fs.realpath@npm:^1.0.0": version: 1.0.0 resolution: "fs.realpath@npm:1.0.0" @@ -18861,16 +18328,6 @@ __metadata: languageName: node linkType: hard -"glob-parent@npm:^3.1.0": - version: 3.1.0 - resolution: "glob-parent@npm:3.1.0" - dependencies: - is-glob: ^3.1.0 - path-dirname: ^1.0.0 - checksum: bfa89ce5ae1dfea4c2ece7b61d2ea230d87fcbec7472915cfdb3f4caf688a91ecb0dc86ae39b1e17505adce7e64cae3b971d64dc66091f3a0131169fd631b00d - languageName: node - linkType: hard - "glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2": version: 5.1.2 resolution: "glob-parent@npm:5.1.2" @@ -18935,7 +18392,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^7.0.0, glob@npm:^7.0.5, glob@npm:^7.1.1, glob@npm:^7.1.2, glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.1.6, glob@npm:^7.2.0, glob@npm:~7.2.0": +"glob@npm:^7.0.5, glob@npm:^7.1.1, glob@npm:^7.1.2, glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.1.6, glob@npm:^7.2.0, glob@npm:~7.2.0": version: 7.2.3 resolution: "glob@npm:7.2.3" dependencies: @@ -19967,7 +19424,7 @@ __metadata: languageName: node linkType: hard -"invariant@npm:^2.2.2, invariant@npm:^2.2.4": +"invariant@npm:^2.2.4": version: 2.2.4 resolution: "invariant@npm:2.2.4" dependencies: @@ -20118,15 +19575,6 @@ __metadata: languageName: node linkType: hard -"is-binary-path@npm:^1.0.0": - version: 1.0.1 - resolution: "is-binary-path@npm:1.0.1" - dependencies: - binary-extensions: ^1.0.0 - checksum: 16e456fa3782eaf3d8e28d382b750507e3d54ff6694df8a1b2c6498da321e2ead311de9c42e653d8fb3213de72bac204b5f97e4a110cda8a72f17b1c1b4eb643 - languageName: node - linkType: hard - "is-binary-path@npm:~2.1.0": version: 2.1.0 resolution: "is-binary-path@npm:2.1.0" @@ -20160,7 +19608,7 @@ __metadata: languageName: node linkType: hard -"is-builtin-module@npm:^3.2.0, is-builtin-module@npm:^3.2.1": +"is-builtin-module@npm:^3.2.1": version: 3.2.1 resolution: "is-builtin-module@npm:3.2.1" dependencies: @@ -20291,7 +19739,7 @@ __metadata: languageName: node linkType: hard -"is-extglob@npm:^2.1.0, is-extglob@npm:^2.1.1": +"is-extglob@npm:^2.1.1": version: 2.1.1 resolution: "is-extglob@npm:2.1.1" checksum: 5487da35691fbc339700bbb2730430b07777a3c21b9ebaecb3072512dfd7b4ba78ac2381a87e8d78d20ea08affb3f1971b4af629173a6bf435ff8a4c47747912 @@ -20339,15 +19787,6 @@ __metadata: languageName: node linkType: hard -"is-glob@npm:^3.1.0": - version: 3.1.0 - resolution: "is-glob@npm:3.1.0" - dependencies: - is-extglob: ^2.1.0 - checksum: ba816a35dcf5285de924a8a4654df7b183a86381d73ea3bbf3df3cc61b3ba61fdddf90ee205709a2235b210ee600ee86e5e8600093cf291a662607fd032e2ff4 - languageName: node - linkType: hard - "is-glob@npm:^4.0.0, is-glob@npm:^4.0.1, is-glob@npm:^4.0.3, is-glob@npm:~4.0.1": version: 4.0.3 resolution: "is-glob@npm:4.0.3" @@ -20533,7 +19972,7 @@ __metadata: languageName: node linkType: hard -"is-reference@npm:1.2.1, is-reference@npm:^1.2.1": +"is-reference@npm:^1.2.1": version: 1.2.1 resolution: "is-reference@npm:1.2.1" dependencies: @@ -21182,18 +20621,6 @@ __metadata: languageName: node linkType: hard -"jest-diff@npm:^27.5.1": - version: 27.5.1 - resolution: "jest-diff@npm:27.5.1" - dependencies: - chalk: ^4.0.0 - diff-sequences: ^27.5.1 - jest-get-type: ^27.5.1 - pretty-format: ^27.5.1 - checksum: 48f008c7b4ea7794108319eb61050315b1723e7391cb01e4377c072cadcab10a984cb09d2a6876cb65f100d06c970fd932996192e092b26006f885c00945e7ad - languageName: node - linkType: hard - "jest-diff@npm:^29.7.0": version: 29.7.0 resolution: "jest-diff@npm:29.7.0" @@ -21378,13 +20805,6 @@ __metadata: languageName: node linkType: hard -"jest-get-type@npm:^27.5.1": - version: 27.5.1 - resolution: "jest-get-type@npm:27.5.1" - checksum: 42ee0101336bccfc3c1cff598b603c6006db7876b6117e5bd4a9fb7ffaadfb68febdb9ae68d1c47bc3a4174b070153fc6cfb59df995dcd054e81ace5028a7269 - languageName: node - linkType: hard - "jest-get-type@npm:^29.6.3": version: 29.6.3 resolution: "jest-get-type@npm:29.6.3" @@ -21569,18 +20989,6 @@ __metadata: languageName: node linkType: hard -"jest-matcher-utils@npm:^27.0.0": - version: 27.5.1 - resolution: "jest-matcher-utils@npm:27.5.1" - dependencies: - chalk: ^4.0.0 - jest-diff: ^27.5.1 - jest-get-type: ^27.5.1 - pretty-format: ^27.5.1 - checksum: a2f082062e8bedc9cfe2654177a894ca43768c6db4c0f4efc0d6ec195e305a99e3d868ff54cc61bcd7f1c810d8ee28c9ac6374de21715dc52f136876de739a73 - languageName: node - linkType: hard - "jest-matcher-utils@npm:^29.7.0": version: 29.7.0 resolution: "jest-matcher-utils@npm:29.7.0" @@ -22602,15 +22010,6 @@ __metadata: languageName: node linkType: hard -"json-schema-ref-parser@npm:^9.0.9": - version: 9.0.9 - resolution: "json-schema-ref-parser@npm:9.0.9" - dependencies: - "@apidevtools/json-schema-ref-parser": 9.0.9 - checksum: c6602a4e4f003629819a83540520850f3a06cb49a738d273854e4e2d8ebabb51b80cfc17d66cfc00ccadcb3a4c33eedf85b26b0af3b2c142f68f9f9dd5531a9c - languageName: node - linkType: hard - "json-schema-traverse@npm:^0.4.1": version: 0.4.1 resolution: "json-schema-traverse@npm:0.4.1" @@ -23074,15 +22473,6 @@ __metadata: languageName: node linkType: hard -"levenary@npm:^1.1.1": - version: 1.1.1 - resolution: "levenary@npm:1.1.1" - dependencies: - leven: ^3.1.0 - checksum: 320c5e36351704f6284879752de8acc604bf2f98c9fc9389a12e1b9f3a74bd57e2776d2859d5bcbf65a8127f705ea4ee9d06d428d9be389c80caf343f7981d14 - languageName: node - linkType: hard - "levn@npm:^0.4.1": version: 0.4.1 resolution: "levn@npm:0.4.1" @@ -24027,7 +23417,7 @@ __metadata: languageName: node linkType: hard -"micromatch@npm:^3.1.10, micromatch@npm:^3.1.4": +"micromatch@npm:^3.1.4": version: 3.1.10 resolution: "micromatch@npm:3.1.10" dependencies: @@ -24780,20 +24170,6 @@ __metadata: languageName: node linkType: hard -"node-fetch@npm:2.6.7": - version: 2.6.7 - resolution: "node-fetch@npm:2.6.7" - dependencies: - whatwg-url: ^5.0.0 - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - checksum: fcae80f5ac52fbf5012f5e19df2bd3915e67d3b3ad51cb5942943df2238d32ba15890fecabd0e166876a9f98a581ab50f3f10eb942b09405c49ef8da36b826c7 - languageName: node - linkType: hard - "node-fetch@npm:^2.0.0, node-fetch@npm:^2.5.0, node-fetch@npm:^2.6.1, node-fetch@npm:^2.6.12": version: 2.7.0 resolution: "node-fetch@npm:2.7.0" @@ -25738,15 +25114,6 @@ __metadata: languageName: node linkType: hard -"pascalcase@npm:^2.0.0": - version: 2.0.0 - resolution: "pascalcase@npm:2.0.0" - dependencies: - camelcase: ^6.2.1 - checksum: c43658cd7bea0dc2b4362b0b15c803ee976fb6f981addab8452e1ad67cd768739979b7e687df38452f3743af34fe00f0292234f5aceb73457babb3fbdd585863 - languageName: node - linkType: hard - "passport-custom@npm:^1.1.1": version: 1.1.1 resolution: "passport-custom@npm:1.1.1" @@ -25810,13 +25177,6 @@ __metadata: languageName: node linkType: hard -"path-dirname@npm:^1.0.0": - version: 1.0.2 - resolution: "path-dirname@npm:1.0.2" - checksum: 71e59be2bada7c91f62b976245fd421b7cb01fde3207fe53a82d8880621ad04fd8b434e628c9cf4e796259fc168a107d77cd56837725267c5b2c58cefe2c4e1b - languageName: node - linkType: hard - "path-exists@npm:^3.0.0": version: 3.0.0 resolution: "path-exists@npm:3.0.0" @@ -26926,7 +26286,7 @@ __metadata: languageName: node linkType: hard -"pretty-format@npm:^27.0.0, pretty-format@npm:^27.0.2, pretty-format@npm:^27.5.1": +"pretty-format@npm:^27.0.2": version: 27.5.1 resolution: "pretty-format@npm:27.5.1" dependencies: @@ -27177,15 +26537,6 @@ __metadata: languageName: node linkType: hard -"qs@npm:6.10.3": - version: 6.10.3 - resolution: "qs@npm:6.10.3" - dependencies: - side-channel: ^1.0.4 - checksum: c6684df925fd2c6f0940b8fbfe5d8b5a8634dc96c0908309655cbe61a3fbf94cedc6b11e669fca1971b53459b6f732cccd4eeb6484b5b77b405ad0cfb936e6fe - languageName: node - linkType: hard - "qs@npm:6.11.0": version: 6.11.0 resolution: "qs@npm:6.11.0" @@ -27685,7 +27036,7 @@ __metadata: languageName: node linkType: hard -"readable-stream@npm:^2.0.0, readable-stream@npm:^2.0.2, readable-stream@npm:^2.2.2, readable-stream@npm:^2.3.5, readable-stream@npm:~2.3.6": +"readable-stream@npm:^2.0.0, readable-stream@npm:^2.2.2, readable-stream@npm:^2.3.5, readable-stream@npm:~2.3.6": version: 2.3.8 resolution: "readable-stream@npm:2.3.8" dependencies: @@ -27723,17 +27074,6 @@ __metadata: languageName: node linkType: hard -"readdirp@npm:^2.2.1": - version: 2.2.1 - resolution: "readdirp@npm:2.2.1" - dependencies: - graceful-fs: ^4.1.11 - micromatch: ^3.1.10 - readable-stream: ^2.0.2 - checksum: 770d177372ff2212d382d425d55ca48301fcbf3231ab3827257bbcca7ff44fb51fe4af6acc2dda8512dc7f29da390e9fbea5b2b3fc724b86e85cc828395b7797 - languageName: node - linkType: hard - "readdirp@npm:~3.6.0": version: 3.6.0 resolution: "readdirp@npm:3.6.0" @@ -28502,7 +27842,7 @@ __metadata: languageName: node linkType: hard -"rollup-plugin-terser@npm:7.0.2, rollup-plugin-terser@npm:^7.0.2": +"rollup-plugin-terser@npm:^7.0.2": version: 7.0.2 resolution: "rollup-plugin-terser@npm:7.0.2" dependencies: @@ -28603,20 +27943,6 @@ __metadata: languageName: node linkType: hard -"rollup@npm:3.9.1": - version: 3.9.1 - resolution: "rollup@npm:3.9.1" - dependencies: - fsevents: ~2.3.2 - dependenciesMeta: - fsevents: - optional: true - bin: - rollup: dist/bin/rollup - checksum: 48875f9414b17dda1f3a8eea3a2cfffbe847451f986e0c4f6363f06cde05d508730f29486d3f25f27db28dc76bb411a23959b826b1054d3848bab0d84a471fdd - languageName: node - linkType: hard - "rollup@npm:^2.25.0 || ^3.3.0, rollup@npm:^3.2.5, rollup@npm:^3.26.0, rollup@npm:^3.27.1": version: 3.29.4 resolution: "rollup@npm:3.29.4" @@ -29404,13 +28730,6 @@ __metadata: languageName: node linkType: hard -"slash@npm:^2.0.0": - version: 2.0.0 - resolution: "slash@npm:2.0.0" - checksum: f83dbd3cb62c41bb8fcbbc6bf5473f3234b97fa1d008f571710a9d3757a28c7169e1811cad1554ccb1cc531460b3d221c9a7b37f549398d9a30707f0a5af9193 - languageName: node - linkType: hard - "slash@npm:^3.0.0": version: 3.0.0 resolution: "slash@npm:3.0.0" @@ -29624,7 +28943,7 @@ __metadata: languageName: node linkType: hard -"source-map@npm:^0.5.0, source-map@npm:^0.5.6": +"source-map@npm:^0.5.6": version: 0.5.7 resolution: "source-map@npm:0.5.7" checksum: 904e767bb9c494929be013017380cbba013637da1b28e5943b566031e29df04fba57edf3f093e0914be094648b577372bd8ad247fa98cfba9c600794cd16b599 @@ -31173,13 +30492,6 @@ __metadata: languageName: node linkType: hard -"tslib@npm:2.3.1": - version: 2.3.1 - resolution: "tslib@npm:2.3.1" - checksum: 4efd888895bdb3b987086b2b7793ad1013566f882b0eb7a328384e5ecc0d71cafb16bbeab3196200cbf7f01a73ccc25acc2f131d4ea6ee959be7436a8a306482 - languageName: node - linkType: hard - "tslib@npm:2.5.0": version: 2.5.0 resolution: "tslib@npm:2.5.0" @@ -32091,13 +31403,6 @@ __metadata: languageName: node linkType: hard -"upath@npm:^1.1.1": - version: 1.2.0 - resolution: "upath@npm:1.2.0" - checksum: 3746f24099bf69dbf8234cecb671e1016e1f6b26bd306de4ff8966fb0bc463fa1014ffc48646b375de1ab573660e3a0256f6f2a87218b2dfa1779a84ef6992fa - languageName: node - linkType: hard - "update-browserslist-db@npm:^1.0.13": version: 1.0.15 resolution: "update-browserslist-db@npm:1.0.15"