@llmnative/react 0.1.1 → 1.1.0
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/README.md +397 -364
- package/bin/cli.js +117 -98
- package/dist/index.css +1 -1
- package/dist/index.js +21 -823
- package/dist/index.mjs +14984 -9345
- package/dist/style.css +1 -0
- package/dist/types/src/App.d.ts +75 -14
- package/dist/types/src/Config.d.ts +28 -5
- package/dist/types/src/Global.d.ts +2 -2
- package/dist/types/src/I18n.d.ts +186 -0
- package/dist/types/src/Theme.d.ts +153 -81
- package/dist/types/src/auth.d.ts +13 -1
- package/dist/types/src/components/Component.d.ts +13 -27
- package/dist/types/src/components/ErrorBoundary.d.ts +30 -0
- package/dist/types/src/components/blocks/Brand.d.ts +9 -4
- package/dist/types/src/components/blocks/Breadcrumbs.d.ts +50 -4
- package/dist/types/src/components/blocks/Carousel.d.ts +7 -5
- package/dist/types/src/components/blocks/Dropdown.d.ts +38 -20
- package/dist/types/src/components/blocks/ListCard.d.ts +38 -0
- package/dist/types/src/components/blocks/Menu.d.ts +15 -16
- package/dist/types/src/components/blocks/Notifications.d.ts +11 -3
- package/dist/types/src/components/blocks/ProviderSwitcher.d.ts +65 -0
- package/dist/types/src/components/blocks/Search.d.ts +3 -2
- package/dist/types/src/components/blocks/SideNav.d.ts +45 -0
- package/dist/types/src/components/blocks/ThemeSwitcher.d.ts +28 -0
- package/dist/types/src/components/blocks/Toolbar.d.ts +23 -0
- package/dist/types/src/components/index.d.ts +28 -7
- package/dist/types/src/components/types.d.ts +10 -3
- package/dist/types/src/components/ui/Alert.d.ts +20 -4
- package/dist/types/src/components/ui/Badge.d.ts +12 -5
- package/dist/types/src/components/ui/Buttons.d.ts +16 -12
- package/dist/types/src/components/ui/Card.d.ts +11 -7
- package/dist/types/src/components/ui/Code.d.ts +5 -1
- package/dist/types/src/components/ui/Gallery.d.ts +16 -16
- package/dist/types/src/components/ui/GridSystem.d.ts +5 -2
- package/dist/types/src/components/ui/Icon.d.ts +6 -1
- package/dist/types/src/components/ui/Image.d.ts +7 -1
- package/dist/types/src/components/ui/ImageAvatar.d.ts +4 -1
- package/dist/types/src/components/ui/Loader.d.ts +3 -1
- package/dist/types/src/components/ui/LocaleSwitcher.d.ts +14 -0
- package/dist/types/src/components/ui/Modal.d.ts +46 -15
- package/dist/types/src/components/ui/Pagination.d.ts +16 -3
- package/dist/types/src/components/ui/Percentage.d.ts +14 -5
- package/dist/types/src/components/ui/Repeat.d.ts +14 -6
- package/dist/types/src/components/ui/Tab.d.ts +29 -2
- package/dist/types/src/components/ui/TabDynamic.d.ts +4 -3
- package/dist/types/src/components/ui/Table.d.ts +18 -14
- package/dist/types/src/components/ui/fields/CodeEditor.d.ts +46 -0
- package/dist/types/src/components/ui/fields/ContextMenu.d.ts +87 -0
- package/dist/types/src/components/ui/fields/Crop.d.ts +4 -2
- package/dist/types/src/components/ui/fields/ImageField.d.ts +31 -0
- package/dist/types/src/components/ui/fields/Input.d.ts +43 -14
- package/dist/types/src/components/ui/fields/Prompt.d.ts +2 -31
- package/dist/types/src/components/ui/fields/RichText.d.ts +89 -0
- package/dist/types/src/components/ui/fields/Select.d.ts +13 -10
- package/dist/types/src/components/ui/fields/Upload.d.ts +50 -2
- package/dist/types/src/components/ui/fields/UploadCSV.d.ts +2 -0
- package/dist/types/src/components/ui/useRecordSelection.d.ts +1 -2
- package/dist/types/src/components/widgets/Form.d.ts +80 -43
- package/dist/types/src/components/widgets/ImageEditor.d.ts +4 -5
- package/dist/types/src/components/widgets/MarkdownReader.d.ts +4 -4
- package/dist/types/src/components/widgets/Prompt.d.ts +90 -22
- package/dist/types/src/components/widgets/TabDynamic.d.ts +4 -3
- package/dist/types/src/components/widgets/form-controller.d.ts +42 -0
- package/dist/types/src/components/widgets/grid-core/GridCore.d.ts +1 -1
- package/dist/types/src/components/widgets/grid-core/GridDB.d.ts +1 -1
- package/dist/types/src/components/widgets/grid-core/GridGalleryView.d.ts +1 -1
- package/dist/types/src/components/widgets/grid-core/GridTableView.d.ts +1 -1
- package/dist/types/src/components/widgets/grid-core/types.d.ts +77 -27
- package/dist/types/src/components/widgets/grid-core/useGridActions.d.ts +4 -8
- package/dist/types/src/components/widgets/grid-core/useGridColumns.d.ts +2 -2
- package/dist/types/src/components/widgets/grid-core/useGridDBRecords.d.ts +1 -2
- package/dist/types/src/components/widgets/grid-core/useGridPreparedRecords.d.ts +2 -2
- package/dist/types/src/components/widgets/grid-core/useGridSelection.d.ts +4 -5
- package/dist/types/src/components/widgets/grid-core/utils.d.ts +11 -3
- package/dist/types/src/conf/Prompt.d.ts +1 -1
- package/dist/types/src/conf/i18n/ar.d.ts +2 -0
- package/dist/types/src/conf/i18n/de.d.ts +2 -0
- package/dist/types/src/conf/i18n/en.d.ts +2 -0
- package/dist/types/src/conf/i18n/index.d.ts +6 -0
- package/dist/types/src/conf/i18n/it.d.ts +2 -0
- package/dist/types/src/conf/i18n/ru.d.ts +2 -0
- package/dist/types/src/conf/i18n/zh.d.ts +2 -0
- package/dist/types/src/constant.d.ts +1 -1
- package/dist/types/src/index.d.ts +48 -13
- package/dist/types/src/libs/converter.d.ts +4 -4
- package/dist/types/src/libs/editorHeight.d.ts +12 -0
- package/dist/types/src/libs/fetch.d.ts +4 -4
- package/dist/types/src/libs/imageBuilder.d.ts +63 -14
- package/dist/types/src/libs/imageVariants.d.ts +35 -0
- package/dist/types/src/libs/index.d.ts +1 -4
- package/dist/types/src/libs/promptUtils.d.ts +24 -0
- package/dist/types/src/libs/sanitizer.d.ts +2 -2
- package/dist/types/src/libs/utils.d.ts +9 -10
- package/dist/types/src/pages/index.d.ts +0 -2
- package/dist/types/src/providers/ProviderConfiguration.d.ts +6 -0
- package/dist/types/src/providers/ProviderDescriptor.d.ts +18 -0
- package/dist/types/src/providers/ProviderRegistryContext.d.ts +51 -0
- package/dist/types/src/providers/ProviderSession.d.ts +68 -0
- package/dist/types/src/providers/ai/AIProvider.d.ts +57 -0
- package/dist/types/src/providers/ai/AIProviderContext.d.ts +13 -0
- package/dist/types/src/providers/ai/anthropic.d.ts +2 -0
- package/dist/types/src/providers/ai/deepseek.d.ts +1 -0
- package/dist/types/src/providers/ai/gemini.d.ts +2 -0
- package/dist/types/src/providers/ai/glm.d.ts +1 -0
- package/dist/types/src/providers/ai/index.d.ts +20 -134
- package/dist/types/src/providers/ai/mistral.d.ts +1 -0
- package/dist/types/src/providers/ai/openai.d.ts +1 -0
- package/dist/types/src/providers/ai/openaiCompatible.d.ts +19 -0
- package/dist/types/src/providers/ai/opencode.d.ts +2 -0
- package/dist/types/src/providers/ai/openrouter.d.ts +1 -0
- package/dist/types/src/providers/ai/shared.d.ts +55 -0
- package/dist/types/src/providers/api/ApiProvider.d.ts +43 -0
- package/dist/types/src/providers/api/direct.d.ts +14 -0
- package/dist/types/src/providers/api/firebase.d.ts +14 -0
- package/dist/types/src/providers/api/mock.d.ts +7 -0
- package/dist/types/src/providers/api/supabase.d.ts +14 -0
- package/dist/types/src/providers/auth/AuthProvider.d.ts +10 -2
- package/dist/types/src/providers/auth/firebase/FirebaseAuthProvider.d.ts +49 -0
- package/dist/types/src/providers/auth/google/GoogleAuth.d.ts +2 -2
- package/dist/types/src/providers/auth/supabase/SupabaseAuthProvider.d.ts +48 -0
- package/dist/types/src/providers/credentials/CredentialsProvider.d.ts +3 -0
- package/dist/types/src/providers/credentials/CredentialsProviderContext.d.ts +12 -0
- package/dist/types/src/providers/credentials/google/GoogleServiceAccountProvider.d.ts +8 -0
- package/dist/types/src/providers/data/DataProvider.d.ts +27 -1
- package/dist/types/src/providers/data/firebase.d.ts +5 -4
- package/dist/types/src/providers/data/firestore.d.ts +45 -0
- package/dist/types/src/providers/data/mock.d.ts +8 -1
- package/dist/types/src/providers/data/supabase.d.ts +36 -10
- package/dist/types/src/providers/email/definitions.d.ts +3 -0
- package/dist/types/src/providers/firebase-init.d.ts +24 -7
- package/dist/types/src/providers/icon/PhosphorIconProvider.d.ts +1 -1
- package/dist/types/src/providers/manifest.d.ts +20 -14
- package/dist/types/src/providers/proxy/index.d.ts +7 -0
- package/dist/types/src/providers/proxy/vite.d.ts +3 -0
- package/dist/types/src/providers/publish/PublishProvider.d.ts +29 -0
- package/dist/types/src/providers/publish/definitions.d.ts +3 -0
- package/dist/types/src/providers/scrape/index.d.ts +2 -1
- package/dist/types/src/providers/seo/google/keyword.d.ts +6 -1
- package/dist/types/src/providers/storage/StorageProvider.d.ts +155 -4
- package/dist/types/src/providers/storage/dropbox.d.ts +3 -3
- package/dist/types/src/providers/storage/firebase.d.ts +44 -7
- package/dist/types/src/providers/storage/supabase.d.ts +47 -7
- package/dist/types/src/providers/supabase-init.d.ts +35 -0
- package/dist/types/src/types/FormFields.d.ts +4 -2
- package/dist/types/src/types/FormSchema.d.ts +29 -0
- package/dist/types/themes/tokyo-night-light.d.ts +3 -0
- package/dist/types/themes/tokyo-night.d.ts +3 -0
- package/dist/types/themes/vscode-dark-plus.d.ts +3 -0
- package/dist/types/themes/vscode-light-plus.d.ts +3 -0
- package/dist/vite.js +1 -0
- package/dist/vite.mjs +54 -0
- package/package.json +46 -8
- package/scripts/cli/proxy-templates/cloudflare.ts +34 -0
- package/scripts/cli/proxy-templates/express.ts +77 -0
- package/scripts/cli/proxy-templates/nextjs-app.ts +42 -0
- package/scripts/cli/proxy-templates/nextjs-pages.ts +41 -0
- package/scripts/cli/proxy-templates/scaffold.json +33 -0
- package/scripts/cli/setup-devtools.js +155 -85
- package/scripts/cli/setup-project.js +618 -484
- package/themes/cyber.ts +469 -405
- package/themes/default.ts +469 -405
- package/themes/flat.ts +469 -405
- package/themes/tokyo-night-light.ts +38 -0
- package/themes/tokyo-night.ts +38 -0
- package/themes/vscode-dark-plus.ts +29 -0
- package/themes/vscode-light-plus.ts +29 -0
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/types/src/components/FormEnhancer.d.ts +0 -26
- package/dist/types/src/components/Template.d.ts +0 -18
- package/dist/types/src/components/ui/fields/AssistantAI.d.ts +0 -23
- package/dist/types/src/components/ui/fields/Command.d.ts +0 -15
- package/dist/types/src/components/ui/fields/ImageUrl.d.ts +0 -7
- package/dist/types/src/libs/cache.d.ts +0 -9
- package/dist/types/src/libs/database.d.ts +0 -3
- package/dist/types/src/libs/log.d.ts +0 -2
- package/dist/types/src/libs/seo.d.ts +0 -8
- package/dist/types/src/libs/storage.d.ts +0 -2
- package/dist/types/src/pages/Blog.d.ts +0 -3
- package/dist/types/src/pages/BlogPost.d.ts +0 -16
- package/dist/types/src/pages/Helper.d.ts +0 -8
- package/dist/types/src/providers/auth/google/apis/auth.d.ts +0 -4
- package/dist/types/src/types/Block.d.ts +0 -4
- package/dist/types/src/types/Section.d.ts +0 -4
|
@@ -6,6 +6,12 @@ export interface ProviderConfigurationState {
|
|
|
6
6
|
export interface ProviderConfigurable {
|
|
7
7
|
isConfigured?(): boolean;
|
|
8
8
|
getConfigurationState?(): ProviderConfigurationState;
|
|
9
|
+
/**
|
|
10
|
+
* Optional teardown hook. Called by setProvider() before an adapter is replaced
|
|
11
|
+
* in the registry — e.g. unsubscribe realtime listeners, sign out, close connections.
|
|
12
|
+
* Never called on unmount; only on explicit replacement.
|
|
13
|
+
*/
|
|
14
|
+
dispose?(): Promise<void> | void;
|
|
9
15
|
}
|
|
10
16
|
export declare const getMissingKeys: (config: Record<string, unknown> | undefined, keys: string[], prefix?: string) => string[];
|
|
11
17
|
export declare const createConfigurationState: (provider: string, missingKeys: string[]) => ProviderConfigurationState;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ProviderCredentialField = {
|
|
2
|
+
key: string;
|
|
3
|
+
label: string;
|
|
4
|
+
type: 'text' | 'password' | 'textarea';
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
};
|
|
7
|
+
export type ProviderDescriptor = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
description: string;
|
|
11
|
+
credentialFields: ProviderCredentialField[];
|
|
12
|
+
/** Where to go find/generate this credential (the provider's own dashboard/API keys page). */
|
|
13
|
+
credentialsUrl?: string;
|
|
14
|
+
/** Short guidance on where in that dashboard to look, when the URL alone isn't obvious. */
|
|
15
|
+
credentialsHint?: string;
|
|
16
|
+
/** Numbered walkthrough for setups too involved for a one-line hint (e.g. multi-console flows). Rendered instead of credentialsHint when present. */
|
|
17
|
+
credentialsSteps?: string[];
|
|
18
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DataProviderAdapter } from './data/DataProvider';
|
|
3
|
+
import type { StorageProviderAdapter } from './storage/StorageProvider';
|
|
4
|
+
import type { AuthProviderAdapter } from './auth/AuthProvider';
|
|
5
|
+
import type { EmailProviderAdapter } from './email/EmailProvider';
|
|
6
|
+
import type { AIProviderAdapter } from './ai/AIProvider';
|
|
7
|
+
import type { CredentialsAdapter } from './credentials/CredentialsProvider';
|
|
8
|
+
export type ProviderAdapterMap = {
|
|
9
|
+
data: DataProviderAdapter;
|
|
10
|
+
storage: StorageProviderAdapter;
|
|
11
|
+
auth: AuthProviderAdapter;
|
|
12
|
+
email: EmailProviderAdapter;
|
|
13
|
+
ai: AIProviderAdapter;
|
|
14
|
+
credentials: CredentialsAdapter;
|
|
15
|
+
};
|
|
16
|
+
/** The 6 categories the framework ships out of the box. Any other string is a valid category too — see customCategories on <App>. */
|
|
17
|
+
export type ProviderService = keyof ProviderAdapterMap;
|
|
18
|
+
export type ProviderRegistrySnapshot = Record<string, {
|
|
19
|
+
registry: Record<string, unknown>;
|
|
20
|
+
defaultKey: string;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Replaces a single named adapter in a provider registry at runtime, in ANY
|
|
24
|
+
* category — one of the 6 built-in ones (typed) or an arbitrary custom one a
|
|
25
|
+
* vertical registered (string). Calls the previous adapter's dispose() (if
|
|
26
|
+
* defined) before swapping it in, then propagates the new registry to every
|
|
27
|
+
* useXProvider()/useProvider() consumer. If `category` didn't exist yet, it's
|
|
28
|
+
* created — categories can be registered after bootstrap, not only via <App providers>.
|
|
29
|
+
*/
|
|
30
|
+
export type SetProviderFn = {
|
|
31
|
+
<S extends ProviderService>(category: S, key: string, adapter: ProviderAdapterMap[S]): Promise<void>;
|
|
32
|
+
(category: string, key: string, adapter: unknown): Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
type ProviderRegistryContextValue = {
|
|
35
|
+
registries: ProviderRegistrySnapshot;
|
|
36
|
+
setProvider: SetProviderFn;
|
|
37
|
+
};
|
|
38
|
+
declare const ProviderRegistryContext: React.Context<ProviderRegistryContextValue | null>;
|
|
39
|
+
export declare const ProviderRegistryProvider: ({ registries, setProvider, children, }: ProviderRegistryContextValue & {
|
|
40
|
+
children: React.ReactNode;
|
|
41
|
+
}) => React.JSX.Element;
|
|
42
|
+
/** Imperatively swap a provider adapter at runtime (e.g. reconnect data/storage to a different backend). */
|
|
43
|
+
export declare const useSetProvider: () => SetProviderFn;
|
|
44
|
+
/**
|
|
45
|
+
* Generic read access to any provider category — built-in or custom. Prefer the
|
|
46
|
+
* typed useDataProvider()/useStorageProvider()/... for the 6 built-ins; reach for
|
|
47
|
+
* this when consuming a category the framework doesn't know about (registered via
|
|
48
|
+
* providers.customCategories or a runtime setProvider() call).
|
|
49
|
+
*/
|
|
50
|
+
export declare const useProvider: <T = unknown>(category: string, key?: string) => T;
|
|
51
|
+
export default ProviderRegistryContext;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { SetProviderFn } from './ProviderRegistryContext';
|
|
2
|
+
/**
|
|
3
|
+
* Generic multi-backend session switch — no domain vocabulary (tenant, workspace, ...).
|
|
4
|
+
* Given an endpoint that returns which backend project to connect to (per category —
|
|
5
|
+
* data, storage, or any custom category a vertical registered) and a scoped credential
|
|
6
|
+
* for it, resolves the right adapter and swaps it in via setProvider().
|
|
7
|
+
*
|
|
8
|
+
* A vertical app (e.g. a CMS with tenants) wraps this in its own thin, named provider
|
|
9
|
+
* (e.g. TenantProvider, mounted via <App contextProviders>) that knows what a "session"
|
|
10
|
+
* means for that app — this hook only knows how to connect to a backend and get out
|
|
11
|
+
* of the way.
|
|
12
|
+
*/
|
|
13
|
+
export type ProviderSessionCredential = {
|
|
14
|
+
type: string;
|
|
15
|
+
} & Record<string, unknown>;
|
|
16
|
+
export type ProviderSessionAssignment = {
|
|
17
|
+
/**
|
|
18
|
+
* Matched against the factory registry below — 'firebase'/'supabase'/'mock' are
|
|
19
|
+
* built in, a vertical can register more with registerProviderSessionFactory().
|
|
20
|
+
* An assignment whose (category, type) has no registered factory is discarded,
|
|
21
|
+
* not an error — a session response can describe categories/types this particular
|
|
22
|
+
* app build doesn't know about without breaking the switch for the ones it does.
|
|
23
|
+
*/
|
|
24
|
+
type: string;
|
|
25
|
+
/** Client-safe config for this provider's project — never a secret. */
|
|
26
|
+
publicConfig: Record<string, unknown>;
|
|
27
|
+
/** Scoped, short-lived credential resolved server-side. Absent = anonymous/public access. */
|
|
28
|
+
credential?: ProviderSessionCredential;
|
|
29
|
+
};
|
|
30
|
+
/** category (data, storage, or any custom one) → assignment. Open-ended on purpose. */
|
|
31
|
+
export type ProviderSessionResponse = {
|
|
32
|
+
providers: Record<string, ProviderSessionAssignment>;
|
|
33
|
+
};
|
|
34
|
+
export type ProviderSessionFactory = (assignment: ProviderSessionAssignment) => unknown | Promise<unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Registers how to turn a ProviderSessionAssignment into a live adapter for a given
|
|
37
|
+
* (category, type) pair. Callable anytime — at module load, or later once a feature
|
|
38
|
+
* that needs it is loaded — not only at <App> bootstrap.
|
|
39
|
+
*/
|
|
40
|
+
export declare const registerProviderSessionFactory: (category: string, type: string, factory: ProviderSessionFactory) => void;
|
|
41
|
+
export type ProviderSessionSwitchOptions = {
|
|
42
|
+
fetchOptions?: RequestInit;
|
|
43
|
+
/**
|
|
44
|
+
* Inspect or transform the raw response before it's applied — e.g. inject an extra
|
|
45
|
+
* category, filter one out, forward it to an audit log. Whatever this returns
|
|
46
|
+
* (defaults to the untouched response) is what actually gets applied.
|
|
47
|
+
*/
|
|
48
|
+
onResponse?: (response: ProviderSessionResponse) => ProviderSessionResponse | Promise<ProviderSessionResponse>;
|
|
49
|
+
};
|
|
50
|
+
/** Which (category, type) pairs were actually applied vs had no matching factory. */
|
|
51
|
+
export type ProviderSessionSwitchResult = {
|
|
52
|
+
applied: string[];
|
|
53
|
+
skipped: {
|
|
54
|
+
category: string;
|
|
55
|
+
type: string;
|
|
56
|
+
}[];
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Either a URL to fetch (real backend) or a resolver function that produces the same
|
|
60
|
+
* response shape directly (e.g. a mock backend, or any non-HTTP source). Everything
|
|
61
|
+
* downstream of "here's the response body" is identical either way — only the transport
|
|
62
|
+
* differs, so swapping a mock resolver for a real endpoint later touches no other code.
|
|
63
|
+
*/
|
|
64
|
+
export type SwitchProviderSessionFn = (source: string | (() => Promise<ProviderSessionResponse>), options?: ProviderSessionSwitchOptions) => Promise<ProviderSessionSwitchResult>;
|
|
65
|
+
export declare const useProviderSession: () => {
|
|
66
|
+
switchSession: SwitchProviderSessionFn;
|
|
67
|
+
setProvider: SetProviderFn;
|
|
68
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { PromptVariables } from '../../conf/Prompt';
|
|
2
|
+
import type { ProviderConfigurable } from '../ProviderConfiguration';
|
|
3
|
+
export interface AIModelDescriptor {
|
|
4
|
+
id: string;
|
|
5
|
+
provider: string;
|
|
6
|
+
model: string;
|
|
7
|
+
label: string;
|
|
8
|
+
deprecated?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface AIProviderCapabilities {
|
|
11
|
+
models: AIModelDescriptor[];
|
|
12
|
+
supportsTemperature?: boolean;
|
|
13
|
+
supportsVision?: boolean;
|
|
14
|
+
supportsDocuments?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface AIAttachment {
|
|
17
|
+
mimeType: string;
|
|
18
|
+
base64: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AIRequestOptions {
|
|
22
|
+
language?: string;
|
|
23
|
+
voice?: string;
|
|
24
|
+
style?: string;
|
|
25
|
+
role?: string;
|
|
26
|
+
model?: string;
|
|
27
|
+
temperature?: number;
|
|
28
|
+
attachments?: AIAttachment[];
|
|
29
|
+
}
|
|
30
|
+
export interface AICompleteRequest extends AIRequestOptions {
|
|
31
|
+
prompt: string;
|
|
32
|
+
data?: PromptVariables;
|
|
33
|
+
}
|
|
34
|
+
export interface AIKeyValidationResult {
|
|
35
|
+
valid: boolean;
|
|
36
|
+
/** Human-readable error from the provider API (e.g. "Incorrect API key provided"). */
|
|
37
|
+
error?: string;
|
|
38
|
+
/** URL to the provider's API key management page, for showing in UI. */
|
|
39
|
+
dashboardUrl?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface AIProviderAdapter extends ProviderConfigurable {
|
|
42
|
+
id: string;
|
|
43
|
+
label: string;
|
|
44
|
+
defaultModel: string;
|
|
45
|
+
/** URL to the provider's API key management page. */
|
|
46
|
+
dashboardUrl?: string;
|
|
47
|
+
getCapabilities(forceRefresh?: boolean): Promise<AIProviderCapabilities>;
|
|
48
|
+
complete(request: AICompleteRequest): Promise<string | null>;
|
|
49
|
+
/** Makes a live API call to verify the key is accepted. Never uses cache. */
|
|
50
|
+
validateApiKey(): Promise<AIKeyValidationResult>;
|
|
51
|
+
}
|
|
52
|
+
export interface AIModelRef {
|
|
53
|
+
provider: string;
|
|
54
|
+
model: string;
|
|
55
|
+
}
|
|
56
|
+
export declare const formatAIModelRef: (provider: string, model: string) => string;
|
|
57
|
+
export declare const parseAIModelRef: (value?: string | null) => AIModelRef | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AIProviderAdapter } from './AIProvider';
|
|
3
|
+
type AIProviderContextValue = {
|
|
4
|
+
registry: Record<string, AIProviderAdapter>;
|
|
5
|
+
defaultKey: string;
|
|
6
|
+
};
|
|
7
|
+
declare const AIProviderContext: React.Context<AIProviderContextValue | null>;
|
|
8
|
+
export declare const AIProvider: ({ registry, defaultKey, children, }: AIProviderContextValue & {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}) => React.JSX.Element;
|
|
11
|
+
export declare const useAIProvider: (name?: string) => AIProviderAdapter | null;
|
|
12
|
+
export declare const useAIProviderRegistry: () => AIProviderContextValue | null;
|
|
13
|
+
export default AIProviderContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEEPSEEK_PROVIDER_DEFINITION: import("./shared").AIProviderDefinition;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GLM_PROVIDER_DEFINITION: import("./shared").AIProviderDefinition;
|
|
@@ -1,134 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
language?: string;
|
|
22
|
-
voice?: string;
|
|
23
|
-
style?: string;
|
|
24
|
-
role?: string;
|
|
25
|
-
model?: string;
|
|
26
|
-
temperature?: number;
|
|
27
|
-
}
|
|
28
|
-
export interface AIFetchConfig extends AIOptions {
|
|
29
|
-
provider?: keyof typeof PROVIDERS;
|
|
30
|
-
}
|
|
31
|
-
export declare const getAIProviderConfigurationState: (provider?: keyof typeof PROVIDERS) => ProviderConfigurationState;
|
|
32
|
-
declare const PROVIDERS: {
|
|
33
|
-
openai: {
|
|
34
|
-
name: string;
|
|
35
|
-
url: string;
|
|
36
|
-
model: string;
|
|
37
|
-
models: string[];
|
|
38
|
-
framework: string;
|
|
39
|
-
frameworks: string[];
|
|
40
|
-
temperature: number;
|
|
41
|
-
parseHeaders: () => {
|
|
42
|
-
'Content-Type': string;
|
|
43
|
-
Authorization: string;
|
|
44
|
-
};
|
|
45
|
-
parseBody: (prompt: string, role: string, options: AIOptions) => {
|
|
46
|
-
model: string;
|
|
47
|
-
messages: {
|
|
48
|
-
role: string;
|
|
49
|
-
content: string;
|
|
50
|
-
}[];
|
|
51
|
-
temperature: number;
|
|
52
|
-
};
|
|
53
|
-
parseResponse: (response: any) => any;
|
|
54
|
-
};
|
|
55
|
-
gemini: {
|
|
56
|
-
name: string;
|
|
57
|
-
url: string;
|
|
58
|
-
model: string;
|
|
59
|
-
models: string[];
|
|
60
|
-
temperature: number;
|
|
61
|
-
parseHeaders: () => {
|
|
62
|
-
'Content-Type': string;
|
|
63
|
-
Authorization: string;
|
|
64
|
-
};
|
|
65
|
-
parseBody: (prompt: string, role: string, options: AIOptions) => {
|
|
66
|
-
model: string;
|
|
67
|
-
instances: {
|
|
68
|
-
content: string;
|
|
69
|
-
}[];
|
|
70
|
-
temperature: number;
|
|
71
|
-
};
|
|
72
|
-
parseResponse: (response: any) => any;
|
|
73
|
-
};
|
|
74
|
-
anthropic: {
|
|
75
|
-
name: string;
|
|
76
|
-
url: string;
|
|
77
|
-
model: string;
|
|
78
|
-
models: string[];
|
|
79
|
-
temperature: number;
|
|
80
|
-
parseHeaders: () => {
|
|
81
|
-
'Content-Type': string;
|
|
82
|
-
Authorization: string;
|
|
83
|
-
};
|
|
84
|
-
parseBody: (prompt: string, role: string, options: AIOptions) => {
|
|
85
|
-
model: string;
|
|
86
|
-
messages: {
|
|
87
|
-
role: string;
|
|
88
|
-
content: string;
|
|
89
|
-
}[];
|
|
90
|
-
temperature: number;
|
|
91
|
-
};
|
|
92
|
-
parseResponse: (response: any) => any;
|
|
93
|
-
};
|
|
94
|
-
mistral: {
|
|
95
|
-
name: string;
|
|
96
|
-
url: string;
|
|
97
|
-
model: string;
|
|
98
|
-
models: string[];
|
|
99
|
-
temperature: number;
|
|
100
|
-
parseHeaders: () => {
|
|
101
|
-
'Content-Type': string;
|
|
102
|
-
Authorization: string;
|
|
103
|
-
};
|
|
104
|
-
parseBody: (prompt: string, role: string, options: AIOptions) => {
|
|
105
|
-
model: string;
|
|
106
|
-
messages: {
|
|
107
|
-
role: string;
|
|
108
|
-
content: string;
|
|
109
|
-
}[];
|
|
110
|
-
temperature: number;
|
|
111
|
-
};
|
|
112
|
-
parseResponse: (response: any) => any;
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
export declare class AI extends Prompt {
|
|
116
|
-
config: AIProvider;
|
|
117
|
-
options: AIOptions;
|
|
118
|
-
data?: PromptVariables;
|
|
119
|
-
static fetch(prompt: string, config: AIFetchConfig, data?: PromptVariables): Promise<any>;
|
|
120
|
-
static getModels(provider?: keyof typeof PROVIDERS): string[];
|
|
121
|
-
constructor(provider?: keyof typeof PROVIDERS);
|
|
122
|
-
setOptions(options: AIOptions): this;
|
|
123
|
-
setData(data?: PromptVariables): this;
|
|
124
|
-
static defaults(): {
|
|
125
|
-
model: string;
|
|
126
|
-
role: string;
|
|
127
|
-
language: string;
|
|
128
|
-
country: string;
|
|
129
|
-
voice: string;
|
|
130
|
-
style: string;
|
|
131
|
-
};
|
|
132
|
-
fetchAPI(prompt: string): Promise<any>;
|
|
133
|
-
}
|
|
134
|
-
export {};
|
|
1
|
+
import type { AIConfig } from '../../Config';
|
|
2
|
+
import type { ProviderDescriptor } from '../ProviderDescriptor';
|
|
3
|
+
import type { AIProviderAdapter } from './AIProvider';
|
|
4
|
+
import { type AIProviderDefinition } from './shared';
|
|
5
|
+
export type { AIProviderAdapter, AIKeyValidationResult, AIModelDescriptor, AIProviderCapabilities, AIRequestOptions, AIAttachment } from './AIProvider';
|
|
6
|
+
export { formatAIModelRef, parseAIModelRef } from './AIProvider';
|
|
7
|
+
export type { AIModelCatalog, AIProviderDefinition } from './shared';
|
|
8
|
+
export { getAIModelCatalog } from './shared';
|
|
9
|
+
export declare const AI_PROVIDER_DEFINITIONS: AIProviderDefinition[];
|
|
10
|
+
/** Generic "connect this provider" view of an AIProviderDefinition — the shape a CMS/admin
|
|
11
|
+
* UI needs (label, description, credential fields, where to find them), independent of the
|
|
12
|
+
* runtime completion contract (discoverModels/complete) it also carries. */
|
|
13
|
+
export declare const toProviderDescriptor: (definition: AIProviderDefinition) => ProviderDescriptor;
|
|
14
|
+
export declare const AI_PROVIDER_DESCRIPTORS: ProviderDescriptor[];
|
|
15
|
+
/** The user-configurable "bring your own endpoint" slot — metadata-only counterpart of the
|
|
16
|
+
* dynamic definition getDynamicAIProviderDefinitions() builds once a baseUrl is actually
|
|
17
|
+
* known. Not part of AI_PROVIDER_DEFINITIONS (there's nothing to build a working adapter
|
|
18
|
+
* from until the user supplies that URL), but a "connect" UI still needs to offer it. */
|
|
19
|
+
export declare const OPENAI_COMPATIBLE_PROVIDER_DESCRIPTOR: ProviderDescriptor;
|
|
20
|
+
export declare const createAIProviderRegistry: (aiConfig?: AIConfig) => Record<string, AIProviderAdapter>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MISTRAL_PROVIDER_DEFINITION: import("./shared").AIProviderDefinition;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const OPENAI_PROVIDER_DEFINITION: import("./shared").AIProviderDefinition;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AIProviderDefinition, BuiltInAIProviderId } from './shared';
|
|
2
|
+
type OpenAICompatibleDefinitionOptions = {
|
|
3
|
+
id: BuiltInAIProviderId;
|
|
4
|
+
label: string;
|
|
5
|
+
description: string;
|
|
6
|
+
configKey: string;
|
|
7
|
+
requiredConfigKeys?: string[];
|
|
8
|
+
defaultModel: string;
|
|
9
|
+
fallbackModels: string[];
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
modelsUrl?: string;
|
|
12
|
+
chatCompletionsUrl?: string;
|
|
13
|
+
dashboardUrl?: string;
|
|
14
|
+
credentialsHint?: string;
|
|
15
|
+
/** Override the default validateApiKey when the models endpoint is public or uses a non-standard error format. */
|
|
16
|
+
validateApiKey?: AIProviderDefinition['validateApiKey'];
|
|
17
|
+
};
|
|
18
|
+
export declare const createOpenAICompatibleProviderDefinition: ({ id, label, description, configKey, requiredConfigKeys, defaultModel, fallbackModels, baseUrl, modelsUrl, chatCompletionsUrl, dashboardUrl, credentialsHint, validateApiKey: validateApiKeyOverride, }: OpenAICompatibleDefinitionOptions) => AIProviderDefinition;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const OPENROUTER_PROVIDER_DEFINITION: import("./shared").AIProviderDefinition;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type ProviderConfigurationState } from '../ProviderConfiguration';
|
|
2
|
+
import type { ProviderCredentialField } from '../ProviderDescriptor';
|
|
3
|
+
import type { AICompleteRequest, AIKeyValidationResult, AIModelDescriptor, AIProviderAdapter, AIProviderCapabilities, AIRequestOptions } from './AIProvider';
|
|
4
|
+
export type BuiltInAIProviderId = 'openai' | 'openrouter' | 'opencode' | 'openai-compatible' | 'deepseek' | 'gemini' | 'anthropic' | 'mistral' | 'glm';
|
|
5
|
+
export type AIProviderDefinition = {
|
|
6
|
+
id: BuiltInAIProviderId;
|
|
7
|
+
label: string;
|
|
8
|
+
/** One-line description shown in a "connect this provider" UI. */
|
|
9
|
+
description?: string;
|
|
10
|
+
configKey?: string;
|
|
11
|
+
requiredConfigKeys?: string[];
|
|
12
|
+
defaultModel: string;
|
|
13
|
+
fallbackModels: string[];
|
|
14
|
+
/** URL to the provider's API key management page (shown in UI on validation error, and
|
|
15
|
+
* surfaced as ProviderDescriptor.credentialsUrl via toProviderDescriptor()). */
|
|
16
|
+
dashboardUrl?: string;
|
|
17
|
+
/** Credential fields a "connect" UI should collect (defaults to a single apiKey field
|
|
18
|
+
* when omitted — see toProviderDescriptor() in ./index.ts). */
|
|
19
|
+
credentialFields?: ProviderCredentialField[];
|
|
20
|
+
/** Short guidance on where in the dashboard to find the credential. */
|
|
21
|
+
credentialsHint?: string;
|
|
22
|
+
capabilities?: Omit<AIProviderCapabilities, 'models'>;
|
|
23
|
+
discoverModels: (apiKey: string) => Promise<string[]>;
|
|
24
|
+
complete: (apiKey: string, request: Required<Pick<AICompleteRequest, 'prompt' | 'model'>> & AIRequestOptions) => Promise<string | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Per-provider auth check. When omitted, the default implementation in
|
|
27
|
+
* RuntimeAIProvider calls discoverModels() live (no cache) and treats any
|
|
28
|
+
* thrown error as invalid. Providers whose error format is non-standard or
|
|
29
|
+
* whose models endpoint is public MUST provide their own implementation.
|
|
30
|
+
*/
|
|
31
|
+
validateApiKey?: (apiKey: string) => Promise<Omit<AIKeyValidationResult, 'dashboardUrl'>>;
|
|
32
|
+
};
|
|
33
|
+
export type AIModelCatalog = {
|
|
34
|
+
models: AIModelDescriptor[];
|
|
35
|
+
modelsByProvider: Record<string, AIModelDescriptor[]>;
|
|
36
|
+
capabilitiesByProvider: Record<string, AIProviderCapabilities>;
|
|
37
|
+
};
|
|
38
|
+
export declare const extractProviderError: (err: unknown) => string;
|
|
39
|
+
export declare const createBrowserTransportError: (label: string) => Error;
|
|
40
|
+
export declare const parseTextResponse: (value: unknown) => string | null;
|
|
41
|
+
export declare const getAIModelCatalog: (registry: Record<string, AIProviderAdapter>, forceRefresh?: boolean) => Promise<AIModelCatalog>;
|
|
42
|
+
export declare class RuntimeAIProvider implements AIProviderAdapter {
|
|
43
|
+
id: BuiltInAIProviderId;
|
|
44
|
+
label: string;
|
|
45
|
+
defaultModel: string;
|
|
46
|
+
dashboardUrl?: string;
|
|
47
|
+
private readonly definition;
|
|
48
|
+
private readonly apiKey;
|
|
49
|
+
constructor(definition: AIProviderDefinition, apiKey: string);
|
|
50
|
+
isConfigured(): boolean;
|
|
51
|
+
getConfigurationState(): ProviderConfigurationState;
|
|
52
|
+
getCapabilities(forceRefresh?: boolean): Promise<AIProviderCapabilities>;
|
|
53
|
+
complete(request: AICompleteRequest): Promise<string | null>;
|
|
54
|
+
validateApiKey(): Promise<AIKeyValidationResult>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ProviderConfigurable } from '../ProviderConfiguration';
|
|
2
|
+
/**
|
|
3
|
+
* "api" — a real provider category (docs/24-tenant-platform.md, Service Gateway), same
|
|
4
|
+
* registry/lifecycle as data/storage/etc. Registers a third-party REST integration (Brevo,
|
|
5
|
+
* a payments API, a non-streaming AI provider, ...) once — base URL, fixed header/query/body
|
|
6
|
+
* fields (where a secret usually lives) — and exposes one generic call:
|
|
7
|
+
*
|
|
8
|
+
* setProvider('api', 'payments', new DirectApiProviderAdapter({
|
|
9
|
+
* baseUrl: 'https://payments.acme.com/api',
|
|
10
|
+
* header: { Authorization: 'Bearer <secret>' },
|
|
11
|
+
* }));
|
|
12
|
+
*
|
|
13
|
+
* useApiProvider('payments').fetch({ path: '/charges', method: 'post', body: { amount: 1000 } });
|
|
14
|
+
*
|
|
15
|
+
* Registered/fixed fields always win over a matching key the caller passes — same
|
|
16
|
+
* authoritative-merge rule as the tenant-session handshake.
|
|
17
|
+
*
|
|
18
|
+
* Other category adapters (an EmailProviderAdapter for Brevo, an AIProviderAdapter for a
|
|
19
|
+
* REST-only model) call an ApiProviderAdapter internally instead of fetch()/proxyFetch()
|
|
20
|
+
* directly — a vendor adapter is just a few lines of normal code, no framework-provided bridge.
|
|
21
|
+
*
|
|
22
|
+
* Adapters (same interface, different execution context — mirrors DataProviderAdapter's
|
|
23
|
+
* Firebase/Supabase/Mock split), one file each like data/storage:
|
|
24
|
+
* - direct.ts — DirectApiProviderAdapter, client-resident, via proxyFetch (CORS-safe). The
|
|
25
|
+
* secret IS visible to the browser here — a dev/personal key, or a no-backend deploy, never
|
|
26
|
+
* a real shared tenant secret.
|
|
27
|
+
* - firebase.ts — FirebaseApiProviderAdapter, routes through a Firebase Callable Function;
|
|
28
|
+
* the secret lives server-side, resolved there from the real tenant/user registration.
|
|
29
|
+
* - supabase.ts — SupabaseApiProviderAdapter, same idea via a Supabase Edge Function.
|
|
30
|
+
* - mock.ts — MockApiProviderAdapter, resolves via a local function, no network. Dev/tests.
|
|
31
|
+
*/
|
|
32
|
+
export type ApiProviderRequest = {
|
|
33
|
+
path: string;
|
|
34
|
+
/** Default: 'POST'. */
|
|
35
|
+
method?: string;
|
|
36
|
+
query?: Record<string, string>;
|
|
37
|
+
body?: unknown;
|
|
38
|
+
};
|
|
39
|
+
export interface ApiProviderAdapter extends ProviderConfigurable {
|
|
40
|
+
fetch(request: ApiProviderRequest): Promise<unknown>;
|
|
41
|
+
}
|
|
42
|
+
/** Convenience wrapper over useProvider('api', name) — same registry, just the ergonomic one-arg form. */
|
|
43
|
+
export declare const useApiProvider: (name: string) => ApiProviderAdapter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ApiProviderAdapter, ApiProviderRequest } from './ApiProvider';
|
|
2
|
+
export type DirectApiProviderConfig = {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
/** Fixed fields merged into every call — this is where a secret normally lives. Always wins over a matching key in the request. */
|
|
5
|
+
header?: Record<string, string>;
|
|
6
|
+
query?: Record<string, string>;
|
|
7
|
+
body?: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
/** Client-resident: calls the target directly via proxyFetch (CORS-safe). Secret visible to the browser — dev/personal key or no-backend deploy only. */
|
|
10
|
+
export declare class DirectApiProviderAdapter implements ApiProviderAdapter {
|
|
11
|
+
private config;
|
|
12
|
+
constructor(config: DirectApiProviderConfig);
|
|
13
|
+
fetch(request: ApiProviderRequest): Promise<unknown>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ApiProviderAdapter, ApiProviderRequest } from './ApiProvider';
|
|
2
|
+
export type FirebaseApiProviderConfig = {
|
|
3
|
+
/** Name of the Callable Function that receives { provider, request } and does the real, secret-bearing call server-side. */
|
|
4
|
+
functionName: string;
|
|
5
|
+
/** The registered provider's own name — sent alongside the request so the function knows which registration to resolve. */
|
|
6
|
+
providerName: string;
|
|
7
|
+
region?: string;
|
|
8
|
+
};
|
|
9
|
+
/** Routes through a Firebase Callable Function — the secret lives server-side, resolved there from the real tenant/user registration. */
|
|
10
|
+
export declare class FirebaseApiProviderAdapter implements ApiProviderAdapter {
|
|
11
|
+
private config;
|
|
12
|
+
constructor(config: FirebaseApiProviderConfig);
|
|
13
|
+
fetch(request: ApiProviderRequest): Promise<unknown>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ApiProviderAdapter, ApiProviderRequest } from './ApiProvider';
|
|
2
|
+
/** Resolves via a local function, no network. Dev/tests. */
|
|
3
|
+
export declare class MockApiProviderAdapter implements ApiProviderAdapter {
|
|
4
|
+
private resolver;
|
|
5
|
+
constructor(resolver: (request: ApiProviderRequest) => unknown | Promise<unknown>);
|
|
6
|
+
fetch(request: ApiProviderRequest): Promise<unknown>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ApiProviderAdapter, ApiProviderRequest } from './ApiProvider';
|
|
2
|
+
export type SupabaseApiProviderConfig = {
|
|
3
|
+
url: string;
|
|
4
|
+
anonKey: string;
|
|
5
|
+
/** Name of the Edge Function that receives { provider, request } and does the real, secret-bearing call server-side. */
|
|
6
|
+
functionName: string;
|
|
7
|
+
providerName: string;
|
|
8
|
+
};
|
|
9
|
+
/** Routes through a Supabase Edge Function — the secret lives server-side, resolved there from the real tenant/user registration. */
|
|
10
|
+
export declare class SupabaseApiProviderAdapter implements ApiProviderAdapter {
|
|
11
|
+
private config;
|
|
12
|
+
constructor(config: SupabaseApiProviderConfig);
|
|
13
|
+
fetch(request: ApiProviderRequest): Promise<unknown>;
|
|
14
|
+
}
|
|
@@ -4,13 +4,13 @@ export interface UserProfile {
|
|
|
4
4
|
email?: string;
|
|
5
5
|
displayName?: string;
|
|
6
6
|
photoURL?: string;
|
|
7
|
-
[key: string]:
|
|
7
|
+
[key: string]: unknown;
|
|
8
8
|
}
|
|
9
9
|
export type AuthIntent = 'signIn' | 'connect' | 'signOut' | 'disconnect' | 'reauthorize';
|
|
10
10
|
export interface AuthSignInOptions {
|
|
11
11
|
scopes?: string[];
|
|
12
12
|
intent?: AuthIntent;
|
|
13
|
-
[key: string]:
|
|
13
|
+
[key: string]: unknown;
|
|
14
14
|
}
|
|
15
15
|
export interface AuthProviderAdapter extends ProviderConfigurable {
|
|
16
16
|
getUser(): UserProfile | null;
|
|
@@ -19,4 +19,12 @@ export interface AuthProviderAdapter extends ProviderConfigurable {
|
|
|
19
19
|
onAuthChange(callback: (user: UserProfile | null) => void): () => void;
|
|
20
20
|
getAccessToken?(scopes?: string[]): Promise<string>;
|
|
21
21
|
isAuthenticated?(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Custom claims embedded in the current session's token (e.g. a JWT's payload),
|
|
24
|
+
* for providers backed by one — Firebase custom claims, a Supabase JWT, etc.
|
|
25
|
+
* Optional: providers with no token-claims concept (e.g. plain OAuth) omit it.
|
|
26
|
+
* Read-only/UI convenience — never a security boundary, the server always
|
|
27
|
+
* re-verifies the raw token itself rather than trusting client-read claims.
|
|
28
|
+
*/
|
|
29
|
+
getIdTokenClaims?(): Promise<Record<string, unknown> | null>;
|
|
22
30
|
}
|