@icib.dev/api-client 1.0.4 → 1.1.0
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 +28 -12
- package/dist/scripts/generate.js +36 -13
- package/dist/scripts/verify.js +0 -0
- package/package.json +9 -16
- package/dist/api/apiClient.d.ts +0 -6
- package/dist/api/apiClient.d.ts.map +0 -1
- package/dist/api/apiClient.js +0 -5
- package/dist/api/client.d.ts +0 -15
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/client.js +0 -37
- package/dist/api/contexts/QR_Code.d.ts +0 -41
- package/dist/api/contexts/QR_Code.d.ts.map +0 -1
- package/dist/api/contexts/QR_Code.js +0 -42
- package/dist/api/contexts/allegati.d.ts +0 -58
- package/dist/api/contexts/allegati.d.ts.map +0 -1
- package/dist/api/contexts/allegati.js +0 -52
- package/dist/api/contexts/allegato.d.ts +0 -19
- package/dist/api/contexts/allegato.d.ts.map +0 -1
- package/dist/api/contexts/allegato.js +0 -22
- package/dist/api/contexts/articolo.d.ts +0 -98
- package/dist/api/contexts/articolo.d.ts.map +0 -1
- package/dist/api/contexts/articolo.js +0 -76
- package/dist/api/contexts/aspetto_beni.d.ts +0 -73
- package/dist/api/contexts/aspetto_beni.d.ts.map +0 -1
- package/dist/api/contexts/aspetto_beni.js +0 -57
- package/dist/api/contexts/auth.d.ts +0 -23
- package/dist/api/contexts/auth.d.ts.map +0 -1
- package/dist/api/contexts/auth.js +0 -29
- package/dist/api/contexts/azienda.d.ts +0 -81
- package/dist/api/contexts/azienda.d.ts.map +0 -1
- package/dist/api/contexts/azienda.js +0 -61
- package/dist/api/contexts/banca.d.ts +0 -77
- package/dist/api/contexts/banca.d.ts.map +0 -1
- package/dist/api/contexts/banca.js +0 -59
- package/dist/api/contexts/building-media.d.ts +0 -109
- package/dist/api/contexts/building-media.d.ts.map +0 -1
- package/dist/api/contexts/building-media.js +0 -93
- package/dist/api/contexts/building.d.ts +0 -77
- package/dist/api/contexts/building.d.ts.map +0 -1
- package/dist/api/contexts/building.js +0 -59
- package/dist/api/contexts/catalog.d.ts +0 -77
- package/dist/api/contexts/catalog.d.ts.map +0 -1
- package/dist/api/contexts/catalog.js +0 -59
- package/dist/api/contexts/causale_trasporto.d.ts +0 -77
- package/dist/api/contexts/causale_trasporto.d.ts.map +0 -1
- package/dist/api/contexts/causale_trasporto.js +0 -59
- package/dist/api/contexts/change_password.d.ts +0 -5
- package/dist/api/contexts/change_password.d.ts.map +0 -1
- package/dist/api/contexts/change_password.js +0 -8
- package/dist/api/contexts/client-catalog.d.ts +0 -81
- package/dist/api/contexts/client-catalog.d.ts.map +0 -1
- package/dist/api/contexts/client-catalog.js +0 -61
- package/dist/api/contexts/client-user.d.ts +0 -92
- package/dist/api/contexts/client-user.d.ts.map +0 -1
- package/dist/api/contexts/client-user.js +0 -63
- package/dist/api/contexts/client.d.ts +0 -85
- package/dist/api/contexts/client.d.ts.map +0 -1
- package/dist/api/contexts/client.js +0 -67
- package/dist/api/contexts/cliente_fornitore.d.ts +0 -157
- package/dist/api/contexts/cliente_fornitore.d.ts.map +0 -1
- package/dist/api/contexts/cliente_fornitore.js +0 -100
- package/dist/api/contexts/cliente_fornitore_banca.d.ts +0 -73
- package/dist/api/contexts/cliente_fornitore_banca.d.ts.map +0 -1
- package/dist/api/contexts/cliente_fornitore_banca.js +0 -57
- package/dist/api/contexts/cliente_fornitore_contatto.d.ts +0 -85
- package/dist/api/contexts/cliente_fornitore_contatto.d.ts.map +0 -1
- package/dist/api/contexts/cliente_fornitore_contatto.js +0 -63
- package/dist/api/contexts/cliente_fornitore_sede.d.ts +0 -81
- package/dist/api/contexts/cliente_fornitore_sede.d.ts.map +0 -1
- package/dist/api/contexts/cliente_fornitore_sede.js +0 -61
- package/dist/api/contexts/codice_iva.d.ts +0 -81
- package/dist/api/contexts/codice_iva.d.ts.map +0 -1
- package/dist/api/contexts/codice_iva.js +0 -61
- package/dist/api/contexts/comment.d.ts +0 -73
- package/dist/api/contexts/comment.d.ts.map +0 -1
- package/dist/api/contexts/comment.js +0 -57
- package/dist/api/contexts/contact.d.ts +0 -81
- package/dist/api/contexts/contact.d.ts.map +0 -1
- package/dist/api/contexts/contact.js +0 -61
- package/dist/api/contexts/contract.d.ts +0 -73
- package/dist/api/contexts/contract.d.ts.map +0 -1
- package/dist/api/contexts/contract.js +0 -57
- package/dist/api/contexts/dashboard.d.ts +0 -9
- package/dist/api/contexts/dashboard.d.ts.map +0 -1
- package/dist/api/contexts/dashboard.js +0 -12
- package/dist/api/contexts/documento.d.ts +0 -1036
- package/dist/api/contexts/documento.d.ts.map +0 -1
- package/dist/api/contexts/documento.js +0 -733
- package/dist/api/contexts/equipment.d.ts +0 -85
- package/dist/api/contexts/equipment.d.ts.map +0 -1
- package/dist/api/contexts/equipment.js +0 -63
- package/dist/api/contexts/equipment_document.d.ts +0 -109
- package/dist/api/contexts/equipment_document.d.ts.map +0 -1
- package/dist/api/contexts/equipment_document.js +0 -93
- package/dist/api/contexts/equipment_field.d.ts +0 -77
- package/dist/api/contexts/equipment_field.d.ts.map +0 -1
- package/dist/api/contexts/equipment_field.js +0 -59
- package/dist/api/contexts/equipment_model.d.ts +0 -77
- package/dist/api/contexts/equipment_model.d.ts.map +0 -1
- package/dist/api/contexts/equipment_model.js +0 -59
- package/dist/api/contexts/equipment_model_checklist_item.d.ts +0 -73
- package/dist/api/contexts/equipment_model_checklist_item.d.ts.map +0 -1
- package/dist/api/contexts/equipment_model_checklist_item.js +0 -57
- package/dist/api/contexts/fe-invio.d.ts +0 -110
- package/dist/api/contexts/fe-invio.d.ts.map +0 -1
- package/dist/api/contexts/fe-invio.js +0 -76
- package/dist/api/contexts/fe-ricezione.d.ts +0 -385
- package/dist/api/contexts/fe-ricezione.d.ts.map +0 -1
- package/dist/api/contexts/fe-ricezione.js +0 -287
- package/dist/api/contexts/field.d.ts +0 -85
- package/dist/api/contexts/field.d.ts.map +0 -1
- package/dist/api/contexts/field.js +0 -63
- package/dist/api/contexts/info.d.ts +0 -5
- package/dist/api/contexts/info.d.ts.map +0 -1
- package/dist/api/contexts/info.js +0 -8
- package/dist/api/contexts/items.d.ts +0 -5
- package/dist/api/contexts/items.d.ts.map +0 -1
- package/dist/api/contexts/items.js +0 -8
- package/dist/api/contexts/law.d.ts +0 -89
- package/dist/api/contexts/law.d.ts.map +0 -1
- package/dist/api/contexts/law.js +0 -73
- package/dist/api/contexts/magazzino.d.ts +0 -81
- package/dist/api/contexts/magazzino.d.ts.map +0 -1
- package/dist/api/contexts/magazzino.js +0 -61
- package/dist/api/contexts/me.d.ts +0 -5
- package/dist/api/contexts/me.d.ts.map +0 -1
- package/dist/api/contexts/me.js +0 -8
- package/dist/api/contexts/media.d.ts +0 -57
- package/dist/api/contexts/media.d.ts.map +0 -1
- package/dist/api/contexts/media.js +0 -44
- package/dist/api/contexts/movimento.d.ts +0 -85
- package/dist/api/contexts/movimento.d.ts.map +0 -1
- package/dist/api/contexts/movimento.js +0 -63
- package/dist/api/contexts/movimento_magazzino.d.ts +0 -97
- package/dist/api/contexts/movimento_magazzino.d.ts.map +0 -1
- package/dist/api/contexts/movimento_magazzino.js +0 -69
- package/dist/api/contexts/non-conformity-product.d.ts +0 -81
- package/dist/api/contexts/non-conformity-product.d.ts.map +0 -1
- package/dist/api/contexts/non-conformity-product.js +0 -61
- package/dist/api/contexts/non_conformity.d.ts +0 -113
- package/dist/api/contexts/non_conformity.d.ts.map +0 -1
- package/dist/api/contexts/non_conformity.js +0 -85
- package/dist/api/contexts/non_conformity_equipment.d.ts +0 -85
- package/dist/api/contexts/non_conformity_equipment.d.ts.map +0 -1
- package/dist/api/contexts/non_conformity_equipment.js +0 -63
- package/dist/api/contexts/offer-item-product.d.ts +0 -85
- package/dist/api/contexts/offer-item-product.d.ts.map +0 -1
- package/dist/api/contexts/offer-item-product.js +0 -63
- package/dist/api/contexts/offer-item.d.ts +0 -77
- package/dist/api/contexts/offer-item.d.ts.map +0 -1
- package/dist/api/contexts/offer-item.js +0 -59
- package/dist/api/contexts/offer.d.ts +0 -111
- package/dist/api/contexts/offer.d.ts.map +0 -1
- package/dist/api/contexts/offer.js +0 -85
- package/dist/api/contexts/pagamento.d.ts +0 -97
- package/dist/api/contexts/pagamento.d.ts.map +0 -1
- package/dist/api/contexts/pagamento.js +0 -79
- package/dist/api/contexts/piano_conti.d.ts +0 -77
- package/dist/api/contexts/piano_conti.d.ts.map +0 -1
- package/dist/api/contexts/piano_conti.js +0 -59
- package/dist/api/contexts/price-tag.d.ts +0 -77
- package/dist/api/contexts/price-tag.d.ts.map +0 -1
- package/dist/api/contexts/price-tag.js +0 -59
- package/dist/api/contexts/product-accessory.d.ts +0 -77
- package/dist/api/contexts/product-accessory.d.ts.map +0 -1
- package/dist/api/contexts/product-accessory.js +0 -59
- package/dist/api/contexts/product-family.d.ts +0 -81
- package/dist/api/contexts/product-family.d.ts.map +0 -1
- package/dist/api/contexts/product-family.js +0 -69
- package/dist/api/contexts/product-installation.d.ts +0 -77
- package/dist/api/contexts/product-installation.d.ts.map +0 -1
- package/dist/api/contexts/product-installation.js +0 -59
- package/dist/api/contexts/product-law.d.ts +0 -77
- package/dist/api/contexts/product-law.d.ts.map +0 -1
- package/dist/api/contexts/product-law.js +0 -59
- package/dist/api/contexts/product-media.d.ts +0 -117
- package/dist/api/contexts/product-media.d.ts.map +0 -1
- package/dist/api/contexts/product-media.js +0 -101
- package/dist/api/contexts/product-supplier.d.ts +0 -81
- package/dist/api/contexts/product-supplier.d.ts.map +0 -1
- package/dist/api/contexts/product-supplier.js +0 -61
- package/dist/api/contexts/product.d.ts +0 -161
- package/dist/api/contexts/product.d.ts.map +0 -1
- package/dist/api/contexts/product.js +0 -123
- package/dist/api/contexts/registry.d.ts +0 -89
- package/dist/api/contexts/registry.d.ts.map +0 -1
- package/dist/api/contexts/registry.js +0 -65
- package/dist/api/contexts/registry_model.d.ts +0 -97
- package/dist/api/contexts/registry_model.d.ts.map +0 -1
- package/dist/api/contexts/registry_model.js +0 -85
- package/dist/api/contexts/scadenzario.d.ts +0 -151
- package/dist/api/contexts/scadenzario.d.ts.map +0 -1
- package/dist/api/contexts/scadenzario.js +0 -106
- package/dist/api/contexts/scadenzario_tipologia.d.ts +0 -73
- package/dist/api/contexts/scadenzario_tipologia.d.ts.map +0 -1
- package/dist/api/contexts/scadenzario_tipologia.js +0 -57
- package/dist/api/contexts/sezionale.d.ts +0 -81
- package/dist/api/contexts/sezionale.d.ts.map +0 -1
- package/dist/api/contexts/sezionale.js +0 -61
- package/dist/api/contexts/supplier.d.ts +0 -81
- package/dist/api/contexts/supplier.d.ts.map +0 -1
- package/dist/api/contexts/supplier.js +0 -69
- package/dist/api/contexts/tipo_articolo.d.ts +0 -73
- package/dist/api/contexts/tipo_articolo.d.ts.map +0 -1
- package/dist/api/contexts/tipo_articolo.js +0 -57
- package/dist/api/contexts/unitamisura.d.ts +0 -77
- package/dist/api/contexts/unitamisura.d.ts.map +0 -1
- package/dist/api/contexts/unitamisura.js +0 -59
- package/dist/api/contexts/utente.d.ts +0 -99
- package/dist/api/contexts/utente.d.ts.map +0 -1
- package/dist/api/contexts/utente.js +0 -77
- package/dist/api/contexts/validation.d.ts +0 -81
- package/dist/api/contexts/validation.d.ts.map +0 -1
- package/dist/api/contexts/validation.js +0 -61
- package/dist/api/contexts/visit-equipment-media.d.ts +0 -109
- package/dist/api/contexts/visit-equipment-media.d.ts.map +0 -1
- package/dist/api/contexts/visit-equipment-media.js +0 -93
- package/dist/api/contexts/visit-equipment.d.ts +0 -87
- package/dist/api/contexts/visit-equipment.d.ts.map +0 -1
- package/dist/api/contexts/visit-equipment.js +0 -69
- package/dist/api/contexts/visit-job.d.ts +0 -77
- package/dist/api/contexts/visit-job.d.ts.map +0 -1
- package/dist/api/contexts/visit-job.js +0 -59
- package/dist/api/contexts/visit-technician.d.ts +0 -77
- package/dist/api/contexts/visit-technician.d.ts.map +0 -1
- package/dist/api/contexts/visit-technician.js +0 -59
- package/dist/api/contexts/visit.d.ts +0 -107
- package/dist/api/contexts/visit.d.ts.map +0 -1
- package/dist/api/contexts/visit.js +0 -83
- package/dist/api/index.d.ts +0 -5
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -4
- package/dist/api/types/index.d.ts +0 -10
- package/dist/api/types/index.d.ts.map +0 -1
- package/dist/api/types/index.js +0 -2
package/README.md
CHANGED
|
@@ -1,29 +1,41 @@
|
|
|
1
1
|
# @icib.dev/api-client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Generator for strictly-typed TypeScript API clients from OpenAPI specs. The client is generated in your project—nothing is published to npm.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @icib.dev/api-client
|
|
8
|
+
npm install @icib.dev/api-client axios
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
|
+
1. Generate the client in your project:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx api-client-generate
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
2. Import from your generated client:
|
|
20
|
+
|
|
13
21
|
```typescript
|
|
14
|
-
import { setAuthToken, apiClient } from "
|
|
22
|
+
import { setAuthToken, apiClient } from "./api"; // or your --out path
|
|
15
23
|
|
|
16
|
-
// Set your auth token (e.g. from env)
|
|
17
24
|
setAuthToken(process.env.API_TOKEN);
|
|
18
|
-
|
|
19
|
-
// Use the API - fully typed!
|
|
20
25
|
const res = await apiClient.allegati.list({ page: 1, size: 10 });
|
|
21
|
-
const detail = await apiClient.allegati.read({ id: res.data.results[0].id });
|
|
22
26
|
```
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
3. Add verify to your build (fails if docs changed or client was modified):
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "api-client-verify && tsc"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
25
37
|
|
|
26
|
-
|
|
38
|
+
## API Client Generator
|
|
27
39
|
|
|
28
40
|
### From consuming apps (npx)
|
|
29
41
|
|
|
@@ -42,9 +54,13 @@ npx api-client-generate --url https://api.example.com/docs/openapi --out api
|
|
|
42
54
|
# Using BASE_URL env (default: $BASE_URL/docs/openapi)
|
|
43
55
|
BASE_URL=https://api.example.com npx api-client-generate --out api
|
|
44
56
|
|
|
45
|
-
# Custom base path (
|
|
57
|
+
# Custom base path (default empty; when set, included in axios baseURL)
|
|
46
58
|
npx api-client-generate --base-path /v1/api
|
|
47
59
|
BASE_PATH=/v2 npx api-client-generate
|
|
60
|
+
|
|
61
|
+
# Custom client base URL (default: from spec URL, BASE_URL, or spec host)
|
|
62
|
+
npx api-client-generate --base-url https://api.mycompany.com
|
|
63
|
+
BASE_URL=https://api.mycompany.com npx api-client-generate
|
|
48
64
|
```
|
|
49
65
|
|
|
50
66
|
The client is generated in your project directory (e.g. `./api/`).
|
|
@@ -74,7 +90,7 @@ api/
|
|
|
74
90
|
|
|
75
91
|
### Hash verification
|
|
76
92
|
|
|
77
|
-
|
|
93
|
+
Add `api-client-verify` before your build to ensure the generated client matches the current OpenAPI docs. When you run your build, it:
|
|
78
94
|
|
|
79
95
|
1. Reads the manifest (created by `generate`)
|
|
80
96
|
2. Fetches the current docs and compares their hash
|
|
@@ -102,7 +118,7 @@ The generated client includes JSDoc comments from the OpenAPI spec:
|
|
|
102
118
|
Endpoints that return files (CSV, PDF, etc.) are detected from the spec (description, path patterns like `/download/`, `x-response-type: blob`). They return `Blob` and support `download: true` to trigger a browser download:
|
|
103
119
|
|
|
104
120
|
```typescript
|
|
105
|
-
import { apiClient } from "
|
|
121
|
+
import { apiClient } from "./api";
|
|
106
122
|
|
|
107
123
|
// Get blob in response.data
|
|
108
124
|
const res = await apiClient.QR_Code.downloadUnassigned({ page: 1, size: 100 });
|
package/dist/scripts/generate.js
CHANGED
|
@@ -19,6 +19,7 @@ function parseArgs() {
|
|
|
19
19
|
let url = getDefaultUrl();
|
|
20
20
|
let out = DEFAULT_OUT;
|
|
21
21
|
let basePath = process.env.BASE_PATH;
|
|
22
|
+
let baseUrl = process.env.BASE_URL;
|
|
22
23
|
for (let i = 0; i < args.length; i++) {
|
|
23
24
|
if (args[i] === "--url" && args[i + 1]) {
|
|
24
25
|
url = args[++i];
|
|
@@ -26,11 +27,16 @@ function parseArgs() {
|
|
|
26
27
|
else if (args[i] === "--out" && args[i + 1]) {
|
|
27
28
|
out = args[++i];
|
|
28
29
|
}
|
|
29
|
-
else if ((args[i] === "--base-path" || args[i] === "--basePath") &&
|
|
30
|
+
else if ((args[i] === "--base-path" || args[i] === "--basePath") &&
|
|
31
|
+
args[i + 1]) {
|
|
30
32
|
basePath = args[++i];
|
|
31
33
|
}
|
|
34
|
+
else if ((args[i] === "--base-url" || args[i] === "--baseUrl") &&
|
|
35
|
+
args[i + 1]) {
|
|
36
|
+
baseUrl = args[++i];
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
|
-
return { url, out, basePath };
|
|
39
|
+
return { url, out, basePath, baseUrl };
|
|
34
40
|
}
|
|
35
41
|
async function fetchSpec(url) {
|
|
36
42
|
const res = await fetch(url);
|
|
@@ -61,7 +67,7 @@ function getBaseUrl(doc) {
|
|
|
61
67
|
}
|
|
62
68
|
return "https://api.icib.dev/api";
|
|
63
69
|
}
|
|
64
|
-
/** Returns origin only (no basePath) for axios baseURL
|
|
70
|
+
/** Returns origin only (no basePath) for axios baseURL */
|
|
65
71
|
function getOrigin(doc) {
|
|
66
72
|
const oas2 = doc;
|
|
67
73
|
if (oas2.host) {
|
|
@@ -70,9 +76,15 @@ function getOrigin(doc) {
|
|
|
70
76
|
}
|
|
71
77
|
return "https://api.icib.dev";
|
|
72
78
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
/** Extract origin (protocol + host) from a URL string */
|
|
80
|
+
function getOriginFromUrl(url) {
|
|
81
|
+
try {
|
|
82
|
+
const parsed = new URL(url);
|
|
83
|
+
return `${parsed.protocol}//${parsed.host}`;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
76
88
|
}
|
|
77
89
|
function getDefinitions(doc) {
|
|
78
90
|
return doc.definitions ?? doc.components?.schemas ?? {};
|
|
@@ -172,11 +184,11 @@ function generateTypes(definitions) {
|
|
|
172
184
|
lines.push("}\n");
|
|
173
185
|
return lines.join("\n");
|
|
174
186
|
}
|
|
175
|
-
function extractOperations(paths,
|
|
187
|
+
function extractOperations(paths, definitions) {
|
|
176
188
|
const ops = [];
|
|
177
189
|
const methods = ["get", "post", "put", "patch", "delete"];
|
|
178
190
|
for (const [path, pathItem] of Object.entries(paths)) {
|
|
179
|
-
const fullPath =
|
|
191
|
+
const fullPath = path.startsWith("/") ? path : `/${path}`;
|
|
180
192
|
for (const method of methods) {
|
|
181
193
|
const op = pathItem[method];
|
|
182
194
|
if (!op?.operationId)
|
|
@@ -619,13 +631,21 @@ function generateIndex(contextTags) {
|
|
|
619
631
|
return exports.join("\n");
|
|
620
632
|
}
|
|
621
633
|
async function main() {
|
|
622
|
-
const { url, out, basePath: basePathOverride } = parseArgs();
|
|
634
|
+
const { url, out, basePath: basePathOverride, baseUrl: baseUrlOverride } = parseArgs();
|
|
623
635
|
console.log(`Fetching spec from ${url}...`);
|
|
624
636
|
const rawSpec = await loadRawSpec(url);
|
|
625
637
|
const doc = await parseSpec(rawSpec);
|
|
626
|
-
const baseUrl =
|
|
638
|
+
const baseUrl = (() => {
|
|
639
|
+
const override = baseUrlOverride ?? process.env.BASE_URL;
|
|
640
|
+
if (override)
|
|
641
|
+
return getOriginFromUrl(override) ?? override.replace(/\/$/, "");
|
|
642
|
+
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
643
|
+
return getOriginFromUrl(url) ?? getOrigin(doc);
|
|
644
|
+
}
|
|
645
|
+
return getOrigin(doc);
|
|
646
|
+
})();
|
|
627
647
|
const basePath = (() => {
|
|
628
|
-
const raw = basePathOverride ??
|
|
648
|
+
const raw = basePathOverride ?? "";
|
|
629
649
|
if (raw === "")
|
|
630
650
|
return "";
|
|
631
651
|
return raw.startsWith("/") ? raw : `/${raw}`;
|
|
@@ -636,7 +656,7 @@ async function main() {
|
|
|
636
656
|
console.log(`Base path: ${basePath}`);
|
|
637
657
|
console.log(`Paths: ${Object.keys(paths).length}`);
|
|
638
658
|
console.log(`Definitions: ${Object.keys(definitions).length}`);
|
|
639
|
-
const ops = extractOperations(paths,
|
|
659
|
+
const ops = extractOperations(paths, definitions);
|
|
640
660
|
const byTag = groupByTag(ops, paths);
|
|
641
661
|
const cwd = process.cwd();
|
|
642
662
|
const outDir = join(cwd, out);
|
|
@@ -644,8 +664,11 @@ async function main() {
|
|
|
644
664
|
const contextsDir = join(outDir, "contexts");
|
|
645
665
|
mkdirSync(typesDir, { recursive: true });
|
|
646
666
|
mkdirSync(contextsDir, { recursive: true });
|
|
667
|
+
const clientBaseUrl = basePath
|
|
668
|
+
? `${baseUrl.replace(/\/$/, "")}${basePath}`
|
|
669
|
+
: baseUrl;
|
|
647
670
|
writeFileSync(join(typesDir, "index.ts"), generateTypes(definitions));
|
|
648
|
-
writeFileSync(join(outDir, "client.ts"), generateClient(
|
|
671
|
+
writeFileSync(join(outDir, "client.ts"), generateClient(clientBaseUrl));
|
|
649
672
|
const sortedTags = [...byTag.keys()].sort();
|
|
650
673
|
for (const tag of sortedTags) {
|
|
651
674
|
const ctxName = sanitizeContextName(tag);
|
package/dist/scripts/verify.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icib.dev/api-client",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Generator for strictly-typed TypeScript API clients from OpenAPI specs",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/api/index.js",
|
|
7
|
-
"types": "./dist/api/index.d.ts",
|
|
8
6
|
"bin": {
|
|
9
|
-
"api-client-generate": "./dist/scripts/generate.js"
|
|
10
|
-
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"types": "./dist/api/index.d.ts",
|
|
14
|
-
"import": "./dist/api/index.js",
|
|
15
|
-
"default": "./dist/api/index.js"
|
|
16
|
-
}
|
|
7
|
+
"api-client-generate": "./dist/scripts/generate.js",
|
|
8
|
+
"api-client-verify": "./dist/scripts/verify.js"
|
|
17
9
|
},
|
|
18
10
|
"files": [
|
|
19
|
-
"dist"
|
|
11
|
+
"dist/scripts"
|
|
20
12
|
],
|
|
21
13
|
"scripts": {
|
|
22
14
|
"generate": "tsx scripts/generate.ts",
|
|
23
|
-
"
|
|
15
|
+
"verify": "tsx scripts/verify.ts",
|
|
16
|
+
"build": "tsc -p tsconfig.scripts.json",
|
|
17
|
+
"build:full": "tsx scripts/verify.ts && tsc -p tsconfig.build.json && tsc -p tsconfig.scripts.json",
|
|
24
18
|
"test": "vitest run",
|
|
25
19
|
"test:watch": "vitest",
|
|
26
20
|
"prepublishOnly": "npm run build"
|
|
27
21
|
},
|
|
28
22
|
"dependencies": {
|
|
29
|
-
"@apidevtools/swagger-parser": "^12.1.0"
|
|
30
|
-
"axios": "^1.13.6"
|
|
23
|
+
"@apidevtools/swagger-parser": "^12.1.0"
|
|
31
24
|
},
|
|
32
25
|
"devDependencies": {
|
|
33
26
|
"@types/node": "^25.5.0",
|
package/dist/api/apiClient.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apiClient.d.ts","sourceRoot":"","sources":["../../api/apiClient.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS;;;;CAErB,CAAC"}
|
package/dist/api/apiClient.js
DELETED
package/dist/api/client.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type AxiosInstance } from "axios";
|
|
2
|
-
export declare function setAuthToken(token: string | null): void;
|
|
3
|
-
export declare const client: AxiosInstance;
|
|
4
|
-
/** Options for blob/download endpoints */
|
|
5
|
-
export interface BlobDownloadOptions {
|
|
6
|
-
/** When true, triggers a file download in the browser */
|
|
7
|
-
download?: boolean;
|
|
8
|
-
/** Suggested filename (falls back to Content-Disposition or default) */
|
|
9
|
-
filename?: string;
|
|
10
|
-
}
|
|
11
|
-
/** Headers type for blob download (compatible with Axios response headers) */
|
|
12
|
-
export type BlobDownloadHeaders = import("axios").AxiosResponseHeaders | import("axios").RawAxiosResponseHeaders | Record<string, import("axios").AxiosHeaderValue>;
|
|
13
|
-
/** Triggers a blob download in the browser. No-op in Node.js. */
|
|
14
|
-
export declare function triggerBlobDownload(blob: Blob, headers: BlobDownloadHeaders, suggestedFilename?: string): void;
|
|
15
|
-
//# sourceMappingURL=client.d.ts.map
|
package/dist/api/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../api/client.ts"],"names":[],"mappings":"AACA,OAAc,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAIlD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAEvD;AAED,eAAO,MAAM,MAAM,EAAE,aAKnB,CAAC;AASH,0CAA0C;AAC1C,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAC3B,OAAO,OAAO,EAAE,oBAAoB,GACpC,OAAO,OAAO,EAAE,uBAAuB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAErD,iEAAiE;AACjE,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,mBAAmB,EAC5B,iBAAiB,CAAC,EAAE,MAAM,GACzB,IAAI,CAiBN"}
|
package/dist/api/client.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Auto-generated Axios client
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
let _token = null;
|
|
4
|
-
export function setAuthToken(token) {
|
|
5
|
-
_token = token;
|
|
6
|
-
}
|
|
7
|
-
export const client = axios.create({
|
|
8
|
-
baseURL: "https://api.example.com",
|
|
9
|
-
headers: {
|
|
10
|
-
"Content-Type": "application/json",
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
client.interceptors.request.use((config) => {
|
|
14
|
-
if (_token) {
|
|
15
|
-
config.headers.Authorization = `Bearer ${_token}`;
|
|
16
|
-
}
|
|
17
|
-
return config;
|
|
18
|
-
});
|
|
19
|
-
/** Triggers a blob download in the browser. No-op in Node.js. */
|
|
20
|
-
export function triggerBlobDownload(blob, headers, suggestedFilename) {
|
|
21
|
-
if (typeof document === "undefined")
|
|
22
|
-
return;
|
|
23
|
-
const cdRaw = "get" in headers && typeof headers.get === "function"
|
|
24
|
-
? headers.get("content-disposition")
|
|
25
|
-
: headers["content-disposition"];
|
|
26
|
-
const cd = typeof cdRaw === "string" ? cdRaw : Array.isArray(cdRaw) ? cdRaw[0] : "";
|
|
27
|
-
const filename = suggestedFilename ??
|
|
28
|
-
(cd && cd.includes("filename=")
|
|
29
|
-
? cd.split("filename=")[1]?.replace(/^["']|["']$/g, "").trim()
|
|
30
|
-
: "download");
|
|
31
|
-
const url = URL.createObjectURL(blob);
|
|
32
|
-
const a = document.createElement("a");
|
|
33
|
-
a.href = url;
|
|
34
|
-
a.download = filename;
|
|
35
|
-
a.click();
|
|
36
|
-
URL.revokeObjectURL(url);
|
|
37
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { type BlobDownloadOptions } from "../client.js";
|
|
2
|
-
/** API client for QR Code endpoints */
|
|
3
|
-
export declare const QR_Code: {
|
|
4
|
-
/**
|
|
5
|
-
* Assegna QR code a presidio
|
|
6
|
-
* Collega un QR code a un presidio. - Se il QR code è già assegnato e force=False: errore 400. - Se force=True: sostituisce il presidio precedente.
|
|
7
|
-
* @param data - force: Se True, sostituisce il presidio già collegato
|
|
8
|
-
*/
|
|
9
|
-
assignQrcode(data: {
|
|
10
|
-
qrcode_id: string;
|
|
11
|
-
equipment_id: string;
|
|
12
|
-
force?: boolean;
|
|
13
|
-
}): Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
14
|
-
/**
|
|
15
|
-
* Scarica QR codes non assegnati
|
|
16
|
-
* Scarica CSV di tutti i QR codes non ancora assegnati a un presidio. Solo staff (debug).
|
|
17
|
-
* @param params.search - A search term.
|
|
18
|
-
* @param params.ordering - Which field to use when ordering the results.
|
|
19
|
-
* @param params.page - A page number within the paginated result set.
|
|
20
|
-
* @param params.size - Number of results to return per page.
|
|
21
|
-
* @param options.download - When true, triggers a file download in the browser
|
|
22
|
-
* @param options.filename - Suggested filename for the download
|
|
23
|
-
*/
|
|
24
|
-
downloadUnassigned(params?: {
|
|
25
|
-
search?: string;
|
|
26
|
-
ordering?: string;
|
|
27
|
-
page?: number;
|
|
28
|
-
size?: number;
|
|
29
|
-
}, options?: BlobDownloadOptions): Promise<import("axios").AxiosResponse<Blob, any, {}>>;
|
|
30
|
-
/**
|
|
31
|
-
* Genera QR codes
|
|
32
|
-
* Genera N nuovi QR codes (UUID v4) e restituisce un file CSV. Solo staff. I QR codes creati sono non assegnati e possono essere collegati a un presidio tramite assign-qrcode.
|
|
33
|
-
* @param data - n: Numero di QR codes da generare (1-10000)
|
|
34
|
-
* @param options.download - When true, triggers a file download in the browser
|
|
35
|
-
* @param options.filename - Suggested filename for the download
|
|
36
|
-
*/
|
|
37
|
-
generateCsv(data: {
|
|
38
|
-
n: number;
|
|
39
|
-
}, options?: BlobDownloadOptions): Promise<import("axios").AxiosResponse<Blob, any, {}>>;
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=QR_Code.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QR_Code.d.ts","sourceRoot":"","sources":["../../../api/contexts/QR_Code.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+B,KAAK,mBAAmB,EAA4B,MAAM,cAAc,CAAC;AAE/G,uCAAuC;AACvC,eAAO,MAAM,OAAO;IAChB;;;;OAIG;uBACsB;QAC3B,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;IAGG;;;;;;;;;OASG;gCAC+B;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,YAAY,mBAAmB;IAKrI;;;;;;OAMG;sBACqB;QAC1B,CAAC,EAAE,MAAM,CAAC;KACX,YAAY,mBAAmB;CAK/B,CAAC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Auto-generated API client for context: QR Code
|
|
2
|
-
import { client, triggerBlobDownload } from "../client.js";
|
|
3
|
-
/** API client for QR Code endpoints */
|
|
4
|
-
export const QR_Code = {
|
|
5
|
-
/**
|
|
6
|
-
* Assegna QR code a presidio
|
|
7
|
-
* Collega un QR code a un presidio. - Se il QR code è già assegnato e force=False: errore 400. - Se force=True: sostituisce il presidio precedente.
|
|
8
|
-
* @param data - force: Se True, sostituisce il presidio già collegato
|
|
9
|
-
*/
|
|
10
|
-
async assignQrcode(data) {
|
|
11
|
-
return client.post("/api/qrcode/assign-qrcode/", data);
|
|
12
|
-
},
|
|
13
|
-
/**
|
|
14
|
-
* Scarica QR codes non assegnati
|
|
15
|
-
* Scarica CSV di tutti i QR codes non ancora assegnati a un presidio. Solo staff (debug).
|
|
16
|
-
* @param params.search - A search term.
|
|
17
|
-
* @param params.ordering - Which field to use when ordering the results.
|
|
18
|
-
* @param params.page - A page number within the paginated result set.
|
|
19
|
-
* @param params.size - Number of results to return per page.
|
|
20
|
-
* @param options.download - When true, triggers a file download in the browser
|
|
21
|
-
* @param options.filename - Suggested filename for the download
|
|
22
|
-
*/
|
|
23
|
-
async downloadUnassigned(params, options) {
|
|
24
|
-
const res = await client.get("/api/qrcode/download-unassigned/", { responseType: "blob", params });
|
|
25
|
-
if (options?.download)
|
|
26
|
-
triggerBlobDownload(res.data, res.headers, options.filename);
|
|
27
|
-
return res;
|
|
28
|
-
},
|
|
29
|
-
/**
|
|
30
|
-
* Genera QR codes
|
|
31
|
-
* Genera N nuovi QR codes (UUID v4) e restituisce un file CSV. Solo staff. I QR codes creati sono non assegnati e possono essere collegati a un presidio tramite assign-qrcode.
|
|
32
|
-
* @param data - n: Numero di QR codes da generare (1-10000)
|
|
33
|
-
* @param options.download - When true, triggers a file download in the browser
|
|
34
|
-
* @param options.filename - Suggested filename for the download
|
|
35
|
-
*/
|
|
36
|
-
async generateCsv(data, options) {
|
|
37
|
-
const res = await client.post("/api/qrcode/generate-csv/", data, { responseType: "blob" });
|
|
38
|
-
if (options?.download)
|
|
39
|
-
triggerBlobDownload(res.data, res.headers, options.filename);
|
|
40
|
-
return res;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { Allegato } from "../types/index.js";
|
|
2
|
-
/** API client for allegati endpoints */
|
|
3
|
-
export declare const allegati: {
|
|
4
|
-
/**
|
|
5
|
-
* @param params.search - A search term.
|
|
6
|
-
* @param params.ordering - Which field to use when ordering the results.
|
|
7
|
-
* @param params.page - A page number within the paginated result set.
|
|
8
|
-
* @param params.size - Number of results to return per page.
|
|
9
|
-
*/
|
|
10
|
-
list(params?: {
|
|
11
|
-
search?: string;
|
|
12
|
-
ordering?: string;
|
|
13
|
-
page?: number;
|
|
14
|
-
size?: number;
|
|
15
|
-
}): Promise<import("axios").AxiosResponse<{
|
|
16
|
-
count: number;
|
|
17
|
-
next?: string | null;
|
|
18
|
-
previous?: string | null;
|
|
19
|
-
results: Array<Allegato>;
|
|
20
|
-
}, any, {}>>;
|
|
21
|
-
/**
|
|
22
|
-
* @param data - Request body
|
|
23
|
-
*/
|
|
24
|
-
create(data: Allegato): Promise<import("axios").AxiosResponse<Allegato, any, {}>>;
|
|
25
|
-
/**
|
|
26
|
-
* @param params.id - A unique integer value identifying this Allegato.
|
|
27
|
-
*/
|
|
28
|
-
read(params: {
|
|
29
|
-
id: string | number;
|
|
30
|
-
}): Promise<import("axios").AxiosResponse<Allegato, any, {}>>;
|
|
31
|
-
/**
|
|
32
|
-
* @param params.id - A unique integer value identifying this Allegato.
|
|
33
|
-
* @param data - Request body
|
|
34
|
-
*/
|
|
35
|
-
update(params: {
|
|
36
|
-
id: string | number;
|
|
37
|
-
}, data: Allegato): Promise<import("axios").AxiosResponse<Allegato, any, {}>>;
|
|
38
|
-
/**
|
|
39
|
-
* @param params.id - A unique integer value identifying this Allegato.
|
|
40
|
-
* @param data - Request body
|
|
41
|
-
*/
|
|
42
|
-
partialUpdate(params: {
|
|
43
|
-
id: string | number;
|
|
44
|
-
}, data: Allegato): Promise<import("axios").AxiosResponse<Allegato, any, {}>>;
|
|
45
|
-
/**
|
|
46
|
-
* @param params.id - A unique integer value identifying this Allegato.
|
|
47
|
-
*/
|
|
48
|
-
delete(params: {
|
|
49
|
-
id: string | number;
|
|
50
|
-
}): Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
51
|
-
/**
|
|
52
|
-
* @param params.id - A unique integer value identifying this Allegato.
|
|
53
|
-
*/
|
|
54
|
-
token(params: {
|
|
55
|
-
id: string | number;
|
|
56
|
-
}): Promise<import("axios").AxiosResponse<Allegato, any, {}>>;
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=allegati.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"allegati.d.ts","sourceRoot":"","sources":["../../../api/contexts/allegati.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,wCAAwC;AACxC,eAAO,MAAM,QAAQ;IACjB;;;;;OAKG;kBACiB;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;eAEnF,MAAM;eACN,MAAM,GAAG,IAAI;mBACT,MAAM,GAAG,IAAI;iBACf,KAAK,CAAC,QAAQ,CAAC;;IAGtB;;OAEG;iBACgB,QAAQ;IAG3B;;OAEG;iBACgB;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;IAG1C;;;OAGG;mBACkB;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,QAAQ,QAAQ;IAG5D;;;OAGG;0BACyB;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,QAAQ,QAAQ;IAGnE;;OAEG;mBACkB;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;IAG5C;;OAEG;kBACiB;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;CAG9C,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// Auto-generated API client for context: allegati
|
|
2
|
-
import { client } from "../client.js";
|
|
3
|
-
/** API client for allegati endpoints */
|
|
4
|
-
export const allegati = {
|
|
5
|
-
/**
|
|
6
|
-
* @param params.search - A search term.
|
|
7
|
-
* @param params.ordering - Which field to use when ordering the results.
|
|
8
|
-
* @param params.page - A page number within the paginated result set.
|
|
9
|
-
* @param params.size - Number of results to return per page.
|
|
10
|
-
*/
|
|
11
|
-
async list(params) {
|
|
12
|
-
return client.get("/api/allegati/", { params });
|
|
13
|
-
},
|
|
14
|
-
/**
|
|
15
|
-
* @param data - Request body
|
|
16
|
-
*/
|
|
17
|
-
async create(data) {
|
|
18
|
-
return client.post("/api/allegati/", data);
|
|
19
|
-
},
|
|
20
|
-
/**
|
|
21
|
-
* @param params.id - A unique integer value identifying this Allegato.
|
|
22
|
-
*/
|
|
23
|
-
async read(params) {
|
|
24
|
-
return client.get(`/api/allegati/${String(params.id)}/`);
|
|
25
|
-
},
|
|
26
|
-
/**
|
|
27
|
-
* @param params.id - A unique integer value identifying this Allegato.
|
|
28
|
-
* @param data - Request body
|
|
29
|
-
*/
|
|
30
|
-
async update(params, data) {
|
|
31
|
-
return client.put(`/api/allegati/${String(params.id)}/`, data);
|
|
32
|
-
},
|
|
33
|
-
/**
|
|
34
|
-
* @param params.id - A unique integer value identifying this Allegato.
|
|
35
|
-
* @param data - Request body
|
|
36
|
-
*/
|
|
37
|
-
async partialUpdate(params, data) {
|
|
38
|
-
return client.patch(`/api/allegati/${String(params.id)}/`, data);
|
|
39
|
-
},
|
|
40
|
-
/**
|
|
41
|
-
* @param params.id - A unique integer value identifying this Allegato.
|
|
42
|
-
*/
|
|
43
|
-
async delete(params) {
|
|
44
|
-
return client.delete(`/api/allegati/${String(params.id)}/`);
|
|
45
|
-
},
|
|
46
|
-
/**
|
|
47
|
-
* @param params.id - A unique integer value identifying this Allegato.
|
|
48
|
-
*/
|
|
49
|
-
async token(params) {
|
|
50
|
-
return client.get(`/api/allegati/${String(params.id)}/token/`);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type BlobDownloadOptions } from "../client.js";
|
|
2
|
-
/** API client for allegato endpoints */
|
|
3
|
-
export declare const allegato: {
|
|
4
|
-
/**
|
|
5
|
-
* @param params.token - Path parameter
|
|
6
|
-
* @param options.download - When true, triggers a file download in the browser
|
|
7
|
-
* @param options.filename - Suggested filename for the download
|
|
8
|
-
*/
|
|
9
|
-
downloadRead(params: {
|
|
10
|
-
token: string | number;
|
|
11
|
-
}, options?: BlobDownloadOptions): Promise<import("axios").AxiosResponse<Blob, any, {}>>;
|
|
12
|
-
/**
|
|
13
|
-
* @param params.id - Path parameter
|
|
14
|
-
*/
|
|
15
|
-
previewRead(params: {
|
|
16
|
-
id: string | number;
|
|
17
|
-
}): Promise<import("axios").AxiosResponse<unknown, any, {}>>;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=allegato.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"allegato.d.ts","sourceRoot":"","sources":["../../../api/contexts/allegato.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+B,KAAK,mBAAmB,EAA4B,MAAM,cAAc,CAAC;AAE/G,wCAAwC;AACxC,eAAO,MAAM,QAAQ;IACjB;;;;OAIG;yBACwB;QAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,YAAY,mBAAmB;IAKpF;;OAEG;wBACuB;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;CAGpD,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Auto-generated API client for context: allegato
|
|
2
|
-
import { client, triggerBlobDownload } from "../client.js";
|
|
3
|
-
/** API client for allegato endpoints */
|
|
4
|
-
export const allegato = {
|
|
5
|
-
/**
|
|
6
|
-
* @param params.token - Path parameter
|
|
7
|
-
* @param options.download - When true, triggers a file download in the browser
|
|
8
|
-
* @param options.filename - Suggested filename for the download
|
|
9
|
-
*/
|
|
10
|
-
async downloadRead(params, options) {
|
|
11
|
-
const res = await client.get(`/api/allegato/download/${String(params.token)}`, { responseType: "blob" });
|
|
12
|
-
if (options?.download)
|
|
13
|
-
triggerBlobDownload(res.data, res.headers, options.filename);
|
|
14
|
-
return res;
|
|
15
|
-
},
|
|
16
|
-
/**
|
|
17
|
-
* @param params.id - Path parameter
|
|
18
|
-
*/
|
|
19
|
-
async previewRead(params) {
|
|
20
|
-
return client.get(`/api/allegato/preview/${String(params.id)}`);
|
|
21
|
-
}
|
|
22
|
-
};
|