@povio/openapi-codegen-cli 0.0.9

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 ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@povio/openapi-codegen-cli",
3
+ "version": "0.0.9",
4
+ "bin": {
5
+ "openapi-codegen": "./dist/sh.js"
6
+ },
7
+ "type": "module",
8
+ "scripts": {
9
+ "start": "node --import tsx/esm ./src/sh.ts",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest",
12
+ "build:clean": "rm -rf ./dist",
13
+ "build": "yarn build:clean && node ./esbuild.mjs && chmod +x ./dist/sh.js",
14
+ "build:check": "yarn tsc --project . --noEmit",
15
+ "start:dist": "node ./dist/sh.js",
16
+ "lint": "eslint --fix",
17
+ "format:check": "prettier --check .",
18
+ "format:fix": "prettier --write .",
19
+ "push": "yarn exec ./scripts/publish.sh"
20
+ },
21
+ "files": [
22
+ "dist/*",
23
+ "src/generators/templates/**",
24
+ "README.md"
25
+ ],
26
+ "keywords": [
27
+ "povio",
28
+ "openapi",
29
+ "codegen",
30
+ "zod",
31
+ "react-query"
32
+ ],
33
+ "homepage": "https://github.com/povio/openapi-codegen-cli",
34
+ "bugs": "https://github.com/povio/openapi-codegen-cli/issues",
35
+ "repository": {
36
+ "url": "git+https://github.com/povio/openapi-codegen-cli.git",
37
+ "type": "git"
38
+ },
39
+ "license": "BSD-3-Clause",
40
+ "devDependencies": {
41
+ "@apidevtools/swagger-parser": "^10.1.0",
42
+ "@types/node": "^20.12.12",
43
+ "@types/prettier": "^3.0.0",
44
+ "@types/prompt-sync": "^4.2.3",
45
+ "@types/yargs": "^17.0.32",
46
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
47
+ "@typescript-eslint/parser": "^6.21.0",
48
+ "chalk": "^5.3.0",
49
+ "esbuild": "^0.21.3",
50
+ "eslint": "^8.57.0",
51
+ "eslint-config-prettier": "^9.1.0",
52
+ "eslint-plugin-prettier": "^5.1.3",
53
+ "handlebars": "^4.7.8",
54
+ "openapi-types": "^12.1.3",
55
+ "prettier": "^3.2.5",
56
+ "prompt-sync": "^4.2.0",
57
+ "reflect-metadata": "^0.2.2",
58
+ "ts-node": "^10.9.2",
59
+ "ts-pattern": "^5.3.1",
60
+ "tsx": "^4.10.5",
61
+ "type-fest": "^4.26.0",
62
+ "typescript": "^5.4.5",
63
+ "vitest": "^2.0.5",
64
+ "yargs": "^17.7.2"
65
+ },
66
+ "engines": {
67
+ "node": ">= 14",
68
+ "yarn": ">= 3.2",
69
+ "npm": ">= 8"
70
+ },
71
+ "packageManager": "yarn@4.2.2"
72
+ }
@@ -0,0 +1,35 @@
1
+ {{! Rest client import}}
2
+ {{{genImport restClientImport}}}
3
+ {{! Zod import }}
4
+ {{#if hasZodImport}}
5
+ {{{genImport zodImport}}}
6
+ {{/if}}
7
+ {{! Models import }}
8
+ {{#each modelsImports as | modelsImport |}}
9
+ {{{genImport modelsImport}}}
10
+ {{/each}}
11
+
12
+ {{#if includeNamespace}}
13
+ export namespace {{namespace}} {
14
+ {{/if}}
15
+ {{! Endpoints export }}
16
+ {{#each endpoints as | endpoint |}}
17
+ export const {{endpointName endpoint}} = ({{{genEndpointParams endpoint}}}) => {
18
+ return {{../restClientName}}.{{endpoint.method}}(
19
+ {{! Response }}
20
+ { resSchema: {{importedZodSchemaName endpoint.response}} },
21
+ {{! Path }}
22
+ `{{endpointPath endpoint}}`,
23
+ {{! Body }}
24
+ {{#with (endpointBody endpoint) as | endpointBody |}}
25
+ {{#if endpointBody}}{{endpointBody.name}}, {{/if}}
26
+ {{/with}}
27
+ {{! Config }}
28
+ {{{genEndpointConfig endpoint}}}
29
+ )
30
+ };
31
+
32
+ {{/each}}
33
+ {{#if includeNamespace}}
34
+ }
35
+ {{/if}}
@@ -0,0 +1,20 @@
1
+ {{! Zod import}}
2
+ {{{genImport zodImport}}}
3
+ {{! Models import }}
4
+ {{#each modelsImports as | modelsImport |}}
5
+ {{{genImport modelsImport}}}
6
+ {{/each}}
7
+
8
+ {{#if includeNamespace}}
9
+ export namespace {{namespace}} {
10
+ {{/if}}
11
+ {{#each zodSchemas as | zodSchema |}}
12
+ {{! Zod schema export }}
13
+ export const {{@key}} = {{{zodSchema}}};
14
+ {{! Zod schema infered type export }}
15
+ export type {{zodInferedType @key}} = z.infer<typeof {{@key}}>;
16
+
17
+ {{/each}}
18
+ {{#if includeNamespace}}
19
+ }
20
+ {{/if}}
@@ -0,0 +1,18 @@
1
+ {
2
+ {{! Query params}}
3
+ {{#if endpointConfig.params}}
4
+ params: {
5
+ {{#each endpointConfig.params as | param |}}
6
+ {{param.name}},
7
+ {{/each}}
8
+ },
9
+ {{/if}}
10
+ {{! Headers}}
11
+ {{#if endpointConfig.headers}}
12
+ headers: {
13
+ {{#each endpointConfig.headers as | header |}}
14
+ '{{@key}}': '{{header}}',
15
+ {{/each}}
16
+ },
17
+ {{/if}}
18
+ }
@@ -0,0 +1 @@
1
+ {{#each (endpointParams endpoint) as | endpointParam |}}{{endpointParam.name}}{{#unless endpointParam.required}}?{{/unless}}: {{endpointParam.type}}, {{/each}}
@@ -0,0 +1 @@
1
+ import { {{commaSeparated import.bindings}} } from "{{import.from}}";
@@ -0,0 +1,5 @@
1
+ export const keys = {
2
+ {{#each endpoints as | endpoint |}}
3
+ {{endpointName endpoint}}: ({{{genEndpointParams endpoint}}}) => ["{{endpoint.path}}", {{{endpointArgs endpoint}}}] as const,
4
+ {{/each}}
5
+ };
@@ -0,0 +1,5 @@
1
+ export const {{queryName endpoint}} = () => {
2
+ return {{queryHook}}({
3
+ mutationFn: {{#if (moreThanOneParameter endpoint)}}({ {{{endpointArgs endpoint}}} }: { {{{genEndpointParams endpoint}}} }) => {{importedEndpointName endpoint}}({{{endpointArgs endpoint}}}){{else}}{{importedEndpointName endpoint}}{{/if}},
4
+ });
5
+ };
@@ -0,0 +1,6 @@
1
+ export const {{queryName endpoint}} = ({{{genEndpointParams endpoint}}}) => {
2
+ return {{queryHook}}({
3
+ queryKey: keys.{{endpointName endpoint}}({{{endpointArgs endpoint}}}),
4
+ queryFn: {{#if (endpointParams endpoint)}}() => {{importedEndpointName endpoint}}({{{endpointArgs endpoint}}}){{else}}{{importedEndpointName endpoint}}{{/if}},
5
+ });
6
+ };
@@ -0,0 +1,26 @@
1
+ {{! React query import }}
2
+ {{{genImport queryImport}}}
3
+ {{! Models import }}
4
+ {{#each modelsImports as | modelsImport |}}
5
+ {{{genImport modelsImport}}}
6
+ {{/each}}
7
+ {{! Endpoints import }}
8
+ {{#each endpointsImports as | endpointsImport |}}
9
+ {{{genImport endpointsImport}}}
10
+ {{/each}}
11
+
12
+ {{#if includeNamespace}}
13
+ export namespace {{namespace}} {
14
+ {{/if}}
15
+ {{! Query keys export}}
16
+ {{{genQueryKeys queryEndpoints}}}
17
+
18
+ {{! Query export }}
19
+ {{#each endpoints as | endpoint |}}
20
+ {{{genQuery endpoint}}}
21
+
22
+ {{/each}}
23
+
24
+ {{#if includeNamespace}}
25
+ }
26
+ {{/if}}