@openapi-qraft/cli 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +109 -43
- package/bin.mjs +3 -1
- package/dist/bin.d.ts +13 -1
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +71 -59
- package/dist/bin.js.map +1 -1
- package/dist/builtInPlugins.d.ts +5 -0
- package/dist/builtInPlugins.d.ts.map +1 -0
- package/dist/builtInPlugins.js +5 -0
- package/dist/builtInPlugins.js.map +1 -0
- package/package.json +16 -12
- package/src/bin.ts +99 -0
- package/src/builtInPlugins.ts +6 -0
- package/dist/lib/fileHeader.d.ts +0 -1
- package/dist/lib/fileHeader.js +0 -5
- package/dist/lib/fileHeader.js.map +0 -1
- package/dist/lib/open-api/OpenAPISchemaType.d.ts +0 -31
- package/dist/lib/open-api/OpenAPISchemaType.js +0 -2
- package/dist/lib/open-api/OpenAPISchemaType.js.map +0 -1
- package/dist/lib/open-api/getContent.d.ts +0 -5
- package/dist/lib/open-api/getContent.js +0 -23
- package/dist/lib/open-api/getContent.js.map +0 -1
- package/dist/lib/open-api/getOperationName.d.ts +0 -6
- package/dist/lib/open-api/getOperationName.js +0 -20
- package/dist/lib/open-api/getOperationName.js.map +0 -1
- package/dist/lib/open-api/getServiceName.d.ts +0 -5
- package/dist/lib/open-api/getServiceName.js +0 -13
- package/dist/lib/open-api/getServiceName.js.map +0 -1
- package/dist/lib/open-api/getServiceNamesByOperationEndpoint.d.ts +0 -4
- package/dist/lib/open-api/getServiceNamesByOperationEndpoint.js +0 -30
- package/dist/lib/open-api/getServiceNamesByOperationEndpoint.js.map +0 -1
- package/dist/lib/open-api/getServiceNamesByOperationTags.d.ts +0 -1
- package/dist/lib/open-api/getServiceNamesByOperationTags.js +0 -11
- package/dist/lib/open-api/getServiceNamesByOperationTags.js.map +0 -1
- package/dist/lib/open-api/getServices.d.ts +0 -32
- package/dist/lib/open-api/getServices.js +0 -112
- package/dist/lib/open-api/getServices.js.map +0 -1
- package/dist/lib/open-api/readSchema.d.ts +0 -7
- package/dist/lib/open-api/readSchema.js +0 -15
- package/dist/lib/open-api/readSchema.js.map +0 -1
- package/dist/lib/ts-factory/astToString.d.ts +0 -8
- package/dist/lib/ts-factory/astToString.js +0 -14
- package/dist/lib/ts-factory/astToString.js.map +0 -1
- package/dist/lib/ts-factory/getClientFactory.d.ts +0 -7
- package/dist/lib/ts-factory/getClientFactory.js +0 -82
- package/dist/lib/ts-factory/getClientFactory.js.map +0 -1
- package/dist/lib/ts-factory/getIndexFactory.d.ts +0 -5
- package/dist/lib/ts-factory/getIndexFactory.js +0 -17
- package/dist/lib/ts-factory/getIndexFactory.js.map +0 -1
- package/dist/lib/ts-factory/getServiceFactory.d.ts +0 -10
- package/dist/lib/ts-factory/getServiceFactory.js +0 -120
- package/dist/lib/ts-factory/getServiceFactory.js.map +0 -1
- package/dist/lib/ts-factory/getServiceIndexFactory.d.ts +0 -7
- package/dist/lib/ts-factory/getServiceIndexFactory.js +0 -26
- package/dist/lib/ts-factory/getServiceIndexFactory.js.map +0 -1
- package/dist/writeOpenAPIServices.d.ts +0 -23
- package/dist/writeOpenAPIServices.js +0 -97
- package/dist/writeOpenAPIServices.js.map +0 -1
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export type OpenAPISchemaType = {
|
|
2
|
-
paths: {
|
|
3
|
-
[path: string]: {
|
|
4
|
-
[method: string]: {
|
|
5
|
-
tags?: string[];
|
|
6
|
-
description?: string;
|
|
7
|
-
summary?: string;
|
|
8
|
-
operationId?: string;
|
|
9
|
-
parameters?: Record<string, any>;
|
|
10
|
-
deprecated?: boolean;
|
|
11
|
-
requestBody?: {
|
|
12
|
-
content: {
|
|
13
|
-
[contentType: string]: {
|
|
14
|
-
schema: any;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
responses: {
|
|
19
|
-
[statusCode in number | 'default']: {
|
|
20
|
-
description: string;
|
|
21
|
-
content: {
|
|
22
|
-
[contentType: string]: {
|
|
23
|
-
schema: any;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAPISchemaType.js","sourceRoot":"","sources":["../../../src/lib/open-api/OpenAPISchemaType.ts"],"names":[],"mappings":""}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const BASIC_MEDIA_TYPES = [
|
|
2
|
-
"application/json-patch+json",
|
|
3
|
-
"application/json",
|
|
4
|
-
"application/x-www-form-urlencoded",
|
|
5
|
-
"text/json",
|
|
6
|
-
"text/plain",
|
|
7
|
-
"multipart/form-data",
|
|
8
|
-
"multipart/mixed",
|
|
9
|
-
"multipart/related",
|
|
10
|
-
"multipart/batch",
|
|
11
|
-
];
|
|
12
|
-
export const getContentMediaType = (content) => {
|
|
13
|
-
const basicMediaTypeWithSchema = Object.keys(content)
|
|
14
|
-
.filter((mediaType) => {
|
|
15
|
-
const cleanMediaType = mediaType.split(";")[0].trim();
|
|
16
|
-
return BASIC_MEDIA_TYPES.includes(cleanMediaType);
|
|
17
|
-
})
|
|
18
|
-
.find((mediaType) => content[mediaType]?.schema);
|
|
19
|
-
if (basicMediaTypeWithSchema)
|
|
20
|
-
return basicMediaTypeWithSchema;
|
|
21
|
-
return Object.keys(content).find((mediaType) => content[mediaType]?.schema);
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=getContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getContent.js","sourceRoot":"","sources":["../../../src/lib/open-api/getContent.ts"],"names":[],"mappings":"AAAA,MAAM,iBAAiB,GAAG;IACxB,6BAA6B;IAC7B,kBAAkB;IAClB,mCAAmC;IACnC,WAAW;IACX,YAAY;IACZ,qBAAqB;IACrB,iBAAiB;IACjB,mBAAmB;IACnB,iBAAiB;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAEnC,EAAE,EAAE;IACH,MAAM,wBAAwB,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;SAClD,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE;QACpB,MAAM,cAAc,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACtD,OAAO,iBAAiB,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACpD,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;IAEnD,IAAI,wBAAwB;QAAE,OAAO,wBAAwB,CAAC;IAE9D,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;AAC9E,CAAC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert the input value to a correct operation (method) classname.
|
|
3
|
-
* This will use the operation ID - if available - and otherwise fallback
|
|
4
|
-
* on a generated name from the URL
|
|
5
|
-
*/
|
|
6
|
-
export declare const getOperationName: (url: string, method: string, operationId?: string) => string;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import camelCase from "camelcase";
|
|
2
|
-
/**
|
|
3
|
-
* Convert the input value to a correct operation (method) classname.
|
|
4
|
-
* This will use the operation ID - if available - and otherwise fallback
|
|
5
|
-
* on a generated name from the URL
|
|
6
|
-
*/
|
|
7
|
-
export const getOperationName = (url, method, operationId) => {
|
|
8
|
-
if (operationId) {
|
|
9
|
-
return camelCase(operationId
|
|
10
|
-
.replace(/^[^a-zA-Z]+/g, "")
|
|
11
|
-
.replace(/[^\w\-]+/g, "-")
|
|
12
|
-
.trim());
|
|
13
|
-
}
|
|
14
|
-
const urlWithoutPlaceholders = url
|
|
15
|
-
.replace(/[^/]*?{api-version}.*?\//g, "")
|
|
16
|
-
.replace(/{(.*?)}/g, "")
|
|
17
|
-
.replace(/\//g, "-");
|
|
18
|
-
return camelCase(`${method}-${urlWithoutPlaceholders}`);
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=getOperationName.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationName.js","sourceRoot":"","sources":["../../../src/lib/open-api/getOperationName.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,GAAW,EACX,MAAc,EACd,WAAoB,EACZ,EAAE;IACV,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,SAAS,CACd,WAAW;aACR,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;aAC3B,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC;aACzB,IAAI,EAAE,CACV,CAAC;IACJ,CAAC;IAED,MAAM,sBAAsB,GAAG,GAAG;SAC/B,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC;SACxC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAEvB,OAAO,SAAS,CAAC,GAAG,MAAM,IAAI,sBAAsB,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import camelCase from 'camelcase';
|
|
2
|
-
/**
|
|
3
|
-
* Convert the input value to the correct service name. This converts
|
|
4
|
-
* the input string to PascalCase.
|
|
5
|
-
*/
|
|
6
|
-
export const getServiceName = (value) => {
|
|
7
|
-
const clean = value
|
|
8
|
-
.replace(/^[^a-zA-Z]+/g, '')
|
|
9
|
-
.replace(/[^\w-]+/g, '-')
|
|
10
|
-
.trim();
|
|
11
|
-
return camelCase(clean, { pascalCase: true });
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=getServiceName.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getServiceName.js","sourceRoot":"","sources":["../../../src/lib/open-api/getServiceName.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAU,EAAE;IACtD,MAAM,KAAK,GAAG,KAAK;SAChB,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,IAAI,EAAE,CAAC;IAEV,OAAO,SAAS,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;AAChD,CAAC,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export type ServiceBaseNameByEndpointOption = `endpoint[${number}]`;
|
|
2
|
-
export declare const getServiceNamesByOperationEndpoint: (endpoint: string, format: ServiceBaseNameByEndpointOption, fallbackBaseName: string) => [string];
|
|
3
|
-
export declare const getServiceBaseNameByOperationEndpoint: (endpoint: string, format: ServiceBaseNameByEndpointOption) => string | undefined;
|
|
4
|
-
export declare const getEndpointPartIndex: (endpointOption: ServiceBaseNameByEndpointOption) => number;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { getServiceName } from './getServiceName.js';
|
|
2
|
-
export const getServiceNamesByOperationEndpoint = (endpoint, format, fallbackBaseName) => {
|
|
3
|
-
return [
|
|
4
|
-
getServiceName(getServiceBaseNameByOperationEndpoint(endpoint, format) ??
|
|
5
|
-
fallbackBaseName),
|
|
6
|
-
];
|
|
7
|
-
};
|
|
8
|
-
export const getServiceBaseNameByOperationEndpoint = (endpoint, format) => {
|
|
9
|
-
const endpointParts = endpoint.split('/').filter(Boolean);
|
|
10
|
-
for (let endpointIndex = getEndpointPartIndex(format); endpointIndex >= 0; endpointIndex--) {
|
|
11
|
-
const endpointPart = endpointParts[endpointIndex];
|
|
12
|
-
if (endpointPart)
|
|
13
|
-
return endpointPart;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
export const getEndpointPartIndex = (endpointOption) => {
|
|
17
|
-
const startBracketString = 'endpoint[';
|
|
18
|
-
const endpointIndexStart = endpointOption.indexOf(startBracketString);
|
|
19
|
-
if (endpointIndexStart === -1)
|
|
20
|
-
throw new Error(`Expected endpoint to start with '${startBracketString}' but got: '${endpointOption}'`);
|
|
21
|
-
const endBracketString = ']';
|
|
22
|
-
const endpointIndexEnd = endpointOption.indexOf(endBracketString, endpointIndexStart);
|
|
23
|
-
if (endpointIndexEnd === -1)
|
|
24
|
-
throw new Error(`Expected endpoint to end with '${endBracketString}' but got: '${endpointOption}'`);
|
|
25
|
-
const endpointIndex = parseInt(endpointOption.slice(endpointIndexStart + startBracketString.length, endpointIndexEnd));
|
|
26
|
-
if (!isFinite(endpointIndex))
|
|
27
|
-
throw new Error(`Expected endpoint index to be a number but got: '${endpointOption}'`);
|
|
28
|
-
return endpointIndex;
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=getServiceNamesByOperationEndpoint.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getServiceNamesByOperationEndpoint.js","sourceRoot":"","sources":["../../../src/lib/open-api/getServiceNamesByOperationEndpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAChD,QAAgB,EAChB,MAAuC,EACvC,gBAAwB,EACd,EAAE;IACZ,OAAO;QACL,cAAc,CACZ,qCAAqC,CAAC,QAAQ,EAAE,MAAM,CAAC;YACrD,gBAAgB,CACnB;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qCAAqC,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getServiceNamesByOperationTags: (tags: (string | number | null | undefined)[] | undefined, fallbackBaseName: string) => string[];
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getServiceName } from './getServiceName.js';
|
|
2
|
-
export const getServiceNamesByOperationTags = (tags, fallbackBaseName) => {
|
|
3
|
-
const filteredTags = tags
|
|
4
|
-
?.filter((tag) => typeof tag === 'string')
|
|
5
|
-
.map(getServiceName)
|
|
6
|
-
.filter(Boolean);
|
|
7
|
-
return filteredTags?.length
|
|
8
|
-
? filteredTags
|
|
9
|
-
: [getServiceName(fallbackBaseName)];
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=getServiceNamesByOperationTags.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getServiceNamesByOperationTags.js","sourceRoot":"","sources":["../../../src/lib/open-api/getServiceNamesByOperationTags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,IAAwD,EACxD,gBAAwB,EACd,EAAE;IACZ,MAAM,YAAY,GAAG,IAAI;QACvB,EAAE,MAAM,CAAC,CAAC,GAAG,EAAiB,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC;SACxD,GAAG,CAAC,cAAc,CAAC;SACnB,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnB,OAAO,YAAY,EAAE,MAAM;QACzB,CAAC,CAAC,YAAY;QACd,CAAC,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ServiceBaseNameByEndpointOption } from './getServiceNamesByOperationEndpoint.js';
|
|
2
|
-
import type { OpenAPISchemaType } from './OpenAPISchemaType.js';
|
|
3
|
-
export type ServiceBaseName = ServiceBaseNameByEndpointOption | 'tags';
|
|
4
|
-
export type Service = {
|
|
5
|
-
name: string;
|
|
6
|
-
variableName: string;
|
|
7
|
-
typeName: string;
|
|
8
|
-
fileBaseName: string;
|
|
9
|
-
operations: ServiceOperation[];
|
|
10
|
-
};
|
|
11
|
-
export type ServiceOperation = {
|
|
12
|
-
method: 'get' | 'put' | 'post' | 'patch' | 'delete' | 'options' | 'head' | 'trace';
|
|
13
|
-
path: string;
|
|
14
|
-
name: string;
|
|
15
|
-
description: string | undefined;
|
|
16
|
-
summary: string | undefined;
|
|
17
|
-
deprecated: boolean | undefined;
|
|
18
|
-
mediaType: string | undefined;
|
|
19
|
-
errors: Record<string, string | undefined>;
|
|
20
|
-
success: Record<string, string | undefined>;
|
|
21
|
-
parameters: Record<string, any> | undefined;
|
|
22
|
-
};
|
|
23
|
-
export declare const getServices: (openApiJson: OpenAPISchemaType, { postfixServices, serviceNameBase, }?: {
|
|
24
|
-
postfixServices?: string | undefined;
|
|
25
|
-
serviceNameBase?: ServiceBaseName | undefined;
|
|
26
|
-
}, servicesGlob?: string[]) => Service[];
|
|
27
|
-
/**
|
|
28
|
-
* Create a function to match service paths
|
|
29
|
-
* @param servicesGlob
|
|
30
|
-
*/
|
|
31
|
-
export declare const createServicePathMatch: (servicesGlob: string[]) => (path: string) => boolean;
|
|
32
|
-
export declare const supportedMethod: (method: unknown) => method is "get" | "put" | "post" | "patch" | "delete" | "options" | "head" | "trace";
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import camelCase from 'camelcase';
|
|
2
|
-
import * as console from 'console';
|
|
3
|
-
import micromatch from 'micromatch';
|
|
4
|
-
import { getContentMediaType } from './getContent.js';
|
|
5
|
-
import { getOperationName } from './getOperationName.js';
|
|
6
|
-
import { getServiceNamesByOperationEndpoint, } from './getServiceNamesByOperationEndpoint.js';
|
|
7
|
-
import { getServiceNamesByOperationTags } from './getServiceNamesByOperationTags.js';
|
|
8
|
-
export const getServices = (openApiJson, { postfixServices = 'Service', serviceNameBase = 'endpoint[0]', } = {}, servicesGlob = ['**']) => {
|
|
9
|
-
const paths = openApiJson.paths;
|
|
10
|
-
const services = new Map();
|
|
11
|
-
const isPathMatch = createServicePathMatch(servicesGlob);
|
|
12
|
-
for (const path in paths) {
|
|
13
|
-
if (!paths.hasOwnProperty(path))
|
|
14
|
-
continue;
|
|
15
|
-
for (const method in paths[path]) {
|
|
16
|
-
if (!paths[path].hasOwnProperty(method))
|
|
17
|
-
continue;
|
|
18
|
-
if (!isPathMatch(path))
|
|
19
|
-
continue;
|
|
20
|
-
if (!supportedMethod(method)) {
|
|
21
|
-
console.warn(`The path "${path}" HTTP method "${method}" is not supported`);
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
const methodOperation = paths[path][method];
|
|
25
|
-
const { success, errors } = Object.entries(methodOperation.responses).reduce((acc, [statusCode, response]) => {
|
|
26
|
-
if (!response.content || typeof response.content !== 'object') {
|
|
27
|
-
return acc;
|
|
28
|
-
}
|
|
29
|
-
const statusType = statusCode !== 'default' && // See "default" response https://swagger.io/docs/specification/describing-responses/#default
|
|
30
|
-
Number(statusCode) < 400
|
|
31
|
-
? 'success'
|
|
32
|
-
: 'errors';
|
|
33
|
-
return {
|
|
34
|
-
...acc,
|
|
35
|
-
[statusType]: {
|
|
36
|
-
...acc[statusType],
|
|
37
|
-
[statusCode]: getContentMediaType(response.content),
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
}, {});
|
|
41
|
-
const serviceFallbackBaseName = 'Default';
|
|
42
|
-
const serviceNames = serviceNameBase === 'tags'
|
|
43
|
-
? getServiceNamesByOperationTags(paths[path][method]?.tags, serviceFallbackBaseName)
|
|
44
|
-
: getServiceNamesByOperationEndpoint(path, serviceNameBase, serviceFallbackBaseName);
|
|
45
|
-
for (const name of serviceNames) {
|
|
46
|
-
if (!services.has(name)) {
|
|
47
|
-
services.set(name, {
|
|
48
|
-
name: camelCase(name),
|
|
49
|
-
variableName: `${camelCase(name, {
|
|
50
|
-
preserveConsecutiveUppercase: false,
|
|
51
|
-
})}${postfixServices}`,
|
|
52
|
-
typeName: `${name}${postfixServices}`,
|
|
53
|
-
fileBaseName: `${name}${postfixServices}`,
|
|
54
|
-
operations: [],
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
for (const name of serviceNames) {
|
|
59
|
-
services.get(name).operations.push({
|
|
60
|
-
method,
|
|
61
|
-
path,
|
|
62
|
-
errors,
|
|
63
|
-
name: getOperationName(path, method, methodOperation.operationId),
|
|
64
|
-
description: methodOperation.description,
|
|
65
|
-
summary: methodOperation.summary,
|
|
66
|
-
deprecated: methodOperation.deprecated,
|
|
67
|
-
parameters: Array.isArray(methodOperation.parameters) &&
|
|
68
|
-
!methodOperation.parameters.length
|
|
69
|
-
? undefined
|
|
70
|
-
: methodOperation.parameters,
|
|
71
|
-
mediaType: methodOperation.requestBody?.content
|
|
72
|
-
? getContentMediaType(methodOperation.requestBody.content)
|
|
73
|
-
: undefined,
|
|
74
|
-
success: success,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return Array.from(services.values());
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Create a function to match service paths
|
|
83
|
-
* @param servicesGlob
|
|
84
|
-
*/
|
|
85
|
-
export const createServicePathMatch = (servicesGlob) => {
|
|
86
|
-
const servicePathGlobs = servicesGlob.reduce((acc, glob) => {
|
|
87
|
-
glob.startsWith('!')
|
|
88
|
-
? acc.ignore.push(glob.slice(1))
|
|
89
|
-
: acc.match.push(glob);
|
|
90
|
-
return acc;
|
|
91
|
-
}, {
|
|
92
|
-
match: [],
|
|
93
|
-
ignore: [],
|
|
94
|
-
});
|
|
95
|
-
return function isServicePatchMatch(path) {
|
|
96
|
-
return micromatch.isMatch(path, servicePathGlobs.match, {
|
|
97
|
-
ignore: servicePathGlobs.ignore,
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
export const supportedMethod = (method) => supportedHTTPMethods.includes(method);
|
|
102
|
-
const supportedHTTPMethods = Object.values({
|
|
103
|
-
get: 'get',
|
|
104
|
-
put: 'put',
|
|
105
|
-
post: 'post',
|
|
106
|
-
patch: 'patch',
|
|
107
|
-
delete: 'delete',
|
|
108
|
-
options: 'options',
|
|
109
|
-
head: 'head',
|
|
110
|
-
trace: 'trace',
|
|
111
|
-
});
|
|
112
|
-
//# sourceMappingURL=getServices.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getServices.js","sourceRoot":"","sources":["../../../src/lib/open-api/getServices.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,kCAAkC,GAEnC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAkCrF,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,WAA8B,EAC9B,EACE,eAAe,GAAG,SAAS,EAC3B,eAAe,GAAG,aAAa,MACoC,EAAE,EACvE,YAAY,GAAG,CAAC,IAAI,CAAC,EACrB,EAAE;IACF,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC;IAEhC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE5C,MAAM,WAAW,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAC;IAEzD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;YAAE,SAAS;QAE1C,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,c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<reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
4
|
-
import type { Readable } from 'node:stream';
|
|
5
|
-
import type { OpenAPI3 } from 'openapi-typescript';
|
|
6
|
-
import { OpenAPISchemaType } from './OpenAPISchemaType.js';
|
|
7
|
-
export declare const readSchema: (source: string | URL | OpenAPI3 | Readable | Buffer) => Promise<OpenAPISchemaType>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createConfig } from '@redocly/openapi-core';
|
|
2
|
-
import { validateAndBundle } from 'openapi-typescript/dist/lib/redoc.js';
|
|
3
|
-
export const readSchema = async (source) => {
|
|
4
|
-
const redoc = await createConfig({
|
|
5
|
-
rules: {
|
|
6
|
-
'operation-operationId-unique': { severity: 'error' }, // throw error on duplicate operationIDs
|
|
7
|
-
},
|
|
8
|
-
}, { extends: ['minimal'] });
|
|
9
|
-
const parsed = await validateAndBundle(source, {
|
|
10
|
-
redoc,
|
|
11
|
-
silent: false,
|
|
12
|
-
});
|
|
13
|
-
return parsed;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=readSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readSchema.js","sourceRoot":"","sources":["../../../src/lib/open-api/readSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAIrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAIzE,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAC7B,MAAmD,EACnD,EAAE;IACF,MAAM,KAAK,GAAG,MAAM,YAAY,CAC9B;QACE,KAAK,EAAE;YACL,8BAA8B,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,wCAAwC;SAChG;KACF,EACD,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,CACzB,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE;QAC7C,KAAK;QACL,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;IAEH,OAAO,MAA2B,CAAC;AACrC,CAAC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
export interface AstToStringOptions {
|
|
3
|
-
fileName?: string;
|
|
4
|
-
sourceText?: string;
|
|
5
|
-
formatOptions?: ts.PrinterOptions;
|
|
6
|
-
}
|
|
7
|
-
/** Convert TypeScript AST to string */
|
|
8
|
-
export declare function astToString(ast: ts.Node | ts.Node[] | ts.TypeElement | ts.TypeElement[], options?: AstToStringOptions): string;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
/** Convert TypeScript AST to string */
|
|
3
|
-
export function astToString(ast, options) {
|
|
4
|
-
const sourceFile = ts.createSourceFile(options?.fileName ?? "openapi-ts.ts", options?.sourceText ?? "", ts.ScriptTarget.ESNext, false, ts.ScriptKind.TS);
|
|
5
|
-
// @ts-expect-error it’s OK to overwrite statements once
|
|
6
|
-
sourceFile.statements = ts.factory.createNodeArray(Array.isArray(ast) ? ast : [ast]);
|
|
7
|
-
const printer = ts.createPrinter({
|
|
8
|
-
newLine: ts.NewLineKind.LineFeed,
|
|
9
|
-
removeComments: false,
|
|
10
|
-
...options?.formatOptions,
|
|
11
|
-
});
|
|
12
|
-
return printer.printFile(sourceFile);
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=astToString.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"astToString.js","sourceRoot":"","sources":["../../../src/lib/ts-factory/astToString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAQ5B,uCAAuC;AACvC,MAAM,UAAU,WAAW,CACzB,GAA4D,EAC5D,OAA4B;IAE5B,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CACpC,OAAO,EAAE,QAAQ,IAAI,eAAe,EACpC,OAAO,EAAE,UAAU,IAAI,EAAE,EACzB,EAAE,CAAC,YAAY,CAAC,MAAM,EACtB,KAAK,EACL,EAAE,CAAC,UAAU,CAAC,EAAE,CACjB,CAAC;IAEF,wDAAwD;IACxD,UAAU,CAAC,UAAU,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,CAChD,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CACjC,CAAC;IAEF,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC;QAC/B,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ;QAChC,cAAc,EAAE,KAAK;QACrB,GAAG,OAAO,EAAE,aAAa;KAC1B,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
export const getClientFactory = (options) => {
|
|
3
|
-
return [
|
|
4
|
-
...getClientImportsFactory(options),
|
|
5
|
-
getCallbacksVariableFactory(),
|
|
6
|
-
getCreateClientFunctionFactory(),
|
|
7
|
-
];
|
|
8
|
-
};
|
|
9
|
-
const getClientImportsFactory = ({ servicesDirName, explicitImportExtensions, }) => {
|
|
10
|
-
const factory = ts.factory;
|
|
11
|
-
return [
|
|
12
|
-
factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
|
|
13
|
-
factory.createImportSpecifier(false, undefined, factory.createIdentifier('qraftAPIClient')),
|
|
14
|
-
factory.createImportSpecifier(false, undefined, factory.createIdentifier('QraftClientOptions')),
|
|
15
|
-
])), factory.createStringLiteral('@openapi-qraft/react'), undefined),
|
|
16
|
-
...serviceCallbacks.map((propertyName) => factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
|
|
17
|
-
factory.createImportSpecifier(false, undefined, factory.createIdentifier(propertyName)),
|
|
18
|
-
])), factory.createStringLiteral(`@openapi-qraft/react/callbacks/${propertyName}`), undefined)),
|
|
19
|
-
factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
|
|
20
|
-
factory.createImportSpecifier(false, undefined, factory.createIdentifier('services')),
|
|
21
|
-
factory.createImportSpecifier(false, undefined, factory.createIdentifier('Services')),
|
|
22
|
-
])), factory.createStringLiteral(`./${servicesDirName}/index${explicitImportExtensions ? '.js' : ''}`), undefined),
|
|
23
|
-
];
|
|
24
|
-
};
|
|
25
|
-
const getCallbacksVariableFactory = () => {
|
|
26
|
-
const factory = ts.factory;
|
|
27
|
-
return factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
|
|
28
|
-
factory.createVariableDeclaration(factory.createIdentifier('callbacks'), undefined, undefined, factory.createObjectLiteralExpression(serviceCallbacks.map((propertyName) => factory.createShorthandPropertyAssignment(factory.createIdentifier(propertyName), undefined)), true)),
|
|
29
|
-
], ts.NodeFlags.Const));
|
|
30
|
-
};
|
|
31
|
-
const getCreateClientFunctionFactory = () => {
|
|
32
|
-
const factory = ts.factory;
|
|
33
|
-
return factory.createFunctionDeclaration([factory.createToken(ts.SyntaxKind.ExportKeyword)], undefined, factory.createIdentifier('createAPIClient'), undefined, [
|
|
34
|
-
factory.createParameterDeclaration(undefined, undefined, factory.createIdentifier('options'), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createTypeReferenceNode(factory.createIdentifier('QraftClientOptions'), undefined), undefined),
|
|
35
|
-
], factory.createTypeReferenceNode(factory.createIdentifier('Services'), undefined), factory.createBlock([
|
|
36
|
-
factory.createReturnStatement(factory.createCallExpression(factory.createIdentifier('qraftAPIClient'), [
|
|
37
|
-
factory.createTypeReferenceNode(factory.createIdentifier('Services'), undefined),
|
|
38
|
-
factory.createTypeQueryNode(factory.createIdentifier('callbacks'), undefined),
|
|
39
|
-
], [
|
|
40
|
-
factory.createIdentifier('services'),
|
|
41
|
-
factory.createIdentifier('callbacks'),
|
|
42
|
-
factory.createIdentifier('options'),
|
|
43
|
-
])),
|
|
44
|
-
], true));
|
|
45
|
-
};
|
|
46
|
-
const serviceCallbacks = [
|
|
47
|
-
'getInfiniteQueryData',
|
|
48
|
-
'getInfiniteQueryKey',
|
|
49
|
-
'getMutationKey',
|
|
50
|
-
'getQueryData',
|
|
51
|
-
'getQueriesData',
|
|
52
|
-
'getQueryKey',
|
|
53
|
-
'mutationFn',
|
|
54
|
-
'queryFn',
|
|
55
|
-
'setInfiniteQueryData',
|
|
56
|
-
'setQueryData',
|
|
57
|
-
'setQueriesData',
|
|
58
|
-
'useInfiniteQuery',
|
|
59
|
-
'useMutation',
|
|
60
|
-
'useQuery',
|
|
61
|
-
'useSuspenseQuery',
|
|
62
|
-
'useSuspenseInfiniteQuery',
|
|
63
|
-
'useMutationState',
|
|
64
|
-
'useIsMutating',
|
|
65
|
-
'useQueries',
|
|
66
|
-
'useSuspenseQueries',
|
|
67
|
-
'invalidateQueries',
|
|
68
|
-
'cancelQueries',
|
|
69
|
-
'resetQueries',
|
|
70
|
-
'removeQueries',
|
|
71
|
-
'refetchQueries',
|
|
72
|
-
'isFetching',
|
|
73
|
-
'isMutating',
|
|
74
|
-
'useIsFetching',
|
|
75
|
-
'fetchQuery',
|
|
76
|
-
'prefetchQuery',
|
|
77
|
-
'fetchInfiniteQuery',
|
|
78
|
-
'prefetchInfiniteQuery',
|
|
79
|
-
'getQueryState',
|
|
80
|
-
'getInfiniteQueryState',
|
|
81
|
-
];
|
|
82
|
-
//# sourceMappingURL=getClientFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getClientFactory.js","sourceRoot":"","sources":["../../../src/lib/ts-factory/getClientFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAO5B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAE,EAAE;IACnD,OAAO;QACL,GA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
|
-
import ts from 'typescript';
|
|
2
|
-
export const getIndexFactory = ({ servicesDirName, explicitImportExtensions, }) => {
|
|
3
|
-
const factory = ts.factory;
|
|
4
|
-
const importExtension = explicitImportExtensions ? '.js' : '';
|
|
5
|
-
return [
|
|
6
|
-
factory.createExportDeclaration(undefined, false, factory.createNamedExports([
|
|
7
|
-
factory.createExportSpecifier(false, undefined, factory.createIdentifier('services')),
|
|
8
|
-
]), factory.createStringLiteral(`./${servicesDirName}/index${importExtension}`), undefined),
|
|
9
|
-
factory.createExportDeclaration(undefined, true, factory.createNamedExports([
|
|
10
|
-
factory.createExportSpecifier(false, undefined, factory.createIdentifier('Services')),
|
|
11
|
-
]), factory.createStringLiteral(`./${servicesDirName}/index${importExtension}`), undefined),
|
|
12
|
-
factory.createExportDeclaration(undefined, false, factory.createNamedExports([
|
|
13
|
-
factory.createExportSpecifier(false, undefined, factory.createIdentifier('createAPIClient')),
|
|
14
|
-
]), factory.createStringLiteral(`./create-api-client${importExtension}`), undefined),
|
|
15
|
-
];
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=getIndexFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getIndexFactory.js","sourceRoot":"","sources":["../../../src/lib/ts-factory/getIndexFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,eAAe,EACf,wBAAwB,GAIzB,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;IAC3B,MAAM,eAAe,GAAG,wBAAwB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAE9D,OAAO;QACL,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,KAAK,EACL,OAAO,CAAC,kBAAkB,CAAC;YACzB,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CACrC;SACF,CAAC,EACF,OAAO,CAAC,mBAAmB,CACzB,KAAK,eAAe,SAAS,eAAe,EAAE,CAC/C,EACD,SAAS,CACV;QACD,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,IAAI,EACJ,OAAO,CAAC,kBAAkB,CAAC;YACzB,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CACrC;SACF,CAAC,EACF,OAAO,CAAC,mBAAmB,CACzB,KAAK,eAAe,SAAS,eAAe,EAAE,CAC/C,EACD,SAAS,CACV;QACD,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,KAAK,EACL,OAAO,CAAC,kBAAkB,CAAC;YACzB,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAC5C;SACF,CAAC,EACF,OAAO,CAAC,mBAAmB,CAAC,sBAAsB,eAAe,EAAE,CAAC,EACpE,SAAS,CACV;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
import { ServiceOperation } from '../open-api/getServices.js';
|
|
3
|
-
export type ServiceImportsFactoryOptions = {
|
|
4
|
-
openapiTypesImportPath: string;
|
|
5
|
-
operationGenericsImportPath: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const getServiceFactory: (service: {
|
|
8
|
-
typeName: string;
|
|
9
|
-
variableName: string;
|
|
10
|
-
}, operations: ServiceOperation[], { openapiTypesImportPath, operationGenericsImportPath, }: ServiceImportsFactoryOptions) => (ts.ImportDeclaration | ts.VariableStatement | ts.InterfaceDeclaration)[];
|