@povio/openapi-codegen-cli 0.5.1 → 0.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/openapi-codegen-cli",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "main": "./dist/index.js",
5
5
  "bin": {
6
6
  "openapi-codegen": "./dist/sh.js"
@@ -0,0 +1,10 @@
1
+ /**
2
+ * {{#if (isQuery endpoint)}}Query{{else}}Mutation{{/if}} `{{queryName endpoint}}`{{#if endpoint.summary}}
3
+ * @summary {{addAsteriskAfterNewLine endpoint.summary}}{{/if}}{{#if endpoint.description}}
4
+ * @description {{addAsteriskAfterNewLine endpoint.description}}{{/if}}{{#if endpoint.acl}}
5
+ * @permission Requires `{{abilityFunctionName endpoint}}` ability {{/if}}
6
+ {{#if (endpointParams endpoint)}}{{#each (endpointParams endpoint) as | endpointParam |}} * @param { {{endpointParam.type}} } {{#if (isQuery ../endpoint)}}object{{else}}mutation{{/if}}.{{endpointParam.name}} {{{endpointParamDescription endpointParam}}}
7
+ {{/each}}{{/if}} * @param {{#if (isQuery endpoint)}}{ AppQueryOptions } options Query options{{else}}{ AppMutationOptions } options Mutation options{{/if}}
8
+ * @returns { {{#if (isQuery endpoint)}}UseQueryResult{{else}}UseMutationResult{{/if}}<{{{importedZodSchemaInferedType endpoint.response}}}> } {{endpoint.responseDescription}}
9
+ * @statusCodes [{{commaSeparated endpoint.responseStatusCodes}}]
10
+ */
@@ -1,8 +1,6 @@
1
1
  export const keys = {
2
- {{#each (allQueryKeys endpoints) as | queryKey |}}
3
- {{queryKey.name}}: ["{{queryKey.path}}"] as const,
4
- {{/each}}
5
- {{#each endpoints as | endpoint |}}
6
- {{endpointName endpoint}}: ({{{genEndpointParams endpoint}}}) => [{{{commaSeparated (endpointPathQueryKeys endpoint ../endpoints)}}}, {{{endpointArgs endpoint}}}] as const,
2
+ all: ["{{namespace}}"] as const,
3
+ {{#each queryEndpoints as | endpoint |}}
4
+ {{endpointName endpoint}}: ({{{genEndpointParams endpoint}}}) => [...keys.all, "{{endpoint.path}}", {{{endpointArgs endpoint}}}] as const,
7
5
  {{/each}}
8
6
  };
@@ -1,21 +1,13 @@
1
- /**
2
- * Mutation `{{queryName endpoint}}`{{#if endpoint.summary}}
3
- * @summary {{addAsteriskAfterNewLine endpoint.summary}}{{/if}}{{#if endpoint.description}}
4
- * @description {{addAsteriskAfterNewLine endpoint.description}}{{/if}}{{#if endpoint.acl}}
5
- * @permission Requires `{{abilityFunctionName endpoint}}` ability {{/if}}
6
- {{#if (endpointParams endpoint)}}{{#each (endpointParams endpoint) as | endpointParam |}} * @param { {{endpointParam.type}} } mutation.{{endpointParam.name}} {{{endpointParamDescription endpointParam}}}
7
- {{/each}}{{/if}} * @param { AppMutationOptions } options Mutation options
8
- * @statusCodes [{{commaSeparated endpoint.responseStatusCodes}}]
9
- */
1
+ {{{genQueryJsDocs endpoint}}}
10
2
  export const {{queryName endpoint}} = (options?: AppMutationOptions<typeof {{importedEndpointName endpoint}}, { {{{genEndpointParams endpoint}}} }>) => {
11
- {{#if (endpointAllQueryKey endpoint endpoints)}} const queryClient = useQueryClient();{{/if}}
3
+ {{#if queryEndpoints}} const queryClient = useQueryClient();{{/if}}
12
4
 
13
5
  return {{queryHook}}({
14
6
  mutationFn: ({{#if (endpointParams endpoint)}} { {{{endpointArgs endpoint}}} } {{/if}}) => {{importedEndpointName endpoint}}({{{endpointArgs endpoint}}}),
15
- ...options, {{#if (endpointAllQueryKey endpoint endpoints)}}
7
+ ...options, {{#if queryEndpoints}}
16
8
  onSuccess: (...args) => {
17
9
  if (options?.enableInvalidateAll) {
18
- queryClient.invalidateQueries({ queryKey: keys.{{endpointAllQueryKey endpoint endpoints}} });
10
+ queryClient.invalidateQueries({ queryKey: keys.all });
19
11
  }
20
12
  options?.onSuccess?.(...args);
21
13
  },{{/if}}
@@ -1,12 +1,4 @@
1
- /**
2
- * Query `{{queryName endpoint}}`{{#if endpoint.summary}}
3
- * @summary {{addAsteriskAfterNewLine endpoint.summary}}{{/if}}{{#if endpoint.description}}
4
- * @description {{addAsteriskAfterNewLine endpoint.description}}{{/if}}{{#if endpoint.acl}}
5
- * @permission Requires `{{abilityFunctionName endpoint}}` ability {{/if}}
6
- {{#if (endpointParams endpoint)}}{{#each (endpointParams endpoint) as | endpointParam |}} * @param { {{endpointParam.type}} } object.{{endpointParam.name}} {{{endpointParamDescription endpointParam}}}
7
- {{/each}}{{/if}} * @param { AppQueryOptions } options Query options
8
- * @statusCodes [{{commaSeparated endpoint.responseStatusCodes}}]
9
- */
1
+ {{{genQueryJsDocs endpoint}}}
10
2
  export const {{queryName endpoint}} = <TData>({{#if (endpointParams endpoint)}}{ {{{endpointArgs endpoint}}} }: { {{{genEndpointParams endpoint}}} }, {{/if}}options?: AppQueryOptions<typeof {{importedEndpointName endpoint}}, TData>) => {
11
3
  return {{queryHook}}({
12
4
  queryKey: keys.{{endpointName endpoint}}({{#if (endpointParams endpoint)}}{{{endpointArgs endpoint}}}{{/if}}),
@@ -15,7 +15,7 @@
15
15
  export namespace {{namespace}} {
16
16
  {{/if}}
17
17
  {{! Query keys export}}
18
- {{{genQueryKeys queryEndpoints}}}
18
+ {{{genQueryKeys queryEndpoints namespace}}}
19
19
 
20
20
  {{! Query export }}
21
21
  {{#each endpoints as | endpoint |}}
@@ -1,3 +0,0 @@
1
- import { GenerateOptions } from "src/generators/types/options";
2
- export declare function getAppRestClientImportPath(options: GenerateOptions): string;
3
- export declare function getQueryTypesImportPath(options: GenerateOptions): string;