@povio/openapi-codegen-cli 0.7.2 → 0.8.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/README.md +1 -0
- package/dist/commands/generate.d.ts +1 -1
- package/dist/generators/const/deps.const.d.ts +6 -0
- package/dist/generators/const/endpoints.const.d.ts +1 -0
- package/dist/generators/const/zod.const.d.ts +1 -0
- package/dist/generators/types/generate.d.ts +1 -0
- package/dist/generators/utils/file.utils.d.ts +4 -0
- package/dist/generators/utils/generate/generate.endpoints.utils.d.ts +5 -1
- package/dist/generators/utils/generate/generate.imports.utils.d.ts +2 -3
- package/dist/generators/utils/generate/generate.utils.d.ts +1 -0
- package/dist/generators/utils/hbs/hbs.imports.utils.d.ts +1 -0
- package/dist/index.js +42 -42
- package/dist/sh.js +59 -59
- package/package.json +1 -1
- package/src/assets/fileAction.ts +47 -0
- package/src/assets/rest-client.ts +32 -42
- package/src/generators/templates/app-acl.hbs +1 -1
- package/src/generators/templates/app-rest-client.hbs +1 -1
- package/src/generators/templates/partials/endpoint-config.hbs +6 -0
- package/src/generators/templates/partials/endpoint-params.hbs +1 -1
- package/src/generators/templates/partials/import.hbs +1 -1
- package/src/generators/templates/partials/query-js-docs.hbs +3 -3
- package/src/generators/templates/partials/query-keys.hbs +1 -1
- package/src/generators/templates/partials/query-use-infinite-query.hbs +4 -4
- package/src/generators/templates/partials/query-use-mutation.hbs +14 -2
- package/src/generators/templates/partials/query-use-query.hbs +6 -2
- package/src/generators/templates/queries.hbs +4 -0
- package/src/generators/templates/query-modules.hbs +1 -4
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ yarn openapi-codegen generate --input http://localhost:3001/docs-json --standalo
|
|
|
47
47
|
--axiosRequestConfig Include Axios request config parameters in query hooks (default: false)
|
|
48
48
|
--infiniteQueries Generate infinite queries for paginated API endpoints (default: false)
|
|
49
49
|
--invalidateQueryOptions Add query invalidation options to mutation hooks (default: true)
|
|
50
|
+
--fileActions Add query file actions to query hooks for `x-file-*` operations (default: true)
|
|
50
51
|
|
|
51
52
|
--standalone Generate any missing supporting classes/types, e.g., REST client class, React Query type extensions, etc. (default: false)
|
|
52
53
|
--baseUrl (Requires `--standalone`) Base URL for the REST client; falls back to the OpenAPI spec if not provided
|
|
@@ -3,5 +3,5 @@ export type GenerateParams = {
|
|
|
3
3
|
excludeTags: string;
|
|
4
4
|
prettier: boolean;
|
|
5
5
|
verbose: boolean;
|
|
6
|
-
} & Pick<GenerateOptions, "input" | "output" | "tsNamespaces" | "splitByTags" | "defaultTag" | "removeOperationPrefixEndingWith" | "importPath" | "extractEnums" | "standalone" | "baseUrl" | "replaceOptionalWithNullish" | "infiniteQueries" | "axiosRequestConfig" | "invalidateQueryOptions">;
|
|
6
|
+
} & Pick<GenerateOptions, "input" | "output" | "tsNamespaces" | "splitByTags" | "defaultTag" | "removeOperationPrefixEndingWith" | "importPath" | "extractEnums" | "standalone" | "baseUrl" | "replaceOptionalWithNullish" | "infiniteQueries" | "axiosRequestConfig" | "invalidateQueryOptions" | "fileActions">;
|
|
7
7
|
export declare function generate({ input, excludeTags, prettier, verbose, ...params }: GenerateParams): Promise<void>;
|
|
@@ -16,9 +16,15 @@ export declare enum StandaloneAssetEnum {
|
|
|
16
16
|
}
|
|
17
17
|
export declare const STANDALONE_ASSETS: Record<StandaloneAssetEnum, GenerateFile>;
|
|
18
18
|
export declare const STANDALONE_APP_REST_CLIENT_FILE: GenerateFile;
|
|
19
|
+
export declare const UTILS_DIR = "utils";
|
|
19
20
|
export declare const INVALIDATE_QUERIES: {
|
|
20
21
|
optionsType: string;
|
|
21
22
|
functionName: string;
|
|
22
23
|
};
|
|
23
24
|
export declare const INVALIDATE_QUERY_OPTIONS_FILE: GenerateFile;
|
|
24
25
|
export declare const QUERY_MODULES_FILE: GenerateFile;
|
|
26
|
+
export declare const FILE_ACTION_QUERY_OPTIONS: {
|
|
27
|
+
optionsType: string;
|
|
28
|
+
functionName: string;
|
|
29
|
+
};
|
|
30
|
+
export declare const FILE_ACTION_OPTIONS_FILE: GenerateFile;
|
|
@@ -4,6 +4,7 @@ export declare const DEFAULT_HEADERS: {
|
|
|
4
4
|
Accept: string;
|
|
5
5
|
};
|
|
6
6
|
export declare const BODY_PARAMETER_NAME = "data";
|
|
7
|
+
export declare const AXIOS_DEFAULT_IMPORT_NAME = "axios";
|
|
7
8
|
export declare const AXIOS_REQUEST_CONFIG_NAME = "config";
|
|
8
9
|
export declare const AXIOS_REQUEST_CONFIG_TYPE = "AxiosRequestConfig";
|
|
9
10
|
export declare const AXIOS_IMPORT: Import;
|
|
@@ -6,5 +6,6 @@ export declare const PARAM_SCHEMA_SUFFIX = "Param";
|
|
|
6
6
|
export declare const RESPONSE_SCHEMA_SUFFIX = "Response";
|
|
7
7
|
export declare const ERROR_RESPONSE_SCHEMA_SUFFIX = "ErrorResponse";
|
|
8
8
|
export declare const VOID_SCHEMA = "z.void()";
|
|
9
|
+
export declare const BLOB_SCHEMA = "z.instanceof(Blob)";
|
|
9
10
|
export declare const ENUM_SCHEMA = "z.enum";
|
|
10
11
|
export declare const ZOD_IMPORT: Import;
|
|
@@ -5,4 +5,8 @@ export declare function getOutputFileName({ output, fileName }: {
|
|
|
5
5
|
output: string;
|
|
6
6
|
fileName: string;
|
|
7
7
|
}): string;
|
|
8
|
+
export declare function getUtilsOutputFileName({ output, fileName }: {
|
|
9
|
+
output: string;
|
|
10
|
+
fileName: string;
|
|
11
|
+
}): string;
|
|
8
12
|
export declare function writeGenerateFileData(filesData: GenerateFileData[]): void;
|
|
@@ -6,7 +6,11 @@ export declare const getEndpointName: (endpoint: Endpoint) => string;
|
|
|
6
6
|
export declare function getImportedEndpointName(endpoint: Endpoint, options: GenerateOptions): string;
|
|
7
7
|
export declare const getEndpointPath: (endpoint: Endpoint) => string;
|
|
8
8
|
export declare function getEndpointTag(endpoint: Endpoint, options: GenerateOptions): string;
|
|
9
|
-
export declare function mapEndpointParamsToFunctionParams(resolver: SchemaResolver, endpoint: Endpoint,
|
|
9
|
+
export declare function mapEndpointParamsToFunctionParams(resolver: SchemaResolver, endpoint: Endpoint, options?: {
|
|
10
|
+
removePageParam?: boolean;
|
|
11
|
+
replacePageParam?: boolean;
|
|
12
|
+
includeFileParam?: boolean;
|
|
13
|
+
}): {
|
|
10
14
|
name: string;
|
|
11
15
|
type: string;
|
|
12
16
|
paramType: "Body" | "Query" | "Header" | "Path";
|
|
@@ -13,13 +13,12 @@ export declare function getEndpointsImports({ tag, endpoints, options, }: {
|
|
|
13
13
|
endpoints: Endpoint[];
|
|
14
14
|
options: GenerateOptions;
|
|
15
15
|
}): Import[];
|
|
16
|
-
export declare function getEntityImports({ tags, entityName, getAliasEntityName, type,
|
|
16
|
+
export declare function getEntityImports({ tags, entityName, getAliasEntityName, type, options, }: {
|
|
17
17
|
tags: string[];
|
|
18
18
|
entityName: string;
|
|
19
19
|
getAliasEntityName?: (tag: string) => string;
|
|
20
20
|
type: GenerateType;
|
|
21
|
-
sameDir?: boolean;
|
|
22
21
|
options: GenerateOptions;
|
|
23
22
|
}): Import[];
|
|
24
|
-
export declare function getImportPath(options: Pick<GenerateOptions, "output" | "importPath"
|
|
23
|
+
export declare function getImportPath(options: Pick<GenerateOptions, "output" | "importPath">): string;
|
|
25
24
|
export declare function mergeImports(options: GenerateOptions, ...importArrs: Import[][]): Import[];
|
|
@@ -17,4 +17,5 @@ export declare const getNamespaceName: ({ type, tag, options, }: {
|
|
|
17
17
|
export declare function getAppRestClientImportPath(options: GenerateOptions): string;
|
|
18
18
|
export declare function getQueryTypesImportPath(options: GenerateOptions): string;
|
|
19
19
|
export declare function getInvalidateQueriesImportPath(options: GenerateOptions): string;
|
|
20
|
+
export declare function getFileActionImportPath(options: GenerateOptions): string;
|
|
20
21
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerImportsHbsHelpers(): void;
|