- Modernized setup and using typescript for test files

This commit is contained in:
Ferdi Koomen 2022-01-06 18:41:57 +01:00
parent cfdbe48df3
commit 07c98cf9e6
50 changed files with 765 additions and 773 deletions

View File

@ -1,14 +0,0 @@
'use strict';
module.exports = {
presets: [
['@babel/preset-env', {
targets: {
node: true,
},
}],
['@babel/preset-typescript', {
onlyRemoveTypeImports: true,
}],
],
};

4
.eslintignore Normal file
View File

@ -0,0 +1,4 @@
dist
test/generated
test/e2e/generated
node_modules

View File

@ -1,18 +1,12 @@
{
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier"
],
"extends": ["plugin:@typescript-eslint/recommended", "plugin:prettier/recommended", "prettier"],
"env": {
"es6": true,
"node": true,
"jest": true
},
"plugins": [
"simple-import-sort"
],
"plugins": ["simple-import-sort"],
"rules": {
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-inferrable-types": 0,

18
babel.config.json Normal file
View File

@ -0,0 +1,18 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": true
}
}
],
[
"@babel/preset-typescript",
{
"onlyRemoveTypeImports": true
}
]
]
}

View File

@ -1,40 +0,0 @@
'use strict';
module.exports = {
projects: [
{
displayName: 'UNIT',
testEnvironment: 'node',
testMatch: [
'<rootDir>/src/**/*.spec.ts',
'<rootDir>/test/index.spec.js',
],
moduleFileExtensions: ['js', 'ts', 'd.ts'],
moduleNameMapper: {
'\\.hbs$': '<rootDir>/src/templates/__mocks__/index.js',
},
},
{
displayName: 'E2E',
testEnvironment: 'node',
testMatch: [
'<rootDir>/test/e2e/v2.fetch.spec.js',
'<rootDir>/test/e2e/v2.xhr.spec.js',
'<rootDir>/test/e2e/v2.node.spec.js',
'<rootDir>/test/e2e/v2.axios.spec.js',
'<rootDir>/test/e2e/v2.babel.spec.js',
'<rootDir>/test/e2e/v3.fetch.spec.js',
'<rootDir>/test/e2e/v3.xhr.spec.js',
'<rootDir>/test/e2e/v3.node.spec.js',
'<rootDir>/test/e2e/v3.axios.spec.js',
'<rootDir>/test/e2e/v3.babel.spec.js',
],
},
],
collectCoverageFrom: [
'<rootDir>/src/**/*.ts',
'!<rootDir>/src/**/*.d.ts',
'!<rootDir>/bin',
'!<rootDir>/dist',
],
};

34
jest.config.ts Normal file
View File

@ -0,0 +1,34 @@
import type { Config } from '@jest/types';
const config: Config.InitialOptions = {
projects: [
{
displayName: 'UNIT',
testEnvironment: 'node',
testMatch: ['<rootDir>/src/**/*.spec.ts', '<rootDir>/test/index.spec.ts'],
moduleFileExtensions: ['js', 'ts', 'd.ts'],
moduleNameMapper: {
'\\.hbs$': '<rootDir>/src/templates/__mocks__/index.ts',
},
},
{
displayName: 'E2E',
testEnvironment: 'node',
testMatch: [
'<rootDir>/test/e2e/v2.fetch.spec.ts',
'<rootDir>/test/e2e/v2.xhr.spec.ts',
'<rootDir>/test/e2e/v2.node.spec.ts',
'<rootDir>/test/e2e/v2.axios.spec.ts',
'<rootDir>/test/e2e/v2.babel.spec.ts',
'<rootDir>/test/e2e/v3.fetch.spec.ts',
'<rootDir>/test/e2e/v3.xhr.spec.ts',
'<rootDir>/test/e2e/v3.node.spec.ts',
'<rootDir>/test/e2e/v3.axios.spec.ts',
'<rootDir>/test/e2e/v3.babel.spec.ts',
],
},
],
collectCoverageFrom: ['<rootDir>/src/**/*.ts', '!<rootDir>/src/**/*.d.ts', '!<rootDir>/bin', '!<rootDir>/dist'],
};
export default config;

View File

@ -15,14 +15,13 @@
"keywords": [
"openapi",
"swagger",
"codegen",
"generator",
"client",
"typescript",
"yaml",
"json",
"fetch",
"xhr",
"axios",
"node"
],
"maintainers": [
@ -46,16 +45,15 @@
"build": "rollup --config --environment NODE_ENV:development",
"build:watch": "rollup --config --environment NODE_ENV:development --watch",
"release": "rollup --config --environment NODE_ENV:production",
"run": "NODE_ENV=production node ./test/index.js",
"validate": "tsc --project tsconfig.json --noEmit",
"run": "node ./test/index.js",
"test": "jest --selectProjects UNIT",
"test:update": "jest --selectProjects UNIT --updateSnapshot",
"test:watch": "jest --selectProjects UNIT --watch",
"test:coverage": "jest --selectProjects UNIT --coverage",
"test:e2e": "jest --selectProjects E2E --runInBand",
"eslint": "eslint \"./src/**/*.ts\" \"./bin/index.js\" \"./types/index.d.ts\"",
"eslint:fix": "eslint \"./src/**/*.ts\" \"./bin/index.js\" \"./types/index.d.ts\" --fix",
"prettier": "prettier \"./src/**/*.ts\" \"./bin/index.js\" \"./types/index.d.ts\" --check",
"prettier:fix": "prettier \"./src/**/*.ts\" \"./bin/index.js\" \"./types/index.d.ts\" --write",
"eslint": "eslint .",
"eslint:fix": "eslint . --fix",
"prepublishOnly": "yarn run clean && yarn run release",
"codecov": "codecov --token=66c30c23-8954-4892-bef9-fbaed0a2e42b"
},
@ -68,17 +66,17 @@
"form-data": "^4.0.0",
"handlebars": "^4.7.6",
"json-schema-ref-parser": "^9.0.7",
"mkdirp": "^1.0.4",
"node-fetch": "^2.6.5",
"rimraf": "^3.0.2"
"node-fetch": "^2.6.6"
},
"devDependencies": {
"@babel/cli": "7.16.7",
"@babel/core": "7.16.7",
"@babel/preset-env": "7.16.7",
"@babel/preset-typescript": "7.16.7",
"@rollup/plugin-alias": "3.1.9",
"@rollup/plugin-commonjs": "21.0.1",
"@rollup/plugin-node-resolve": "13.1.3",
"@rollup/plugin-typescript": "8.3.0",
"@types/express": "4.17.13",
"@types/glob": "7.2.0",
"@types/jest": "27.4.0",
@ -98,9 +96,11 @@
"prettier": "2.5.1",
"puppeteer": "13.0.1",
"qs": "6.10.2",
"rimraf": "^3.0.2",
"rollup": "2.63.0",
"rollup-plugin-node-externals": "3.1.2",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.31.1",
"ts-node": "10.4.0",
"tslib": "2.3.1",
"typescript": "4.5.4"
}

View File

