mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 21:52:54 +00:00
# Which Problems Are Solved Pages in `apps/docs` that embed source from GitHub via the Docusaurus convention ```` ```js reference https://github.com/zitadel/actions/blob/main/examples/org_metadata_claim.js ``` ```` stopped working after the migration from Docusaurus to fumadocs. The old `docusaurus-theme-github-codeblock` plugin used to fetch the file and render it; fumadocs has no support for that meta, so the page rendered the raw URL as plain code-block text. Visible at `/docs/apis/actions/code-examples` and 16 other pages. # How the Problems Are Solved - Converted every ```` ```<lang> reference\n<URL>\n``` ```` block (46 total across 17 `.mdx` files) to the native fumadocs JSX form: `<GithubCodeBlock url="<URL>" />`. The existing `<details>`/`<summary>` collapsibles around blocks are kept — they're an authoring choice, not part of the rendering bug. - Updated `apps/docs/components/github-code-block.tsx` to render via `DynamicCodeBlock` from `fumadocs-ui/components/dynamic-codeblock` (proper shiki highlighting) instead of raw `CodeBlock` + `Pre` (which produced unhighlighted output). Also fixed language detection so a URL hash like `#L10-L20` no longer pollutes the language token. - Registered `GithubCodeBlock` globally in `apps/docs/mdx-components.tsx`, matching how every other shared component (`APIPage`, `Callout`, `Tab/Tabs`, `Step/Steps`, `Admonition`, `TerminologyUpdate`) is exposed. MDX files no longer need a local `import`. # Additional Changes - Normalized the two MDX files that were already using the JSX form (`examples/secure-api/python-django.mdx`, `examples/secure-api/java-spring.mdx`): removed their now-redundant local `import { GithubCodeBlock }` and rewrote 9 long-form `<GithubCodeBlock url="..."></GithubCodeBlock>` tags to self-closing for consistency. # Additional Context Verified locally with `pnpm --filter @zitadel/docs dev`: - `/docs/apis/actions/code-examples` — 20 shiki-highlighted code blocks rendered inside the `<details>` collapsibles (was 0). - `/docs/apis/openidoauth/claims` — line-range hashes (`#L9-L11`) honored. - `/docs/examples/login/flutter` — mixed languages (xml/dart/html) detected and highlighted. - `/docs/guides/integrate/external-audit-log` — edge case of fenced reference indented inside a numbered list also converted and rendered. Greps: - `^[ \t]*\`\`\`[a-zA-Z0-9]+ reference` in `apps/docs/content/**/*.mdx` → 0 matches. - `<GithubCodeBlock url="` in `apps/docs/content/**/*.mdx` → 55 matches. - `from '@/components/github-code-block'` in `apps/docs/content/**/*.mdx` → 0 matches. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
148 lines
3.7 KiB
Plaintext
148 lines
3.7 KiB
Plaintext
---
|
|
title: Modules
|
|
description: "The reference of built-in modules available in ZITADEL Actions, including the fetch API for HTTP requests."
|
|
---
|
|
|
|
ZITADEL provides the following modules.
|
|
|
|
## HTTP
|
|
|
|
This module provides functionality to call REST APIs.
|
|
|
|
### Import
|
|
|
|
```js
|
|
let http = require('zitadel/http')
|
|
```
|
|
|
|
### `fetch()` function
|
|
|
|
This function allows to call HTTP servers. The function does NOT fulfil the [Fetch API specification](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
|
|
|
|
#### Parameters
|
|
|
|
- `url` *string*
|
|
- `options`
|
|
**Optional**, containing custom settings that you want to apply to the request.
|
|
- `headers`
|
|
Overwrites the default headers. One of the following types
|
|
- *map[string] string*
|
|
The value is split into separate values after each comma `,`.
|
|
- *map[string] Array of string*
|
|
The value is a string array
|
|
- default:
|
|
- `Content-Type`: `application/json`
|
|
- `Accept`: `application/json`
|
|
- `method`
|
|
The request method. Allowed values are `GET`, `POST`, `PUT`, `DELETE`
|
|
- `body` *Object*
|
|
JSON representation
|
|
|
|
#### Response
|
|
|
|
If the request was invalid, an error will be thrown, otherwise a Response object will be returned.
|
|
|
|
The object has the following fields and methods:
|
|
|
|
- `status` *number*
|
|
Status code of response
|
|
- `body` *string*
|
|
Return value
|
|
- `json()` *Object*
|
|
Returns the body as JSON object, or throws an error if the body is not a json object.
|
|
- `text()` *string*
|
|
Returns the body
|
|
|
|
### Example
|
|
|
|
<GithubCodeBlock url="https://github.com/zitadel/actions/blob/main/examples/make_api_call.js#L10-L20" />
|
|
|
|
## Log
|
|
|
|
The log module provides you with the functionality to log to stdout.
|
|
|
|
### Import
|
|
|
|
```js
|
|
let logger = require("zitadel/log")
|
|
```
|
|
|
|
### `log()`, `warn()`, `error()` function
|
|
|
|
The logger offers three distinct log levels (info, warn, and error) to effectively communicate messages based on their severity, enhancing debugging and troubleshooting efficiency.
|
|
Use the function that reflects your log level.
|
|
|
|
- log()
|
|
- warn()
|
|
- error()
|
|
|
|
### Example
|
|
|
|
```js
|
|
logger.log("This is an info log.")
|
|
|
|
logger.warn("This is a warn log.")
|
|
|
|
logger.error("This is an error log.")
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
- `msg` *string*
|
|
The message you want to print out.
|
|
|
|
## UUID
|
|
|
|
This module provides functionality to generate a UUID
|
|
|
|
### Import
|
|
|
|
```js
|
|
let uuid = require("zitadel/uuid")
|
|
```
|
|
|
|
### `uuid.vX()` function
|
|
|
|
This function generates a UUID using [google/uuid](https://github.com/google/uuid). `vX` allows to define the UUID version:
|
|
|
|
- `uuid.v1()` *string*
|
|
Generates a UUID version 1, based on date-time and MAC address
|
|
- `uuid.v3(namespace, data)` *string*
|
|
Generates a UUID version 3, based on the provided namespace using MD5
|
|
- `uuid.v4()` *string*
|
|
Generates a UUID version 4, which is randomly generated
|
|
- `uuid.v5(namespace, data)` *string*
|
|
Generates a UUID version 5, based on the provided namespace using SHA1
|
|
|
|
#### Parameters
|
|
|
|
- `namespace` *UUID*/*string*
|
|
Namespace to be used in the hashing function. Either provide one of defined [namespaces](#namespaces) or a string representing a UUID.
|
|
- `data` *[]byte*/*string*
|
|
data to be used in the hashing function. Possible types are []byte or string.
|
|
|
|
### Namespaces
|
|
|
|
The following predefined namespaces can be used for `uuid.v3` and `uuid.v5`:
|
|
|
|
- `uuid.namespaceDNS` *UUID*
|
|
6ba7b810-9dad-11d1-80b4-00c04fd430c8
|
|
- `uuid.namespaceURL` *UUID*
|
|
6ba7b811-9dad-11d1-80b4-00c04fd430c8
|
|
- `uuid.namespaceOID` *UUID*
|
|
6ba7b812-9dad-11d1-80b4-00c04fd430c8
|
|
- `uuid.namespaceX500` *UUID*
|
|
6ba7b814-9dad-11d1-80b4-00c04fd430c8
|
|
|
|
### Example
|
|
```js
|
|
let uuid = require("zitadel/uuid")
|
|
function setUUID(ctx, api) {
|
|
if (api.metadata === undefined) {
|
|
return;
|
|
}
|
|
|
|
api.v1.user.appendMetadata('custom-id', uuid.v4());
|
|
}
|
|
```
|