@povio/openapi-codegen-cli 2.0.8-rc.8 → 2.0.8
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 +0 -63
- package/dist/acl.d.ts +4 -0
- package/dist/acl.mjs +7 -62
- package/dist/commands/check.command.d.ts +2 -0
- package/dist/commands/check.d.ts +7 -0
- package/dist/commands/generate.command.d.ts +2 -0
- package/dist/commands/generate.d.ts +8 -0
- package/dist/generator.d.ts +3 -0
- package/dist/generator.js +78 -0
- package/dist/generators/checkOpenAPIDoc.d.ts +3 -0
- package/dist/generators/const/acl.const.d.ts +13 -0
- package/dist/generators/const/buildConfigs.const.d.ts +1 -0
- package/dist/generators/const/deps.const.d.ts +38 -0
- package/dist/generators/const/endpoints.const.d.ts +11 -0
- package/dist/generators/const/js.const.d.ts +1 -0
- package/dist/generators/const/openapi.const.d.ts +7 -0
- package/dist/generators/const/options.const.d.ts +2 -0
- package/dist/generators/const/package.const.d.ts +2 -0
- package/dist/generators/const/queries.const.d.ts +8 -0
- package/dist/generators/const/validation.const.d.ts +53 -0
- package/dist/generators/const/zod.const.d.ts +19 -0
- package/dist/generators/core/SchemaResolver.class.d.ts +71 -0
- package/dist/generators/core/endpoints/getEndpointAcl.d.ts +8 -0
- package/dist/generators/core/endpoints/getEndpointBody.d.ts +13 -0
- package/dist/generators/core/endpoints/getEndpointParameter.d.ts +11 -0
- package/dist/generators/core/endpoints/getEndpointsFromOpenAPIDoc.d.ts +3 -0
- package/dist/generators/core/endpoints/getEndpointsFromOpenAPIDoc.test.d.ts +1 -0
- package/dist/generators/core/getDataFromOpenAPIDoc.d.ts +8 -0
- package/dist/generators/core/getMetadataFromOpenAPIDoc.d.ts +4 -0
- package/dist/generators/core/getMetadataFromOpenAPIDoc.test.d.ts +1 -0
- package/dist/generators/core/openapi/getOpenAPISchemaComplexity.d.ts +2 -0
- package/dist/generators/core/openapi/getOpenAPISchemaComplexity.test.d.ts +1 -0
- package/dist/generators/core/openapi/getOpenAPISchemaDependencyGraph.d.ts +6 -0
- package/dist/generators/core/openapi/getOpenAPISchemaDependencyGraph.test.d.ts +1 -0
- package/dist/generators/core/openapi/getSchemaRefObjs.d.ts +4 -0
- package/dist/generators/core/openapi/iterateSchema.d.ts +22 -0
- package/dist/generators/core/resolveConfig.d.ts +7 -0
- package/dist/generators/core/zod/ZodSchema.class.d.ts +26 -0
- package/dist/generators/core/zod/enumExtraction/resolveExtractedEnumZodSchemaNames.d.ts +2 -0
- package/dist/generators/core/zod/enumExtraction/resolveExtractedEnumZodSchemaTags.d.ts +2 -0
- package/dist/generators/core/zod/enumExtraction/updateExtractedEnumZodSchemaData.d.ts +17 -0
- package/dist/generators/core/zod/getZodChain.d.ts +8 -0
- package/dist/generators/core/zod/getZodSchema.d.ts +17 -0
- package/dist/generators/core/zod/getZodSchema.test.d.ts +1 -0
- package/dist/generators/core/zod/getZodSchemaRefs.d.ts +6 -0
- package/dist/generators/core/zod/getZodSchemasFromOpenAPIDoc.d.ts +6 -0
- package/dist/generators/core/zod/resolveZodSchemaName.d.ts +10 -0
- package/dist/generators/core/zod/sortZodSchemasByTopology.d.ts +4 -0
- package/dist/generators/generate/generateAcl.d.ts +3 -0
- package/dist/generators/generate/generateAclCheck.d.ts +2 -0
- package/dist/generators/generate/generateAppRestClient.d.ts +2 -0
- package/dist/generators/generate/generateConfigs.d.ts +2 -0
- package/dist/generators/generate/generateEndpoints.d.ts +2 -0
- package/dist/generators/generate/generateModels.d.ts +2 -0
- package/dist/generators/generate/generateQueries.d.ts +2 -0
- package/dist/generators/generate/generateQueryModules.d.ts +2 -0
- package/dist/generators/generate/generateZodExtended.d.ts +2 -0
- package/dist/generators/generateCodeFromOpenAPIDoc.d.ts +4 -0
- package/dist/generators/types/builder-config.d.ts +48 -0
- package/dist/generators/types/common.d.ts +27 -0
- package/dist/generators/types/config.d.ts +2 -0
- package/dist/generators/types/endpoint.d.ts +50 -0
- package/dist/generators/types/generate.d.ts +39 -0
- package/dist/generators/types/metadata.d.ts +51 -0
- package/dist/generators/types/openapi.d.ts +22 -0
- package/dist/generators/types/options.d.ts +66 -0
- package/dist/generators/types/validation.d.ts +5 -0
- package/dist/generators/utils/array.utils.d.ts +1 -0
- package/dist/generators/utils/endpoint.utils.d.ts +12 -0
- package/dist/generators/utils/endpoint.utils.test.d.ts +1 -0
- package/dist/generators/utils/file.utils.d.ts +8 -0
- package/dist/generators/utils/generate/generate.acl.utils.d.ts +23 -0
- package/dist/generators/utils/generate/generate.configs.utils.d.ts +15 -0
- package/dist/generators/utils/generate/generate.endpoints.utils.d.ts +41 -0
- package/dist/generators/utils/generate/generate.imports.utils.d.ts +39 -0
- package/dist/generators/utils/generate/generate.imports.utils.test.d.ts +1 -0
- package/dist/generators/utils/generate/generate.openapi.utils.d.ts +2 -0
- package/dist/generators/utils/generate/generate.query.utils.d.ts +6 -0
- package/dist/generators/utils/generate/generate.utils.d.ts +18 -0
- package/dist/generators/utils/generate/generate.zod.utils.d.ts +13 -0
- package/dist/generators/utils/generate-files.utils.d.ts +6 -0
- package/dist/generators/utils/hbs/hbs-template.utils.d.ts +3 -0
- package/dist/generators/utils/hbs/hbs.acl.utils.d.ts +2 -0
- package/dist/generators/utils/hbs/hbs.common.utils.d.ts +1 -0
- package/dist/generators/utils/hbs/hbs.endpoints.utils.d.ts +2 -0
- package/dist/generators/utils/hbs/hbs.imports.utils.d.ts +1 -0
- package/dist/generators/utils/hbs/hbs.partials.utils.d.ts +2 -0
- package/dist/generators/utils/hbs/hbs.query.utils.d.ts +2 -0
- package/dist/generators/utils/hbs/hbs.zod.utils.d.ts +2 -0
- package/dist/generators/utils/js.utils.d.ts +2 -0
- package/dist/generators/utils/js.utils.test.d.ts +1 -0
- package/dist/generators/utils/math.utils.d.ts +1 -0
- package/dist/generators/utils/namespace.utils.d.ts +7 -0
- package/dist/generators/utils/object.utils.d.ts +13 -0
- package/dist/generators/utils/object.utils.test.d.ts +1 -0
- package/dist/generators/utils/openapi-schema.utils.d.ts +15 -0
- package/dist/generators/utils/openapi.utils.d.ts +23 -0
- package/dist/generators/utils/openapi.utils.test.d.ts +1 -0
- package/dist/generators/utils/operation.utils.d.ts +22 -0
- package/dist/generators/utils/operation.utils.test.d.ts +1 -0
- package/dist/generators/utils/query.utils.d.ts +7 -0
- package/dist/generators/utils/sort.utils.d.ts +7 -0
- package/dist/generators/utils/string.utils.d.ts +14 -0
- package/dist/generators/utils/string.utils.test.d.ts +1 -0
- package/dist/generators/utils/tag.utils.d.ts +7 -0
- package/dist/generators/utils/ts.utils.d.ts +16 -0
- package/dist/generators/utils/validation.utils.d.ts +17 -0
- package/dist/generators/utils/zod-schema.utils.d.ts +15 -0
- package/dist/helpers/cli.helper.d.ts +22 -0
- package/dist/helpers/config.helper.d.ts +3 -0
- package/dist/helpers/version.helper.d.ts +4 -0
- package/dist/helpers/yargs.helper.d.ts +10 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.mjs +22 -365
- package/dist/lib/acl/AclGuard.d.ts +8 -0
- package/dist/lib/acl/AclGuard.mjs +14 -0
- package/dist/lib/acl/Can.d.ts +9 -0
- package/dist/lib/acl/Can.mjs +11 -0
- package/dist/lib/acl/ability.context.d.ts +15 -0
- package/dist/lib/acl/ability.context.mjs +37 -0
- package/dist/lib/acl/appAbility.types.d.ts +3 -0
- package/dist/lib/assets/locales/en/translation.json.mjs +8 -0
- package/dist/lib/assets/locales/sl/translation.json.mjs +8 -0
- package/dist/lib/auth/AuthGuard.d.ts +6 -0
- package/dist/lib/auth/AuthGuard.mjs +26 -0
- package/dist/lib/auth/auth.context.d.ts +22 -0
- package/dist/lib/auth/auth.context.mjs +41 -0
- package/dist/lib/config/i18n.d.ts +32 -0
- package/dist/lib/config/i18n.mjs +31 -0
- package/dist/lib/config/queryConfig.context.d.ts +17 -0
- package/dist/lib/config/queryConfig.context.mjs +26 -0
- package/dist/lib/config/router.context.d.ts +9 -0
- package/dist/lib/config/router.context.mjs +20 -0
- package/dist/lib/react-query.types.d.ts +10 -0
- package/dist/lib/rest/error-handling.d.ts +30 -0
- package/dist/lib/rest/error-handling.mjs +132 -0
- package/dist/lib/rest/rest-client.d.ts +22 -0
- package/dist/lib/rest/rest-client.mjs +62 -0
- package/dist/lib/rest/rest-client.types.d.ts +23 -0
- package/dist/lib/rest/rest-interceptor.d.ts +8 -0
- package/dist/lib/rest/rest-interceptor.mjs +21 -0
- package/dist/lib/rest/rest.utils.d.ts +7 -0
- package/dist/lib/rest/rest.utils.mjs +51 -0
- package/dist/sh.d.ts +2 -0
- package/dist/sh.js +635 -0
- package/package.json +41 -47
- package/src/generators/templates/endpoints.hbs +1 -0
- package/src/generators/templates/partials/query-use-infinite-query.hbs +7 -5
- package/src/generators/templates/partials/query-use-query.hbs +4 -3
- package/dist/acl.d.mts +0 -48
- package/dist/auth.context-DKjzWiaA.mjs +0 -59
- package/dist/config-Cu_GYfai.d.mts +0 -6
- package/dist/generate.runner-DNldmk0f.mjs +0 -98
- package/dist/generateCodeFromOpenAPIDoc-B5lnFNGB.mjs +0 -4522
- package/dist/generator.d.mts +0 -65
- package/dist/generator.mjs +0 -144
- package/dist/index.d.mts +0 -246
- package/dist/options-DBz5YE3s.d.mts +0 -90
- package/dist/sh.d.mts +0 -1
- package/dist/sh.mjs +0 -439
- package/dist/vite.d.mts +0 -8
- package/dist/vite.mjs +0 -50
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@povio/openapi-codegen-cli",
|
|
3
|
-
"version": "2.0.8
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"codegen",
|
|
6
6
|
"openapi",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"url": "git+https://github.com/povio/openapi-codegen-cli.git"
|
|
17
17
|
},
|
|
18
18
|
"bin": {
|
|
19
|
-
"openapi-codegen": "./dist/sh.
|
|
19
|
+
"openapi-codegen": "./dist/sh.js"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"README.md",
|
|
@@ -24,62 +24,50 @@
|
|
|
24
24
|
"src/assets/**",
|
|
25
25
|
"src/generators/templates/**"
|
|
26
26
|
],
|
|
27
|
-
"type": "module",
|
|
28
27
|
"main": "./dist/index.mjs",
|
|
29
|
-
"types": "./dist/index.d.
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
30
29
|
"exports": {
|
|
31
30
|
".": {
|
|
32
|
-
"types": "./dist/index.d.
|
|
33
|
-
"import": "./dist/index.mjs"
|
|
34
|
-
|
|
35
|
-
"./vite": {
|
|
36
|
-
"types": "./dist/vite.d.mts",
|
|
37
|
-
"import": "./dist/vite.mjs"
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.mjs",
|
|
33
|
+
"require": "./dist/index.mjs"
|
|
38
34
|
},
|
|
39
35
|
"./generator": {
|
|
40
|
-
"types": "./dist/generator.d.
|
|
41
|
-
"import": "./dist/generator.
|
|
36
|
+
"types": "./dist/generator.d.ts",
|
|
37
|
+
"import": "./dist/generator.js",
|
|
38
|
+
"require": "./dist/generator.js"
|
|
42
39
|
},
|
|
43
40
|
"./acl": {
|
|
44
|
-
"types": "./dist/acl.d.
|
|
45
|
-
"import": "./dist/acl.mjs"
|
|
41
|
+
"types": "./dist/acl.d.ts",
|
|
42
|
+
"import": "./dist/acl.mjs",
|
|
43
|
+
"require": "./dist/acl.mjs"
|
|
46
44
|
}
|
|
47
45
|
},
|
|
48
46
|
"scripts": {
|
|
49
47
|
"start": "node --import tsx ./src/sh.ts",
|
|
50
48
|
"test": "vitest run",
|
|
51
49
|
"test:watch": "vitest",
|
|
52
|
-
"build": "
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"gen:verify": "pnpm gen:base && pnpm gen:next && pnpm test:generated-eq",
|
|
50
|
+
"build:clean": "rm -rf ./dist",
|
|
51
|
+
"build:client": "vite build",
|
|
52
|
+
"build:cli": "node ./esbuild.mjs && chmod +x ./dist/sh.js",
|
|
53
|
+
"build": "yarn build:clean && yarn build:cli && yarn build:client",
|
|
54
|
+
"start:dist": "node ./dist/sh.js",
|
|
58
55
|
"typecheck": "tsc --noEmit",
|
|
59
56
|
"lint": "oxlint --type-aware --fix",
|
|
60
57
|
"lint:check": "oxlint --type-aware",
|
|
61
58
|
"format": "oxfmt",
|
|
62
59
|
"format:check": "oxfmt --check",
|
|
63
|
-
"check": "
|
|
64
|
-
"push": "
|
|
65
|
-
"dev:generate": "rm -rf ./output &&
|
|
66
|
-
"dev:check": "
|
|
67
|
-
"snapshot:openapi-localhost": "node ./scripts/snapshot-openapi-localhost.mjs",
|
|
68
|
-
"bench:vite-codegen": "node ./scripts/benchmark-vite-codegen.mjs"
|
|
60
|
+
"check": "yarn typecheck && yarn lint && yarn test",
|
|
61
|
+
"push": "yarn exec ./scripts/publish.sh",
|
|
62
|
+
"dev:generate": "rm -rf ./output && yarn start generate --config ./test/config.ts",
|
|
63
|
+
"dev:check": "yarn start check --config ./test/config.ts"
|
|
69
64
|
},
|
|
70
65
|
"dependencies": {
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"i18next": "^25.8.13",
|
|
74
|
-
"import-fresh": "^3.3.1",
|
|
75
|
-
"prompt-sync": "^4.2.0",
|
|
76
|
-
"reflect-metadata": "^0.2.2",
|
|
77
|
-
"ts-pattern": "^5.9.0",
|
|
78
|
-
"typescript": "^5.9.3",
|
|
79
|
-
"yargs": "^18.0.0",
|
|
80
|
-
"openapi-types": "^12.1.3"
|
|
66
|
+
"i18next": "^25.8.11",
|
|
67
|
+
"import-fresh": "^3.3.1"
|
|
81
68
|
},
|
|
82
69
|
"devDependencies": {
|
|
70
|
+
"@apidevtools/swagger-parser": "^10.1.0",
|
|
83
71
|
"@casl/ability": "^6.8.0",
|
|
84
72
|
"@casl/react": "^5.0.1",
|
|
85
73
|
"@tanstack/react-query": "~5.90.21",
|
|
@@ -88,16 +76,25 @@
|
|
|
88
76
|
"@types/react": "^19.2.14",
|
|
89
77
|
"@types/yargs": "^17.0.35",
|
|
90
78
|
"@vitejs/plugin-react": "^5.1.4",
|
|
79
|
+
"axios": "^1.13.5",
|
|
80
|
+
"esbuild": "0.27.3",
|
|
81
|
+
"handlebars": "^4.7.8",
|
|
82
|
+
"openapi-types": "^12.1.3",
|
|
91
83
|
"oxfmt": "^0.34.0",
|
|
92
|
-
"oxlint": "^1.
|
|
93
|
-
"oxlint-tsgolint": "^0.
|
|
84
|
+
"oxlint": "^1.49.0",
|
|
85
|
+
"oxlint-tsgolint": "^0.14.1",
|
|
86
|
+
"prompt-sync": "^4.2.0",
|
|
94
87
|
"react": "^19.2.4",
|
|
95
|
-
"
|
|
88
|
+
"reflect-metadata": "^0.2.2",
|
|
89
|
+
"ts-pattern": "^5.9.0",
|
|
96
90
|
"tsx": "^4.21.0",
|
|
97
91
|
"type-fest": "^5.4.4",
|
|
98
|
-
"
|
|
92
|
+
"typescript": "^5.9.3",
|
|
93
|
+
"vite": "^7.3.1",
|
|
99
94
|
"vite-plugin-dts": "^4.5.4",
|
|
100
|
-
"vitest": "4.0.18"
|
|
95
|
+
"vitest": "4.0.18",
|
|
96
|
+
"yargs": "^17.7.2",
|
|
97
|
+
"zod": "^4.3.6"
|
|
101
98
|
},
|
|
102
99
|
"peerDependencies": {
|
|
103
100
|
"@casl/ability": "^6.7.3",
|
|
@@ -105,7 +102,6 @@
|
|
|
105
102
|
"@tanstack/react-query": "^5.90.21",
|
|
106
103
|
"axios": "^1.13.1",
|
|
107
104
|
"react": "^19.1.0",
|
|
108
|
-
"vite": "^6.0.0 || ^7.0.0",
|
|
109
105
|
"zod": "^4.1.12"
|
|
110
106
|
},
|
|
111
107
|
"peerDependenciesMeta": {
|
|
@@ -114,14 +110,12 @@
|
|
|
114
110
|
},
|
|
115
111
|
"@casl/react": {
|
|
116
112
|
"optional": true
|
|
117
|
-
},
|
|
118
|
-
"vite": {
|
|
119
|
-
"optional": true
|
|
120
113
|
}
|
|
121
114
|
},
|
|
122
115
|
"engines": {
|
|
123
116
|
"node": ">= 14",
|
|
124
|
-
"
|
|
117
|
+
"npm": ">= 8",
|
|
118
|
+
"yarn": ">= 3.2"
|
|
125
119
|
},
|
|
126
|
-
"packageManager": "
|
|
120
|
+
"packageManager": "yarn@4.2.2"
|
|
127
121
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{{! Js docs }}
|
|
2
2
|
{{{genQueryJsDocs endpoint infiniteQuery=true}}}
|
|
3
3
|
{{! Infinite query definition}}
|
|
4
|
-
export const {{infiniteQueryName endpoint}} = <TData>({{#if (endpointParams endpoint)}}{ {{{endpointArgs endpoint excludePageParam=true}}} }: { {{{genEndpointParams endpoint excludePageParam=true}}} }, {{/if}}options?: AppInfiniteQueryOptions<typeof {{importedEndpointName endpoint}}, TData>{{#if hasAxiosRequestConfig}}, {{axiosRequestConfigName}}?: {{axiosRequestConfigType}}{{/if}}) => {
|
|
4
|
+
export const {{infiniteQueryName endpoint}} = <TData>({{#if (endpointParams endpoint)}}{{#if (endpointParamsAllOptional endpoint excludePageParam=true)}}params: { {{{genEndpointParams endpoint excludePageParam=true}}} } = {}{{else}}{ {{{endpointArgs endpoint excludePageParam=true}}} }: { {{{genEndpointParams endpoint excludePageParam=true}}} }{{/if}}, {{/if}}options?: AppInfiniteQueryOptions<typeof {{importedEndpointName endpoint}}, TData>{{#if hasAxiosRequestConfig}}, {{axiosRequestConfigName}}?: {{axiosRequestConfigType}}{{/if}}) => {
|
|
5
5
|
{{! Use acl check }}
|
|
6
6
|
{{#if hasAclCheck}}const { checkAcl } = {{aclCheckHook}}();{{/if}}
|
|
7
|
+
{{#if (endpointParams endpoint)}}{{#if (endpointParamsAllOptional endpoint excludePageParam=true)}}const { {{{endpointArgs endpoint excludePageParam=true}}} } = params;{{/if}}{{/if}}
|
|
7
8
|
|
|
8
9
|
return {{infiniteQueryHook}}({
|
|
9
10
|
queryKey: keys.{{endpointName endpoint}}Infinite({{#if (endpointParams endpoint)}}{{{endpointArgs endpoint excludePageParam=true}}}{{/if}}),
|
|
@@ -12,10 +13,11 @@ export const {{infiniteQueryName endpoint}} = <TData>({{#if (endpointParams endp
|
|
|
12
13
|
{{#if hasQueryFnBody}}return {{/if}}{{importedEndpointName endpoint}}({{{endpointArgs endpoint replacePageParam=true}}}{{#if hasAxiosRequestConfig}}, {{axiosRequestConfigName}}{{/if}})
|
|
13
14
|
{{#if hasQueryFnBody}} }{{/if}},
|
|
14
15
|
initialPageParam: 1,
|
|
15
|
-
getNextPageParam: (
|
|
16
|
-
const pageParam = {{pageParamName}} ?? 1;
|
|
17
|
-
|
|
16
|
+
getNextPageParam: (response) => {
|
|
17
|
+
const pageParam = (response.{{pageParamName}} ?? 1);
|
|
18
|
+
const limitParam = response.{{limitParamName}};
|
|
19
|
+
return pageParam * limitParam < response.{{totalItemsName}} ? pageParam + 1 : null;
|
|
18
20
|
},
|
|
19
21
|
...options,
|
|
20
22
|
});
|
|
21
|
-
};
|
|
23
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{{! Js docs }}
|
|
2
2
|
{{{genQueryJsDocs endpoint query=true}}}
|
|
3
3
|
{{! Query definition}}
|
|
4
|
-
export const {{queryName endpoint}} = <TData>({{#if (endpointParams endpoint)}}{ {{{endpointArgs endpoint}}} }: { {{{genEndpointParams endpoint}}} }, {{/if}}options?: AppQueryOptions<typeof {{importedEndpointName endpoint}}, TData>{{#if hasAxiosRequestConfig}}, {{axiosRequestConfigName}}?: {{axiosRequestConfigType}}{{/if}}) => {
|
|
4
|
+
export const {{queryName endpoint}} = <TData>({{#if (endpointParams endpoint)}}{{#if (endpointParamsAllOptional endpoint)}}params: { {{{genEndpointParams endpoint}}} } = {}{{else}}{ {{{endpointArgs endpoint}}} }: { {{{genEndpointParams endpoint}}} }{{/if}}, {{/if}}options?: AppQueryOptions<typeof {{importedEndpointName endpoint}}, TData>{{#if hasAxiosRequestConfig}}, {{axiosRequestConfigName}}?: {{axiosRequestConfigType}}{{/if}}) => {
|
|
5
5
|
{{! Use acl check }}
|
|
6
6
|
{{#if hasAclCheck}}const { checkAcl } = {{aclCheckHook}}();{{/if}}
|
|
7
|
-
|
|
7
|
+
{{#if (endpointParams endpoint)}}{{#if (endpointParamsAllOptional endpoint)}}const { {{{endpointArgs endpoint}}} } = params;{{/if}}{{/if}}
|
|
8
|
+
|
|
8
9
|
return {{queryHook}}({
|
|
9
10
|
queryKey: keys.{{endpointName endpoint}}({{#if (endpointParams endpoint)}}{{{endpointArgs endpoint}}}{{/if}}),
|
|
10
11
|
queryFn: {{#if hasQueryFn}}() => {{#if hasQueryFnBody}}{ {{/if}}
|
|
@@ -13,4 +14,4 @@ export const {{queryName endpoint}} = <TData>({{#if (endpointParams endpoint)}}{
|
|
|
13
14
|
{{#if hasQueryFnBody}} }{{/if}},
|
|
14
15
|
...options,
|
|
15
16
|
});
|
|
16
|
-
};
|
|
17
|
+
};
|
package/dist/acl.d.mts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import * as react from "react";
|
|
2
|
-
import { PropsWithChildren } from "react";
|
|
3
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
-
import { AbilityTuple, PureAbility, RawRuleOf, Subject } from "@casl/ability";
|
|
5
|
-
import { PackRule } from "@casl/ability/extra";
|
|
6
|
-
import { BoundCanProps } from "@casl/react";
|
|
7
|
-
|
|
8
|
-
//#region src/lib/acl/appAbility.types.d.ts
|
|
9
|
-
type AppAbilities = AbilityTuple<string, Subject>;
|
|
10
|
-
type AppAbility = PureAbility<AppAbilities>;
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/lib/acl/ability.context.d.ts
|
|
13
|
-
declare namespace AbilityContext {
|
|
14
|
-
export const Consumer: react.Consumer<AppAbility>;
|
|
15
|
-
interface ProviderProps {
|
|
16
|
-
user?: {
|
|
17
|
-
aclRules?: PackRule<RawRuleOf<AppAbility>>[];
|
|
18
|
-
} | null;
|
|
19
|
-
}
|
|
20
|
-
export const Provider: ({
|
|
21
|
-
children
|
|
22
|
-
}: PropsWithChildren<ProviderProps>) => react_jsx_runtime0.JSX.Element;
|
|
23
|
-
export const useAbility: <TAppAbilities extends AppAbilities = AppAbilities>() => PureAbility<TAppAbilities>;
|
|
24
|
-
export {};
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/lib/acl/AclGuard.d.ts
|
|
28
|
-
interface AclGuardProps<TAppAbilities extends AppAbilities = AppAbilities> {
|
|
29
|
-
canUse: TAppAbilities;
|
|
30
|
-
redirectTo?: string;
|
|
31
|
-
}
|
|
32
|
-
declare const createAclGuard: <TAppAbilities extends AppAbilities = AppAbilities>() => ({
|
|
33
|
-
canUse,
|
|
34
|
-
redirectTo,
|
|
35
|
-
children
|
|
36
|
-
}: PropsWithChildren<AclGuardProps<TAppAbilities>>) => react.ReactNode;
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/lib/acl/Can.d.ts
|
|
39
|
-
type CanAbility = PureAbility<AbilityTuple<AppAbilities[0], AppAbilities[1]>>;
|
|
40
|
-
type CanProps<TAppAbilities extends AppAbilities = AppAbilities> = {
|
|
41
|
-
use: TAppAbilities;
|
|
42
|
-
} & Omit<BoundCanProps<CanAbility>, "do" | "I" | "on" | "a" | "an" | "this">;
|
|
43
|
-
declare const Can: <TAppAbilities extends AppAbilities = AppAbilities>({
|
|
44
|
-
use,
|
|
45
|
-
...props
|
|
46
|
-
}: CanProps<TAppAbilities>) => react_jsx_runtime0.JSX.Element;
|
|
47
|
-
//#endregion
|
|
48
|
-
export { AbilityContext, type AppAbilities, type AppAbility, Can, createAclGuard };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { createContext, use, useMemo } from "react";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
//#region src/lib/config/router.context.tsx
|
|
5
|
-
let OpenApiRouter;
|
|
6
|
-
(function(_OpenApiRouter) {
|
|
7
|
-
const Context = createContext(null);
|
|
8
|
-
_OpenApiRouter.Provider = ({ children, replace }) => {
|
|
9
|
-
return /* @__PURE__ */ jsx(Context, {
|
|
10
|
-
value: useMemo(() => ({ replace }), [replace]),
|
|
11
|
-
children
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
_OpenApiRouter.useRouter = () => {
|
|
15
|
-
const context = use(Context);
|
|
16
|
-
if (!context) throw new Error("useRouter must be used within an OpenApiRouter.Provider");
|
|
17
|
-
return context;
|
|
18
|
-
};
|
|
19
|
-
})(OpenApiRouter || (OpenApiRouter = {}));
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/lib/auth/auth.context.tsx
|
|
23
|
-
let AuthContext;
|
|
24
|
-
(function(_AuthContext) {
|
|
25
|
-
const Context = createContext({});
|
|
26
|
-
_AuthContext.Provider = ({ isAuthenticated, isInitializing, logout, updateTokens, accessToken, user, userPromise, routes, loadingState, children }) => {
|
|
27
|
-
const value = useMemo(() => ({
|
|
28
|
-
isAuthenticated,
|
|
29
|
-
isInitializing,
|
|
30
|
-
logout,
|
|
31
|
-
updateTokens,
|
|
32
|
-
accessToken,
|
|
33
|
-
user,
|
|
34
|
-
userPromise,
|
|
35
|
-
routes,
|
|
36
|
-
loadingState
|
|
37
|
-
}), [
|
|
38
|
-
isAuthenticated,
|
|
39
|
-
isInitializing,
|
|
40
|
-
logout,
|
|
41
|
-
updateTokens,
|
|
42
|
-
accessToken,
|
|
43
|
-
user,
|
|
44
|
-
userPromise,
|
|
45
|
-
routes,
|
|
46
|
-
loadingState
|
|
47
|
-
]);
|
|
48
|
-
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
49
|
-
value,
|
|
50
|
-
children
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
_AuthContext.useAuth = () => {
|
|
54
|
-
return use(Context);
|
|
55
|
-
};
|
|
56
|
-
})(AuthContext || (AuthContext = {}));
|
|
57
|
-
|
|
58
|
-
//#endregion
|
|
59
|
-
export { OpenApiRouter as n, AuthContext as t };
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { a as deepMerge, p as DEFAULT_GENERATE_OPTIONS, r as writeGenerateFileData, t as generateCodeFromOpenAPIDoc, x as Profiler } from "./generateCodeFromOpenAPIDoc-B5lnFNGB.mjs";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
5
|
-
|
|
6
|
-
//#region src/generators/core/resolveConfig.ts
|
|
7
|
-
function resolveConfig({ fileConfig = {}, params: { excludeTags, inlineEndpointsExcludeModules, ...options } }) {
|
|
8
|
-
const resolvedConfig = deepMerge(DEFAULT_GENERATE_OPTIONS, fileConfig ?? {}, {
|
|
9
|
-
...options,
|
|
10
|
-
excludeTags: excludeTags?.split(","),
|
|
11
|
-
inlineEndpointsExcludeModules: inlineEndpointsExcludeModules?.split(",")
|
|
12
|
-
});
|
|
13
|
-
resolvedConfig.checkAcl = resolvedConfig.acl && resolvedConfig.checkAcl;
|
|
14
|
-
return resolvedConfig;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/generators/run/generate.runner.ts
|
|
19
|
-
const CACHE_FILE_NAME = ".openapi-codegen-cache.json";
|
|
20
|
-
async function runGenerate({ fileConfig, params, profiler = new Profiler(process.env.OPENAPI_CODEGEN_PROFILE === "1") }) {
|
|
21
|
-
const config = profiler.runSync("config.resolve", () => resolveConfig({
|
|
22
|
-
fileConfig,
|
|
23
|
-
params: params ?? {}
|
|
24
|
-
}));
|
|
25
|
-
const openApiDoc = await getOpenApiDoc(config.input, profiler);
|
|
26
|
-
const openApiHash = hashString(stableStringify(openApiDoc));
|
|
27
|
-
const optionsHash = hashString(stableStringify(getCacheableConfig(config)));
|
|
28
|
-
const cacheFilePath = path.resolve(config.output, CACHE_FILE_NAME);
|
|
29
|
-
if (config.incremental) {
|
|
30
|
-
const cached = readCache(cacheFilePath);
|
|
31
|
-
if (cached && cached.openApiHash === openApiHash && cached.optionsHash === optionsHash) return {
|
|
32
|
-
skipped: true,
|
|
33
|
-
config
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
const filesData = profiler.runSync("generate.total", () => generateCodeFromOpenAPIDoc(openApiDoc, config, profiler));
|
|
37
|
-
profiler.runSync("files.write", () => writeGenerateFileData(filesData));
|
|
38
|
-
if (config.incremental) writeCache(cacheFilePath, {
|
|
39
|
-
openApiHash,
|
|
40
|
-
optionsHash
|
|
41
|
-
});
|
|
42
|
-
return {
|
|
43
|
-
skipped: false,
|
|
44
|
-
config
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
async function getOpenApiDoc(input, profiler) {
|
|
48
|
-
const parsedDoc = await profiler.runAsync("openapi.parse", async () => await SwaggerParser.parse(input));
|
|
49
|
-
if (!profiler.runSync("openapi.detectExternalRefs", () => hasExternalRef(parsedDoc))) return parsedDoc;
|
|
50
|
-
return await profiler.runAsync("openapi.bundle", async () => await SwaggerParser.bundle(input));
|
|
51
|
-
}
|
|
52
|
-
function hasExternalRef(value) {
|
|
53
|
-
const stack = [value];
|
|
54
|
-
const visited = /* @__PURE__ */ new Set();
|
|
55
|
-
while (stack.length > 0) {
|
|
56
|
-
const current = stack.pop();
|
|
57
|
-
if (!current || typeof current !== "object") continue;
|
|
58
|
-
if (visited.has(current)) continue;
|
|
59
|
-
visited.add(current);
|
|
60
|
-
if ("$ref" in current && typeof current.$ref === "string" && !current.$ref.startsWith("#/")) return true;
|
|
61
|
-
for (const nested of Object.values(current)) if (nested && typeof nested === "object") stack.push(nested);
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
function getCacheableConfig(config) {
|
|
66
|
-
const { output, incremental, ...cacheableConfig } = config;
|
|
67
|
-
return cacheableConfig;
|
|
68
|
-
}
|
|
69
|
-
function readCache(filePath) {
|
|
70
|
-
if (!fs.existsSync(filePath)) return null;
|
|
71
|
-
try {
|
|
72
|
-
return JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
73
|
-
} catch {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function writeCache(filePath, data) {
|
|
78
|
-
const dir = path.dirname(filePath);
|
|
79
|
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
80
|
-
fs.writeFileSync(filePath, JSON.stringify(data), "utf-8");
|
|
81
|
-
}
|
|
82
|
-
function hashString(input) {
|
|
83
|
-
let hash = 2166136261;
|
|
84
|
-
for (let i = 0; i < input.length; i += 1) {
|
|
85
|
-
hash ^= input.charCodeAt(i);
|
|
86
|
-
hash = Math.imul(hash, 16777619);
|
|
87
|
-
}
|
|
88
|
-
return (hash >>> 0).toString(16);
|
|
89
|
-
}
|
|
90
|
-
function stableStringify(input) {
|
|
91
|
-
if (input === null || typeof input !== "object") return JSON.stringify(input);
|
|
92
|
-
if (Array.isArray(input)) return `[${input.map((item) => stableStringify(item)).join(",")}]`;
|
|
93
|
-
const obj = input;
|
|
94
|
-
return `{${Object.keys(obj).sort((a, b) => a.localeCompare(b)).map((key) => `${JSON.stringify(key)}:${stableStringify(obj[key])}`).join(",")}}`;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
//#endregion
|
|
98
|
-
export { resolveConfig as n, runGenerate as t };
|