web: add custom readme to api client

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-08-23 12:00:35 +02:00
parent 6a14ae7975
commit cf7eb88661
4 changed files with 47 additions and 8 deletions

View file

@ -46,6 +46,7 @@ gen-web:
--additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=@goauthentik/api,npmVersion=${NPM_VERSION}
mkdir -p web/node_modules/@goauthentik/api
python -m scripts.web_api_esm
\cp -fv scripts/web_api_readme.md web-api/README.md
cd web-api && npm i
\cp -rfv web-api/* web/node_modules/@goauthentik/api

38
scripts/web_api_readme.md Normal file
View file

@ -0,0 +1,38 @@
## @goauthentik/api
This package provides a generated API Client for [authentik](https://goauthentik.io).
### Building
See https://goauthentik.io/developer-docs/making-schema-changes
### Consuming
```
npm install @goauthentik/api --save
```
Create a configuration:
```typescript
import { Configuration } from "@goauthentik/api";
export const DEFAULT_CONFIG = new Configuration({
// Configure where the API is located
// Can be a full host, ensure CORS is configured
basePath: "",
// Required for POST/PUT/DELETE requests
// getCookie function must return the cookie's contents
headers: {
"X-CSRFToken": getCookie("authentik_csrf"),
},
});
```
Then use the API:
```typescript
import { CoreApi } from "@goauthentik/api";
const user = await new CoreApi(DEFAULT_CONFIG).coreUsersMeRetrieve();
```

14
web/package-lock.json generated
View file

@ -15,7 +15,7 @@
"@babel/preset-env": "^7.15.0",
"@babel/preset-typescript": "^7.15.0",
"@fortawesome/fontawesome-free": "^5.15.4",
"@goauthentik/api": "^2021.8.1-rc1-1629709535",
"@goauthentik/api": "^2021.8.1-rc1-1629712721",
"@lingui/cli": "^3.10.2",
"@lingui/core": "^3.10.4",
"@lingui/macro": "^3.10.2",
@ -1690,9 +1690,9 @@
}
},
"node_modules/@goauthentik/api": {
"version": "2021.8.1-rc1-1629709535",
"resolved": "https://registry.npmjs.org/@goauthentik/api/-/api-2021.8.1-rc1-1629709535.tgz",
"integrity": "sha512-rlOt63gF3ALGuRIn8RiWRT5cZ4JhKu9koCtdFA7FDOYYU9jWBJ3e/YlFLLOLQrL8Cyl2g553We98t0n8AyDOBQ=="
"version": "2021.8.1-rc1-1629712721",
"resolved": "https://registry.npmjs.org/@goauthentik/api/-/api-2021.8.1-rc1-1629712721.tgz",
"integrity": "sha512-YC/txo36I6/dnOlj0nSXcxFV2fuwMkO/lQRIj5LGwNz85Jru1fwJzAuB8UFs8Floqw9yPI/DyWaUObFlatEe6A=="
},
"node_modules/@humanwhocodes/config-array": {
"version": "0.5.0",
@ -9567,9 +9567,9 @@
"integrity": "sha512-eYm8vijH/hpzr/6/1CJ/V/Eb1xQFW2nnUKArb3z+yUWv7HTwj6M7SP957oMjfZjAHU6qpoNc2wQvIxBLWYa/Jg=="
},
"@goauthentik/api": {
"version": "2021.8.1-rc1-1629709535",
"resolved": "https://registry.npmjs.org/@goauthentik/api/-/api-2021.8.1-rc1-1629709535.tgz",
"integrity": "sha512-rlOt63gF3ALGuRIn8RiWRT5cZ4JhKu9koCtdFA7FDOYYU9jWBJ3e/YlFLLOLQrL8Cyl2g553We98t0n8AyDOBQ=="
"version": "2021.8.1-rc1-1629712721",
"resolved": "https://registry.npmjs.org/@goauthentik/api/-/api-2021.8.1-rc1-1629712721.tgz",
"integrity": "sha512-YC/txo36I6/dnOlj0nSXcxFV2fuwMkO/lQRIj5LGwNz85Jru1fwJzAuB8UFs8Floqw9yPI/DyWaUObFlatEe6A=="
},
"@humanwhocodes/config-array": {
"version": "0.5.0",

View file

@ -46,7 +46,7 @@
"@babel/preset-env": "^7.15.0",
"@babel/preset-typescript": "^7.15.0",
"@fortawesome/fontawesome-free": "^5.15.4",
"@goauthentik/api": "^2021.8.1-rc1-1629709535",
"@goauthentik/api": "^2021.8.1-rc1-1629712721",
"@lingui/cli": "^3.10.2",
"@lingui/core": "^3.10.4",
"@lingui/macro": "^3.10.2",