web: add custom readme to api client
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
6a14ae7975
commit
cf7eb88661
1
Makefile
1
Makefile
|
@ -46,6 +46,7 @@ gen-web:
|
||||||
--additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=@goauthentik/api,npmVersion=${NPM_VERSION}
|
--additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=@goauthentik/api,npmVersion=${NPM_VERSION}
|
||||||
mkdir -p web/node_modules/@goauthentik/api
|
mkdir -p web/node_modules/@goauthentik/api
|
||||||
python -m scripts.web_api_esm
|
python -m scripts.web_api_esm
|
||||||
|
\cp -fv scripts/web_api_readme.md web-api/README.md
|
||||||
cd web-api && npm i
|
cd web-api && npm i
|
||||||
\cp -rfv web-api/* web/node_modules/@goauthentik/api
|
\cp -rfv web-api/* web/node_modules/@goauthentik/api
|
||||||
|
|
||||||
|
|
38
scripts/web_api_readme.md
Normal file
38
scripts/web_api_readme.md
Normal 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
14
web/package-lock.json
generated
|
@ -15,7 +15,7 @@
|
||||||
"@babel/preset-env": "^7.15.0",
|
"@babel/preset-env": "^7.15.0",
|
||||||
"@babel/preset-typescript": "^7.15.0",
|
"@babel/preset-typescript": "^7.15.0",
|
||||||
"@fortawesome/fontawesome-free": "^5.15.4",
|
"@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/cli": "^3.10.2",
|
||||||
"@lingui/core": "^3.10.4",
|
"@lingui/core": "^3.10.4",
|
||||||
"@lingui/macro": "^3.10.2",
|
"@lingui/macro": "^3.10.2",
|
||||||
|
@ -1690,9 +1690,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@goauthentik/api": {
|
"node_modules/@goauthentik/api": {
|
||||||
"version": "2021.8.1-rc1-1629709535",
|
"version": "2021.8.1-rc1-1629712721",
|
||||||
"resolved": "https://registry.npmjs.org/@goauthentik/api/-/api-2021.8.1-rc1-1629709535.tgz",
|
"resolved": "https://registry.npmjs.org/@goauthentik/api/-/api-2021.8.1-rc1-1629712721.tgz",
|
||||||
"integrity": "sha512-rlOt63gF3ALGuRIn8RiWRT5cZ4JhKu9koCtdFA7FDOYYU9jWBJ3e/YlFLLOLQrL8Cyl2g553We98t0n8AyDOBQ=="
|
"integrity": "sha512-YC/txo36I6/dnOlj0nSXcxFV2fuwMkO/lQRIj5LGwNz85Jru1fwJzAuB8UFs8Floqw9yPI/DyWaUObFlatEe6A=="
|
||||||
},
|
},
|
||||||
"node_modules/@humanwhocodes/config-array": {
|
"node_modules/@humanwhocodes/config-array": {
|
||||||
"version": "0.5.0",
|
"version": "0.5.0",
|
||||||
|
@ -9567,9 +9567,9 @@
|
||||||
"integrity": "sha512-eYm8vijH/hpzr/6/1CJ/V/Eb1xQFW2nnUKArb3z+yUWv7HTwj6M7SP957oMjfZjAHU6qpoNc2wQvIxBLWYa/Jg=="
|
"integrity": "sha512-eYm8vijH/hpzr/6/1CJ/V/Eb1xQFW2nnUKArb3z+yUWv7HTwj6M7SP957oMjfZjAHU6qpoNc2wQvIxBLWYa/Jg=="
|
||||||
},
|
},
|
||||||
"@goauthentik/api": {
|
"@goauthentik/api": {
|
||||||
"version": "2021.8.1-rc1-1629709535",
|
"version": "2021.8.1-rc1-1629712721",
|
||||||
"resolved": "https://registry.npmjs.org/@goauthentik/api/-/api-2021.8.1-rc1-1629709535.tgz",
|
"resolved": "https://registry.npmjs.org/@goauthentik/api/-/api-2021.8.1-rc1-1629712721.tgz",
|
||||||
"integrity": "sha512-rlOt63gF3ALGuRIn8RiWRT5cZ4JhKu9koCtdFA7FDOYYU9jWBJ3e/YlFLLOLQrL8Cyl2g553We98t0n8AyDOBQ=="
|
"integrity": "sha512-YC/txo36I6/dnOlj0nSXcxFV2fuwMkO/lQRIj5LGwNz85Jru1fwJzAuB8UFs8Floqw9yPI/DyWaUObFlatEe6A=="
|
||||||
},
|
},
|
||||||
"@humanwhocodes/config-array": {
|
"@humanwhocodes/config-array": {
|
||||||
"version": "0.5.0",
|
"version": "0.5.0",
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
"@babel/preset-env": "^7.15.0",
|
"@babel/preset-env": "^7.15.0",
|
||||||
"@babel/preset-typescript": "^7.15.0",
|
"@babel/preset-typescript": "^7.15.0",
|
||||||
"@fortawesome/fontawesome-free": "^5.15.4",
|
"@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/cli": "^3.10.2",
|
||||||
"@lingui/core": "^3.10.4",
|
"@lingui/core": "^3.10.4",
|
||||||
"@lingui/macro": "^3.10.2",
|
"@lingui/macro": "^3.10.2",
|
||||||
|
|
Reference in a new issue