@povio/openapi-codegen-cli 0.13.5 → 0.13.7
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/dist/generators/utils/generate/generate.acl.utils.d.ts +2 -0
- package/dist/generators/utils/generate/generate.imports.utils.d.ts +5 -0
- package/dist/generators/utils/generate/generate.utils.d.ts +1 -1
- package/dist/generators/utils/hbs/hbs.acl.utils.d.ts +2 -1
- package/dist/index.js +46 -46
- package/dist/sh.js +66 -66
- package/package.json +1 -1
- package/src/generators/templates/acl-check.hbs +3 -1
- package/src/generators/templates/partials/acl-check-call.hbs +1 -0
- package/src/generators/templates/partials/query-use-infinite-query.hbs +1 -1
- package/src/generators/templates/partials/query-use-mutation.hbs +1 -1
- package/src/generators/templates/partials/query-use-query.hbs +1 -1
- package/src/generators/templates/queries.hbs +4 -0
- package/src/generators/templates/partials/acl-check-params.hbs +0 -1
package/package.json
CHANGED
|
@@ -5,6 +5,8 @@ import { useCallback } from "react";
|
|
|
5
5
|
{{{genImport errorHandlingImport}}}
|
|
6
6
|
{{! App abilities import }}
|
|
7
7
|
{{{genImport appAbilitiesImport}}}
|
|
8
|
+
{{! Casl ability tuple import }}
|
|
9
|
+
{{{genImport caslAbilityTupleImport}}}
|
|
8
10
|
|
|
9
11
|
interface UseAclCheckProps {
|
|
10
12
|
errorHandler?: {{errorHandler}}<never>;
|
|
@@ -14,7 +16,7 @@ export function {{aclCheckHook}}({ errorHandler }: UseAclCheckProps = {}) {
|
|
|
14
16
|
const ability = {{abilityContext}}.useAbility();
|
|
15
17
|
|
|
16
18
|
const checkAcl = useCallback((appAbility: {{appAbilities}}) => {
|
|
17
|
-
if (!ability.can(...appAbility)) {
|
|
19
|
+
if (!ability.can(...(appAbility as AbilityTuple))) {
|
|
18
20
|
(errorHandler ?? {{sharedErrorHandler}}).rethrowError(new Error("ACL check failed"));
|
|
19
21
|
}
|
|
20
22
|
}, [ability, errorHandler]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
checkAcl({{importedAbilityFunctionName endpoint}}({{#if generateAclCheckParams}}{ {{#each (abilityConditionsTypes endpoint) as | propertyType |}}{{propertyType.name}}, {{/each}} } {{/if}}));
|
|
@@ -8,7 +8,7 @@ export const {{infiniteQueryName endpoint}} = <TData>({{#if (endpointParams endp
|
|
|
8
8
|
return {{infiniteQueryHook}}({
|
|
9
9
|
queryKey: keys.{{endpointName endpoint}}Infinite({{#if (endpointParams endpoint)}}{{{endpointArgs endpoint excludePageParam=true}}}{{/if}}),
|
|
10
10
|
queryFn: ({ pageParam }) => {{#if hasQueryFnBody}}{ {{/if}}
|
|
11
|
-
{{#if hasAclCheck}}
|
|
11
|
+
{{#if hasAclCheck}}{{{genAclCheckCall endpoint}}}{{/if}}
|
|
12
12
|
{{#if hasQueryFnBody}}return {{/if}}{{importedEndpointName endpoint}}({{{endpointArgs endpoint replacePageParam=true}}}{{#if hasAxiosRequestConfig}}, {{axiosRequestConfigName}}{{/if}})
|
|
13
13
|
{{#if hasQueryFnBody}} }{{/if}},
|
|
14
14
|
initialPageParam: 1,
|
|
@@ -9,7 +9,7 @@ export const {{queryName endpoint mutation=true}} = (options?: AppMutationOption
|
|
|
9
9
|
|
|
10
10
|
return {{queryHook}}({
|
|
11
11
|
mutationFn: {{#if endpoint.mediaUpload}}async {{/if}}({{#if (endpointParams endpoint includeFileParam=true)}} { {{{endpointArgs endpoint includeFileParam=true}}} } {{/if}}) => {{#if hasMutationFnBody}} { {{/if}}
|
|
12
|
-
{{#if hasAclCheck}}
|
|
12
|
+
{{#if hasAclCheck}}{{{genAclCheckCall endpoint}}}{{/if}}
|
|
13
13
|
{{#if endpoint.mediaUpload}}const uploadInstructions = await {{importedEndpointName endpoint}}({{{endpointArgs endpoint}}}{{#if hasAxiosRequestConfig}}{{#if (endpointArgs endpoint)}}, {{/if}}{{axiosRequestConfigName}}{{/if}});
|
|
14
14
|
|
|
15
15
|
if (file && uploadInstructions.url) {
|
|
@@ -8,7 +8,7 @@ export const {{queryName endpoint}} = <TData>({{#if (endpointParams endpoint)}}{
|
|
|
8
8
|
return {{queryHook}}({
|
|
9
9
|
queryKey: keys.{{endpointName endpoint}}({{#if (endpointParams endpoint)}}{{{endpointArgs endpoint}}}{{/if}}),
|
|
10
10
|
queryFn: {{#if hasQueryFn}}() => {{#if hasQueryFnBody}}{ {{/if}}
|
|
11
|
-
{{#if hasAclCheck}}
|
|
11
|
+
{{#if hasAclCheck}}{{{genAclCheckCall endpoint}}}{{/if}}
|
|
12
12
|
{{#if hasQueryFnBody}}return {{/if}}{{importedEndpointName endpoint}}({{{endpointArgs endpoint}}}{{#if hasAxiosRequestConfig}}{{#if (endpointArgs endpoint)}}, {{/if}}{{axiosRequestConfigName}}{{/if}}){{else}}{{importedEndpointName endpoint}}{{/if}}
|
|
13
13
|
{{#if hasQueryFnBody}} }{{/if}},
|
|
14
14
|
...options,
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
{{#each endpointsImports as | endpointsImport |}}
|
|
27
27
|
{{{genImport endpointsImport}}}
|
|
28
28
|
{{/each}}
|
|
29
|
+
{{! Acl import }}
|
|
30
|
+
{{#each aclImports as | aclImport |}}
|
|
31
|
+
{{{genImport aclImport}}}
|
|
32
|
+
{{/each}}
|
|
29
33
|
|
|
30
34
|
{{#if includeNamespace}}
|
|
31
35
|
export namespace {{namespace}} {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{{#if generateAclCheckParams}}{ {{#each (abilityConditionsTypes endpoint) as | propertyType |}}{{propertyType.name}}, {{/each}} } {{/if}}
|