@ -1,15 +1,12 @@
'use strict';
const commonjs = require('@rollup/plugin-commonjs');
const { nodeResolve } = require('@rollup/plugin-node-resolve');
const { terser } = require('rollup-plugin-terser');
const typescript = require('rollup-plugin-typescript2');
const handlebars = require('handlebars');
const path = require('path');
const fs = require('fs');
const pkg = require('./package.json');
const external = Object.keys(pkg.dependencies);
import alias from '@rollup/plugin-alias';
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import { readFileSync } from 'fs';
import { precompile } from 'handlebars';
import { dirname, extname, resolve } from 'path';
import externals from 'rollup-plugin-node-externals';
import { terser } from 'rollup-plugin-terser';
/**
* Custom plugin to parse handlebar imports and precompile
@ -18,15 +15,15 @@ const external = Object.keys(pkg.dependencies);
*/
const handlebarsPlugin = () => ({
resolveId: (file, importer) => {
if (path.extname(file) === '.hbs') {
return path.resolve(path.dirname(importer), file);
if (extname(file) === '.hbs') {
return resolve(dirname(importer), file);
}
return null;
},
load: (file) => {
if (path.extname(file) === '.hbs') {
const template = fs.readFileSync(file, 'utf8').toString().trim();
const templateSpec = handlebars.precompile(template, {
load: file => {
if (extname(file) === '.hbs') {
const template = readFileSync(file, 'utf8').toString().trim();
const templateSpec = precompile(template, {
strict: true,
noEscape: true,
preventIndent: true,
@ -38,43 +35,45 @@ const handlebarsPlugin = () => ({
union: true,
intersection: true,
enumerator: true,
escapeQuotes: true,
},
});
return `export default ${templateSpec};`;
}
return null;
}
},
});
const getPlugins = () => {
const plugins = [
handlebarsPlugin(),
typescript(),
externals({
deps: true,
}),
nodeResolve(),
commonjs(),
]
commonjs({
sourceMap: false,
}),
handlebarsPlugin(),
typescript({
module: 'esnext',
}),
alias({
entries: {
handlebars: 'handlebars/lib/handlebars.runtime',
},
}),
];
if (process.env.NODE_ENV === 'development') {
return plugins;
}
return [...plugins, terser()];
};
module.exports = {
export default {
input: './src/index.ts',
output: {
exports: 'named',
file: './dist/index.js',
format: 'cjs',
},
external: [
'fs',
'os',
'util',
'path',
'http',
'https',
'handlebars/runtime',
...external,
],
plugins: getPlugins(),
};

View File

@ -1,4 +1,4 @@
import * as OpenAPI from './index';
import OpenAPI from './index';
describe('index', () => {
it('parses v2 without issues', async () => {

View File

@ -108,3 +108,8 @@ export async function generate({
}
}
}
export default {
HttpClient,
generate,
};

View File

@ -1,4 +1,4 @@
module.exports = {
export default {
compiler: [8, '>= 4.3.0'],
useData: true,
main: function () {

View File

@ -1,7 +1,6 @@
{{>header}}
import { AbortController } from 'abort-controller';
import Blob from 'cross-blob'
import FormData from 'form-data';
import fetch, { BodyInit, Headers, RequestInit, Response } from 'node-fetch';

View File

@ -1,7 +1,7 @@
{
type: '{{export}}',
{{#if description}}
description: '{{{escapeQuotes description}}}',
description: `{{{description}}}`,
{{/if}}
contains: [{{#each properties}}{{>schema}}{{#unless @last}}, {{/unless}}{{/each}}],
{{#if isReadOnly}}

View File

@ -3,7 +3,7 @@
type: '{{{type}}}',
{{/if}}
{{#if description}}
description: '{{{escapeQuotes description}}}',
description: `{{{description}}}`,
{{/if}}
{{#if isReadOnly}}
isReadOnly: {{{isReadOnly}}},

View File

@ -1,6 +1,6 @@
{
{{#if description}}
description: '{{{escapeQuotes description}}}',
description: `{{{description}}}`,
{{/if}}
properties: {
{{#if properties}}

View File

@ -1,8 +0,0 @@
declare module 'camelcase' {
export default function camelcase(
input: string,
options?: {
pascalCase?: boolean;
}
): string;
}

View File

@ -1,3 +0,0 @@
declare module 'mkdirp' {
export default function mkdirp(dir: string): Promise<string>;
}

View File

@ -1,3 +0,0 @@
declare module 'rimraf' {
export default function rimraf(path: string, callback: (error: Error) => void): void;
}

View File

@ -1,6 +1,11 @@
import { copyFile as __copyFile, exists as __exists, readFile as __readFile, writeFile as __writeFile } from 'fs';
import mkdirp from 'mkdirp';
import rimraf from 'rimraf';
import {
copyFile as __copyFile,
exists as __exists,
mkdir as __mkdir,
readFile as __readFile,
rm as __rm,
writeFile as __writeFile,
} from 'fs';
import { promisify } from 'util';
// Wrapped file system calls
@ -9,17 +14,37 @@ export const writeFile = promisify(__writeFile);
export const copyFile = promisify(__copyFile);
export const exists = promisify(__exists);
// Re-export from mkdirp to make mocking easier
export const mkdir = mkdirp;
export const mkdir = (path: string): Promise<void> =>
new Promise((resolve, reject) => {
__mkdir(
path,
{
recursive: true,
},
error => {
if (error) {
reject(error);
} else {
resolve();
}
}
);
});
// Promisified version of rimraf
export const rmdir = (path: string): Promise<void> =>
new Promise((resolve, reject) => {
rimraf(path, (error: Error) => {
if (error) {
reject(error);
} else {
resolve();
__rm(
path,
{
recursive: true,
force: true,
},
error => {
if (error) {
reject(error);
} else {
resolve();
}
}
});
);
});

View File

@ -1,4 +1,4 @@
import * as Handlebars from 'handlebars/runtime';
import Handlebars from 'handlebars';
import { HttpClient } from '../HttpClient';
import { registerHandlebarHelpers } from './registerHandlebarHelpers';
@ -17,6 +17,5 @@ describe('registerHandlebarHelpers', () => {
expect(helpers).toContain('union');
expect(helpers).toContain('intersection');
expect(helpers).toContain('enumerator');
expect(helpers).toContain('escapeQuotes');
});
});

View File

@ -1,4 +1,4 @@
import * as Handlebars from 'handlebars/runtime';
import Handlebars from 'handlebars';
import { Enum } from '../client/interfaces/Enum';
import { Model } from '../client/interfaces/Model';
@ -79,8 +79,4 @@ export function registerHandlebarHelpers(root: {
);
}
);
Handlebars.registerHelper('escapeQuotes', function (value: string): string {
return value.replace(/(')/g, '\\$1');
});
}

View File

@ -1,4 +1,4 @@
import * as Handlebars from 'handlebars/runtime';
import Handlebars from 'handlebars';
import { HttpClient } from '../HttpClient';
import templateCoreApiError from '../templates/core/ApiError.hbs';

View File

@ -32,7 +32,7 @@ describe('writeClient', () => {
},
};
await writeClient(client, templates, './dist', HttpClient.FETCH, false, false, true, true, true, true);
await writeClient(client, templates, './dist', HttpClient.FETCH, false, false, true, true, true, true, '');
expect(rmdir).toBeCalled();
expect(mkdir).toBeCalled();

View File

@ -230,7 +230,16 @@ function isStringWithValue(value: any): value is string {
}
function isBlob(value: any): value is Blob {
return value instanceof 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])
);
}
function isFormData(value: any): value is FormData {
@ -1372,7 +1381,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$Date.ts 1`] = `
/* eslint-disable */
export const $Date = {
type: 'string',
description: 'This is a type-only model that defines Date as a string',
description: \`This is a type-only model that defines Date as a string\`,
} as const;"
`;
@ -1455,7 +1464,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$EnumFromDescription.ts
/* eslint-disable */
export const $EnumFromDescription = {
type: 'number',
description: 'Success=1,Warning=2,Error=3',
description: \`Success=1,Warning=2,Error=3\`,
} as const;"
`;
@ -1492,7 +1501,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelThatExtends.ts 1`
/* eslint-disable */
export const $ModelThatExtends = {
type: 'all-of',
description: 'This is a model that extends another model',
description: \`This is a model that extends another model\`,
contains: [{
type: 'ModelWithString',
}, {
@ -1514,7 +1523,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelThatExtendsExtend
/* eslint-disable */
export const $ModelThatExtendsExtends = {
type: 'all-of',
description: 'This is a model that extends another model',
description: \`This is a model that extends another model\`,
contains: [{
type: 'ModelWithString',
}, {
@ -1537,7 +1546,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithArray.ts 1`]
/* tslint:disable */
/* eslint-disable */
export const $ModelWithArray = {
description: 'This is a model with one property containing an array',
description: \`This is a model with one property containing an array\`,
properties: {
prop: {
type: 'array',
@ -1566,11 +1575,11 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithBoolean.ts 1`
/* tslint:disable */
/* eslint-disable */
export const $ModelWithBoolean = {
description: 'This is a model with one boolean property',
description: \`This is a model with one boolean property\`,
properties: {
prop: {
type: 'boolean',
description: 'This is a simple boolean property',
description: \`This is a simple boolean property\`,
},
},
} as const;"
@ -1581,7 +1590,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithCircularRefer
/* tslint:disable */
/* eslint-disable */
export const $ModelWithCircularReference = {
description: 'This is a model with one property containing a circular reference',
description: \`This is a model with one property containing a circular reference\`,
properties: {
prop: {
type: 'ModelWithCircularReference',
@ -1595,7 +1604,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithDictionary.ts
/* tslint:disable */
/* eslint-disable */
export const $ModelWithDictionary = {
description: 'This is a model with one property containing a dictionary',
description: \`This is a model with one property containing a dictionary\`,
properties: {
prop: {
type: 'dictionary',
@ -1612,7 +1621,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithDuplicateImpo
/* tslint:disable */
/* eslint-disable */
export const $ModelWithDuplicateImports = {
description: 'This is a model with duplicated imports',
description: \`This is a model with duplicated imports\`,
properties: {
propA: {
type: 'ModelWithString',
@ -1632,7 +1641,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithDuplicateProp
/* tslint:disable */
/* eslint-disable */
export const $ModelWithDuplicateProperties = {
description: 'This is a model with duplicated properties',
description: \`This is a model with duplicated properties\`,
properties: {
prop: {
type: 'ModelWithString',
@ -1646,7 +1655,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithEnum.ts 1`] =
/* tslint:disable */
/* eslint-disable */
export const $ModelWithEnum = {
description: 'This is a model with one enum',
description: \`This is a model with one enum\`,
properties: {
test: {
type: 'Enum',
@ -1656,7 +1665,7 @@ export const $ModelWithEnum = {
},
bool: {
type: 'boolean',
description: 'Simple boolean enum',
description: \`Simple boolean enum\`,
},
},
} as const;"
@ -1667,7 +1676,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithEnumFromDescr
/* tslint:disable */
/* eslint-disable */
export const $ModelWithEnumFromDescription = {
description: 'This is a model with one enum',
description: \`This is a model with one enum\`,
properties: {
test: {
type: 'Enum',
@ -1681,11 +1690,11 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithInteger.ts 1`
/* tslint:disable */
/* eslint-disable */
export const $ModelWithInteger = {
description: 'This is a model with one number property',
description: \`This is a model with one number property\`,
properties: {
prop: {
type: 'number',
description: 'This is a simple number property',
description: \`This is a simple number property\`,
},
},
} as const;"
@ -1696,7 +1705,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithNestedEnums.t
/* tslint:disable */
/* eslint-disable */
export const $ModelWithNestedEnums = {
description: 'This is a model with nested enums',
description: \`This is a model with nested enums\`,
properties: {
dictionaryWithEnum: {
type: 'dictionary',
@ -1731,7 +1740,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithNestedPropert
/* tslint:disable */
/* eslint-disable */
export const $ModelWithNestedProperties = {
description: 'This is a model with one nested property',
description: \`This is a model with one nested property\`,
properties: {
first: {
properties: {
@ -1759,16 +1768,16 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithNullableStrin
/* tslint:disable */
/* eslint-disable */
export const $ModelWithNullableString = {
description: 'This is a model with one string property',
description: \`This is a model with one string property\`,
properties: {
nullableProp: {
type: 'string',
description: 'This is a simple string property',
description: \`This is a simple string property\`,
isNullable: true,
},
nullableRequiredProp: {
type: 'string',
description: 'This is a simple string property',
description: \`This is a simple string property\`,
isRequired: true,
isNullable: true,
},
@ -1781,7 +1790,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithOrderedProper
/* tslint:disable */
/* eslint-disable */
export const $ModelWithOrderedProperties = {
description: 'This is a model with ordered properties',
description: \`This is a model with ordered properties\`,
properties: {
zebra: {
type: 'string',
@ -1801,7 +1810,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithPattern.ts 1`
/* tslint:disable */
/* eslint-disable */
export const $ModelWithPattern = {
description: 'This is a model that contains a some patterns',
description: \`This is a model that contains a some patterns\`,
properties: {
key: {
type: 'string',
@ -1840,7 +1849,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithProperties.ts
/* tslint:disable */
/* eslint-disable */
export const $ModelWithProperties = {
description: 'This is a model with one nested property',
description: \`This is a model with one nested property\`,
properties: {
required: {
type: 'string',
@ -1889,7 +1898,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithReference.ts
/* tslint:disable */
/* eslint-disable */
export const $ModelWithReference = {
description: 'This is a model with one property containing a reference',
description: \`This is a model with one property containing a reference\`,
properties: {
prop: {
type: 'ModelWithProperties',
@ -1903,11 +1912,11 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithString.ts 1`]
/* tslint:disable */
/* eslint-disable */
export const $ModelWithString = {
description: 'This is a model with one string property',
description: \`This is a model with one string property\`,
properties: {
prop: {
type: 'string',
description: 'This is a simple string property',
description: \`This is a simple string property\`,
},
},
} as const;"
@ -1919,10 +1928,10 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$MultilineComment.ts 1`
/* eslint-disable */
export const $MultilineComment = {
type: 'number',
description: 'Testing multiline comments.
description: \`Testing multiline comments.
* This must go to the next line.
*
* This will contain a break.',
* This will contain a break.\`,
} as const;"
`;
@ -1932,7 +1941,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleBoolean.ts 1`] =
/* eslint-disable */
export const $SimpleBoolean = {
type: 'boolean',
description: 'This is a simple boolean',
description: \`This is a simple boolean\`,
} as const;"
`;
@ -1942,7 +1951,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleFile.ts 1`] = `
/* eslint-disable */
export const $SimpleFile = {
type: 'binary',
description: 'This is a simple file',
description: \`This is a simple file\`,
} as const;"
`;
@ -1952,7 +1961,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleInteger.ts 1`] =
/* eslint-disable */
export const $SimpleInteger = {
type: 'number',
description: 'This is a simple number',
description: \`This is a simple number\`,
} as const;"
`;
@ -1962,7 +1971,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleReference.ts 1`]
/* eslint-disable */
export const $SimpleReference = {
type: 'ModelWithString',
description: 'This is a simple reference',
description: \`This is a simple reference\`,
} as const;"
`;
@ -1972,7 +1981,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleString.ts 1`] =
/* eslint-disable */
export const $SimpleString = {
type: 'string',
description: 'This is a simple string',
description: \`This is a simple string\`,
} as const;"
`;
@ -1982,7 +1991,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleStringWithPatter
/* eslint-disable */
export const $SimpleStringWithPattern = {
type: 'string',
description: 'This is a simple string',
description: \`This is a simple string\`,
maxLength: 64,
pattern: '^[a-zA-Z0-9_]*$',
} as const;"
@ -2934,7 +2943,16 @@ function isStringWithValue(value: any): value is string {
}
function isBlob(value: any): value is Blob {
return value instanceof 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])
);
}
function isFormData(value: any): value is FormData {
@ -4324,7 +4342,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionBaseModel.t
/* tslint:disable */
/* eslint-disable */
export const $CompositionBaseModel = {
description: 'This is a base model with two simple optional properties',
description: \`This is a base model with two simple optional properties\`,
properties: {
firstName: {
type: 'string',
@ -4342,7 +4360,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionExtendedMod
/* eslint-disable */
export const $CompositionExtendedModel = {
type: 'all-of',
description: 'This is a model that extends the base model',
description: \`This is a model that extends the base model\`,
contains: [{
type: 'CompositionBaseModel',
}, {
@ -4369,7 +4387,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAllOfAn
/* tslint:disable */
/* eslint-disable */
export const $CompositionWithAllOfAndNullable = {
description: 'This is a model with one property with a \\\\'all of\\\\' relationship',
description: \`This is a model with one property with a 'all of' relationship\`,
properties: {
propA: {
type: 'all-of',
@ -4397,7 +4415,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAnyOf.t
/* tslint:disable */
/* eslint-disable */
export const $CompositionWithAnyOf = {
description: 'This is a model with one property with a \\\\'any of\\\\' relationship',
description: \`This is a model with one property with a 'any of' relationship\`,
properties: {
propA: {
type: 'any-of',
@ -4420,7 +4438,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAnyOfAn
/* tslint:disable */
/* eslint-disable */
export const $CompositionWithAnyOfAndNullable = {
description: 'This is a model with one property with a \\\\'any of\\\\' relationship',
description: \`This is a model with one property with a 'any of' relationship\`,
properties: {
propA: {
type: 'any-of',
@ -4448,12 +4466,12 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAnyOfAn
/* tslint:disable */
/* eslint-disable */
export const $CompositionWithAnyOfAnonymous = {
description: 'This is a model with one property with a \\\\'any of\\\\' relationship where the options are not $ref',
description: \`This is a model with one property with a 'any of' relationship where the options are not $ref\`,
properties: {
propA: {
type: 'any-of',
contains: [{
description: 'Anonymous object type',
description: \`Anonymous object type\`,
properties: {
propA: {
type: 'string',
@ -4461,10 +4479,10 @@ export const $CompositionWithAnyOfAnonymous = {
},
}, {
type: 'string',
description: 'Anonymous string type',
description: \`Anonymous string type\`,
}, {
type: 'number',
description: 'Anonymous integer type',
description: \`Anonymous integer type\`,
}],
},
},
@ -4476,7 +4494,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOf.t
/* tslint:disable */
/* eslint-disable */
export const $CompositionWithOneOf = {
description: 'This is a model with one property with a \\\\'one of\\\\' relationship',
description: \`This is a model with one property with a 'one of' relationship\`,
properties: {
propA: {
type: 'one-of',
@ -4499,7 +4517,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOfAn
/* tslint:disable */
/* eslint-disable */
export const $CompositionWithOneOfAndNullable = {
description: 'This is a model with one property with a \\\\'one of\\\\' relationship',
description: \`This is a model with one property with a 'one of' relationship\`,
properties: {
propA: {
type: 'one-of',
@ -4527,12 +4545,12 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOfAn
/* tslint:disable */
/* eslint-disable */
export const $CompositionWithOneOfAnonymous = {
description: 'This is a model with one property with a \\\\'one of\\\\' relationship where the options are not $ref',
description: \`This is a model with one property with a 'one of' relationship where the options are not $ref\`,
properties: {
propA: {
type: 'one-of',
contains: [{
description: 'Anonymous object type',
description: \`Anonymous object type\`,
properties: {
propA: {
type: 'string',
@ -4540,10 +4558,10 @@ export const $CompositionWithOneOfAnonymous = {
},
}, {
type: 'string',
description: 'Anonymous string type',
description: \`Anonymous string type\`,
}, {
type: 'number',
description: 'Anonymous integer type',
description: \`Anonymous integer type\`,
}],
},
},
@ -4556,7 +4574,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOfDi
/* eslint-disable */
export const $CompositionWithOneOfDiscriminator = {
type: 'one-of',
description: 'This is a model with one property with a \\\\'one of\\\\' relationship where the options are not $ref',
description: \`This is a model with one property with a 'one of' relationship where the options are not $ref\`,
contains: [{
type: 'ModelCircle',
}, {
@ -4644,7 +4662,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$EnumFromDescription.ts
/* eslint-disable */
export const $EnumFromDescription = {
type: 'number',
description: 'Success=1,Warning=2,Error=3',
description: \`Success=1,Warning=2,Error=3\`,
} as const;"
`;
@ -4716,7 +4734,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelCircle.ts 1`] = `
/* tslint:disable */
/* eslint-disable */
export const $ModelCircle = {
description: 'Circle',
description: \`Circle\`,
properties: {
kind: {
type: 'string',
@ -4734,7 +4752,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelSquare.ts 1`] = `
/* tslint:disable */
/* eslint-disable */
export const $ModelSquare = {
description: 'Square',
description: \`Square\`,
properties: {
kind: {
type: 'string',
@ -4753,7 +4771,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelThatExtends.ts 1`
/* eslint-disable */
export const $ModelThatExtends = {
type: 'all-of',
description: 'This is a model that extends another model',
description: \`This is a model that extends another model\`,
contains: [{
type: 'ModelWithString',
}, {
@ -4775,7 +4793,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelThatExtendsExtend
/* eslint-disable */
export const $ModelThatExtendsExtends = {
type: 'all-of',
description: 'This is a model that extends another model',
description: \`This is a model that extends another model\`,
contains: [{
type: 'ModelWithString',
}, {
@ -4798,7 +4816,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithArray.ts 1`]
/* tslint:disable */
/* eslint-disable */
export const $ModelWithArray = {
description: 'This is a model with one property containing an array',
description: \`This is a model with one property containing an array\`,
properties: {
prop: {
type: 'array',
@ -4827,11 +4845,11 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithBoolean.ts 1`
/* tslint:disable */
/* eslint-disable */
export const $ModelWithBoolean = {
description: 'This is a model with one boolean property',
description: \`This is a model with one boolean property\`,
properties: {
prop: {
type: 'boolean',
description: 'This is a simple boolean property',
description: \`This is a simple boolean property\`,
},
},
} as const;"
@ -4842,7 +4860,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithCircularRefer
/* tslint:disable */
/* eslint-disable */
export const $ModelWithCircularReference = {
description: 'This is a model with one property containing a circular reference',
description: \`This is a model with one property containing a circular reference\`,
properties: {
prop: {
type: 'ModelWithCircularReference',
@ -4856,7 +4874,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithDictionary.ts
/* tslint:disable */
/* eslint-disable */
export const $ModelWithDictionary = {
description: 'This is a model with one property containing a dictionary',
description: \`This is a model with one property containing a dictionary\`,
properties: {
prop: {
type: 'dictionary',
@ -4873,7 +4891,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithDuplicateImpo
/* tslint:disable */
/* eslint-disable */
export const $ModelWithDuplicateImports = {
description: 'This is a model with duplicated imports',
description: \`This is a model with duplicated imports\`,
properties: {
propA: {
type: 'ModelWithString',
@ -4893,7 +4911,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithDuplicateProp
/* tslint:disable */
/* eslint-disable */
export const $ModelWithDuplicateProperties = {
description: 'This is a model with duplicated properties',
description: \`This is a model with duplicated properties\`,
properties: {
prop: {
type: 'ModelWithString',
@ -4907,7 +4925,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithEnum.ts 1`] =
/* tslint:disable */
/* eslint-disable */
export const $ModelWithEnum = {
description: 'This is a model with one enum',
description: \`This is a model with one enum\`,
properties: {
test: {
type: 'Enum',
@ -4917,7 +4935,7 @@ export const $ModelWithEnum = {
},
bool: {
type: 'boolean',
description: 'Simple boolean enum',
description: \`Simple boolean enum\`,
},
},
} as const;"
@ -4928,7 +4946,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithEnumFromDescr
/* tslint:disable */
/* eslint-disable */
export const $ModelWithEnumFromDescription = {
description: 'This is a model with one enum',
description: \`This is a model with one enum\`,
properties: {
test: {
type: 'Enum',
@ -4942,11 +4960,11 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithInteger.ts 1`
/* tslint:disable */
/* eslint-disable */
export const $ModelWithInteger = {
description: 'This is a model with one number property',
description: \`This is a model with one number property\`,
properties: {
prop: {
type: 'number',
description: 'This is a simple number property',
description: \`This is a simple number property\`,
},
},
} as const;"
@ -4957,7 +4975,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithNestedEnums.t
/* tslint:disable */
/* eslint-disable */
export const $ModelWithNestedEnums = {
description: 'This is a model with nested enums',
description: \`This is a model with nested enums\`,
properties: {
dictionaryWithEnum: {
type: 'dictionary',
@ -4992,7 +5010,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithNestedPropert
/* tslint:disable */
/* eslint-disable */
export const $ModelWithNestedProperties = {
description: 'This is a model with one nested property',
description: \`This is a model with one nested property\`,
properties: {
first: {
properties: {
@ -5023,27 +5041,27 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithNullableStrin
/* tslint:disable */
/* eslint-disable */
export const $ModelWithNullableString = {
description: 'This is a model with one string property',
description: \`This is a model with one string property\`,
properties: {
nullableProp1: {
type: 'string',
description: 'This is a simple string property',
description: \`This is a simple string property\`,
isNullable: true,
},
nullableRequiredProp1: {
type: 'string',
description: 'This is a simple string property',
description: \`This is a simple string property\`,
isRequired: true,
isNullable: true,
},
nullableProp2: {
type: 'string',
description: 'This is a simple string property',
description: \`This is a simple string property\`,
isNullable: true,
},
nullableRequiredProp2: {
type: 'string',
description: 'This is a simple string property',
description: \`This is a simple string property\`,
isRequired: true,
isNullable: true,
},
@ -5056,7 +5074,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithOrderedProper
/* tslint:disable */
/* eslint-disable */
export const $ModelWithOrderedProperties = {
description: 'This is a model with ordered properties',
description: \`This is a model with ordered properties\`,
properties: {
zebra: {
type: 'string',
@ -5076,7 +5094,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithPattern.ts 1`
/* tslint:disable */
/* eslint-disable */
export const $ModelWithPattern = {
description: 'This is a model that contains a some patterns',
description: \`This is a model that contains a some patterns\`,
properties: {
key: {
type: 'string',
@ -5115,7 +5133,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithProperties.ts
/* tslint:disable */
/* eslint-disable */
export const $ModelWithProperties = {
description: 'This is a model with one nested property',
description: \`This is a model with one nested property\`,
properties: {
required: {
type: 'string',
@ -5169,7 +5187,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithReference.ts
/* tslint:disable */
/* eslint-disable */
export const $ModelWithReference = {
description: 'This is a model with one property containing a reference',
description: \`This is a model with one property containing a reference\`,
properties: {
prop: {
type: 'ModelWithProperties',
@ -5183,11 +5201,11 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithString.ts 1`]
/* tslint:disable */
/* eslint-disable */
export const $ModelWithString = {
description: 'This is a model with one string property',
description: \`This is a model with one string property\`,
properties: {
prop: {
type: 'string',
description: 'This is a simple string property',
description: \`This is a simple string property\`,
},
},
} as const;"
@ -5199,10 +5217,10 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$MultilineComment.ts 1`
/* eslint-disable */
export const $MultilineComment = {
type: 'number',
description: 'Testing multiline comments.
description: \`Testing multiline comments.
* This must go to the next line.
*
* This will contain a break.',
* This will contain a break.\`,
} as const;"
`;
@ -5212,7 +5230,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleBoolean.ts 1`] =
/* eslint-disable */
export const $SimpleBoolean = {
type: 'boolean',
description: 'This is a simple boolean',
description: \`This is a simple boolean\`,
} as const;"
`;
@ -5222,7 +5240,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleFile.ts 1`] = `
/* eslint-disable */
export const $SimpleFile = {
type: 'binary',
description: 'This is a simple file',
description: \`This is a simple file\`,
} as const;"
`;
@ -5232,7 +5250,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleInteger.ts 1`] =
/* eslint-disable */
export const $SimpleInteger = {
type: 'number',
description: 'This is a simple number',
description: \`This is a simple number\`,
} as const;"
`;
@ -5242,7 +5260,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleReference.ts 1`]
/* eslint-disable */
export const $SimpleReference = {
type: 'ModelWithString',
description: 'This is a simple reference',
description: \`This is a simple reference\`,
} as const;"
`;
@ -5252,7 +5270,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleString.ts 1`] =
/* eslint-disable */
export const $SimpleString = {
type: 'string',
description: 'This is a simple string',
description: \`This is a simple string\`,
} as const;"
`;
@ -5262,7 +5280,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleStringWithPatter
/* eslint-disable */
export const $SimpleStringWithPattern = {
type: 'string',
description: 'This is a simple string',
description: \`This is a simple string\`,
isNullable: true,
maxLength: 64,
pattern: '^[a-zA-Z0-9_]*$',

View File

@ -1,6 +1,3 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { ApiRequestOptions } from './ApiRequestOptions';
import { CancelablePromise } from './CancelablePromise';
import { OpenAPI } from './OpenAPI';

View File

@ -1,40 +0,0 @@
'use strict';
const puppeteer = require('puppeteer');
let browser;
let page;
async function start() {
// This starts the a new puppeteer browser (Chrome)
// and load the localhost page, this page will load the
// javascript modules (see server.js for more info)
browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
page = await browser.newPage();
// page.on('console', msg => console.log(msg.text()));
await page.goto(`http://localhost:3000/`, {
waitUntil: 'networkidle0',
});
}
async function stop() {
await page.close();
await browser.close();
}
async function evaluate(fn, ...args) {
return await page.evaluate(fn, args);
}
async function exposeFunction(name, fn) {
return await page.exposeFunction(name, fn);
}
module.exports = {
start,
stop,
evaluate,
exposeFunction,
};

View File

@ -0,0 +1,39 @@
import puppeteer, { Browser, EvaluateFn, Page } from 'puppeteer';
let _browser: Browser;
let _page: Page;
const start = async () => {
// This starts a new puppeteer browser (Chrome)
// and load the localhost page, this page will load the
// javascript modules (see server.js for more info)
_browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
_page = await _browser.newPage();
// page.on('console', msg => console.log(msg.text()));
await _page.goto(`http://localhost:3000/`, {
waitUntil: 'networkidle0',
});
};
const stop = async () => {
await _page.close();
await _browser.close();
};
const evaluate = async (fn: EvaluateFn) => {
return await _page.evaluate(fn);
};
// eslint-disable-next-line @typescript-eslint/ban-types
const exposeFunction = async (name: string, fn: Function) => {
return await _page.exposeFunction(name, fn);
};
export default {
start,
stop,
evaluate,
exposeFunction,
};

View File

@ -1,14 +1,12 @@
'use strict';
import { transformSync } from '@babel/core';
import { readFileSync, writeFileSync } from 'fs';
import { sync } from 'glob';
const glob = require('glob');
const fs = require('fs');
const babel = require('@babel/core');
function compileWithBabel(dir) {
glob.sync(`./test/e2e/generated/${dir}/**/*.ts`).forEach(file => {
export const compileWithBabel = (dir: string) => {
sync(`./test/e2e/generated/${dir}/**/*.ts`).forEach(file => {
try {
const content = fs.readFileSync(file, 'utf8').toString();
const result = babel.transformSync(content, {
const content = readFileSync(file, 'utf8').toString();
const result = transformSync(content, {
filename: file,
presets: [
[
@ -28,12 +26,12 @@ function compileWithBabel(dir) {
],
],
});
const out = file.replace(/\.ts$/, '.js');
fs.writeFileSync(out, result.code);
if (result?.code) {
const out = file.replace(/\.ts$/, '.js');
writeFileSync(out, result.code);
}
} catch (error) {
console.error(error);
}
});
}
module.exports = compileWithBabel;
};

View File

@ -1,49 +0,0 @@
'use strict';
const ts = require('typescript');
const path = require('path');
const os = require('os');
function compileWithTypescript(dir) {
const baseDir = `./test/e2e/generated/${dir}/`;
const tsconfig = {
compilerOptions: {
target: 'es2017',
module: 'es6',
moduleResolution: 'node',
lib: ['es6', 'es2017', 'dom'],
declaration: false,
declarationMap: false,
sourceMap: false,
noImplicitReturns: true,
noImplicitThis: true,
noImplicitAny: true,
strict: true,
strictNullChecks: true,
strictFunctionTypes: true,
allowSyntheticDefaultImports: true,
skipLibCheck: true,
},
include: ['./index.ts'],
};
// Compile files to JavaScript (ES6 modules)
const configFile = ts.parseConfigFileTextToJson('tsconfig.json', JSON.stringify(tsconfig));
const configFileResult = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.resolve(process.cwd(), baseDir), undefined, 'tsconfig.json');
const compilerHost = ts.createCompilerHost(configFileResult.options);
const compiler = ts.createProgram(configFileResult.fileNames, configFileResult.options, compilerHost);
const result = compiler.emit();
// Show errors or warnings (if any)
const diagnostics = ts.getPreEmitDiagnostics(compiler).concat(result.diagnostics);
if (diagnostics.length) {
const message = ts.formatDiagnosticsWithColorAndContext(diagnostics, {
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
getCanonicalFileName: f => f,
getNewLine: () => os.EOL,
});
console.log(message);
}
}
module.exports = compileWithTypescript;

View File

@ -0,0 +1,57 @@
import { EOL } from 'os';
import { resolve } from 'path';
import {
createCompilerHost,
createProgram,
formatDiagnosticsWithColorAndContext,
getPreEmitDiagnostics,
parseConfigFileTextToJson,
parseJsonConfigFileContent,
sys,
} from 'typescript';
export const compileWithTypescript = (dir: string) => {
const baseDir = `./test/e2e/generated/${dir}/`;
const tsconfig = {
compilerOptions: {
target: 'es2020',
module: 'es2020',
moduleResolution: 'node',
lib: ['es2020', 'dom'],
declaration: false,
declarationMap: false,
sourceMap: false,
noImplicitReturns: true,
noImplicitThis: true,
noImplicitAny: true,
strict: true,
skipLibCheck: true,
allowSyntheticDefaultImports: true,
},
include: ['./index.ts'],
};
// Compile files to JavaScript (ES6 modules)
const configFile = parseConfigFileTextToJson('tsconfig.json', JSON.stringify(tsconfig));
const configFileResult = parseJsonConfigFileContent(
configFile.config,
sys,
resolve(process.cwd(), baseDir),
undefined,
'tsconfig.json'
);
const compilerHost = createCompilerHost(configFileResult.options);
const compiler = createProgram(configFileResult.fileNames, configFileResult.options, compilerHost);
const result = compiler.emit();
// Show errors or warnings (if any)
const diagnostics = getPreEmitDiagnostics(compiler).concat(result.diagnostics);
if (diagnostics.length) {
const message = formatDiagnosticsWithColorAndContext(diagnostics, {
getCurrentDirectory: () => sys.getCurrentDirectory(),
getCanonicalFileName: f => f,
getNewLine: () => EOL,
});
console.log(message);
}
};

View File

@ -1,9 +0,0 @@
'use strict';
const fs = require('fs');
function copy(dir) {
fs.copyFileSync('./test/e2e/assets/script.js', `./test/e2e/generated/${dir}/script.js`);
}
module.exports = copy;

5
test/e2e/scripts/copy.ts Normal file
View File

@ -0,0 +1,5 @@
import { copyFileSync } from 'fs';
export const copy = (dir: string) => {
copyFileSync('./test/e2e/assets/script.js', `./test/e2e/generated/${dir}/script.js`);
};

View File

@ -1,15 +0,0 @@
'use strict';
const OpenAPI = require('../../../dist');
async function generate(dir, version, client, useOptions = false, useUnionTypes = false) {
await OpenAPI.generate({
input: `./test/spec/${version}.json`,
output: `./test/e2e/generated/${dir}/`,
httpClient: client,
useOptions,
useUnionTypes,
});
}
module.exports = generate;

View File

@ -0,0 +1,17 @@
import { generate as __generate } from '../../../';
export const generate = async (
dir: string,
version: string,
client: 'fetch' | 'xhr' | 'node' | 'axios',
useOptions: boolean = false,
useUnionTypes: boolean = false
) => {
await __generate({
input: `./test/spec/${version}.json`,
output: `./test/e2e/generated/${dir}/`,
httpClient: client,
useOptions,
useUnionTypes,
});
};

View File

@ -1,18 +1,17 @@
'use strict';
import express, { Express } from 'express';
import { Server } from 'http';
const express = require('express');
let _app: Express;
let _server: Server;
let app;
let server;
async function start(dir) {
return new Promise(resolve => {
app = express();
const start = async (dir: string) => {
return new Promise<void>(resolve => {
_app = express();
// Serve the JavaScript files from the specific folder, since we are using browser
// based ES6 modules, this also means that we can just request the js/index.js file
// and all other relative paths are resolved from that file.
app.use(
_app.use(
'/js',
express.static(`./test/e2e/generated/${dir}/`, {
extensions: ['', 'js'],
@ -23,22 +22,22 @@ async function start(dir) {
// When we request the index then we can just return the script loader.
// This file is copied from test/e2e/assets/script.js to the output directory
// of the specific version and client.
app.get('/', (req, res) => {
_app.get('/', (req, res) => {
res.send('<script src="js/script.js"></script>');
});
// Register an 'echo' server for testing error codes. This will just grab the
// status code from the query and return the default response (and text) from Express.
// See the spec files for more information.
app.all('/base/api/v1.0/error', (req, res) => {
const status = parseInt(req.query.status);
_app.all('/base/api/v1.0/error', (req, res) => {
const status = parseInt(String(req.query.status));
res.sendStatus(status);
});
// Register an 'echo' server that just returns all data from the API calls.
// Although this might not be a 'correct' response, we can use this to test
// the majority of API calls.
app.all('/base/api/v1.0/*', (req, res) => {
_app.all('/base/api/v1.0/*', (req, res) => {
setTimeout(() => {
res.json({
method: req.method,
@ -52,19 +51,23 @@ async function start(dir) {
});
}, 100);
});
server = app.listen(3000, resolve);
_server = _app.listen(3000, resolve);
});
}
};
async function stop() {
return new Promise(resolve => {
server.close(resolve);
const stop = async () => {
return new Promise<void>((resolve, reject) => {
_server.close(err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}
};
module.exports = {
export default {
start,
stop,
};

View File

@ -1,8 +1,6 @@
'use strict';
const generate = require('./scripts/generate');
const compileWithTypescript = require('./scripts/compileWithTypescript');
const server = require('./scripts/server');
import { compileWithTypescript } from './scripts/compileWithTypescript';
import { generate } from './scripts/generate';
import server from './scripts/server';
describe('v2.node', () => {
beforeAll(async () => {
@ -46,7 +44,7 @@ describe('v2.node', () => {
}, 10);
await promise;
} catch (e) {
error = e.message;
error = (e as Error).message;
}
expect(error).toContain('The user aborted a request.');
});

View File

@ -1,10 +1,8 @@
'use strict';
const generate = require('./scripts/generate');
const copy = require('./scripts/copy');
const compileWithBabel = require('./scripts/compileWithBabel');
const server = require('./scripts/server');
const browser = require('./scripts/browser');
import browser from './scripts/browser';
import { compileWithBabel } from './scripts/compileWithBabel';
import { copy } from './scripts/copy';
import { generate } from './scripts/generate';
import server from './scripts/server';
describe('v2.babel', () => {
beforeAll(async () => {
@ -23,8 +21,8 @@ describe('v2.babel', () => {
it('requests token', async () => {
await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN'));
const result = await browser.evaluate(async () => {
const { OpenAPI, SimpleService } = window.api;
OpenAPI.TOKEN = window.tokenRequest;
const { OpenAPI, SimpleService } = (window as any).api;
OpenAPI.TOKEN = (window as any).tokenRequest;
return await SimpleService.getCallWithoutParametersAndResponse();
});
expect(result.headers.authorization).toBe('Bearer MY_TOKEN');
@ -32,7 +30,7 @@ describe('v2.babel', () => {
it('supports complex params', async () => {
const result = await browser.evaluate(async () => {
const { ComplexService } = window.api;
const { ComplexService } = (window as any).api;
return await ComplexService.complexTypes({
first: {
second: {

View File

@ -1,10 +1,8 @@
'use strict';
const generate = require('./scripts/generate');
const copy = require('./scripts/copy');
const compileWithTypescript = require('./scripts/compileWithTypescript');
const server = require('./scripts/server');
const browser = require('./scripts/browser');
import browser from './scripts/browser';
import { compileWithTypescript } from './scripts/compileWithTypescript';
import { copy } from './scripts/copy';
import { generate } from './scripts/generate';
import server from './scripts/server';
describe('v2.fetch', () => {
beforeAll(async () => {
@ -23,8 +21,8 @@ describe('v2.fetch', () => {
it('requests token', async () => {
await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN'));
const result = await browser.evaluate(async () => {
const { OpenAPI, SimpleService } = window.api;
OpenAPI.TOKEN = window.tokenRequest;
const { OpenAPI, SimpleService } = (window as any).api;
OpenAPI.TOKEN = (window as any).tokenRequest;
return await SimpleService.getCallWithoutParametersAndResponse();
});
expect(result.headers.authorization).toBe('Bearer MY_TOKEN');
@ -32,7 +30,7 @@ describe('v2.fetch', () => {
it('supports complex params', async () => {
const result = await browser.evaluate(async () => {
const { ComplexService } = window.api;
const { ComplexService } = (window as any).api;
return await ComplexService.complexTypes({
first: {
second: {
@ -48,7 +46,7 @@ describe('v2.fetch', () => {
let error;
try {
await browser.evaluate(async () => {
const { SimpleService } = window.api;
const { SimpleService } = (window as any).api;
const promise = SimpleService.getCallWithoutParametersAndResponse();
setTimeout(() => {
promise.cancel();
@ -56,7 +54,7 @@ describe('v2.fetch', () => {
await promise;
});
} catch (e) {
error = e.message;
error = (e as Error).message;
}
expect(error).toContain('The user aborted a request.');
});
@ -64,18 +62,20 @@ describe('v2.fetch', () => {
it('should throw known error (500)', async () => {
const error = await browser.evaluate(async () => {
try {
const { ErrorService } = window.api;
const { ErrorService } = (window as any).api;
await ErrorService.testErrorCode(500);
} catch (e) {
const error = e as any;
return JSON.stringify({
name: e.name,
message: e.message,
url: e.url,
status: e.status,
statusText: e.statusText,
body: e.body,
name: error.name,
message: error.message,
url: error.url,
status: error.status,
statusText: error.statusText,
body: error.body,
});
}
return;
});
expect(error).toBe(
@ -93,18 +93,20 @@ describe('v2.fetch', () => {
it('should throw unknown error (409)', async () => {
const error = await browser.evaluate(async () => {
try {
const { ErrorService } = window.api;
const { ErrorService } = (window as any).api;
await ErrorService.testErrorCode(409);
} catch (e) {
const error = e as any;
return JSON.stringify({
name: e.name,
message: e.message,
url: e.url,
status: e.status,
statusText: e.statusText,
body: e.body,
name: error.name,
message: error.message,
url: error.url,
status: error.status,
statusText: error.statusText,
body: error.body,
});
}
return;
});
expect(error).toBe(
JSON.stringify({

View File

@ -1,8 +1,6 @@
'use strict';
const generate = require('./scripts/generate');
const compileWithTypescript = require('./scripts/compileWithTypescript');
const server = require('./scripts/server');
import { compileWithTypescript } from './scripts/compileWithTypescript';
import { generate } from './scripts/generate';
import server from './scripts/server';
describe('v2.node', () => {
beforeAll(async () => {
@ -46,7 +44,7 @@ describe('v2.node', () => {
}, 10);
await promise;
} catch (e) {
error = e.message;
error = (e as Error).message;
}
expect(error).toContain('The user aborted a request.');
});
@ -57,13 +55,14 @@ describe('v2.node', () => {
const { ErrorService } = require('./generated/v2/node/index.js');
await ErrorService.testErrorCode(500);
} catch (e) {
const err = e as any;
error = JSON.stringify({
name: e.name,
message: e.message,
url: e.url,
status: e.status,
statusText: e.statusText,
body: e.body,
name: err.name,
message: err.message,
url: err.url,
status: err.status,
statusText: err.statusText,
body: err.body,
});
}
expect(error).toBe(
@ -84,13 +83,14 @@ describe('v2.node', () => {
const { ErrorService } = require('./generated/v2/node/index.js');
await ErrorService.testErrorCode(409);
} catch (e) {
const err = e as any;
error = JSON.stringify({
name: e.name,
message: e.message,
url: e.url,
status: e.status,
statusText: e.statusText,
body: e.body,
name: err.name,
message: err.message,
url: err.url,
status: err.status,
statusText: err.statusText,
body: err.body,
});
}
expect(error).toBe(

View File

@ -1,11 +1,8 @@
'use strict';
const generate = require('./scripts/generate');
const copy = require('./scripts/copy');
const compileWithTypescript = require('./scripts/compileWithTypescript');
const server = require('./scripts/server');
const browser = require('./scripts/browser');
const {ErrorService} = require("./generated/v3/node/index.js");
import browser from './scripts/browser';
import { compileWithTypescript } from './scripts/compileWithTypescript';
import { copy } from './scripts/copy';
import { generate } from './scripts/generate';
import server from './scripts/server';
describe('v2.xhr', () => {
beforeAll(async () => {
@ -24,8 +21,8 @@ describe('v2.xhr', () => {
it('requests token', async () => {
await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN'));
const result = await browser.evaluate(async () => {
const { OpenAPI, SimpleService } = window.api;
OpenAPI.TOKEN = window.tokenRequest;
const { OpenAPI, SimpleService } = (window as any).api;
OpenAPI.TOKEN = (window as any).tokenRequest;
return await SimpleService.getCallWithoutParametersAndResponse();
});
expect(result.headers.authorization).toBe('Bearer MY_TOKEN');
@ -33,7 +30,7 @@ describe('v2.xhr', () => {
it('supports complex params', async () => {
const result = await browser.evaluate(async () => {
const { ComplexService } = window.api;
const { ComplexService } = (window as any).api;
return await ComplexService.complexTypes({
first: {
second: {
@ -49,7 +46,7 @@ describe('v2.xhr', () => {
let error;
try {
await browser.evaluate(async () => {
const { SimpleService } = window.api;
const { SimpleService } = (window as any).api;
const promise = SimpleService.getCallWithoutParametersAndResponse();
setTimeout(() => {
promise.cancel();
@ -57,7 +54,7 @@ describe('v2.xhr', () => {
await promise;
});
} catch (e) {
error = e.message;
error = (e as Error).message;
}
expect(error).toContain('The user aborted a request.');
});
@ -65,18 +62,20 @@ describe('v2.xhr', () => {
it('should throw known error (500)', async () => {
const error = await browser.evaluate(async () => {
try {
const { ErrorService } = window.api;
const { ErrorService } = (window as any).api;
await ErrorService.testErrorCode(500);
} catch (e) {
const error = e as any;
return JSON.stringify({
name: e.name,
message: e.message,
url: e.url,
status: e.status,
statusText: e.statusText,
body: e.body,
name: error.name,
message: error.message,
url: error.url,
status: error.status,
statusText: error.statusText,
body: error.body,
});
}
return;
});
expect(error).toBe(
@ -94,18 +93,20 @@ describe('v2.xhr', () => {
it('should throw unknown error (409)', async () => {
const error = await browser.evaluate(async () => {
try {
const { ErrorService } = window.api;
const { ErrorService } = (window as any).api;
await ErrorService.testErrorCode(409);
} catch (e) {
const error = e as any;
return JSON.stringify({
name: e.name,
message: e.message,
url: e.url,
status: e.status,
statusText: e.statusText,
body: e.body,
name: error.name,
message: error.message,
url: error.url,
status: error.status,
statusText: error.statusText,
body: error.body,
});
}
return;
});
expect(error).toBe(
JSON.stringify({

View File

@ -1,8 +1,6 @@
'use strict';
const generate = require('./scripts/generate');
const compileWithTypescript = require('./scripts/compileWithTypescript');
const server = require('./scripts/server');
import { compileWithTypescript } from './scripts/compileWithTypescript';
import { generate } from './scripts/generate';
import server from './scripts/server';
describe('v3.node', () => {
beforeAll(async () => {
@ -72,7 +70,7 @@ describe('v3.node', () => {
}, 10);
await promise;
} catch (e) {
error = e.message;
error = (e as Error).message;
}
expect(error).toContain('The user aborted a request.');
});

View File

@ -1,10 +1,8 @@
'use strict';
const generate = require('./scripts/generate');
const copy = require('./scripts/copy');
const compileWithBabel = require('./scripts/compileWithBabel');
const server = require('./scripts/server');
const browser = require('./scripts/browser');
import browser from './scripts/browser';
import { compileWithBabel } from './scripts/compileWithBabel';
import { copy } from './scripts/copy';
import { generate } from './scripts/generate';
import server from './scripts/server';
describe('v3.babel', () => {
beforeAll(async () => {
@ -23,8 +21,8 @@ describe('v3.babel', () => {
it('requests token', async () => {
await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN'));
const result = await browser.evaluate(async () => {
const { OpenAPI, SimpleService } = window.api;
OpenAPI.TOKEN = window.tokenRequest;
const { OpenAPI, SimpleService } = (window as any).api;
OpenAPI.TOKEN = (window as any).tokenRequest;
OpenAPI.USERNAME = undefined;
OpenAPI.PASSWORD = undefined;
return await SimpleService.getCallWithoutParametersAndResponse();
@ -34,7 +32,7 @@ describe('v3.babel', () => {
it('uses credentials', async () => {
const result = await browser.evaluate(async () => {
const { OpenAPI, SimpleService } = window.api;
const { OpenAPI, SimpleService } = (window as any).api;
OpenAPI.TOKEN = undefined;
OpenAPI.USERNAME = 'username';
OpenAPI.PASSWORD = 'password';
@ -45,7 +43,7 @@ describe('v3.babel', () => {
it('supports complex params', async () => {
const result = await browser.evaluate(async () => {
const { ComplexService } = window.api;
const { ComplexService } = (window as any).api;
return await ComplexService.complexTypes({
first: {
second: {

View File

@ -1,10 +1,8 @@
'use strict';
const generate = require('./scripts/generate');
const copy = require('./scripts/copy');
const compileWithTypescript = require('./scripts/compileWithTypescript');
const server = require('./scripts/server');
const browser = require('./scripts/browser');
import browser from './scripts/browser';
import { compileWithTypescript } from './scripts/compileWithTypescript';
import { copy } from './scripts/copy';
import { generate } from './scripts/generate';
import server from './scripts/server';
describe('v3.fetch', () => {
beforeAll(async () => {
@ -23,8 +21,8 @@ describe('v3.fetch', () => {
it('requests token', async () => {
await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN'));
const result = await browser.evaluate(async () => {
const { OpenAPI, SimpleService } = window.api;
OpenAPI.TOKEN = window.tokenRequest;
const { OpenAPI, SimpleService } = (window as any).api;
OpenAPI.TOKEN = (window as any).tokenRequest;
OpenAPI.USERNAME = undefined;
OpenAPI.PASSWORD = undefined;
return await SimpleService.getCallWithoutParametersAndResponse();
@ -34,7 +32,7 @@ describe('v3.fetch', () => {
it('uses credentials', async () => {
const result = await browser.evaluate(async () => {
const { OpenAPI, SimpleService } = window.api;
const { OpenAPI, SimpleService } = (window as any).api;
OpenAPI.TOKEN = undefined;
OpenAPI.USERNAME = 'username';
OpenAPI.PASSWORD = 'password';
@ -45,7 +43,7 @@ describe('v3.fetch', () => {
it('supports complex params', async () => {
const result = await browser.evaluate(async () => {
const { ComplexService } = window.api;
const { ComplexService } = (window as any).api;
return await ComplexService.complexTypes({
first: {
second: {
@ -59,7 +57,7 @@ describe('v3.fetch', () => {
it('support form data', async () => {
const result = await browser.evaluate(async () => {
const { ParametersService } = window.api;
const { ParametersService } = (window as any).api;
return await ParametersService.callWithParameters(
'valueHeader',
'valueQuery',
@ -78,7 +76,7 @@ describe('v3.fetch', () => {
let error;
try {
await browser.evaluate(async () => {
const { SimpleService } = window.api;
const { SimpleService } = (window as any).api;
const promise = SimpleService.getCallWithoutParametersAndResponse();
setTimeout(() => {
promise.cancel();
@ -86,7 +84,7 @@ describe('v3.fetch', () => {
await promise;
});
} catch (e) {
error = e.message;
error = (e as Error).message;
}
expect(error).toContain('The user aborted a request.');
});
@ -94,18 +92,20 @@ describe('v3.fetch', () => {
it('should throw known error (500)', async () => {
const error = await browser.evaluate(async () => {
try {
const { ErrorService } = window.api;
const { ErrorService } = (window as any).api;
await ErrorService.testErrorCode(500);
} catch (e) {
const error = e as any;
return JSON.stringify({
name: e.name,
message: e.message,
url: e.url,
status: e.status,
statusText: e.statusText,
body: e.body,
name: error.name,
message: error.message,
url: error.url,
status: error.status,
statusText: error.statusText,
body: error.body,
});
}
return;
});
expect(error).toBe(
@ -123,18 +123,20 @@ describe('v3.fetch', () => {
it('should throw unknown error (409)', async () => {
const error = await browser.evaluate(async () => {
try {
const { ErrorService } = window.api;
const { ErrorService } = (window as any).api;
await ErrorService.testErrorCode(409);
} catch (e) {
const error = e as any;
return JSON.stringify({
name: e.name,
message: e.message,
url: e.url,
status: e.status,
statusText: e.statusText,
body: e.body,
name: error.name,
message: error.message,
url: error.url,
status: error.status,
statusText: error.statusText,
body: error.body,
});
}
return;
});
expect(error).toBe(
JSON.stringify({

View File

@ -1,8 +1,6 @@
'use strict';
const generate = require('./scripts/generate');
const compileWithTypescript = require('./scripts/compileWithTypescript');
const server = require('./scripts/server');
import { compileWithTypescript } from './scripts/compileWithTypescript';
import { generate } from './scripts/generate';
import server from './scripts/server';
describe('v3.node', () => {
beforeAll(async () => {
@ -72,7 +70,7 @@ describe('v3.node', () => {
}, 10);
await promise;
} catch (e) {
error = e.message;
error = (e as Error).message;
}
expect(error).toContain('The user aborted a request.');
});
@ -83,13 +81,14 @@ describe('v3.node', () => {
const { ErrorService } = require('./generated/v3/node/index.js');
await ErrorService.testErrorCode(500);
} catch (e) {
const err = e as any;
error = JSON.stringify({
name: e.name,
message: e.message,
url: e.url,
status: e.status,
statusText: e.statusText,
body: e.body,
name: err.name,
message: err.message,
url: err.url,
status: err.status,
statusText: err.statusText,
body: err.body,
});
}
expect(error).toBe(
@ -110,13 +109,14 @@ describe('v3.node', () => {
const { ErrorService } = require('./generated/v3/node/index.js');
await ErrorService.testErrorCode(409);
} catch (e) {
const err = e as any;
error = JSON.stringify({
name: e.name,
message: e.message,
url: e.url,
status: e.status,
statusText: e.statusText,
body: e.body,
name: err.name,
message: err.message,
url: err.url,
status: err.status,
statusText: err.statusText,
body: err.body,
});
}
expect(error).toBe(

View File

@ -1,10 +1,8 @@
'use strict';
const generate = require('./scripts/generate');
const copy = require('./scripts/copy');
const compileWithTypescript = require('./scripts/compileWithTypescript');
const server = require('./scripts/server');
const browser = require('./scripts/browser');
import browser from './scripts/browser';
import { compileWithTypescript } from './scripts/compileWithTypescript';
import { copy } from './scripts/copy';
import { generate } from './scripts/generate';
import server from './scripts/server';
describe('v3.xhr', () => {
beforeAll(async () => {
@ -23,8 +21,8 @@ describe('v3.xhr', () => {
it('requests token', async () => {
await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN'));
const result = await browser.evaluate(async () => {
const { OpenAPI, SimpleService } = window.api;
OpenAPI.TOKEN = window.tokenRequest;
const { OpenAPI, SimpleService } = (window as any).api;
OpenAPI.TOKEN = (window as any).tokenRequest;
OpenAPI.USERNAME = undefined;
OpenAPI.PASSWORD = undefined;
return await SimpleService.getCallWithoutParametersAndResponse();
@ -34,7 +32,7 @@ describe('v3.xhr', () => {
it('uses credentials', async () => {
const result = await browser.evaluate(async () => {
const { OpenAPI, SimpleService } = window.api;
const { OpenAPI, SimpleService } = (window as any).api;
OpenAPI.TOKEN = undefined;
OpenAPI.USERNAME = 'username';
OpenAPI.PASSWORD = 'password';
@ -45,7 +43,7 @@ describe('v3.xhr', () => {
it('supports complex params', async () => {
const result = await browser.evaluate(async () => {
const { ComplexService } = window.api;
const { ComplexService } = (window as any).api;
return await ComplexService.complexTypes({
first: {
second: {
@ -60,7 +58,7 @@ describe('v3.xhr', () => {
it('can abort the request', async () => {
try {
await browser.evaluate(async () => {
const { SimpleService } = window.api;
const { SimpleService } = (window as any).api;
const promise = SimpleService.getCallWithoutParametersAndResponse();
setTimeout(() => {
promise.cancel();
@ -68,25 +66,27 @@ describe('v3.xhr', () => {
await promise;
});
} catch (e) {
expect(e.message).toContain('The user aborted a request.');
expect((e as Error).message).toContain('The user aborted a request.');
}
});
it('should throw known error (500)', async () => {
const error = await browser.evaluate(async () => {
try {
const { ErrorService } = window.api;
const { ErrorService } = (window as any).api;
await ErrorService.testErrorCode(500);
} catch (e) {
const error = e as any;
return JSON.stringify({
name: e.name,
message: e.message,
url: e.url,
status: e.status,
statusText: e.statusText,
body: e.body,
name: error.name,
message: error.message,
url: error.url,
status: error.status,
statusText: error.statusText,
body: error.body,
});
}
return;
});
expect(error).toBe(
JSON.stringify({
@ -103,18 +103,20 @@ describe('v3.xhr', () => {
it('should throw unknown error (409)', async () => {
const error = await browser.evaluate(async () => {
try {
const { ErrorService } = window.api;
const { ErrorService } = (window as any).api;
await ErrorService.testErrorCode(409);
} catch (e) {
const error = e as any;
return JSON.stringify({
name: e.name,
message: e.message,
url: e.url,
status: e.status,
statusText: e.statusText,
body: e.body,
name: error.name,
message: error.message,
url: error.url,
status: error.status,
statusText: error.statusText,
body: error.body,
});
}
return;
});
expect(error).toBe(
JSON.stringify({

View File

@ -1,13 +1,13 @@
'use strict';
const OpenAPI = require('../dist');
const OpenAPI = require('../');
const fetch = require('node-fetch');
async function generate(input, output) {
const generate = async (input, output) => {
await OpenAPI.generate({
input,
output,
httpClient: OpenAPI.HttpClient.AXIOS,
httpClient: OpenAPI.HttpClient.NODE,
useOptions: false,
useUnionTypes: false,
exportCore: true,
@ -17,9 +17,10 @@ async function generate(input, output) {
// postfix: 'Api',
// request: './test/custom/request.ts',
});
}
};
async function generateRealWorldSpecs() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const generateRealWorldSpecs = async () => {
const response = await fetch('https://api.apis.guru/v2/list.json');
const list = await response.json();
@ -51,12 +52,12 @@ async function generateRealWorldSpecs() {
const spec = specs[i];
await generate(spec.url, `./test/generated/${spec.name}/`);
}
}
};
async function main() {
const main = async () => {
await generate('./test/spec/v2.json', './test/generated/v2/');
await generate('./test/spec/v3.json', './test/generated/v3/');
// await generateRealWorldSpecs();
}
};
main();

View File

@ -1,15 +1,14 @@
'use strict';
import { readFileSync } from 'fs';
import { sync } from 'glob';
const OpenAPI = require('../dist');
const glob = require('glob');
const fs = require('fs');
import { generate, HttpClient } from '../';
describe('v2', () => {
it('should generate', async () => {
await OpenAPI.generate({
await generate({
input: './test/spec/v2.json',
output: './test/generated/v2/',
httpClient: OpenAPI.HttpClient.FETCH,
httpClient: HttpClient.FETCH,
useOptions: false,
useUnionTypes: false,
exportCore: true,
@ -18,8 +17,8 @@ describe('v2', () => {
exportServices: true,
});
glob.sync('./test/generated/v2/**/*.ts').forEach(file => {
const content = fs.readFileSync(file, 'utf8').toString();
sync('./test/generated/v2/**/*.ts').forEach(file => {
const content = readFileSync(file, 'utf8').toString();
expect(content).toMatchSnapshot(file);
});
});
@ -27,10 +26,10 @@ describe('v2', () => {
describe('v3', () => {
it('should generate', async () => {
await OpenAPI.generate({
await generate({
input: './test/spec/v3.json',
output: './test/generated/v3/',
httpClient: OpenAPI.HttpClient.FETCH,
httpClient: HttpClient.FETCH,
useOptions: false,
useUnionTypes: false,
exportCore: true,
@ -39,8 +38,8 @@ describe('v3', () => {
exportServices: true,
});
glob.sync('./test/generated/v3/**/*.ts').forEach(file => {
const content = fs.readFileSync(file, 'utf8').toString();
sync('./test/generated/v3/**/*.ts').forEach(file => {
const content = readFileSync(file, 'utf8').toString();
expect(content).toMatchSnapshot(file);
});
});

View File

@ -1,10 +1,10 @@
{
"compilerOptions": {
"outDir": "./dist",
"target": "es2017",
"module": "es6",
"target": "es2020",
"module": "commonjs",
"moduleResolution": "node",
"lib": ["es6", "es2017", "dom"],
"lib": ["es2020", "dom"],
"types": ["jest", "node"],
"declaration": false,
"declarationMap": false,
@ -13,17 +13,12 @@
"noImplicitThis": true,
"noImplicitAny": true,
"strict": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
"skipLibCheck": true,
"allowSyntheticDefaultImports": true
},
"files": [
"./src/typings/hbs.d.ts",
"./src/typings/camelcase.d.ts",
"./src/typings/mkdirp.d.ts",
"./src/typings/rimraf.d.ts"
"./src/typings/hbs.d.ts"
],
"include": [
@ -31,7 +26,7 @@
],
"exclude": [
"node_modules"
"node_modules",
"**/__mocks__"
]
}

7
types/index.d.ts vendored
View File

@ -8,7 +8,7 @@ export declare enum HttpClient {
export type Options = {
input: string | Record<string, any>;
output: string;
httpClient?: HttpClient;
httpClient?: HttpClient | 'fetch' | 'xhr' | 'node' | 'axios';
useOptions?: boolean;
useUnionTypes?: boolean;
exportCore?: boolean;
@ -20,3 +20,8 @@ export type Options = {
};
export declare function generate(options: Options): Promise<void>;
export default {
HttpClient,
generate,
};

307
yarn.lock
View File

@ -1200,6 +1200,18 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@cspotcode/source-map-consumer@0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b"
integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==
"@cspotcode/source-map-support@0.7.0":
version "0.7.0"
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz#4789840aa859e46d2f3173727ab707c66bf344f5"
integrity sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==
dependencies:
"@cspotcode/source-map-consumer" "0.8.0"
"@eslint/eslintrc@^1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.0.5.tgz#33f1b838dbf1f923bfa517e008362b78ddbbf318"
@ -1456,6 +1468,13 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"
"@rollup/plugin-alias@3.1.9":
version "3.1.9"
resolved "https://registry.yarnpkg.com/@rollup/plugin-alias/-/plugin-alias-3.1.9.tgz#a5d267548fe48441f34be8323fb64d1d4a1b3fdf"
integrity sha512-QI5fsEvm9bDzt32k39wpOwZhVzRcL5ydcffUHMyLVaVaLeC70I8TJZ17F1z1eMoLu4E/UOcH9BWVkKpIKdrfiw==
dependencies:
slash "^3.0.0"
"@rollup/plugin-commonjs@21.0.1":
version "21.0.1"
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-21.0.1.tgz#1e57c81ae1518e4df0954d681c642e7d94588fee"
@ -1481,6 +1500,14 @@
is-module "^1.0.0"
resolve "^1.19.0"
"@rollup/plugin-typescript@8.3.0":
version "8.3.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-8.3.0.tgz#bc1077fa5897b980fc27e376c4e377882c63e68b"
integrity sha512-I5FpSvLbtAdwJ+naznv+B4sjXZUcIvLLceYpITAn7wAP8W0wqc5noLdGIp9HGVntNhRWXctwPYrSSFQxtl0FPA==
dependencies:
"@rollup/pluginutils" "^3.1.0"
resolve "^1.17.0"
"@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
@ -1490,14 +1517,6 @@
estree-walker "^1.0.1"
picomatch "^2.2.2"
"@rollup/pluginutils@^4.1.0":
version "4.1.1"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.1.1.tgz#1d4da86dd4eded15656a57d933fda2b9a08d47ec"
integrity sha512-clDjivHqWGXi7u+0d2r2sBi4Ie6VLEAzWMIkvJLnDmxoOhBYOTfzGbOQBA32THHm11/LiJbd01tJUpJsbshSWQ==
dependencies:
estree-walker "^2.0.1"
picomatch "^2.2.2"
"@sinonjs/commons@^1.7.0":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d"
@ -1517,13 +1536,25 @@
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==
"@ts-type/package-dts@^1.0.54":
version "1.0.54"
resolved "https://registry.yarnpkg.com/@ts-type/package-dts/-/package-dts-1.0.54.tgz#c6bcf02464bb4bfb4bfdd1bd12c400458082af75"
integrity sha512-lJWJBVfPCbPBdSWM3PGkooYl9p273n7A1nXB93vyHQIO+LWVXFi70ajj5GdgLU0cs+pwjdCE+1RoK/1EfC6a/A==
dependencies:
"@types/semver" "^7.3.9"
ts-type "^2.0.3"
"@tsconfig/node10@^1.0.7":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9"
integrity sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==
"@tsconfig/node12@^1.0.7":
version "1.0.9"
resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.9.tgz#62c1f6dee2ebd9aead80dc3afa56810e58e1a04c"
integrity sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==
"@tsconfig/node14@^1.0.0":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2"
integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==
"@tsconfig/node16@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e"
integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==
"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14":
version "7.1.16"
@ -1699,11 +1730,6 @@
dependencies:
"@types/node" "*"
"@types/semver@^7.3.9":
version "7.3.9"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.9.tgz#152c6c20a7688c30b967ec1841d31ace569863fc"
integrity sha512-L/TMpyURfBkf+o/526Zb6kd/tchUP3iBDEPjqjb+U2MAJhVRxxrmr2fwpe08E7QsV7YLcpq0tUaQ9O9x97ZIxQ==
"@types/serve-static@*":
version "1.13.10"
resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.10.tgz#f5e0ce8797d2d7cc5ebeda48a52c96c4fa47a8d9"
@ -1816,16 +1842,6 @@
"@typescript-eslint/types" "5.9.0"
eslint-visitor-keys "^3.0.0"
"@yarn-tool/resolve-package@^1.0.36":
version "1.0.39"
resolved "https://registry.yarnpkg.com/@yarn-tool/resolve-package/-/resolve-package-1.0.39.tgz#73705894d0116b9533f2149fde3dce880789e27c"
integrity sha512-Muv+aW1tcyPhkwG4db3fP/KjknzJMidykLbrwEdU0fI0C6DFzBehhLLu9Z/rIO26OoJWqprxyR27w+SgNXNOoQ==
dependencies:
"@ts-type/package-dts" "^1.0.54"
pkg-dir "< 6 >= 5"
tslib "^2.3.1"
upath2 "^3.1.10"
abab@^2.0.3, abab@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.5.tgz#c0b678fb32d60fc1219c784d6a826fe385aeb79a"
@ -1864,6 +1880,11 @@ acorn-walk@^7.1.1:
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc"
integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==
acorn-walk@^8.1.1:
version "8.2.0"
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1"
integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==
acorn@^7.1.1:
version "7.4.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
@ -1874,7 +1895,7 @@ acorn@^8.2.4:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.5.0.tgz#4512ccb99b3698c752591e9bb4472e38ad43cee2"
integrity sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q==
acorn@^8.7.0:
acorn@^8.4.1, acorn@^8.7.0:
version "8.7.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf"
integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==
@ -1940,6 +1961,11 @@ anymatch@^3.0.3, anymatch@~3.1.2:
normalize-path "^3.0.0"
picomatch "^2.0.4"
arg@^4.1.0:
version "4.1.3"
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==
argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
@ -2095,11 +2121,6 @@ bl@^4.0.3:
inherits "^2.0.4"
readable-stream "^3.4.0"
blob-polyfill@^5.0.20210201:
version "5.0.20210201"
resolved "https://registry.yarnpkg.com/blob-polyfill/-/blob-polyfill-5.0.20210201.tgz#0024bfa5dcc3440eb5a2f1e5991cb1612a558465"
integrity sha512-SrH6IG6aXL9pCgSysBCiDpGcAJ1j6/c1qCwR3sTEQJhb+MTk6FITNA6eW6WNYQDNZVi4Z9GjxH5v2MMTv59CrQ==
body-parser@1.19.1:
version "1.19.1"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.1.tgz#1499abbaa9274af3ecc9f6f10396c995943e31d4"
@ -2419,13 +2440,10 @@ core-js-compat@^3.19.1:
browserslist "^4.18.1"
semver "7.0.0"
cross-blob@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/cross-blob/-/cross-blob-2.0.1.tgz#7c187282e0855353705ed9ac5af2ee7f27c910c6"
integrity sha512-ARuKPPo3I6DSqizal4UCyMCiGPQdMpMJS3Owx6Lleuh26vSt2UnfWRwbMLCYqbJUrcol+KzGVSLR91ezSHP80A==
dependencies:
blob-polyfill "^5.0.20210201"
fetch-blob "^2.1.2"
create-require@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333"
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==
cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
@ -2538,6 +2556,11 @@ diff-sequences@^27.4.0:
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.4.0.tgz#d783920ad8d06ec718a060d00196dfef25b132a5"
integrity sha512-YqiQzkrsmHMH5uuh8OdQFU9/ZpADnwzml8z0O5HvRNda+5UZsaX/xN+AAxfR2hWq1Y7HZnAzO9J5lJXOuDz2Ww==
diff@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==
dir-glob@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f"
@ -2933,11 +2956,6 @@ fd-slicer@~1.1.0:
dependencies:
pend "~1.2.0"
fetch-blob@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-2.1.2.tgz#a7805db1361bd44c1ef62bb57fb5fe8ea173ef3c"
integrity sha512-YKqtUDwqLyfyMnmbw8XD6Q8j9i/HggKtPEI+pZ1+8bvheBu78biSmNaXWusx1TauGqtUUGx/cBb1mKdq2rLYow==
file-entry-cache@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027"
@ -2965,15 +2983,6 @@ finalhandler@~1.1.2:
statuses "~1.5.0"
unpipe "~1.0.0"
find-cache-dir@^3.3.1:
version "3.3.2"
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.2.tgz#b30c5b6eff0730731aea9bbd9dbecbd80256d64b"
integrity sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==
dependencies:
commondir "^1.0.1"
make-dir "^3.0.2"
pkg-dir "^4.1.0"
find-up@^4.0.0, find-up@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19"
@ -2982,13 +2991,13 @@ find-up@^4.0.0, find-up@^4.1.0:
locate-path "^5.0.0"
path-exists "^4.0.0"
find-up@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc"
integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==
find-up@^6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-6.2.0.tgz#f3b81d633fa83bebe64f83a8bab357f86d5914be"
integrity sha512-yWHzMzXCaFoABSnFTCPKNFlYoq4mSga9QLRRKOCLSJ33hSkzROB14ITbAWW0QDQDyuzsPQ33S1DsOWQb/oW1yA==
dependencies:
locate-path "^6.0.0"
path-exists "^4.0.0"
locate-path "^7.0.0"
path-exists "^5.0.0"
flat-cache@^3.0.4:
version "3.0.4"
@ -3041,15 +3050,6 @@ fs-constants@^1.0.0:
resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad"
integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==
fs-extra@8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
dependencies:
graceful-fs "^4.2.0"
jsonfile "^4.0.0"
universalify "^0.1.0"
fs-readdir-recursive@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27"
@ -3161,7 +3161,7 @@ globby@^11.0.4:
merge2 "^1.3.0"
slash "^3.0.0"
graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4:
graceful-fs@^4.2.4:
version "4.2.8"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a"
integrity sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==
@ -3943,13 +3943,6 @@ json5@^2.1.2:
dependencies:
minimist "^1.2.5"
jsonfile@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
optionalDependencies:
graceful-fs "^4.1.6"
kleur@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
@ -3983,12 +3976,12 @@ locate-path@^5.0.0:
dependencies:
p-locate "^4.1.0"
locate-path@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286"
integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==
locate-path@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-7.0.0.tgz#f0a60c8dd7ef0f737699eb9461b9567a92bc97da"
integrity sha512-+cg2yXqDUKfo4hsFxwa3G1cBJeA+gs1vD8FyV9/odWoUlQe/4syxHQ5DPtKjtfm6gnKbZzjCqzX03kXosvZB1w==
dependencies:
p-locate "^5.0.0"
p-locate "^6.0.0"
lodash.debounce@^4.0.8:
version "4.0.8"
@ -4000,7 +3993,7 @@ lodash.merge@^4.6.2:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
lodash@^4.17.21, lodash@^4.7.0:
lodash@^4.7.0:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
@ -4027,13 +4020,18 @@ make-dir@^2.1.0:
pify "^4.0.1"
semver "^5.6.0"
make-dir@^3.0.0, make-dir@^3.0.2:
make-dir@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==
dependencies:
semver "^6.0.0"
make-error@^1.1.1:
version "1.3.6"
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
makeerror@1.0.12:
version "1.0.12"
resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.12.tgz#3e5dd2079a82e812e983cc6610c4a2cb0eaa801a"
@ -4113,11 +4111,6 @@ mkdirp-classic@^0.5.2:
resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113"
integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==
mkdirp@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
@ -4155,7 +4148,7 @@ node-fetch@2.6.5:
dependencies:
whatwg-url "^5.0.0"
node-fetch@^2.6.1, node-fetch@^2.6.5:
node-fetch@^2.6.1, node-fetch@^2.6.6:
version "2.6.6"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.6.tgz#1751a7c01834e8e1697758732e9efb6eeadfaf89"
integrity sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==
@ -4261,12 +4254,12 @@ p-limit@^2.2.0:
dependencies:
p-try "^2.0.0"
p-limit@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b"
integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==
p-limit@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-4.0.0.tgz#914af6544ed32bfa54670b061cafcbd04984b644"
integrity sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==
dependencies:
yocto-queue "^0.1.0"
yocto-queue "^1.0.0"
p-locate@^4.1.0:
version "4.1.0"
@ -4275,12 +4268,12 @@ p-locate@^4.1.0:
dependencies:
p-limit "^2.2.0"
p-locate@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834"
integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==
p-locate@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-6.0.0.tgz#3da9a49d4934b901089dca3302fa65dc5a05c04f"
integrity sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==
dependencies:
p-limit "^3.0.2"
p-limit "^4.0.0"
p-try@^2.0.0:
version "2.2.0"
@ -4309,18 +4302,16 @@ path-exists@^4.0.0:
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==
path-exists@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-5.0.0.tgz#a6aad9489200b21fab31e49cf09277e5116fb9e7"
integrity sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
path-is-network-drive@^1.0.10:
version "1.0.10"
resolved "https://registry.yarnpkg.com/path-is-network-drive/-/path-is-network-drive-1.0.10.tgz#d9d7164e6d05a49d7876813a53ec5c4ae86aa542"
integrity sha512-D6kJYPUSKGZBpTM2nv10sOWNdC056p4JDx0y7ARe6gop0aXXm5G86Gn/SyKvaf0Ce8c9Guctf+J+qoFmzuhDQg==
dependencies:
tslib "^2.3.1"
path-key@^3.0.0, path-key@^3.1.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
@ -4331,13 +4322,6 @@ path-parse@^1.0.6:
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
path-strip-sep@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/path-strip-sep/-/path-strip-sep-1.0.7.tgz#51f31fd53099b7ba59876b7b9e6492397441223d"
integrity sha512-9xDVZPblHde4lTuTDnwqBKr9LTbPZW+Iae63ho500+BpEiZe3X6wvLInHgbB6FSMtwCTvztljw3k2zcNDNESzg==
dependencies:
tslib "^2.3.1"
path-to-regexp@0.1.7:
version "0.1.7"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
@ -4373,20 +4357,13 @@ pirates@^4.0.4:
resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.4.tgz#07df81e61028e402735cdd49db701e4885b4e6e6"
integrity sha512-ZIrVPH+A52Dw84R0L3/VS9Op04PuQ2SEoJL6bkshmiTic/HldyW9Tf7oH5mhJZBK7NmDx27vSMrYEXPXclpDKw==
pkg-dir@4.2.0, pkg-dir@^4.1.0, pkg-dir@^4.2.0:
pkg-dir@4.2.0, pkg-dir@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3"
integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==
dependencies:
find-up "^4.0.0"
"pkg-dir@< 6 >= 5":
version "5.0.0"
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-5.0.0.tgz#a02d6aebe6ba133a928f74aec20bafdfe6b8e760"
integrity sha512-NPE8TDbzl/3YQYY7CSS228s3g2ollTFnc+Qi3tqmqJp9Vg2ovUpixcJEo2HJScN2Ez+kEaal6y70c0ehqJBJeA==
dependencies:
find-up "^5.0.0"
prelude-ls@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
@ -4635,7 +4612,7 @@ resolve.exports@^1.1.0:
resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-1.1.0.tgz#5ce842b94b05146c0e03076985d1d0e7e48c90c9"
integrity sha512-J1l+Zxxp4XK3LUDZ9m60LRJF/mAe4z6a4xyabPHk7pvK5t35dACV32iIjJDFeWZFfZlO29w6SZ67knR0tHzJtQ==
resolve@1.20.0, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.19.0, resolve@^1.20.0:
resolve@^1.14.2, resolve@^1.17.0, resolve@^1.19.0, resolve@^1.20.0:
version "1.20.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
@ -4655,6 +4632,13 @@ rimraf@3.0.2, rimraf@^3.0.0, rimraf@^3.0.2:
dependencies:
glob "^7.1.3"
rollup-plugin-node-externals@3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/rollup-plugin-node-externals/-/rollup-plugin-node-externals-3.1.2.tgz#1604aa28384a8771735168fe900d6f00f450d0fa"
integrity sha512-2y5lNDI2QNLTntYDOcLzyEVJYszDyQkd2WiRTGQ/6Hdfgt/fSQb5V5trsgBMEkxs2eaunQ0aAW29Ki6jMNutIg==
dependencies:
find-up "^6.2.0"
rollup-plugin-terser@7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d"
@ -4665,18 +4649,6 @@ rollup-plugin-terser@7.0.2:
serialize-javascript "^4.0.0"
terser "^5.0.0"
rollup-plugin-typescript2@0.31.1:
version "0.31.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.31.1.tgz#3b3a0e29b29b2ed8244b1a78fd8e2cac93ab79a4"
integrity sha512-sklqXuQwQX+stKi4kDfEkneVESPi3YM/2S899vfRdF9Yi40vcC50Oq4A4cSZJNXsAQE/UsBZl5fAOsBLziKmjw==
dependencies:
"@rollup/pluginutils" "^4.1.0"
"@yarn-tool/resolve-package" "^1.0.36"
find-cache-dir "^3.3.1"
fs-extra "8.1.0"
resolve "1.20.0"
tslib "2.2.0"
rollup@2.63.0:
version "2.63.0"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.63.0.tgz#fe2f7fec2133f3fab9e022b9ac245628d817c6bb"
@ -5070,20 +5042,25 @@ tr46@~0.0.3:
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=
ts-type@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/ts-type/-/ts-type-2.0.3.tgz#1e9002dcf8d5052e27e77a8f6c9565030c4bd3c3"
integrity sha512-Cc2kgkUwmCK/h2m/sVbr2piqOGE+Hs4qAgJ7CiI4OSMJFWorE6f6yoisjSBE5izGb2/VZnHSN2CcOQR6/Yfazw==
ts-node@10.4.0:
version "10.4.0"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.4.0.tgz#680f88945885f4e6cf450e7f0d6223dd404895f7"
integrity sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==
dependencies:
tslib "^2.3.1"
typedarray-dts "^1.0.0"
"@cspotcode/source-map-support" "0.7.0"
"@tsconfig/node10" "^1.0.7"
"@tsconfig/node12" "^1.0.7"
"@tsconfig/node14" "^1.0.0"
"@tsconfig/node16" "^1.0.2"
acorn "^8.4.1"
acorn-walk "^8.1.1"
arg "^4.1.0"
create-require "^1.1.0"
diff "^4.0.1"
make-error "^1.1.1"
yn "3.1.1"
tslib@2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c"
integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==
tslib@2.3.1, tslib@^2.3.1:
tslib@2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==
@ -5137,11 +5114,6 @@ type-is@~1.6.18:
media-typer "0.3.0"
mime-types "~2.1.24"
typedarray-dts@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/typedarray-dts/-/typedarray-dts-1.0.0.tgz#9dec9811386dbfba964c295c2606cf9a6b982d06"
integrity sha512-Ka0DBegjuV9IPYFT1h0Qqk5U4pccebNIJCGl8C5uU7xtOs+jpJvKGAY4fHGK25hTmXZOEUl9Cnsg5cS6K/b5DA==
typedarray-to-buffer@^3.1.5:
version "3.1.5"
resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080"
@ -5190,7 +5162,7 @@ unicode-property-aliases-ecmascript@^2.0.0:
resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.0.0.tgz#0a36cb9a585c4f6abd51ad1deddb285c165297c8"
integrity sha512-5Zfuy9q/DFr4tfO7ZPeVXb1aPoeQSdeFMLpYuFebehDAhbuevLs5yxSZmIFN1tP5F9Wl4IpJrYojg85/zgyZHQ==
universalify@^0.1.0, universalify@^0.1.2:
universalify@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
@ -5200,16 +5172,6 @@ unpipe@1.0.0, unpipe@~1.0.0:
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=
upath2@^3.1.10:
version "3.1.10"
resolved "https://registry.yarnpkg.com/upath2/-/upath2-3.1.10.tgz#bd3de76523946102d06d00d4b3723e3a6ff753f6"
integrity sha512-7ph3GzTaVbQX+oIoMsGtM+9BAWQr+6Mn28TJKPu28+yGpZ+J4am590CPDBlDG0zyuo9T9T7o21ciqNzwIp/q0A==
dependencies:
lodash "^4.17.21"
path-is-network-drive "^1.0.10"
path-strip-sep "^1.0.7"
tslib "^2.3.1"
uri-js@^4.2.2:
version "4.4.1"
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e"
@ -5420,7 +5382,12 @@ yauzl@^2.10.0:
buffer-crc32 "~0.2.3"
fd-slicer "~1.1.0"
yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
yn@3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==
yocto-queue@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.0.0.tgz#7f816433fb2cbc511ec8bf7d263c3b58a1a3c251"
integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==