@icib.dev/api-client 1.0.1 → 1.0.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/README.md +39 -15
- package/dist/api/apiClient.d.ts +1 -3620
- package/dist/api/apiClient.d.ts.map +1 -1
- package/dist/api/apiClient.js +2 -144
- package/dist/api/client.js +1 -1
- package/dist/api/contexts/items.d.ts +5 -0
- package/dist/api/contexts/items.d.ts.map +1 -0
- package/dist/api/contexts/items.js +8 -0
- package/dist/api/index.d.ts +1 -72
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -72
- package/dist/api/types/index.d.ts +1 -1926
- package/dist/api/types/index.d.ts.map +1 -1
- package/dist/scripts/generate.js +670 -0
- package/dist/scripts/hash.js +49 -0
- package/dist/scripts/verify.js +52 -0
- package/package.json +14 -8
package/README.md
CHANGED
|
@@ -21,23 +21,41 @@ const res = await apiClient.allegati.list({ page: 1, size: 10 });
|
|
|
21
21
|
const detail = await apiClient.allegati.read({ id: res.data.results[0].id });
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
## API Client Generator
|
|
24
|
+
## API Client Generator
|
|
25
25
|
|
|
26
|
-
To regenerate the client from the OpenAPI spec
|
|
26
|
+
To regenerate the client from the OpenAPI spec.
|
|
27
|
+
|
|
28
|
+
### From consuming apps (npx)
|
|
29
|
+
|
|
30
|
+
If you use this library in your app, run the generator from your project root:
|
|
27
31
|
|
|
28
32
|
```bash
|
|
29
|
-
|
|
33
|
+
npx api-client-generate
|
|
30
34
|
```
|
|
31
35
|
|
|
32
36
|
With options:
|
|
33
37
|
|
|
34
38
|
```bash
|
|
35
|
-
|
|
39
|
+
# Custom URL
|
|
40
|
+
npx api-client-generate --url https://api.example.com/docs/openapi --out api
|
|
41
|
+
|
|
42
|
+
# Using BASE_URL env (default: $BASE_URL/docs/openapi)
|
|
43
|
+
BASE_URL=https://api.example.com npx api-client-generate --out api
|
|
36
44
|
```
|
|
37
45
|
|
|
46
|
+
The client is generated in your project directory (e.g. `./api/`).
|
|
47
|
+
|
|
48
|
+
### From the library repo (maintainers)
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm run generate
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
By default, the spec URL is `$BASE_URL/docs/openapi` when the `BASE_URL` env variable is set. If unset, it falls back to the ICIB default.
|
|
55
|
+
|
|
38
56
|
### Output
|
|
39
57
|
|
|
40
|
-
The generator creates an `api/` folder:
|
|
58
|
+
The generator creates an `api/` folder and a local manifest (`api-client.manifest.json`, gitignored):
|
|
41
59
|
|
|
42
60
|
```
|
|
43
61
|
api/
|
|
@@ -50,6 +68,22 @@ api/
|
|
|
50
68
|
└── index.ts # Re-exports all contexts and types
|
|
51
69
|
```
|
|
52
70
|
|
|
71
|
+
### Hash verification
|
|
72
|
+
|
|
73
|
+
The build verifies that the generated client matches the current OpenAPI docs. When you run `npm run build`, it:
|
|
74
|
+
|
|
75
|
+
1. Reads the manifest (created by `generate`)
|
|
76
|
+
2. Fetches the current docs and compares their hash
|
|
77
|
+
3. Hashes the generated client files and compares with the manifest
|
|
78
|
+
|
|
79
|
+
**If docs changed:** Build fails with:
|
|
80
|
+
> API docs have changed. Run `npm run generate` to regenerate the client, then update your application.
|
|
81
|
+
|
|
82
|
+
**If client was manually edited:** Build fails with:
|
|
83
|
+
> Generated client files were modified. Run `npm run generate` to regenerate.
|
|
84
|
+
|
|
85
|
+
**If manifest is missing:** Run `npm run generate` first (e.g. after a fresh clone).
|
|
86
|
+
|
|
53
87
|
### JSDoc documentation
|
|
54
88
|
|
|
55
89
|
The generated client includes JSDoc comments from the OpenAPI spec:
|
|
@@ -77,13 +111,3 @@ await apiClient.QR_Code.generateCsv(
|
|
|
77
111
|
{ download: true, filename: "qrcodes.csv" },
|
|
78
112
|
);
|
|
79
113
|
```
|
|
80
|
-
|
|
81
|
-
## Publishing
|
|
82
|
-
|
|
83
|
-
To publish to npm under the `@icib.dev` scope:
|
|
84
|
-
|
|
85
|
-
1. Ensure you're logged in: `npm login`
|
|
86
|
-
2. Create the org if needed: `npm org create icib.dev` (or add your user to it)
|
|
87
|
-
3. Publish: `npm publish --access public`
|
|
88
|
-
|
|
89
|
-
The `prepublishOnly` script will automatically run `generate` and `build` before publishing.
|