Skip to content

Commit 6e4cfdb

Browse files
ivictborCopilot
andcommitted
feat: add various adapter documentation and update completion adapter interface
Co-authored-by: Copilot <copilot@github.com>
1 parent cfc976b commit 6e4cfdb

15 files changed

Lines changed: 447 additions & 474 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Email Adapters
2+
3+
Used to send emails.
4+
5+
[Email adapter base class](https://github.com/devforth/adminforth/blob/917d897c866975a4aee29273377f2c07cb6ddf81/adminforth/types/adapters/EmailAdapter.ts#L17)
6+
7+
## AWS SES Email Adapter
8+
9+
```bash
10+
pnpm i @adminforth/email-adapter-aws-ses
11+
```
12+
13+
Enables email delivery via [Amazon Simple Email Service (SES)](https://aws.amazon.com/ses/), suitable for high-volume, programmatic email sending.
14+
15+
## Mailgun Email Adapter
16+
17+
```bash
18+
pnpm i @adminforth/email-adapter-mailgun
19+
```
20+
21+
Allows sending transactional or marketing emails using [Mailgun](https://www.mailgun.com/), a developer-friendly email service.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# OAuth2 Adapters
2+
3+
Used to authenticate users via OAuth 2.0 providers.
4+
5+
[OAuth2Adapter source class](https://github.com/devforth/adminforth/blob/917d897c866975a4aee29273377f2c07cb6ddf81/adminforth/types/adapters/OAuth2Adapter.ts#L9)
6+
7+
## Google OAuth Adapter
8+
9+
```bash
10+
pnpm i @adminforth/google-oauth-adapter
11+
```
12+
13+
Supports Google sign-in to allow users to authenticate using their Google or Google Workspaces accounts.
14+
15+
## GitHub OAuth Adapter
16+
17+
```bash
18+
pnpm i @adminforth/github-oauth-adapter
19+
```
20+
21+
Enables authentication via GitHub accounts, useful for developer tools and open-source apps.
22+
23+
## Facebook OAuth Adapter
24+
25+
```bash
26+
pnpm i @adminforth/facebook-oauth-adapter
27+
```
28+
29+
Allows users to log in with Facebook credentials. Facebook OAuth is commonly used for social media integrations.
30+
31+
## Keycloak OAuth Adapter
32+
33+
```bash
34+
pnpm i @adminforth/keycloak-oauth-adapter
35+
```
36+
37+
Connects AdminForth to an open-source [Keycloak](https://www.keycloak.org/) identity provider for enterprise-grade SSO (Single Sign-On).
38+
39+
## Microsoft OAuth Adapter
40+
41+
```bash
42+
pnpm i @adminforth/microsoft-oauth-adapter
43+
```
44+
45+
Supports login through Microsoft accounts including Azure AD, Office365, and Outlook.com.
46+
47+
## Twitch OAuth Adapter
48+
49+
```bash
50+
pnpm i @adminforth/twitch-oauth-adapter
51+
```
52+
53+
Adds support for Twitch authentication, useful for streaming or creator-oriented platforms.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Image Generation Adapters
2+
3+
Used for image-generating AI tools.
4+
5+
[ImageGenerationAdapter source class](https://github.com/devforth/adminforth/blob/917d897c866975a4aee29273377f2c07cb6ddf81/adminforth/types/adapters/ImageGenerationAdapter.ts#L32)
6+
7+
## OpenAI Image Generation Adapter
8+
9+
```bash
10+
pnpm i @adminforth/image-generation-adapter-openai
11+
```
12+
13+
Uses OpenAI image generation models such as DALL·E, `gpt-image-1`, and `gpt-image-1.5` to generate images from text prompts.
14+
15+
Up to the winter 2026 OpenAI models are one of the most powerful image generation models available, especially GPT-Image-1.5, which is why we started with them.
16+
17+
## Gemini (Nano Banana) Image Generation Adapter
18+
19+
```bash
20+
pnpm i @adminforth/image-generation-adapter-nano-banana
21+
```
22+
23+
Uses the latest `gemini-3.1-flash-image-preview` model for instant image generation with text descriptions.
24+
25+
This model is the top of the Nano Banana line as of 2026, combining the speed of the Flash series with the improved detail of version 3.1. The adapter lets you integrate the advanced capabilities of previous models into your interface and generate precise visuals even for specific or complex prompts.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Storage Adapters
2+
3+
Used for storing files.
4+
5+
[StorageAdapter source class](https://github.com/devforth/adminforth/blob/917d897c866975a4aee29273377f2c07cb6ddf81/adminforth/types/adapters/StorageAdapter.ts#L8)
6+
7+
## Amazon S3 Storage Adapter
8+
9+
```bash
10+
pnpm i @adminforth/storage-adapter-amazon-s3
11+
```
12+
13+
Stores uploaded files in [Amazon S3](https://aws.amazon.com/s3/), providing scalable cloud storage. It can be forked and customized to work with S3-compatible services such as MinIO, Wasabi, or other third-party S3 providers.
14+
15+
## Local Storage Adapter
16+
17+
```bash
18+
pnpm i @adminforth/storage-adapter-local
19+
```
20+
21+
Stores files locally on the server filesystem. It is suitable for development or small self-hosted setups, but cloud storage is generally a better production option for reliability and scalability.
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# AI Completion Adapters
2+
3+
Used for AI-powered text completion.
4+
5+
[CompletionAdapter source class](https://github.com/devforth/adminforth/blob/917d897c866975a4aee29273377f2c07cb6ddf81/adminforth/types/adapters/CompletionAdapter.ts#L16)
6+
7+
Feel free to fork and implement other models, including Anthropic, Google Gemini, or any other AI model that supports text completion.
8+
9+
## Common `complete()` signature
10+
11+
All completion adapters implement the same `complete()` method signature from the shared `CompletionAdapter` interface.
12+
13+
```ts
14+
complete({
15+
content: string,
16+
maxTokens: number,
17+
outputSchema?: any,
18+
reasoningEffort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh',
19+
tools?: CompletionTool[],
20+
onChunk?: (
21+
chunk: string,
22+
event?: {
23+
type: 'output' | 'reasoning';
24+
delta: string;
25+
text: string;
26+
source?: 'summary' | 'text';
27+
},
28+
) => void | Promise<void>,
29+
})
30+
```
31+
32+
`reasoningEffort` is optional and defaults to `low` in the adapter implementation.
33+
34+
## Using `json_schema`
35+
36+
All completion adapters accept structured output through the shared `outputSchema` field in the request object. The example below uses the OpenAI adapter, but the same request shape is common for all completion adapters.
37+
38+
```ts
39+
const adapter = new CompletionAdapterOpenAIResponses({
40+
openAiApiKey: process.env.OPENAI_API_KEY as string,
41+
model: 'gpt-5-mini',
42+
});
43+
44+
const prompt = 'What is the capital of France? return json';
45+
46+
adapter.complete({
47+
content: prompt,
48+
maxTokens: 200,
49+
outputSchema: {
50+
name: 'capital_response',
51+
schema: {
52+
type: 'object',
53+
properties: {
54+
capital: { type: 'string' },
55+
},
56+
required: ['capital'],
57+
},
58+
},
59+
}).then((resp) => {
60+
console.log(resp);
61+
});
62+
```
63+
64+
65+
## Using streaming output and reasoning events
66+
67+
All completion adapters accept `onChunk` inside the request object. The example below uses the OpenAI adapter, but the callback signature is common for all completion adapters.
68+
69+
Streaming reasoning events depend on the selected model and provider response.
70+
71+
```ts
72+
const adapter = new CompletionAdapterOpenAIResponses({
73+
openAiApiKey: process.env.OPENAI_API_KEY as string,
74+
model: 'gpt-5-mini',
75+
});
76+
77+
await adapter.complete({
78+
content: 'Think step by step and write a short answer about how ABS brakes work',
79+
maxTokens: 300,
80+
reasoningEffort: 'medium',
81+
onChunk: async (chunk, event) => {
82+
if (!event) return;
83+
84+
if (event.type === 'reasoning') {
85+
console.log('Reasoning chunk:', event.delta);
86+
return;
87+
}
88+
89+
console.log('Output chunk:', event.delta);
90+
},
91+
});
92+
```
93+
94+
Then output will be like:
95+
96+
```ts
97+
{ content: '{"capital":"Paris"}', finishReason: 'stop' }
98+
```
99+
100+
101+
## OpenAI Responses Completion Adapter
102+
103+
```bash
104+
pnpm i @adminforth/completion-adapter-openai-responses
105+
```
106+
107+
Integrates AdminForth with OpenAI's Responses API to provide AI-powered completion and conversational features.
108+
109+
The older `@adminforth/completion-adapter-open-ai-chat-gpt` package is deprecated. Use this package instead.
110+
111+
```ts
112+
import CompletionAdapterOpenAIResponses from '@adminforth/completion-adapter-openai-responses';
113+
114+
new CompletionAdapterOpenAIResponses({
115+
openAiApiKey: process.env.OPENAI_API_KEY as string,
116+
model: 'gpt-5.2',
117+
extraRequestBodyParameters: {
118+
temperature: 0.7,
119+
reasoning: {
120+
effort: 'medium',
121+
},
122+
},
123+
}),
124+
```
125+
126+
You can specify any GPT model you need. The default is `gpt-5-nano`.
127+
128+
This adapter uses the OpenAI `responses` API.
129+
130+
## Google Gemini Completion Adapter
131+
132+
```bash
133+
pnpm i @adminforth/completion-adapter-google-gemini
134+
```
135+
136+
Integrates AdminForth with Google Gemini models to provide AI-powered completion and conversational features.
137+
138+
```ts
139+
import CompletionAdapterGoogleGemini from '@adminforth/completion-adapter-google-gemini';
140+
141+
new CompletionAdapterGoogleGemini({
142+
geminiApiKey: process.env.GEMINI_API_KEY as string,
143+
model: 'gemini-3-pro-preview',
144+
extraRequestBodyParameters: {
145+
temperature: 0.7,
146+
},
147+
}),
148+
```
149+
150+
You can specify any Gemini model you need. The default is `gemini-3-flash-preview`.
151+
152+
## Adding extra request body params
153+
154+
There might be cases where you want to add extra body params to the request sent to the AI provider. For those cases you can use `extraRequestBodyParameters`:
155+
156+
```ts
157+
import CompletionAdapterGoogleGemini from '@adminforth/completion-adapter-google-gemini';
158+
159+
new CompletionAdapterGoogleGemini({
160+
geminiApiKey: process.env.GEMINI_API_KEY as string,
161+
model: 'gemini-3-pro-preview',
162+
extraRequestBodyParameters: {
163+
temperature: 0.7,
164+
responseMimeType: 'application/json',
165+
},
166+
}),
167+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Image Analysis Adapters
2+
3+
Used for AI-powered image analysis.
4+
5+
[ImageVisionAdapter source class](https://github.com/devforth/adminforth/blob/1efdc19e3bb7a5fc3b19106704e4ae8bb7c73276/adminforth/types/adapters/ImageVisionAdapter.ts#L1)
6+
7+
These adapters can analyze image content, extract text from images, identify objects, describe scenes, and provide detailed image insights.
8+
9+
## OpenAI Vision Adapter
10+
11+
```bash
12+
pnpm install @adminforth/image-vision-adapter-openai --save
13+
```
14+
15+
Integrates AdminForth with OpenAI to provide advanced AI-powered image analysis. It can describe image content, read and extract text from images, identify objects and people, and provide detailed visual insights.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Key-value Adapters
2+
3+
Key-value adapters are used to store data in a key-value format. They provide a simple and efficient way to manage data where quick access to values based on unique keys is required.
4+
5+
[Key-value adapter source class](https://github.com/devforth/adminforth/blob/86bb9236fed9e844fdb07688318c050641f9eb1c/adminforth/types/adapters/KeyValueAdapter.ts#L6)
6+
7+
## RAM Adapter
8+
9+
```bash
10+
pnpm i @adminforth/key-value-adapter-ram
11+
```
12+
13+
The RAM adapter is a simple in-memory key-value store. It keeps data in process memory, so it is not suitable for multi-process deployments because each process would have its own isolated store. In that case you need a centralized KV adapter such as Redis.
14+
15+
Pros:
16+
17+
- Simplest to use and does not require an external daemon.
18+
19+
Cons:
20+
21+
- Suitable for single-process installations only.
22+
23+
## Redis Adapter
24+
25+
```bash
26+
pnpm i @adminforth/key-value-adapter-redis
27+
```
28+
29+
Redis uses in-memory storage with $O(1)$ get complexity. It is a great fit for lightweight workloads that fit in RAM, and it also works well for multi-process or replica-based installations as a centralized store. If persistence across restarts is important, configure Redis persistence separately.
30+
31+
```ts
32+
import RedisKeyValueAdapter from '@adminforth/key-value-adapter-redis';
33+
34+
const adapter = new RedisKeyValueAdapter({
35+
redisUrl: '127.0.0.1:6379',
36+
});
37+
38+
adapter.set('test-key', 'test-value', 120);
39+
```
40+
41+
## LevelDB Adapter
42+
43+
```bash
44+
pnpm i @adminforth/key-value-adapter-leveldb
45+
```
46+
47+
LevelDB uses disk storage with $O(\log n)$ get complexity. It is a good fit for large or persistent KV datasets that still require fast lookups but do not efficiently fit in RAM. This is a single-process adapter only, so multiple admin processes should not point to the same LevelDB directory.
48+
49+
You can use replicas with isolated disks, but in that case the state will also be isolated between replicas.
50+
51+
```ts
52+
import LevelDBKeyValueAdapter from '@adminforth/key-value-adapter-leveldb';
53+
54+
const adapter = new LevelDBKeyValueAdapter({
55+
dbPath: './testdb',
56+
});
57+
58+
adapter.set('test-key', 'test-value', 120);
59+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Captcha Adapters
2+
3+
Used to add captcha to the login screen.
4+
5+
[Captcha adapter source class](https://github.com/devforth/adminforth/blob/65153408a119314dad339f452700e0937952034a/adminforth/types/adapters/CaptchaAdapter.ts#L5)
6+
7+
## Cloudflare Adapter
8+
9+
```bash
10+
pnpm i @adminforth/login-captcha-adapter-cloudflare
11+
```
12+
13+
## reCaptcha Adapter
14+
15+
```bash
16+
pnpm i @adminforth/login-captcha-adapter-recaptcha
17+
```

0 commit comments

Comments
 (0)