@gandalan/weblibs 1.5.17 → 1.5.19
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/JSDOC.md +661 -0
- package/README.md +106 -17
- package/api/business/ablageApi.js +106 -0
- package/api/business/anpassungApi.js +74 -0
- package/api/business/artikelApi.js +242 -0
- package/api/business/authApi.js +63 -0
- package/api/business/avApi.js +458 -0
- package/api/business/belegApi.js +365 -0
- package/api/business/belegPositionenApi.js +52 -0
- package/api/business/benutzerApi.js +96 -0
- package/api/business/fakturaApi.js +88 -0
- package/api/business/farbeApi.js +129 -0
- package/api/business/fileApi.js +72 -0
- package/api/business/historieApi.js +144 -0
- package/api/business/index.js +63 -0
- package/api/business/kontaktApi.js +70 -0
- package/api/business/lagerApi.js +162 -0
- package/api/business/lieferungApi.js +127 -0
- package/api/business/mailApi.js +41 -0
- package/api/business/mandantApi.js +137 -0
- package/api/business/materialApi.js +37 -0
- package/api/business/printApi.js +49 -0
- package/api/business/produktionApi.js +141 -0
- package/api/business/rechnungApi.js +155 -0
- package/api/business/serienApi.js +375 -0
- package/api/business/settingsApi.js +168 -0
- package/api/business/systemApi.js +209 -0
- package/api/business/uiApi.js +256 -0
- package/api/business/utilityApi.js +288 -0
- package/api/business/vorgangApi.js +128 -0
- package/api/dtos/allgemein.js +107 -0
- package/api/dtos/artikel.js +46 -0
- package/api/dtos/av.js +171 -0
- package/api/dtos/belege.js +614 -0
- package/api/dtos/benutzer.js +101 -0
- package/api/dtos/druck.js +50 -0
- package/api/dtos/faktura.js +128 -0
- package/api/dtos/farben.js +93 -0
- package/api/dtos/index.js +501 -0
- package/api/dtos/kunden.js +217 -0
- package/api/dtos/lager.js +66 -0
- package/api/dtos/mail.js +30 -0
- package/api/dtos/mandanten.js +60 -0
- package/api/dtos/nachrichten.js +18 -0
- package/api/dtos/produktGruppen.js +18 -0
- package/api/dtos/produktion.js +564 -0
- package/api/dtos/settings.js +172 -0
- package/api/dtos/technik.js +163 -0
- package/api/dtos/ui.js +496 -0
- package/api/dtos/webjob.js +12 -0
- package/api/fluentApi.js +10 -8
- package/api/fluentAuthManager.js +22 -14
- package/api/fluentRestClient.js +7 -7
- package/api/idasFluentApi.js +458 -0
- package/index.js +53 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,35 +1,124 @@
|
|
|
1
1
|
# WebLibs for Gandalan JS/TS projects
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Deutsch
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Zweck
|
|
6
|
+
`@gandalan/weblibs` stellt Hilfsfunktionen für die Authentifizierung und API-Kommunikation mit IDAS sowie lokale API-Aufrufe bereit.
|
|
6
7
|
|
|
8
|
+
### Referenz
|
|
9
|
+
- IDAS API (Swagger): https://api.dev.idas-cloudservices.net/swagger/
|
|
10
|
+
|
|
11
|
+
### Voraussetzungen
|
|
12
|
+
- Browser-Umgebung (es werden `window`, `localStorage`, URL-Redirects und `fetch` verwendet)
|
|
13
|
+
- Gültiger App-Token als UUID (wird auf Anfrage von Gandalan ausgegeben)
|
|
14
|
+
- Kontakt für Zugangsdaten/App-Token: dev-support@gandalan.de
|
|
15
|
+
- IDAS/Auth-Base-URL vorzugsweise aus `fetchEnvConfig(...)` (z. B. `envConfig.idas`)
|
|
16
|
+
- Falls die URL manuell gesetzt wird: mit abschließendem Slash (z. B. `https://api.dev.idas-cloudservices.net/api/`)
|
|
17
|
+
|
|
18
|
+
### Installation
|
|
19
|
+
```bash
|
|
20
|
+
npm i @gandalan/weblibs
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Schnellstart (Fluent API + Auth)
|
|
7
24
|
```js
|
|
8
25
|
import { fetchEnvConfig, fluentApi, fluentIdasAuthManager } from '@gandalan/weblibs';
|
|
9
26
|
|
|
10
27
|
async function initializeAuthAndApi() {
|
|
11
|
-
const serviceName = 'myService'
|
|
12
|
-
const appToken = '
|
|
13
|
-
const envConfig = await fetchEnvConfig('dev'); //
|
|
28
|
+
const serviceName = 'myService';
|
|
29
|
+
const appToken = '00000000-0000-0000-0000-000000000000'; // UUID
|
|
30
|
+
const envConfig = await fetchEnvConfig('dev'); // envConfig.idas kommt aus fetchEnvConfig(...)
|
|
14
31
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
32
|
+
let authManager;
|
|
33
|
+
try {
|
|
34
|
+
authManager = await fluentIdasAuthManager(appToken, envConfig.idas).init();
|
|
35
|
+
} catch {
|
|
36
|
+
// init() kann auf Login umleiten und dabei eine Exception werfen.
|
|
37
|
+
// In diesem Fall Seite verlassen / später erneut starten.
|
|
38
|
+
return;
|
|
18
39
|
}
|
|
19
40
|
|
|
20
|
-
|
|
21
|
-
|
|
41
|
+
const idas = fluentApi(envConfig.idas, authManager, serviceName);
|
|
42
|
+
const api = fluentApi('/api/', authManager, serviceName);
|
|
43
|
+
|
|
44
|
+
const mandanten = await idas.get('mandanten');
|
|
45
|
+
console.log(mandanten[0]?.Name);
|
|
46
|
+
|
|
47
|
+
const localResult = await api.get('some-endpoint');
|
|
48
|
+
console.log(localResult);
|
|
22
49
|
}
|
|
23
50
|
```
|
|
24
51
|
|
|
25
|
-
|
|
52
|
+
### Exportierte APIs (Kurzüberblick)
|
|
53
|
+
- `fetchEnvConfig(env)` lädt Endpunktkonfiguration (z. B. `dev`, `staging`, `produktiv`)
|
|
54
|
+
- `fluentIdasAuthManager(appToken, authBaseUrl)` erzeugt Auth-Manager
|
|
55
|
+
- `fluentApi(baseUrl, authManager, serviceName)` erzeugt API-Client mit `get/put/post/delete`
|
|
56
|
+
- `createAuthManager()`, `createApi()`, `restClient()` für manuelle Konfiguration
|
|
57
|
+
- Legacy zusätzlich vorhanden: `initIDAS`, `IDASFactory`, `RESTClient`
|
|
58
|
+
|
|
59
|
+
### Wichtige Hinweise
|
|
60
|
+
- `init()` gibt nicht immer nur `null` zurück, sondern kann beim Redirect eine Exception auslösen.
|
|
61
|
+
- Refresh-Token wird aus URL-Parameter `t` gelesen und in `localStorage` (`idas-refresh-token`) persistiert.
|
|
62
|
+
- Ohne gültigen Auth-Status werden Requests ggf. intern per `ensureAuthenticated()` nachgezogen.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## English
|
|
67
|
+
|
|
68
|
+
### Purpose
|
|
69
|
+
`@gandalan/weblibs` provides helpers for authentication and API communication with IDAS as well as local API calls.
|
|
70
|
+
|
|
71
|
+
### Reference
|
|
72
|
+
- IDAS API (Swagger): https://api.dev.idas-cloudservices.net/swagger/
|
|
73
|
+
|
|
74
|
+
### Requirements
|
|
75
|
+
- Browser environment (uses `window`, `localStorage`, URL redirects, and `fetch`)
|
|
76
|
+
- Valid app token in UUID format (issued by Gandalan on request)
|
|
77
|
+
- Contact for credentials/app token: dev-support@gandalan.de
|
|
78
|
+
- Prefer the IDAS/auth base URL from `fetchEnvConfig(...)` (for example `envConfig.idas`)
|
|
79
|
+
- If the URL is set manually, use a trailing slash (for example `https://api.dev.idas-cloudservices.net/api/`)
|
|
26
80
|
|
|
81
|
+
### Installation
|
|
82
|
+
```bash
|
|
83
|
+
npm i @gandalan/weblibs
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Quick start (Fluent API + auth)
|
|
27
87
|
```js
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
88
|
+
import { fetchEnvConfig, fluentApi, fluentIdasAuthManager } from '@gandalan/weblibs';
|
|
89
|
+
|
|
90
|
+
async function initializeAuthAndApi() {
|
|
91
|
+
const serviceName = 'myService';
|
|
92
|
+
const appToken = '00000000-0000-0000-0000-000000000000'; // UUID
|
|
93
|
+
const envConfig = await fetchEnvConfig('dev'); // envConfig.idas is provided by fetchEnvConfig(...)
|
|
94
|
+
|
|
95
|
+
let authManager;
|
|
96
|
+
try {
|
|
97
|
+
authManager = await fluentIdasAuthManager(appToken, envConfig.idas).init();
|
|
98
|
+
} catch {
|
|
99
|
+
// init() may redirect to login and throw while doing so.
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const idas = fluentApi(envConfig.idas, authManager, serviceName);
|
|
104
|
+
const api = fluentApi('/api/', authManager, serviceName);
|
|
105
|
+
|
|
106
|
+
const mandanten = await idas.get('mandanten');
|
|
107
|
+
console.log(mandanten[0]?.Name);
|
|
31
108
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
109
|
+
const localResult = await api.get('some-endpoint');
|
|
110
|
+
console.log(localResult);
|
|
111
|
+
}
|
|
35
112
|
```
|
|
113
|
+
|
|
114
|
+
### Exported APIs (short overview)
|
|
115
|
+
- `fetchEnvConfig(env)` loads endpoint configuration (for example `dev`, `staging`, `produktiv`)
|
|
116
|
+
- `fluentIdasAuthManager(appToken, authBaseUrl)` creates an auth manager
|
|
117
|
+
- `fluentApi(baseUrl, authManager, serviceName)` creates an API client with `get/put/post/delete`
|
|
118
|
+
- `createAuthManager()`, `createApi()`, `restClient()` for manual composition
|
|
119
|
+
- Legacy exports still available: `initIDAS`, `IDASFactory`, `RESTClient`
|
|
120
|
+
|
|
121
|
+
### Important notes
|
|
122
|
+
- `init()` does not only return `null`; it may throw during login redirect.
|
|
123
|
+
- Refresh token can be read from URL parameter `t` and is stored in `localStorage` (`idas-refresh-token`).
|
|
124
|
+
- Without valid auth state, requests may trigger `ensureAuthenticated()` internally.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../fluentApi.js').FluentApi} FluentApi
|
|
3
|
+
* @typedef {import('../dtos/produktion.js').AblageDTO} AblageDTO
|
|
4
|
+
* @typedef {import('../dtos/produktion.js').AblageFachDTO} AblageFachDTO
|
|
5
|
+
* @typedef {import('../dtos/produktion.js').FachzuordnungResultDTO} FachzuordnungResultDTO
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Ablage API - Storage and bin management
|
|
10
|
+
* @param {FluentApi} fluentApi
|
|
11
|
+
*/
|
|
12
|
+
export function createAblageApi(fluentApi) {
|
|
13
|
+
return {
|
|
14
|
+
// AblageWebRoutinen
|
|
15
|
+
/**
|
|
16
|
+
* Get storage by GUID
|
|
17
|
+
* @param {string} guid
|
|
18
|
+
* @returns {Promise<AblageDTO>}
|
|
19
|
+
*/
|
|
20
|
+
get: (guid) => fluentApi.get(`Ablage/?id=${guid}`),
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get all storage locations
|
|
24
|
+
* @param {Date} [changedSince]
|
|
25
|
+
* @param {boolean} [includeDetails=true]
|
|
26
|
+
* @returns {Promise<AblageDTO[]>}
|
|
27
|
+
*/
|
|
28
|
+
getAll: (changedSince, includeDetails = true) => {
|
|
29
|
+
if (changedSince) {
|
|
30
|
+
return fluentApi.get(`Ablage?changedSince=${changedSince.toISOString()}&includeDetails=${includeDetails}`);
|
|
31
|
+
}
|
|
32
|
+
return fluentApi.get(`Ablage?includeDetails=${includeDetails}`);
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Save storage
|
|
37
|
+
* @param {AblageDTO} dto
|
|
38
|
+
* @returns {Promise<void>}
|
|
39
|
+
*/
|
|
40
|
+
save: (dto) => fluentApi.put("Ablage/", dto),
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Delete storage
|
|
44
|
+
* @param {string} guid
|
|
45
|
+
* @returns {Promise<void>}
|
|
46
|
+
*/
|
|
47
|
+
delete: (guid) => fluentApi.delete(`Ablage/?id=${guid}`),
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Distribute serie to bins
|
|
51
|
+
* @param {string} serieGuid
|
|
52
|
+
* @returns {Promise<FachzuordnungResultDTO>}
|
|
53
|
+
*/
|
|
54
|
+
serienFachverteilung: (serieGuid) =>
|
|
55
|
+
fluentApi.put(`Ablage/SerienFachverteilung/${serieGuid}`, null),
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Distribute AV positions to bins
|
|
59
|
+
* @param {string[]} avGuids
|
|
60
|
+
* @returns {Promise<FachzuordnungResultDTO>}
|
|
61
|
+
*/
|
|
62
|
+
fachverteilung: (avGuids) =>
|
|
63
|
+
fluentApi.put("Ablage/Fachverteilung", avGuids),
|
|
64
|
+
|
|
65
|
+
// AblageFachWebRoutinen
|
|
66
|
+
fach: {
|
|
67
|
+
/**
|
|
68
|
+
* Get bin by GUID
|
|
69
|
+
* @param {string} guid
|
|
70
|
+
* @returns {Promise<AblageFachDTO>}
|
|
71
|
+
*/
|
|
72
|
+
get: (guid) => fluentApi.get(`AblageFach/?id=${guid}`),
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get all bins
|
|
76
|
+
* @param {Date} [changedSince]
|
|
77
|
+
* @param {boolean} [includeDetails=true]
|
|
78
|
+
* @returns {Promise<AblageFachDTO[]>}
|
|
79
|
+
*/
|
|
80
|
+
getAll: (changedSince, includeDetails = true) => {
|
|
81
|
+
if (changedSince) {
|
|
82
|
+
return fluentApi.get(`AblageFach?changedSince=${changedSince.toISOString()}&includeDetails=${includeDetails}`);
|
|
83
|
+
}
|
|
84
|
+
return fluentApi.get(`AblageFach?includeDetails=${includeDetails}`);
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Save bin
|
|
89
|
+
* @param {AblageFachDTO} dto
|
|
90
|
+
* @returns {Promise<void>}
|
|
91
|
+
*/
|
|
92
|
+
save: (dto) => fluentApi.put("AblageFach/", dto),
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Delete bin
|
|
96
|
+
* @param {string} guid
|
|
97
|
+
* @returns {Promise<void>}
|
|
98
|
+
*/
|
|
99
|
+
delete: (guid) => fluentApi.delete(`AblageFach/?id=${guid}`),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @typedef {ReturnType<typeof createAblageApi>} AblageApi
|
|
106
|
+
*/
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../fluentApi.js').FluentApi} FluentApi
|
|
3
|
+
* @typedef {import('../dtos/index.js').AnpassungDTO} AnpassungDTO
|
|
4
|
+
* @typedef {import('../dtos/index.js').AnpassungVorlageDTO} AnpassungVorlageDTO
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Anpassung API - Customization and adjustment management
|
|
9
|
+
* @param {FluentApi} fluentApi
|
|
10
|
+
*/
|
|
11
|
+
export function createAnpassungApi(fluentApi) {
|
|
12
|
+
return {
|
|
13
|
+
// AnpassungenWebRoutinen
|
|
14
|
+
/**
|
|
15
|
+
* Get all adjustments
|
|
16
|
+
* @returns {Promise<AnpassungDTO[]>}
|
|
17
|
+
*/
|
|
18
|
+
getAll: () => fluentApi.get("Anpassungen"),
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Save adjustment
|
|
22
|
+
* @param {AnpassungDTO} dto
|
|
23
|
+
* @returns {Promise<void>}
|
|
24
|
+
*/
|
|
25
|
+
save: (dto) => fluentApi.put(`Anpassungen/${dto.anpassungGuid}`, dto),
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Delete adjustment
|
|
29
|
+
* @param {string} anpassungGuid
|
|
30
|
+
* @returns {Promise<void>}
|
|
31
|
+
*/
|
|
32
|
+
delete: (anpassungGuid) => fluentApi.delete(`Anpassungen/${anpassungGuid}`),
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Run adjustment web job
|
|
36
|
+
* @returns {Promise<void>}
|
|
37
|
+
*/
|
|
38
|
+
runWebJob: () => fluentApi.post("Anpassungen/WebJob", ""),
|
|
39
|
+
|
|
40
|
+
// AnpassungVorlagenWebRoutinen
|
|
41
|
+
vorlage: {
|
|
42
|
+
/**
|
|
43
|
+
* Get all adjustment templates
|
|
44
|
+
* @returns {Promise<AnpassungVorlageDTO[]>}
|
|
45
|
+
*/
|
|
46
|
+
getAll: () => fluentApi.get("AnpassungVorlagen"),
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get adjustment template by GUID
|
|
50
|
+
* @param {string} guid
|
|
51
|
+
* @returns {Promise<AnpassungVorlageDTO>}
|
|
52
|
+
*/
|
|
53
|
+
get: (guid) => fluentApi.get(`AnpassungVorlagen/${guid}`),
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Save adjustment template
|
|
57
|
+
* @param {AnpassungVorlageDTO} dto
|
|
58
|
+
* @returns {Promise<void>}
|
|
59
|
+
*/
|
|
60
|
+
save: (dto) => fluentApi.put(`AnpassungVorlagen/${dto.anpassungVorlageGuid}`, dto),
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Delete adjustment template
|
|
64
|
+
* @param {string} guid
|
|
65
|
+
* @returns {Promise<void>}
|
|
66
|
+
*/
|
|
67
|
+
delete: (guid) => fluentApi.delete(`AnpassungVorlagen/${guid}`),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @typedef {ReturnType<typeof createAnpassungApi>} AnpassungApi
|
|
74
|
+
*/
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../fluentApi.js').FluentApi} FluentApi
|
|
3
|
+
* @typedef {import('../dtos/index.js').WarenGruppeDTO} WarenGruppeDTO
|
|
4
|
+
* @typedef {import('../dtos/index.js').KatalogArtikelDTO} KatalogArtikelDTO
|
|
5
|
+
* @typedef {import('../dtos/index.js').ProduktGruppeDTO} ProduktGruppeDTO
|
|
6
|
+
* @typedef {import('../dtos/index.js').ProduktFamilieDTO} ProduktFamilieDTO
|
|
7
|
+
* @typedef {import('../dtos/index.js').KomponenteDTO} KomponenteDTO
|
|
8
|
+
* @typedef {import('../dtos/index.js').VarianteDTO} VarianteDTO
|
|
9
|
+
* @typedef {import('../dtos/index.js').KonturDTO} KonturDTO
|
|
10
|
+
* @typedef {import('../dtos/index.js').KatalogArtikelIndiDatenDTO} KatalogArtikelIndiDatenDTO
|
|
11
|
+
* @typedef {import('../dtos/index.js').SchnittDTO} SchnittDTO
|
|
12
|
+
* @typedef {import('../dtos/belege.js').BelegDTO} BelegDTO
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Artikel API - Article and product management
|
|
17
|
+
* @param {FluentApi} fluentApi
|
|
18
|
+
*/
|
|
19
|
+
export function createArtikelApi(fluentApi) {
|
|
20
|
+
return {
|
|
21
|
+
// ArtikelWebRoutinen
|
|
22
|
+
/**
|
|
23
|
+
* Get all articles
|
|
24
|
+
* @param {Date} [changedSince] - Filter by change date
|
|
25
|
+
* @returns {Promise<WarenGruppeDTO[]>}
|
|
26
|
+
*/
|
|
27
|
+
getAll: (changedSince) => {
|
|
28
|
+
const url = changedSince
|
|
29
|
+
? `Artikel?changedSince=${changedSince.toISOString()}`
|
|
30
|
+
: "Artikel";
|
|
31
|
+
return fluentApi.get(url);
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Save article
|
|
36
|
+
* @param {KatalogArtikelDTO} artikel
|
|
37
|
+
* @returns {Promise<KatalogArtikelDTO>}
|
|
38
|
+
*/
|
|
39
|
+
saveArtikel: (artikel) => fluentApi.put(`Artikel/${artikel.katalogArtikelGuid}`, artikel),
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Delete article
|
|
43
|
+
* @param {KatalogArtikelDTO} artikel
|
|
44
|
+
* @returns {Promise<void>}
|
|
45
|
+
*/
|
|
46
|
+
deleteArtikel: (artikel) => fluentApi.delete(`Artikel/${artikel.katalogArtikelGuid}`),
|
|
47
|
+
|
|
48
|
+
// ArtikelIndiDatenWebRoutinen
|
|
49
|
+
/**
|
|
50
|
+
* Get all article individual data
|
|
51
|
+
* @param {Date} [changedSince] - Filter by change date
|
|
52
|
+
* @returns {Promise<KatalogArtikelIndiDatenDTO[]>}
|
|
53
|
+
*/
|
|
54
|
+
getAllIndiDaten: (changedSince) => {
|
|
55
|
+
const url = changedSince
|
|
56
|
+
? `ArtikelIndiDaten?changedSince=${changedSince.toISOString()}`
|
|
57
|
+
: "ArtikelIndiDaten";
|
|
58
|
+
return fluentApi.get(url);
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Save article individual data
|
|
63
|
+
* @param {KatalogArtikelIndiDatenDTO} daten
|
|
64
|
+
* @returns {Promise<void>}
|
|
65
|
+
*/
|
|
66
|
+
saveArtikelIndiDaten: (daten) => fluentApi.put(`ArtikelIndiDaten/${daten.katalogArtikelGuid}`, daten),
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Delete article individual data
|
|
70
|
+
* @param {KatalogArtikelIndiDatenDTO} daten
|
|
71
|
+
* @returns {Promise<void>}
|
|
72
|
+
*/
|
|
73
|
+
deleteArtikelIndiDaten: (daten) => fluentApi.delete(`ArtikelIndiDaten/${daten.katalogArtikelGuid}`),
|
|
74
|
+
|
|
75
|
+
// WarenGruppeWebRoutinen
|
|
76
|
+
/**
|
|
77
|
+
* Get all product groups
|
|
78
|
+
* @returns {Promise<WarenGruppeDTO[]>}
|
|
79
|
+
*/
|
|
80
|
+
getAllWarenGruppen: () => fluentApi.get("WarenGruppe"),
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Save product group
|
|
84
|
+
* @param {WarenGruppeDTO} dto
|
|
85
|
+
* @returns {Promise<void>}
|
|
86
|
+
*/
|
|
87
|
+
saveWarenGruppe: (dto) => fluentApi.put(`WarenGruppe/${dto.warenGruppeGuid}`, dto),
|
|
88
|
+
|
|
89
|
+
// ProduktGruppenWebRoutinen
|
|
90
|
+
/**
|
|
91
|
+
* Get all product groups
|
|
92
|
+
* @param {boolean} [includeFamilien=true] - Include families and variants
|
|
93
|
+
* @returns {Promise<ProduktGruppeDTO[]>}
|
|
94
|
+
*/
|
|
95
|
+
getAllProduktGruppen: (includeFamilien = true) =>
|
|
96
|
+
fluentApi.get(`ProduktGruppe?includeFamilien=${includeFamilien}&includeVarianten=${includeFamilien}&includeUIDefs=${includeFamilien}&maxLevel=99`),
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Save product group
|
|
100
|
+
* @param {ProduktGruppeDTO} produktGruppe
|
|
101
|
+
* @returns {Promise<ProduktGruppeDTO>}
|
|
102
|
+
*/
|
|
103
|
+
saveProduktGruppe: (produktGruppe) =>
|
|
104
|
+
fluentApi.put(`ProduktGruppe/${produktGruppe.produktGruppeGuid}`, produktGruppe),
|
|
105
|
+
|
|
106
|
+
// ProduktFamilienWebRoutinen
|
|
107
|
+
/**
|
|
108
|
+
* Get all product families
|
|
109
|
+
* @param {boolean} [includeVarianten=true] - Include variants
|
|
110
|
+
* @returns {Promise<ProduktFamilieDTO[]>}
|
|
111
|
+
*/
|
|
112
|
+
getAllProduktFamilien: (includeVarianten = true) =>
|
|
113
|
+
fluentApi.get(`ProduktFamilie?includeVarianten=${includeVarianten}&includeUIDefs=${includeVarianten}&maxLevel=99`),
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Save product family
|
|
117
|
+
* @param {ProduktFamilieDTO} produktFamilie
|
|
118
|
+
* @returns {Promise<ProduktFamilieDTO>}
|
|
119
|
+
*/
|
|
120
|
+
saveProduktFamilie: (produktFamilie) =>
|
|
121
|
+
fluentApi.put(`ProduktFamilie/${produktFamilie.produktFamilieGuid}`, produktFamilie),
|
|
122
|
+
|
|
123
|
+
// KomponentenWebRoutinen
|
|
124
|
+
/**
|
|
125
|
+
* Get all components
|
|
126
|
+
* @returns {Promise<KomponenteDTO[]>}
|
|
127
|
+
*/
|
|
128
|
+
getAllKomponenten: () => fluentApi.get("Komponente"),
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Save component
|
|
132
|
+
* @param {KomponenteDTO} dto
|
|
133
|
+
* @returns {Promise<void>}
|
|
134
|
+
*/
|
|
135
|
+
saveKomponente: (dto) => fluentApi.put("Komponente", dto),
|
|
136
|
+
|
|
137
|
+
// VariantenWebRoutinen
|
|
138
|
+
/**
|
|
139
|
+
* Get all variants
|
|
140
|
+
* @returns {Promise<VarianteDTO[]>}
|
|
141
|
+
*/
|
|
142
|
+
getAllVarianten: () => fluentApi.get("Variante?includeUIDefs=true&maxLevel=99"),
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Get all variant GUIDs
|
|
146
|
+
* @returns {Promise<string[]>}
|
|
147
|
+
*/
|
|
148
|
+
getAllVariantenGuids: () => fluentApi.get("Variante/GetAllGuids"),
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Get all variant changes since date
|
|
152
|
+
* @param {Date} [changedSince]
|
|
153
|
+
* @returns {Promise<string[]>}
|
|
154
|
+
*/
|
|
155
|
+
getAllVariantenChanges: (changedSince) => {
|
|
156
|
+
const url = changedSince
|
|
157
|
+
? `Variante/GetAllVariantenChanges?changedSince=${changedSince.toISOString()}`
|
|
158
|
+
: "Variante/GetAllGuids";
|
|
159
|
+
return fluentApi.get(url);
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Get variant by GUID
|
|
164
|
+
* @param {string} varianteGuid
|
|
165
|
+
* @param {boolean} [includeUIDefs=true]
|
|
166
|
+
* @param {boolean} [includeKonfigs=true]
|
|
167
|
+
* @returns {Promise<VarianteDTO>}
|
|
168
|
+
*/
|
|
169
|
+
getVariante: (varianteGuid, includeUIDefs = true, includeKonfigs = true) =>
|
|
170
|
+
fluentApi.get(`Variante/${varianteGuid}?includeUIDefs=${includeUIDefs}&maxLevel=99&includeKonfigs=${includeKonfigs}`),
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Save variant
|
|
174
|
+
* @param {VarianteDTO} variante
|
|
175
|
+
* @returns {Promise<VarianteDTO>}
|
|
176
|
+
*/
|
|
177
|
+
saveVariante: (variante) => fluentApi.put(`Variante/${variante.varianteGuid}`, variante),
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Trigger variant cache web job
|
|
181
|
+
* @returns {Promise<void>}
|
|
182
|
+
*/
|
|
183
|
+
cacheWebJob: () => fluentApi.post("Variante/CacheWebJob", null),
|
|
184
|
+
|
|
185
|
+
// KonturenWebRoutinen
|
|
186
|
+
/**
|
|
187
|
+
* Get all contours
|
|
188
|
+
* @returns {Promise<KonturDTO[]>}
|
|
189
|
+
*/
|
|
190
|
+
getAllKonturen: () => fluentApi.get("Kontur"),
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Save contour
|
|
194
|
+
* @param {KonturDTO} dto
|
|
195
|
+
* @returns {Promise<void>}
|
|
196
|
+
*/
|
|
197
|
+
saveKontur: (dto) => fluentApi.put("Kontur", dto),
|
|
198
|
+
|
|
199
|
+
// SchnitteWebRoutinen
|
|
200
|
+
/**
|
|
201
|
+
* Get all cuts
|
|
202
|
+
* @returns {Promise<SchnittDTO[]>}
|
|
203
|
+
*/
|
|
204
|
+
getAllSchnitte: () => fluentApi.get("Schnitt"),
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Save cut
|
|
208
|
+
* @param {SchnittDTO} dto
|
|
209
|
+
* @returns {Promise<void>}
|
|
210
|
+
*/
|
|
211
|
+
saveSchnitt: (dto) => fluentApi.put("Schnitt", dto),
|
|
212
|
+
|
|
213
|
+
// SonderfarbWebRoutinen
|
|
214
|
+
/**
|
|
215
|
+
* Calculate special colors for beleg
|
|
216
|
+
* @param {string} belegGuid
|
|
217
|
+
* @returns {Promise<BelegDTO>}
|
|
218
|
+
*/
|
|
219
|
+
berechneSonderfarben: (belegGuid) => fluentApi.post(`BelegSonderfarben?bguid=${belegGuid}`, null),
|
|
220
|
+
|
|
221
|
+
// BenutzerVariantenWebRoutinen
|
|
222
|
+
/**
|
|
223
|
+
* Get user variants
|
|
224
|
+
* @param {string} benutzerGuid
|
|
225
|
+
* @param {boolean} mitSperrliste
|
|
226
|
+
* @returns {Promise<VarianteDTO[]>}
|
|
227
|
+
*/
|
|
228
|
+
getBenutzerVarianten: (benutzerGuid, mitSperrliste) =>
|
|
229
|
+
fluentApi.get(`BenutzerVarianten?id=${benutzerGuid}&mitSperrliste=${mitSperrliste}`),
|
|
230
|
+
|
|
231
|
+
// ResetCacheVariantenListenWebRoutinen
|
|
232
|
+
/**
|
|
233
|
+
* Reset variant list cache
|
|
234
|
+
* @returns {Promise<void>}
|
|
235
|
+
*/
|
|
236
|
+
resetCacheVariantenListen: () => fluentApi.put("ResetCacheVariantenListen", null),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @typedef {ReturnType<typeof createArtikelApi>} ArtikelApi
|
|
242
|
+
*/
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../fluentApi.js').FluentApi} FluentApi
|
|
3
|
+
* @typedef {import('../dtos/index.js').LoginDTO} LoginDTO
|
|
4
|
+
* @typedef {import('../dtos/index.js').CreateServiceTokenRequestDTO} CreateServiceTokenRequestDTO
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Auth API - Authentication and token management
|
|
9
|
+
* @param {FluentApi} fluentApi
|
|
10
|
+
*/
|
|
11
|
+
export function createAuthApi(fluentApi) {
|
|
12
|
+
return {
|
|
13
|
+
// LoginJwtRoutinen
|
|
14
|
+
/**
|
|
15
|
+
* Authenticate
|
|
16
|
+
* @param {LoginDTO} dto
|
|
17
|
+
* @returns {Promise<string>}
|
|
18
|
+
*/
|
|
19
|
+
authenticate: (dto) => fluentApi.post("LoginJwt/Authenticate", dto),
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Authenticate for function
|
|
23
|
+
* @param {string} email
|
|
24
|
+
* @returns {Promise<string>}
|
|
25
|
+
*/
|
|
26
|
+
authenticateForFunction: (email) =>
|
|
27
|
+
fluentApi.post(`LoginJwt/AuthenticateForFunction/?email=${encodeURIComponent(email)}`, null),
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Refresh token
|
|
31
|
+
* @param {string} token
|
|
32
|
+
* @returns {Promise<string>}
|
|
33
|
+
*/
|
|
34
|
+
refreshToken: (token) => fluentApi.put("LoginJwt/Refresh", token),
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Create service token
|
|
38
|
+
* @param {CreateServiceTokenRequestDTO} [dto]
|
|
39
|
+
* @returns {Promise<string>}
|
|
40
|
+
*/
|
|
41
|
+
createServiceToken: (dto) => fluentApi.post("LoginJwt/CreateServiceToken", dto),
|
|
42
|
+
|
|
43
|
+
// AuthTokenWebRoutinen
|
|
44
|
+
/**
|
|
45
|
+
* Remove expired tokens
|
|
46
|
+
* @returns {Promise<void>}
|
|
47
|
+
*/
|
|
48
|
+
removeExpiredTokens: () =>
|
|
49
|
+
fluentApi.post("AuthToken/RemoveExpiredTokens", null),
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get external app auth token
|
|
53
|
+
* @param {string} fremdApp
|
|
54
|
+
* @returns {Promise<import('../dtos/index.js').UserAuthTokenDTO>}
|
|
55
|
+
*/
|
|
56
|
+
getFremdAppAuthToken: (fremdApp) =>
|
|
57
|
+
fluentApi.get(`AuthToken/GetFremdAppAuthToken?fremdApp=${fremdApp}`),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @typedef {ReturnType<typeof createAuthApi>} AuthApi
|
|
63
|
+
*/
|