@ps-aux/api-client-gen 0.1.1-rc1 → 0.7.0-rc.2
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 +42 -0
- package/dist/bin.cjs +23 -0
- package/dist/bin.mjs +21 -0
- package/dist/generateApiClient.cjs +6386 -0
- package/dist/generateApiClient.mjs +6365 -0
- package/dist/{index.js → index.cjs} +5 -2
- package/dist/index.d.cts +27 -0
- package/dist/index.d.mts +27 -0
- package/dist/index.d.ts +27 -1
- package/dist/index.mjs +10 -0
- package/package.json +66 -15
- package/templates/api.ejs +2 -9
- package/templates/http-client.eta +24 -9
- package/templates/procedure-call.ejs +36 -28
- package/dist/bin.esm.js +0 -22
- package/dist/bin.js +0 -24
- package/dist/downloadSpec.d.ts +0 -1
- package/dist/generateApiClient-BHDOH9mh.js +0 -188
- package/dist/generateApiClient-BSM0HlFv.js +0 -162
- package/dist/generateApiClient-CJ2UZFXk.js +0 -187
- package/dist/generateApiClient-DBkHX8se.js +0 -182
- package/dist/generateApiClient-DUCQclNI.js +0 -168
- package/dist/generateApiClient-PeRLjZk9.js +0 -168
- package/dist/generateApiClient-d_X--WFl.js +0 -188
- package/dist/generateApiClient-f8NyPBtp.js +0 -167
- package/dist/generateApiClient.d.ts +0 -15
- package/dist/generateOpenApiModel.d.ts +0 -11
- package/dist/generateSchemas.d.ts +0 -4
- package/dist/go.d.ts +0 -2
- package/dist/index.esm.js +0 -7
- package/rollup.config.mjs +0 -40
- package/tsconfig.json +0 -9
- package/vitest.config.ts +0 -8
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @ps-aux/api-client-gen
|
|
2
|
+
|
|
3
|
+
CLI and programmatic generator for OpenAPI clients with optional Zod schemas.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @ps-aux/api-client-gen
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## CLI
|
|
12
|
+
|
|
13
|
+
Create api-client-gen.config.json (via [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig?tab=readme-ov-file#usage-for-end-users)):
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"petstore": {
|
|
18
|
+
"srcSpec": "https://petstore3.swagger.io/api/v3/openapi.json",
|
|
19
|
+
"dstDir": "./generated",
|
|
20
|
+
"apiName": "PetstoreApi",
|
|
21
|
+
"zodSchemas": { "enabled": true }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Run: `npx gen-api-client petstore`
|
|
27
|
+
|
|
28
|
+
## Programmatic
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { generateApiClient } from '@ps-aux/api-client-gen'
|
|
32
|
+
|
|
33
|
+
await generateApiClient({
|
|
34
|
+
srcSpec: 'https://petstore3.swagger.io/api/v3/openapi.json',
|
|
35
|
+
dstDir: './generated',
|
|
36
|
+
apiName: 'PetstoreApi'
|
|
37
|
+
})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT
|
package/dist/bin.cjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var generateApiClient = require('./generateApiClient.cjs');
|
|
5
|
+
var cosmiconfig = require('cosmiconfig');
|
|
6
|
+
require('path');
|
|
7
|
+
require('fs');
|
|
8
|
+
require('fs/promises');
|
|
9
|
+
require('node:path');
|
|
10
|
+
require('node:fs/promises');
|
|
11
|
+
require('node:fs');
|
|
12
|
+
require('swagger-typescript-api');
|
|
13
|
+
require('node:url');
|
|
14
|
+
require('ts-to-zod');
|
|
15
|
+
|
|
16
|
+
const profile = process.argv[2];
|
|
17
|
+
if (!profile) throw new Error(`No profile specified`);
|
|
18
|
+
const conf = cosmiconfig.cosmiconfigSync("api-client-gen").search();
|
|
19
|
+
if (!conf) throw new Error(`No config provided`);
|
|
20
|
+
const profileConf = conf.config[profile];
|
|
21
|
+
if (!profileConf)
|
|
22
|
+
throw new Error(`Profile "${profile}" not present in the configuration`);
|
|
23
|
+
generateApiClient.generateApiClient(profileConf).catch(console.error);
|
package/dist/bin.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { g as generateApiClient } from './generateApiClient.mjs';
|
|
3
|
+
import { cosmiconfigSync } from 'cosmiconfig';
|
|
4
|
+
import 'path';
|
|
5
|
+
import 'fs';
|
|
6
|
+
import 'fs/promises';
|
|
7
|
+
import 'node:path';
|
|
8
|
+
import 'node:fs/promises';
|
|
9
|
+
import 'node:fs';
|
|
10
|
+
import 'swagger-typescript-api';
|
|
11
|
+
import 'node:url';
|
|
12
|
+
import 'ts-to-zod';
|
|
13
|
+
|
|
14
|
+
const profile = process.argv[2];
|
|
15
|
+
if (!profile) throw new Error(`No profile specified`);
|
|
16
|
+
const conf = cosmiconfigSync("api-client-gen").search();
|
|
17
|
+
if (!conf) throw new Error(`No config provided`);
|
|
18
|
+
const profileConf = conf.config[profile];
|
|
19
|
+
if (!profileConf)
|
|
20
|
+
throw new Error(`Profile "${profile}" not present in the configuration`);
|
|
21
|
+
generateApiClient(profileConf).catch(console.error);
|