@intlayer/design-system 9.5.2 → 9.5.4-canary.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 +7 -7
- package/dist/esm/api/useAuth/useOAuth2.mjs +1 -1
- package/dist/esm/api/useAuth/useSession.mjs +2 -2
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.mjs +6 -6
- package/dist/esm/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs +11 -11
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs.map +1 -1
- package/dist/esm/components/Form/FormBase.mjs +17 -3
- package/dist/esm/components/Form/FormBase.mjs.map +1 -1
- package/dist/esm/components/Form/elements/FormElement.mjs +4 -1
- package/dist/esm/components/Form/elements/FormElement.mjs.map +1 -1
- package/dist/esm/components/Form/elements/FormElementWrapper.mjs +2 -2
- package/dist/esm/components/Form/elements/FormElementWrapper.mjs.map +1 -1
- package/dist/esm/components/Form/elements/OTPElement.mjs +1 -1
- package/dist/esm/components/Form/index.mjs +2 -2
- package/dist/esm/components/IDE/MarkDownRender.mjs +1 -1
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +1 -1
- package/dist/esm/components/Modal/Modal.mjs +2 -2
- package/dist/esm/components/Navbar/MobileNavbar.mjs +1 -1
- package/dist/esm/components/Pagination/Pagination.mjs +1 -1
- package/dist/esm/components/Pattern/GridDistortionPattern.mjs +1 -1
- package/dist/esm/components/RightDrawer/RightDrawer.mjs +3 -3
- package/dist/esm/components/Status/index.mjs +3 -6
- package/dist/esm/components/Status/index.mjs.map +1 -1
- package/dist/esm/components/Tab/Tab.mjs +1 -1
- package/dist/esm/components/index.mjs +2 -2
- package/dist/esm/hooks/index.mjs +11 -9
- package/dist/esm/hooks/useRemoteMcpTools.mjs +56 -0
- package/dist/esm/hooks/useRemoteMcpTools.mjs.map +1 -0
- package/dist/esm/hooks/useWebMCPTools.mjs +44 -0
- package/dist/esm/hooks/useWebMCPTools.mjs.map +1 -0
- package/dist/esm/libs/auth.mjs +3 -2
- package/dist/esm/libs/auth.mjs.map +1 -1
- package/dist/esm/providers/index.mjs +1 -1
- package/dist/esm/structured-data/index.mjs +6 -6
- package/dist/esm/webmcp/createRemoteMcpTools.mjs +65 -0
- package/dist/esm/webmcp/createRemoteMcpTools.mjs.map +1 -0
- package/dist/esm/webmcp/getModelContext.mjs +28 -0
- package/dist/esm/webmcp/getModelContext.mjs.map +1 -0
- package/dist/esm/webmcp/index.mjs +5 -0
- package/dist/esm/webmcp/registerWebMCPTools.mjs +54 -0
- package/dist/esm/webmcp/registerWebMCPTools.mjs.map +1 -0
- package/dist/esm/webmcp/types.mjs +0 -0
- package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.d.ts +7 -7
- package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.d.ts.map +1 -1
- package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts +10 -10
- package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts.map +1 -1
- package/dist/types/components/Form/FormBase.d.ts +27 -4
- package/dist/types/components/Form/FormBase.d.ts.map +1 -1
- package/dist/types/components/Form/elements/FormElement.d.ts +1 -0
- package/dist/types/components/Form/elements/FormElement.d.ts.map +1 -1
- package/dist/types/components/Form/elements/FormElementWrapper.d.ts +3 -3
- package/dist/types/components/Form/index.d.ts +2 -2
- package/dist/types/components/index.d.ts +2 -2
- package/dist/types/hooks/index.d.ts +3 -1
- package/dist/types/hooks/useRemoteMcpTools.d.ts +18 -0
- package/dist/types/hooks/useRemoteMcpTools.d.ts.map +1 -0
- package/dist/types/hooks/useWebMCPTools.d.ts +22 -0
- package/dist/types/hooks/useWebMCPTools.d.ts.map +1 -0
- package/dist/types/libs/auth.d.ts.map +1 -1
- package/dist/types/webmcp/createRemoteMcpTools.d.ts +52 -0
- package/dist/types/webmcp/createRemoteMcpTools.d.ts.map +1 -0
- package/dist/types/webmcp/getModelContext.d.ts +18 -0
- package/dist/types/webmcp/getModelContext.d.ts.map +1 -0
- package/dist/types/webmcp/index.d.ts +5 -0
- package/dist/types/webmcp/registerWebMCPTools.d.ts +19 -0
- package/dist/types/webmcp/registerWebMCPTools.d.ts.map +1 -0
- package/dist/types/webmcp/types.d.ts +74 -0
- package/dist/types/webmcp/types.d.ts.map +1 -0
- package/package.json +36 -30
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Mcp_Root } from "../routes.mjs";
|
|
4
|
+
import { isWebMCPAvailable } from "../webmcp/getModelContext.mjs";
|
|
5
|
+
import { createRemoteMcpTools } from "../webmcp/createRemoteMcpTools.mjs";
|
|
6
|
+
import { useEffect, useRef, useState } from "react";
|
|
7
|
+
|
|
8
|
+
//#region src/hooks/useRemoteMcpTools.ts
|
|
9
|
+
/**
|
|
10
|
+
* Tools of the hosted `@intlayer/mcp` server worth mirroring in the browser.
|
|
11
|
+
* The rest either needs API credentials or duplicates a page tool.
|
|
12
|
+
*/
|
|
13
|
+
const INTLAYER_DOC_TOOL_NAMES = /* @__PURE__ */ new Set(["fetch-doc-chunks", "get-doc-by-slug"]);
|
|
14
|
+
const isIntlayerDocTool = (tool) => INTLAYER_DOC_TOOL_NAMES.has(tool.name);
|
|
15
|
+
/** `fetch-doc-chunks` → `fetchDocChunks`, matching the page's own tool names. */
|
|
16
|
+
const toCamelCase = (name) => name.replace(/-(\w)/g, (_match, character) => character.toUpperCase());
|
|
17
|
+
/**
|
|
18
|
+
* Bridges the tools of a remote MCP server into the page, so an agent in the
|
|
19
|
+
* browser gets the same retrieval an IDE agent has, without the page
|
|
20
|
+
* re-implementing them.
|
|
21
|
+
*
|
|
22
|
+
* Defaults to the documentation tools of the Intlayer MCP server. Discovery
|
|
23
|
+
* runs once per `serverUrl`; the other options are read at that moment.
|
|
24
|
+
*
|
|
25
|
+
* @returns The wrapped tools, empty until discovery completes or when no
|
|
26
|
+
* browser agent could use them.
|
|
27
|
+
*/
|
|
28
|
+
const useRemoteMcpTools = (options = {}) => {
|
|
29
|
+
const [remoteTools, setRemoteTools] = useState([]);
|
|
30
|
+
const optionsRef = useRef(options);
|
|
31
|
+
const serverUrl = options.serverUrl ?? "https://mcp.intlayer.org";
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
optionsRef.current = options;
|
|
34
|
+
});
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!isWebMCPAvailable()) return;
|
|
37
|
+
const abortController = new AbortController();
|
|
38
|
+
const { filter = isIntlayerDocTool, renameTool = toCamelCase, ...discoveryOptions } = optionsRef.current;
|
|
39
|
+
createRemoteMcpTools({
|
|
40
|
+
...discoveryOptions,
|
|
41
|
+
serverUrl,
|
|
42
|
+
filter,
|
|
43
|
+
renameTool,
|
|
44
|
+
signal: abortController.signal
|
|
45
|
+
}).then(setRemoteTools).catch((error) => {
|
|
46
|
+
if (abortController.signal.aborted) return;
|
|
47
|
+
console.warn(`[WebMCP] MCP server unreachable: ${serverUrl}`, error);
|
|
48
|
+
});
|
|
49
|
+
return () => abortController.abort();
|
|
50
|
+
}, [serverUrl]);
|
|
51
|
+
return remoteTools;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { useRemoteMcpTools };
|
|
56
|
+
//# sourceMappingURL=useRemoteMcpTools.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRemoteMcpTools.mjs","names":[],"sources":["../../../src/hooks/useRemoteMcpTools.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef, useState } from 'react';\nimport { Mcp_Root } from '../routes';\nimport {\n type CreateRemoteMcpToolsOptions,\n createRemoteMcpTools,\n} from '../webmcp/createRemoteMcpTools';\nimport { isWebMCPAvailable } from '../webmcp/getModelContext';\nimport type { WebMCPTool } from '../webmcp/types';\n\n/**\n * Tools of the hosted `@intlayer/mcp` server worth mirroring in the browser.\n * The rest either needs API credentials or duplicates a page tool.\n */\nconst INTLAYER_DOC_TOOL_NAMES = new Set([\n 'fetch-doc-chunks',\n 'get-doc-by-slug',\n]);\n\nconst isIntlayerDocTool: NonNullable<CreateRemoteMcpToolsOptions['filter']> = (\n tool\n) => INTLAYER_DOC_TOOL_NAMES.has(tool.name);\n\n/** `fetch-doc-chunks` → `fetchDocChunks`, matching the page's own tool names. */\nconst toCamelCase = (name: string): string =>\n name.replace(/-(\\w)/g, (_match, character: string) =>\n character.toUpperCase()\n );\n\nexport type UseRemoteMcpToolsOptions = Partial<\n Omit<CreateRemoteMcpToolsOptions, 'signal'>\n>;\n\n/**\n * Bridges the tools of a remote MCP server into the page, so an agent in the\n * browser gets the same retrieval an IDE agent has, without the page\n * re-implementing them.\n *\n * Defaults to the documentation tools of the Intlayer MCP server. Discovery\n * runs once per `serverUrl`; the other options are read at that moment.\n *\n * @returns The wrapped tools, empty until discovery completes or when no\n * browser agent could use them.\n */\nexport const useRemoteMcpTools = (\n options: UseRemoteMcpToolsOptions = {}\n): WebMCPTool[] => {\n const [remoteTools, setRemoteTools] = useState<WebMCPTool[]>([]);\n const optionsRef = useRef(options);\n const serverUrl = options.serverUrl ?? Mcp_Root;\n\n useEffect(() => {\n optionsRef.current = options;\n });\n\n useEffect(() => {\n // Skip the discovery request when no agent could use its result.\n if (!isWebMCPAvailable()) return;\n\n const abortController = new AbortController();\n const {\n filter = isIntlayerDocTool,\n renameTool = toCamelCase,\n ...discoveryOptions\n } = optionsRef.current;\n\n createRemoteMcpTools({\n ...discoveryOptions,\n serverUrl,\n filter,\n renameTool,\n signal: abortController.signal,\n })\n .then(setRemoteTools)\n .catch((error: unknown) => {\n if (abortController.signal.aborted) return;\n console.warn(`[WebMCP] MCP server unreachable: ${serverUrl}`, error);\n });\n\n return () => abortController.abort();\n }, [serverUrl]);\n\n return remoteTools;\n};\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,0CAA0B,IAAI,IAAI,CACtC,oBACA,iBACF,CAAC;AAED,MAAM,qBACJ,SACG,wBAAwB,IAAI,KAAK,IAAI;;AAG1C,MAAM,eAAe,SACnB,KAAK,QAAQ,WAAW,QAAQ,cAC9B,UAAU,YAAY,CACxB;;;;;;;;;;;;AAiBF,MAAa,qBACX,UAAoC,CAAC,MACpB;CACjB,MAAM,CAAC,aAAa,kBAAkB,SAAuB,CAAC,CAAC;CAC/D,MAAM,aAAa,OAAO,OAAO;CACjC,MAAM,YAAY,QAAQ;CAE1B,gBAAgB;EACd,WAAW,UAAU;CACvB,CAAC;CAED,gBAAgB;EAEd,IAAI,CAAC,kBAAkB,GAAG;EAE1B,MAAM,kBAAkB,IAAI,gBAAgB;EAC5C,MAAM,EACJ,SAAS,mBACT,aAAa,aACb,GAAG,qBACD,WAAW;EAEf,qBAAqB;GACnB,GAAG;GACH;GACA;GACA;GACA,QAAQ,gBAAgB;EAC1B,CAAC,CAAC,CACC,KAAK,cAAc,CAAC,CACpB,OAAO,UAAmB;GACzB,IAAI,gBAAgB,OAAO,SAAS;GACpC,QAAQ,KAAK,oCAAoC,aAAa,KAAK;EACrE,CAAC;EAEH,aAAa,gBAAgB,MAAM;CACrC,GAAG,CAAC,SAAS,CAAC;CAEd,OAAO;AACT"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { registerWebMCPTools } from "../webmcp/registerWebMCPTools.mjs";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/hooks/useWebMCPTools.ts
|
|
7
|
+
/** Identifies the tool set the browser currently sees. */
|
|
8
|
+
const getToolsSignature = (tools) => JSON.stringify(tools.map((tool) => [
|
|
9
|
+
tool.name,
|
|
10
|
+
tool.description,
|
|
11
|
+
tool.inputSchema ?? null,
|
|
12
|
+
tool.annotations ?? null
|
|
13
|
+
]));
|
|
14
|
+
/**
|
|
15
|
+
* Exposes tools to browser agents for as long as the calling component is
|
|
16
|
+
* mounted, which scopes page-specific tools (a formatter, a scanner) to the
|
|
17
|
+
* page they belong to.
|
|
18
|
+
*
|
|
19
|
+
* Registration happens once per distinct tool set; `execute` handlers are
|
|
20
|
+
* read through a ref, so tools may close over fresh React state without being
|
|
21
|
+
* re-registered on every render. Renders nothing on the server.
|
|
22
|
+
*
|
|
23
|
+
* @param tools - Tools to expose while mounted.
|
|
24
|
+
*/
|
|
25
|
+
const useWebMCPTools = (tools) => {
|
|
26
|
+
const toolsRef = useRef(tools);
|
|
27
|
+
const signature = getToolsSignature(tools);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
toolsRef.current = tools;
|
|
30
|
+
});
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const proxies = toolsRef.current.map((tool) => ({
|
|
33
|
+
...tool,
|
|
34
|
+
execute: (input, options) => {
|
|
35
|
+
return (toolsRef.current.find((candidate) => candidate.name === tool.name) ?? tool).execute(input, options);
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
return registerWebMCPTools(proxies);
|
|
39
|
+
}, [signature]);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { useWebMCPTools };
|
|
44
|
+
//# sourceMappingURL=useWebMCPTools.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWebMCPTools.mjs","names":[],"sources":["../../../src/hooks/useWebMCPTools.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\nimport { registerWebMCPTools } from '../webmcp/registerWebMCPTools';\nimport type { WebMCPTool, WebMCPToolExecuteOptions } from '../webmcp/types';\n\n/**\n * A tool of any input type. `never` is assignable from every input, so tools\n * declared with a precise input type fit in one list; the browser hands each\n * `execute` the object it parsed from the agent's JSON.\n */\nexport type AnyWebMCPTool = WebMCPTool<never>;\n\n/** Identifies the tool set the browser currently sees. */\nconst getToolsSignature = (tools: AnyWebMCPTool[]): string =>\n JSON.stringify(\n tools.map((tool) => [\n tool.name,\n tool.description,\n tool.inputSchema ?? null,\n tool.annotations ?? null,\n ])\n );\n\n/**\n * Exposes tools to browser agents for as long as the calling component is\n * mounted, which scopes page-specific tools (a formatter, a scanner) to the\n * page they belong to.\n *\n * Registration happens once per distinct tool set; `execute` handlers are\n * read through a ref, so tools may close over fresh React state without being\n * re-registered on every render. Renders nothing on the server.\n *\n * @param tools - Tools to expose while mounted.\n */\nexport const useWebMCPTools = (tools: AnyWebMCPTool[]): void => {\n const toolsRef = useRef<AnyWebMCPTool[]>(tools);\n const signature = getToolsSignature(tools);\n\n useEffect(() => {\n toolsRef.current = tools;\n });\n\n useEffect(() => {\n const proxies: AnyWebMCPTool[] = toolsRef.current.map((tool) => ({\n ...tool,\n execute: (input: unknown, options?: WebMCPToolExecuteOptions) => {\n const latest =\n toolsRef.current.find((candidate) => candidate.name === tool.name) ??\n tool;\n return latest.execute(input as never, options);\n },\n }));\n\n return registerWebMCPTools(proxies);\n }, [signature]);\n};\n"],"mappings":";;;;;;;AAcA,MAAM,qBAAqB,UACzB,KAAK,UACH,MAAM,KAAK,SAAS;CAClB,KAAK;CACL,KAAK;CACL,KAAK,eAAe;CACpB,KAAK,eAAe;AACtB,CAAC,CACH;;;;;;;;;;;;AAaF,MAAa,kBAAkB,UAAiC;CAC9D,MAAM,WAAW,OAAwB,KAAK;CAC9C,MAAM,YAAY,kBAAkB,KAAK;CAEzC,gBAAgB;EACd,SAAS,UAAU;CACrB,CAAC;CAED,gBAAgB;EACd,MAAM,UAA2B,SAAS,QAAQ,KAAK,UAAU;GAC/D,GAAG;GACH,UAAU,OAAgB,YAAuC;IAI/D,QAFE,SAAS,QAAQ,MAAM,cAAc,UAAU,SAAS,KAAK,IAAI,KACjE,KACW,CAAC,QAAQ,OAAgB,OAAO;GAC/C;EACF,EAAE;EAEF,OAAO,oBAAoB,OAAO;CACpC,GAAG,CAAC,SAAS,CAAC;AAChB"}
|
package/dist/esm/libs/auth.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { ssoClient } from "@better-auth/sso/client";
|
|
|
3
3
|
import { editor } from "@intlayer/config/built";
|
|
4
4
|
import { BACKEND_URL } from "@intlayer/config/defaultValues";
|
|
5
5
|
import { createAuthClient } from "better-auth/client";
|
|
6
|
-
import { magicLinkClient, multiSessionClient, twoFactorClient } from "better-auth/client/plugins";
|
|
6
|
+
import { lastLoginMethodClient, magicLinkClient, multiSessionClient, twoFactorClient } from "better-auth/client/plugins";
|
|
7
7
|
|
|
8
8
|
//#region src/libs/auth.ts
|
|
9
9
|
const getAuthClient = (backendURL) => createAuthClient({
|
|
@@ -18,7 +18,8 @@ const getAuthClient = (backendURL) => createAuthClient({
|
|
|
18
18
|
passkeyClient(),
|
|
19
19
|
magicLinkClient(),
|
|
20
20
|
ssoClient(),
|
|
21
|
-
multiSessionClient()
|
|
21
|
+
multiSessionClient(),
|
|
22
|
+
lastLoginMethodClient()
|
|
22
23
|
]
|
|
23
24
|
});
|
|
24
25
|
const getAuthAPI = (intlayerConfig) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.mjs","names":[],"sources":["../../../src/libs/auth.ts"],"sourcesContent":["import { passkeyClient } from '@better-auth/passkey/client';\nimport { ssoClient } from '@better-auth/sso/client';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createAuthClient } from 'better-auth/client';\nimport {\n magicLinkClient,\n multiSessionClient,\n twoFactorClient,\n} from 'better-auth/client/plugins';\n\nconst getAuthClient = (backendURL: string) =>\n createAuthClient({\n baseURL: backendURL,\n withCredentials: true, // makes fetch forward cookies\n plugins: [\n twoFactorClient({\n onTwoFactorRedirect: () => {\n // Preserve redirect_url when redirecting to 2FA\n const searchParams = new URLSearchParams(window.location.search);\n const redirectUrl = searchParams.get('redirect_url');\n const twoFaUrl = redirectUrl\n ? `/auth/2fa?redirect_url=${encodeURIComponent(redirectUrl)}`\n : '/auth/2fa';\n window.location.href = twoFaUrl;\n },\n }),\n passkeyClient(),\n magicLinkClient() as never,\n ssoClient(),\n multiSessionClient(),\n ],\n });\n\ntype AuthClient = ReturnType<typeof getAuthClient>;\n\nexport interface AuthAPI {\n getAuthClient: () => AuthClient;\n signInEmail: AuthClient['signIn']['email'];\n signUpEmail: AuthClient['signUp']['email'];\n signOut: AuthClient['signOut'];\n signInSocial: AuthClient['signIn']['social'];\n linkSocial: AuthClient['linkSocial'];\n changePasswordSession: AuthClient['changePassword'];\n requestPasswordResetSession: AuthClient['requestPasswordReset'];\n resetPassword: AuthClient['resetPassword'];\n verifyEmailSession: AuthClient['verifyEmail'];\n getSession: AuthClient['getSession'];\n forgetPassword: AuthClient['requestPasswordReset'];\n sendVerificationEmail: AuthClient['sendVerificationEmail'];\n changeEmail: AuthClient['changeEmail'];\n deleteUser: AuthClient['deleteUser'];\n revokeSession: AuthClient['revokeSession'];\n revokeSessions: AuthClient['revokeSessions'];\n revokeOtherSessions: AuthClient['revokeOtherSessions'];\n listAccounts: AuthClient['listAccounts'];\n unlinkAccount: AuthClient['unlinkAccount'];\n refreshToken: AuthClient['refreshToken'];\n getAccessToken: AuthClient['getAccessToken'];\n accountInfo: AuthClient['accountInfo'];\n updateUser: AuthClient['updateUser'];\n listSessions: AuthClient['listSessions'];\n enableTwoFactor: AuthClient['twoFactor']['enable'];\n disableTwoFactor: AuthClient['twoFactor']['disable'];\n verifyTotp: AuthClient['twoFactor']['verifyTotp'];\n verifyBackupCode: AuthClient['twoFactor']['verifyBackupCode'];\n addPasskey: AuthClient['passkey']['addPasskey'];\n signInPasskey: AuthClient['signIn']['passkey'];\n deletePasskey: AuthClient['passkey']['deletePasskey'];\n listPasskeys: () => Promise<any>;\n signInMagicLink: (\n // Redeclare it because of type inference issues\n input: { email: string; callbackURL: string }\n ) => any;\n registerSSO: AuthClient['sso']['register'];\n listSSOProviders: () => Promise<any>;\n deleteSSOProvider: (args: { providerId: string }) => Promise<any>;\n signInSSO: AuthClient['signIn']['sso'];\n listDeviceSessions: AuthClient['multiSession']['listDeviceSessions'];\n setActiveSession: AuthClient['multiSession']['setActive'];\n revokeDeviceSession: AuthClient['multiSession']['revoke'];\n}\n\nexport const getAuthAPI = (\n intlayerConfig?: Pick<IntlayerConfig, 'editor'>\n): AuthAPI => {\n let backendURL = intlayerConfig?.editor?.backendURL ?? editor?.backendURL;\n\n if (!backendURL) {\n backendURL = BACKEND_URL;\n console.error('Backend URL is not defined in the Intlayer configuration.');\n }\n\n const client = getAuthClient(backendURL);\n\n const signInEmail: AuthClient['signIn']['email'] = async (...args) => {\n return client.signIn.email(...args);\n };\n\n const signInSocial: AuthClient['signIn']['social'] = async (...args) => {\n return client.signIn.social(...args);\n };\n\n const signUpEmail: AuthClient['signUp']['email'] = async (...args) => {\n return client.signUp.email(...args);\n };\n\n const signOut: AuthClient['signOut'] = async (...args) => {\n return client.signOut(...args);\n };\n\n const changePasswordSession: AuthClient['changePassword'] = async (\n ...args\n ) => {\n return client.changePassword(...args);\n };\n\n const requestPasswordResetSession: AuthClient['requestPasswordReset'] =\n async (...args) => {\n return client.requestPasswordReset(...args);\n };\n\n // @ts-ignore - resetPassword is not typed\n const resetPassword: AuthClient['resetPassword'] = async (...args) => {\n return client.resetPassword(...args);\n };\n\n const verifyEmailSession: AuthClient['verifyEmail'] = async (...args) => {\n return client.verifyEmail(...args);\n };\n\n const getSession: AuthClient['getSession'] = async (...args) => {\n return client.getSession(...args);\n };\n\n const forgetPassword: AuthClient['requestPasswordReset'] = async (\n ...args\n ) => {\n return client.requestPasswordReset(...args);\n };\n\n const sendVerificationEmail: AuthClient['sendVerificationEmail'] = async (\n ...args\n ) => {\n return client.sendVerificationEmail(...args);\n };\n\n const changeEmail: AuthClient['changeEmail'] = async (...args) => {\n return client.changeEmail(...args);\n };\n\n // @ts-ignore - deleteUser is not typed\n const deleteUser: AuthClient['deleteUser'] = async (...args) => {\n return client.deleteUser(...args);\n };\n\n const revokeSession: AuthClient['revokeSession'] = async (...args) => {\n return client.revokeSession(...args);\n };\n\n const revokeSessions: AuthClient['revokeSessions'] = async (...args) => {\n return client.revokeSessions(...args);\n };\n\n const revokeOtherSessions: AuthClient['revokeOtherSessions'] = async (\n ...args\n ) => {\n return client.revokeOtherSessions(...args);\n };\n\n const linkSocial: AuthClient['linkSocial'] = async (...args) => {\n return client.linkSocial(...args);\n };\n\n const listAccounts: AuthClient['listAccounts'] = async (...args) => {\n return client.listAccounts(...args);\n };\n\n const unlinkAccount: AuthClient['unlinkAccount'] = async (...args) => {\n return client.unlinkAccount(...args);\n };\n\n const refreshToken: AuthClient['refreshToken'] = async (...args) => {\n return client.refreshToken(...args);\n };\n\n const getAccessToken: AuthClient['getAccessToken'] = async (...args) => {\n return client.getAccessToken(...args);\n };\n\n const accountInfo: AuthClient['accountInfo'] = async (...args) => {\n return client.accountInfo(...args);\n };\n\n const updateUser: AuthClient['updateUser'] = async (...args) => {\n return client.updateUser(...args);\n };\n\n const listSessions: AuthClient['listSessions'] = async (...args) => {\n return client.listSessions(...args);\n };\n\n const enableTwoFactor: AuthClient['twoFactor']['enable'] = async (\n ...args\n ) => {\n return client.twoFactor.enable(...args) as ReturnType<\n AuthClient['twoFactor']['enable']\n >;\n };\n\n const disableTwoFactor: AuthClient['twoFactor']['disable'] = async (\n ...args\n ) => {\n return client.twoFactor.disable(...args) as ReturnType<\n AuthClient['twoFactor']['disable']\n >;\n };\n\n const verifyTotp: AuthClient['twoFactor']['verifyTotp'] = async (...args) => {\n return client.twoFactor.verifyTotp(...args) as ReturnType<\n AuthClient['twoFactor']['verifyTotp']\n >;\n };\n\n const verifyBackupCode: AuthClient['twoFactor']['verifyBackupCode'] = async (\n ...args\n ) => {\n return client.twoFactor.verifyBackupCode(...args) as ReturnType<\n AuthClient['twoFactor']['verifyBackupCode']\n >;\n };\n\n const addPasskey: AuthClient['passkey']['addPasskey'] = async (...args) => {\n return client.passkey.addPasskey(...args);\n };\n\n const signInPasskey: AuthClient['signIn']['passkey'] = async (...args) => {\n return client.signIn.passkey(...args);\n };\n\n const deletePasskey: AuthClient['passkey']['deletePasskey'] = async (\n ...args\n ) => {\n return client.passkey.deletePasskey(...args);\n };\n\n const listPasskeys = async () => {\n // @ts-ignore - listPasskeys may not be typed yet\n return client.$fetch('/passkey/list-user-passkeys', {\n method: 'GET',\n });\n };\n\n const signInMagicLink: any = async (...args: any[]) => {\n return (client.signIn as any).magicLink(...args);\n };\n\n const signInSSO: AuthClient['signIn']['sso'] = async (...args) => {\n return client.signIn.sso(...args);\n };\n\n const registerSSO: AuthClient['sso']['register'] = async (...args) => {\n return client.sso.register(...args);\n };\n\n const listSSOProviders = async () => {\n const response = await (client.sso as any).providers();\n return { data: response?.data?.providers ?? [] };\n };\n\n const deleteSSOProvider = async (args: { providerId: string }) => {\n return (client.sso as any).deleteProvider({ providerId: args.providerId });\n };\n\n const listDeviceSessions: AuthClient['multiSession']['listDeviceSessions'] =\n async (...args) => {\n return client.multiSession.listDeviceSessions(...args);\n };\n\n const setActiveSession: AuthClient['multiSession']['setActive'] = async (\n ...args\n ) => {\n return client.multiSession.setActive(...args);\n };\n\n const revokeDeviceSession: AuthClient['multiSession']['revoke'] = async (\n ...args\n ) => {\n return client.multiSession.revoke(...args);\n };\n\n return {\n getAuthClient: () => client,\n signInEmail,\n signUpEmail,\n signOut,\n signInSocial,\n linkSocial,\n changePasswordSession,\n requestPasswordResetSession,\n resetPassword,\n verifyEmailSession,\n getSession,\n forgetPassword,\n sendVerificationEmail,\n changeEmail,\n deleteUser,\n revokeSession,\n revokeSessions,\n revokeOtherSessions,\n listAccounts,\n unlinkAccount,\n refreshToken,\n getAccessToken,\n accountInfo,\n updateUser,\n listSessions,\n enableTwoFactor,\n disableTwoFactor,\n verifyTotp,\n verifyBackupCode,\n addPasskey,\n signInPasskey,\n deletePasskey,\n listPasskeys,\n signInMagicLink,\n signInSSO,\n registerSSO,\n listSSOProviders,\n deleteSSOProvider,\n listDeviceSessions,\n revokeDeviceSession,\n setActiveSession,\n };\n};\n"],"mappings":";;;;;;;;AAYA,MAAM,iBAAiB,eACrB,iBAAiB;CACf,SAAS;CACT,iBAAiB;CACjB,SAAS;EACP,gBAAgB,EACd,2BAA2B;GAGzB,MAAM,cAAc,IADK,gBAAgB,OAAO,SAAS,MAC1B,CAAC,CAAC,IAAI,cAAc;GACnD,MAAM,WAAW,cACb,0BAA0B,mBAAmB,WAAW,MACxD;GACJ,OAAO,SAAS,OAAO;EACzB,EACF,CAAC;EACD,cAAc;EACd,gBAAgB;EAChB,UAAU;EACV,mBAAmB;CACrB;AACF,CAAC;AAmDH,MAAa,cACX,mBACY;CACZ,IAAI,aAAa,gBAAgB,QAAQ,cAAc,QAAQ;CAE/D,IAAI,CAAC,YAAY;EACf,aAAa;EACb,QAAQ,MAAM,2DAA2D;CAC3E;CAEA,MAAM,SAAS,cAAc,UAAU;CAEvC,MAAM,cAA6C,OAAO,GAAG,SAAS;EACpE,OAAO,OAAO,OAAO,MAAM,GAAG,IAAI;CACpC;CAEA,MAAM,eAA+C,OAAO,GAAG,SAAS;EACtE,OAAO,OAAO,OAAO,OAAO,GAAG,IAAI;CACrC;CAEA,MAAM,cAA6C,OAAO,GAAG,SAAS;EACpE,OAAO,OAAO,OAAO,MAAM,GAAG,IAAI;CACpC;CAEA,MAAM,UAAiC,OAAO,GAAG,SAAS;EACxD,OAAO,OAAO,QAAQ,GAAG,IAAI;CAC/B;CAEA,MAAM,wBAAsD,OAC1D,GAAG,SACA;EACH,OAAO,OAAO,eAAe,GAAG,IAAI;CACtC;CAEA,MAAM,8BACJ,OAAO,GAAG,SAAS;EACjB,OAAO,OAAO,qBAAqB,GAAG,IAAI;CAC5C;CAGF,MAAM,gBAA6C,OAAO,GAAG,SAAS;EACpE,OAAO,OAAO,cAAc,GAAG,IAAI;CACrC;C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,OAAO,SAAiC;EAChE,OAAQ,OAAO,IAAY,eAAe,EAAE,YAAY,KAAK,WAAW,CAAC;CAC3E;CAEA,MAAM,qBACJ,OAAO,GAAG,SAAS;EACjB,OAAO,OAAO,aAAa,mBAAmB,GAAG,IAAI;CACvD;CAEF,MAAM,mBAA4D,OAChE,GAAG,SACA;EACH,OAAO,OAAO,aAAa,UAAU,GAAG,IAAI;CAC9C;CAEA,MAAM,sBAA4D,OAChE,GAAG,SACA;EACH,OAAO,OAAO,aAAa,OAAO,GAAG,IAAI;CAC3C;CAEA,OAAO;EACL,qBAAqB;EACrB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"auth.mjs","names":[],"sources":["../../../src/libs/auth.ts"],"sourcesContent":["import { passkeyClient } from '@better-auth/passkey/client';\nimport { ssoClient } from '@better-auth/sso/client';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createAuthClient } from 'better-auth/client';\nimport {\n lastLoginMethodClient,\n magicLinkClient,\n multiSessionClient,\n twoFactorClient,\n} from 'better-auth/client/plugins';\n\nconst getAuthClient = (backendURL: string) =>\n createAuthClient({\n baseURL: backendURL,\n withCredentials: true, // makes fetch forward cookies\n plugins: [\n twoFactorClient({\n onTwoFactorRedirect: () => {\n // Preserve redirect_url when redirecting to 2FA\n const searchParams = new URLSearchParams(window.location.search);\n const redirectUrl = searchParams.get('redirect_url');\n const twoFaUrl = redirectUrl\n ? `/auth/2fa?redirect_url=${encodeURIComponent(redirectUrl)}`\n : '/auth/2fa';\n window.location.href = twoFaUrl;\n },\n }),\n passkeyClient(),\n magicLinkClient() as never,\n ssoClient(),\n multiSessionClient(),\n lastLoginMethodClient(),\n ],\n });\n\ntype AuthClient = ReturnType<typeof getAuthClient>;\n\nexport interface AuthAPI {\n getAuthClient: () => AuthClient;\n signInEmail: AuthClient['signIn']['email'];\n signUpEmail: AuthClient['signUp']['email'];\n signOut: AuthClient['signOut'];\n signInSocial: AuthClient['signIn']['social'];\n linkSocial: AuthClient['linkSocial'];\n changePasswordSession: AuthClient['changePassword'];\n requestPasswordResetSession: AuthClient['requestPasswordReset'];\n resetPassword: AuthClient['resetPassword'];\n verifyEmailSession: AuthClient['verifyEmail'];\n getSession: AuthClient['getSession'];\n forgetPassword: AuthClient['requestPasswordReset'];\n sendVerificationEmail: AuthClient['sendVerificationEmail'];\n changeEmail: AuthClient['changeEmail'];\n deleteUser: AuthClient['deleteUser'];\n revokeSession: AuthClient['revokeSession'];\n revokeSessions: AuthClient['revokeSessions'];\n revokeOtherSessions: AuthClient['revokeOtherSessions'];\n listAccounts: AuthClient['listAccounts'];\n unlinkAccount: AuthClient['unlinkAccount'];\n refreshToken: AuthClient['refreshToken'];\n getAccessToken: AuthClient['getAccessToken'];\n accountInfo: AuthClient['accountInfo'];\n updateUser: AuthClient['updateUser'];\n listSessions: AuthClient['listSessions'];\n enableTwoFactor: AuthClient['twoFactor']['enable'];\n disableTwoFactor: AuthClient['twoFactor']['disable'];\n verifyTotp: AuthClient['twoFactor']['verifyTotp'];\n verifyBackupCode: AuthClient['twoFactor']['verifyBackupCode'];\n addPasskey: AuthClient['passkey']['addPasskey'];\n signInPasskey: AuthClient['signIn']['passkey'];\n deletePasskey: AuthClient['passkey']['deletePasskey'];\n listPasskeys: () => Promise<any>;\n signInMagicLink: (\n // Redeclare it because of type inference issues\n input: { email: string; callbackURL: string }\n ) => any;\n registerSSO: AuthClient['sso']['register'];\n listSSOProviders: () => Promise<any>;\n deleteSSOProvider: (args: { providerId: string }) => Promise<any>;\n signInSSO: AuthClient['signIn']['sso'];\n listDeviceSessions: AuthClient['multiSession']['listDeviceSessions'];\n setActiveSession: AuthClient['multiSession']['setActive'];\n revokeDeviceSession: AuthClient['multiSession']['revoke'];\n}\n\nexport const getAuthAPI = (\n intlayerConfig?: Pick<IntlayerConfig, 'editor'>\n): AuthAPI => {\n let backendURL = intlayerConfig?.editor?.backendURL ?? editor?.backendURL;\n\n if (!backendURL) {\n backendURL = BACKEND_URL;\n console.error('Backend URL is not defined in the Intlayer configuration.');\n }\n\n const client = getAuthClient(backendURL);\n\n const signInEmail: AuthClient['signIn']['email'] = async (...args) => {\n return client.signIn.email(...args);\n };\n\n const signInSocial: AuthClient['signIn']['social'] = async (...args) => {\n return client.signIn.social(...args);\n };\n\n const signUpEmail: AuthClient['signUp']['email'] = async (...args) => {\n return client.signUp.email(...args);\n };\n\n const signOut: AuthClient['signOut'] = async (...args) => {\n return client.signOut(...args);\n };\n\n const changePasswordSession: AuthClient['changePassword'] = async (\n ...args\n ) => {\n return client.changePassword(...args);\n };\n\n const requestPasswordResetSession: AuthClient['requestPasswordReset'] =\n async (...args) => {\n return client.requestPasswordReset(...args);\n };\n\n // @ts-ignore - resetPassword is not typed\n const resetPassword: AuthClient['resetPassword'] = async (...args) => {\n return client.resetPassword(...args);\n };\n\n const verifyEmailSession: AuthClient['verifyEmail'] = async (...args) => {\n return client.verifyEmail(...args);\n };\n\n const getSession: AuthClient['getSession'] = async (...args) => {\n return client.getSession(...args);\n };\n\n const forgetPassword: AuthClient['requestPasswordReset'] = async (\n ...args\n ) => {\n return client.requestPasswordReset(...args);\n };\n\n const sendVerificationEmail: AuthClient['sendVerificationEmail'] = async (\n ...args\n ) => {\n return client.sendVerificationEmail(...args);\n };\n\n const changeEmail: AuthClient['changeEmail'] = async (...args) => {\n return client.changeEmail(...args);\n };\n\n // @ts-ignore - deleteUser is not typed\n const deleteUser: AuthClient['deleteUser'] = async (...args) => {\n return client.deleteUser(...args);\n };\n\n const revokeSession: AuthClient['revokeSession'] = async (...args) => {\n return client.revokeSession(...args);\n };\n\n const revokeSessions: AuthClient['revokeSessions'] = async (...args) => {\n return client.revokeSessions(...args);\n };\n\n const revokeOtherSessions: AuthClient['revokeOtherSessions'] = async (\n ...args\n ) => {\n return client.revokeOtherSessions(...args);\n };\n\n const linkSocial: AuthClient['linkSocial'] = async (...args) => {\n return client.linkSocial(...args);\n };\n\n const listAccounts: AuthClient['listAccounts'] = async (...args) => {\n return client.listAccounts(...args);\n };\n\n const unlinkAccount: AuthClient['unlinkAccount'] = async (...args) => {\n return client.unlinkAccount(...args);\n };\n\n const refreshToken: AuthClient['refreshToken'] = async (...args) => {\n return client.refreshToken(...args);\n };\n\n const getAccessToken: AuthClient['getAccessToken'] = async (...args) => {\n return client.getAccessToken(...args);\n };\n\n const accountInfo: AuthClient['accountInfo'] = async (...args) => {\n return client.accountInfo(...args);\n };\n\n const updateUser: AuthClient['updateUser'] = async (...args) => {\n return client.updateUser(...args);\n };\n\n const listSessions: AuthClient['listSessions'] = async (...args) => {\n return client.listSessions(...args);\n };\n\n const enableTwoFactor: AuthClient['twoFactor']['enable'] = async (\n ...args\n ) => {\n return client.twoFactor.enable(...args) as ReturnType<\n AuthClient['twoFactor']['enable']\n >;\n };\n\n const disableTwoFactor: AuthClient['twoFactor']['disable'] = async (\n ...args\n ) => {\n return client.twoFactor.disable(...args) as ReturnType<\n AuthClient['twoFactor']['disable']\n >;\n };\n\n const verifyTotp: AuthClient['twoFactor']['verifyTotp'] = async (...args) => {\n return client.twoFactor.verifyTotp(...args) as ReturnType<\n AuthClient['twoFactor']['verifyTotp']\n >;\n };\n\n const verifyBackupCode: AuthClient['twoFactor']['verifyBackupCode'] = async (\n ...args\n ) => {\n return client.twoFactor.verifyBackupCode(...args) as ReturnType<\n AuthClient['twoFactor']['verifyBackupCode']\n >;\n };\n\n const addPasskey: AuthClient['passkey']['addPasskey'] = async (...args) => {\n return client.passkey.addPasskey(...args);\n };\n\n const signInPasskey: AuthClient['signIn']['passkey'] = async (...args) => {\n return client.signIn.passkey(...args);\n };\n\n const deletePasskey: AuthClient['passkey']['deletePasskey'] = async (\n ...args\n ) => {\n return client.passkey.deletePasskey(...args);\n };\n\n const listPasskeys = async () => {\n // @ts-ignore - listPasskeys may not be typed yet\n return client.$fetch('/passkey/list-user-passkeys', {\n method: 'GET',\n });\n };\n\n const signInMagicLink: any = async (...args: any[]) => {\n return (client.signIn as any).magicLink(...args);\n };\n\n const signInSSO: AuthClient['signIn']['sso'] = async (...args) => {\n return client.signIn.sso(...args);\n };\n\n const registerSSO: AuthClient['sso']['register'] = async (...args) => {\n return client.sso.register(...args);\n };\n\n const listSSOProviders = async () => {\n const response = await (client.sso as any).providers();\n return { data: response?.data?.providers ?? [] };\n };\n\n const deleteSSOProvider = async (args: { providerId: string }) => {\n return (client.sso as any).deleteProvider({ providerId: args.providerId });\n };\n\n const listDeviceSessions: AuthClient['multiSession']['listDeviceSessions'] =\n async (...args) => {\n return client.multiSession.listDeviceSessions(...args);\n };\n\n const setActiveSession: AuthClient['multiSession']['setActive'] = async (\n ...args\n ) => {\n return client.multiSession.setActive(...args);\n };\n\n const revokeDeviceSession: AuthClient['multiSession']['revoke'] = async (\n ...args\n ) => {\n return client.multiSession.revoke(...args);\n };\n\n return {\n getAuthClient: () => client,\n signInEmail,\n signUpEmail,\n signOut,\n signInSocial,\n linkSocial,\n changePasswordSession,\n requestPasswordResetSession,\n resetPassword,\n verifyEmailSession,\n getSession,\n forgetPassword,\n sendVerificationEmail,\n changeEmail,\n deleteUser,\n revokeSession,\n revokeSessions,\n revokeOtherSessions,\n listAccounts,\n unlinkAccount,\n refreshToken,\n getAccessToken,\n accountInfo,\n updateUser,\n listSessions,\n enableTwoFactor,\n disableTwoFactor,\n verifyTotp,\n verifyBackupCode,\n addPasskey,\n signInPasskey,\n deletePasskey,\n listPasskeys,\n signInMagicLink,\n signInSSO,\n registerSSO,\n listSSOProviders,\n deleteSSOProvider,\n listDeviceSessions,\n revokeDeviceSession,\n setActiveSession,\n };\n};\n"],"mappings":";;;;;;;;AAaA,MAA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Aa,mBAAmB,GAAG,IAAI;CACvD;CAEF,MAAM,mBAA4D,OAChE,GAAG,SACA;EACH,OAAO,OAAO,aAAa,UAAU,GAAG,IAAI;CAC9C;CAEA,MAAM,sBAA4D,OAChE,GAAG,SACA;EACH,OAAO,OAAO,aAAa,OAAO,GAAG,IAAI;CAC3C;CAEA,OAAO;EACL,qBAAqB;EACrB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DeferredAuthProvider, useIsAuthFetchEnabled } from "./DeferredAuthProvider.mjs";
|
|
2
1
|
import { ThemeProvider, useTheme } from "./ThemeProvider.mjs";
|
|
3
2
|
import { ReactQueryProvider, getQueryClient } from "./ReactQueryProvider.mjs";
|
|
3
|
+
import { DeferredAuthProvider, useIsAuthFetchEnabled } from "./DeferredAuthProvider.mjs";
|
|
4
4
|
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
5
5
|
|
|
6
6
|
export { DeferredAuthProvider, ReactQueryDevtools, ReactQueryProvider, ThemeProvider, getQueryClient, useIsAuthFetchEnabled, useTheme };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { normalizeJsonLdUrl, normalizeJsonLdUrls } from "./normalizeJsonLdUrl.mjs";
|
|
2
|
-
import { buildOrganizationJsonLd } from "./buildOrganizationJsonLd.mjs";
|
|
3
|
-
import { buildSoftwareApplicationJsonLd } from "./buildSoftwareApplicationJsonLd.mjs";
|
|
4
|
-
import { buildBreadcrumbsJsonLd } from "./buildBreadcrumbsJsonLd.mjs";
|
|
5
|
-
import { buildWebsiteJsonLd } from "./buildWebsiteJsonLd.mjs";
|
|
6
2
|
import { buildProductJsonLd } from "./buildProductJsonLd.mjs";
|
|
7
|
-
import { buildItemListJsonLd } from "./buildItemListJsonLd.mjs";
|
|
8
|
-
import { buildCreativeWorkJsonLd } from "./buildCreativeWorkJsonLd.mjs";
|
|
9
3
|
import { buildAuthorJsonLd } from "./buildAuthorJsonLd.mjs";
|
|
4
|
+
import { buildBreadcrumbsJsonLd } from "./buildBreadcrumbsJsonLd.mjs";
|
|
5
|
+
import { buildCreativeWorkJsonLd } from "./buildCreativeWorkJsonLd.mjs";
|
|
10
6
|
import { buildFAQPageJsonLd } from "./buildFAQPageJsonLd.mjs";
|
|
7
|
+
import { buildItemListJsonLd } from "./buildItemListJsonLd.mjs";
|
|
8
|
+
import { buildOrganizationJsonLd } from "./buildOrganizationJsonLd.mjs";
|
|
9
|
+
import { buildSoftwareApplicationJsonLd } from "./buildSoftwareApplicationJsonLd.mjs";
|
|
10
|
+
import { buildWebsiteJsonLd } from "./buildWebsiteJsonLd.mjs";
|
|
11
11
|
|
|
12
12
|
export { buildAuthorJsonLd, buildBreadcrumbsJsonLd, buildCreativeWorkJsonLd, buildFAQPageJsonLd, buildItemListJsonLd, buildOrganizationJsonLd, buildProductJsonLd, buildSoftwareApplicationJsonLd, buildWebsiteJsonLd, normalizeJsonLdUrl, normalizeJsonLdUrls };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region src/webmcp/createRemoteMcpTools.ts
|
|
2
|
+
const isReadOnly = (tool) => tool.annotations?.readOnlyHint === true;
|
|
3
|
+
/**
|
|
4
|
+
* Sends one JSON-RPC request to a streamable-HTTP MCP server.
|
|
5
|
+
*
|
|
6
|
+
* Each call opens its own session: the browser cannot read the
|
|
7
|
+
* `mcp-session-id` response header (it is not CORS-exposed), and the server
|
|
8
|
+
* answers stateless `tools/list` / `tools/call` requests without one.
|
|
9
|
+
*/
|
|
10
|
+
const callJsonRpc = async (serverUrl, method, params, fetchImplementation, signal) => {
|
|
11
|
+
const response = await fetchImplementation(serverUrl, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
headers: {
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
Accept: "application/json, text/event-stream"
|
|
16
|
+
},
|
|
17
|
+
body: JSON.stringify({
|
|
18
|
+
jsonrpc: "2.0",
|
|
19
|
+
id: 1,
|
|
20
|
+
method,
|
|
21
|
+
params
|
|
22
|
+
}),
|
|
23
|
+
signal
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok) throw new Error(`MCP server answered HTTP ${response.status}`);
|
|
26
|
+
const payload = await response.json();
|
|
27
|
+
if (payload.error) throw new Error(payload.error.message);
|
|
28
|
+
if (payload.result === void 0) throw new Error("MCP server returned an empty result");
|
|
29
|
+
return payload.result;
|
|
30
|
+
};
|
|
31
|
+
/** Flattens an MCP tool result into the text an agent can read. */
|
|
32
|
+
const formatRemoteMcpResult = (result) => {
|
|
33
|
+
const text = (result.content ?? []).map((entry) => entry.text).filter((entry) => typeof entry === "string").join("\n\n");
|
|
34
|
+
if (result.isError) return text ? `Error: ${text}` : "The tool reported an error.";
|
|
35
|
+
return text || "The tool returned no text content.";
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Discovers the tools of a remote MCP server and wraps each as a WebMCP tool
|
|
39
|
+
* forwarding its calls, so a page can expose an existing MCP server (the
|
|
40
|
+
* Intlayer documentation server, for instance) to browser agents without
|
|
41
|
+
* re-implementing its tools.
|
|
42
|
+
*
|
|
43
|
+
* @returns The wrapped tools, ready for `registerWebMCPTools`.
|
|
44
|
+
*/
|
|
45
|
+
const createRemoteMcpTools = async ({ serverUrl, filter = isReadOnly, namePrefix = "", renameTool = (name) => name, signal, fetch: fetchImplementation = globalThis.fetch }) => {
|
|
46
|
+
const { tools } = await callJsonRpc(serverUrl, "tools/list", void 0, fetchImplementation, signal);
|
|
47
|
+
return tools.filter(filter).map((tool) => ({
|
|
48
|
+
name: `${namePrefix}${renameTool(tool.name)}`,
|
|
49
|
+
title: tool.title,
|
|
50
|
+
description: tool.description ?? tool.name,
|
|
51
|
+
inputSchema: tool.inputSchema ?? {
|
|
52
|
+
type: "object",
|
|
53
|
+
properties: {}
|
|
54
|
+
},
|
|
55
|
+
annotations: tool.annotations,
|
|
56
|
+
execute: async (input, options) => formatRemoteMcpResult(await callJsonRpc(serverUrl, "tools/call", {
|
|
57
|
+
name: tool.name,
|
|
58
|
+
arguments: input ?? {}
|
|
59
|
+
}, fetchImplementation, options?.signal))
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { createRemoteMcpTools, formatRemoteMcpResult };
|
|
65
|
+
//# sourceMappingURL=createRemoteMcpTools.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRemoteMcpTools.mjs","names":[],"sources":["../../../src/webmcp/createRemoteMcpTools.ts"],"sourcesContent":["import type {\n WebMCPJsonSchema,\n WebMCPTool,\n WebMCPToolAnnotations,\n} from './types';\n\n/** A tool as described by an MCP server's `tools/list` response. */\nexport type RemoteMcpToolDescriptor = {\n name: string;\n title?: string;\n description?: string;\n inputSchema?: WebMCPJsonSchema;\n annotations?: WebMCPToolAnnotations;\n};\n\n/** Text-bearing entry of an MCP `tools/call` result. */\ntype RemoteMcpContent = { type: string; text?: string };\n\ntype RemoteMcpToolCallResult = {\n content?: RemoteMcpContent[];\n isError?: boolean;\n};\n\ntype JsonRpcResponse<TResult> = {\n jsonrpc: '2.0';\n id: number;\n result?: TResult;\n error?: { code: number; message: string };\n};\n\nexport type CreateRemoteMcpToolsOptions = {\n /** Streamable-HTTP endpoint of the MCP server (`https://mcp.intlayer.org`). */\n serverUrl: string;\n /**\n * Keeps only the tools worth exposing to a browser agent. Defaults to\n * read-only tools, which excludes anything needing credentials.\n */\n filter?: (tool: RemoteMcpToolDescriptor) => boolean;\n /** Prepended to every tool name to avoid collisions with page tools. */\n namePrefix?: string;\n /**\n * Rewrites a server tool name before it is exposed, e.g. to camelCase a\n * kebab-case name. The server still receives the original name.\n */\n renameTool?: (name: string) => string;\n /** Aborts the discovery request. */\n signal?: AbortSignal;\n /** Injectable for tests. Defaults to the global `fetch`. */\n fetch?: typeof globalThis.fetch;\n};\n\nconst isReadOnly = (tool: RemoteMcpToolDescriptor): boolean =>\n tool.annotations?.readOnlyHint === true;\n\n/**\n * Sends one JSON-RPC request to a streamable-HTTP MCP server.\n *\n * Each call opens its own session: the browser cannot read the\n * `mcp-session-id` response header (it is not CORS-exposed), and the server\n * answers stateless `tools/list` / `tools/call` requests without one.\n */\nconst callJsonRpc = async <TResult>(\n serverUrl: string,\n method: string,\n params: Record<string, unknown> | undefined,\n fetchImplementation: typeof globalThis.fetch,\n signal?: AbortSignal\n): Promise<TResult> => {\n const response = await fetchImplementation(serverUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json, text/event-stream',\n },\n body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),\n signal,\n });\n\n if (!response.ok) {\n throw new Error(`MCP server answered HTTP ${response.status}`);\n }\n\n const payload = (await response.json()) as JsonRpcResponse<TResult>;\n\n if (payload.error) {\n throw new Error(payload.error.message);\n }\n\n if (payload.result === undefined) {\n throw new Error('MCP server returned an empty result');\n }\n\n return payload.result;\n};\n\n/** Flattens an MCP tool result into the text an agent can read. */\nexport const formatRemoteMcpResult = (\n result: RemoteMcpToolCallResult\n): string => {\n const text = (result.content ?? [])\n .map((entry) => entry.text)\n .filter((entry): entry is string => typeof entry === 'string')\n .join('\\n\\n');\n\n if (result.isError) {\n return text ? `Error: ${text}` : 'The tool reported an error.';\n }\n\n return text || 'The tool returned no text content.';\n};\n\n/**\n * Discovers the tools of a remote MCP server and wraps each as a WebMCP tool\n * forwarding its calls, so a page can expose an existing MCP server (the\n * Intlayer documentation server, for instance) to browser agents without\n * re-implementing its tools.\n *\n * @returns The wrapped tools, ready for `registerWebMCPTools`.\n */\nexport const createRemoteMcpTools = async ({\n serverUrl,\n filter = isReadOnly,\n namePrefix = '',\n renameTool = (name) => name,\n signal,\n fetch: fetchImplementation = globalThis.fetch,\n}: CreateRemoteMcpToolsOptions): Promise<WebMCPTool[]> => {\n const { tools } = await callJsonRpc<{ tools: RemoteMcpToolDescriptor[] }>(\n serverUrl,\n 'tools/list',\n undefined,\n fetchImplementation,\n signal\n );\n\n return tools.filter(filter).map((tool) => ({\n name: `${namePrefix}${renameTool(tool.name)}`,\n title: tool.title,\n description: tool.description ?? tool.name,\n inputSchema: tool.inputSchema ?? { type: 'object', properties: {} },\n annotations: tool.annotations,\n execute: async (input, options) =>\n formatRemoteMcpResult(\n await callJsonRpc<RemoteMcpToolCallResult>(\n serverUrl,\n 'tools/call',\n { name: tool.name, arguments: input ?? {} },\n fetchImplementation,\n options?.signal\n )\n ),\n }));\n};\n"],"mappings":";AAmDA,MAAM,cAAc,SAClB,KAAK,aAAa,iBAAiB;;;;;;;;AASrC,MAAM,cAAc,OAClB,WACA,QACA,QACA,qBACA,WACqB;CACrB,MAAM,WAAW,MAAM,oBAAoB,WAAW;EACpD,QAAQ;EACR,SAAS;GACP,gBAAgB;GAChB,QAAQ;EACV;EACA,MAAM,KAAK,UAAU;GAAE,SAAS;GAAO,IAAI;GAAG;GAAQ;EAAO,CAAC;EAC9D;CACF,CAAC;CAED,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,4BAA4B,SAAS,QAAQ;CAG/D,MAAM,UAAW,MAAM,SAAS,KAAK;CAErC,IAAI,QAAQ,OACV,MAAM,IAAI,MAAM,QAAQ,MAAM,OAAO;CAGvC,IAAI,QAAQ,WAAW,QACrB,MAAM,IAAI,MAAM,qCAAqC;CAGvD,OAAO,QAAQ;AACjB;;AAGA,MAAa,yBACX,WACW;CACX,MAAM,QAAQ,OAAO,WAAW,CAAC,EAAC,CAC/B,KAAK,UAAU,MAAM,IAAI,CAAC,CAC1B,QAAQ,UAA2B,OAAO,UAAU,QAAQ,CAAC,CAC7D,KAAK,MAAM;CAEd,IAAI,OAAO,SACT,OAAO,OAAO,UAAU,SAAS;CAGnC,OAAO,QAAQ;AACjB;;;;;;;;;AAUA,MAAa,uBAAuB,OAAO,EACzC,WACA,SAAS,YACT,aAAa,IACb,cAAc,SAAS,MACvB,QACA,OAAO,sBAAsB,WAAW,YACgB;CACxD,MAAM,EAAE,UAAU,MAAM,YACtB,WACA,cACA,QACA,qBACA,MACF;CAEA,OAAO,MAAM,OAAO,MAAM,CAAC,CAAC,KAAK,UAAU;EACzC,MAAM,GAAG,aAAa,WAAW,KAAK,IAAI;EAC1C,OAAO,KAAK;EACZ,aAAa,KAAK,eAAe,KAAK;EACtC,aAAa,KAAK,eAAe;GAAE,MAAM;GAAU,YAAY,CAAC;EAAE;EAClE,aAAa,KAAK;EAClB,SAAS,OAAO,OAAO,YACrB,sBACE,MAAM,YACJ,WACA,cACA;GAAE,MAAM,KAAK;GAAM,WAAW,SAAS,CAAC;EAAE,GAC1C,qBACA,SAAS,MACX,CACF;CACJ,EAAE;AACJ"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/webmcp/getModelContext.ts
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the WebMCP entry point exposed by the current browser, if any.
|
|
4
|
+
*
|
|
5
|
+
* Candidates are probed in order: `navigator.modelContextTesting` (Chrome with
|
|
6
|
+
* the `#enable-webmcp-testing` flag), `navigator.modelContext` (Chrome early
|
|
7
|
+
* preview / origin trial) and `document.modelContext` (W3C draft). Only an
|
|
8
|
+
* object able to register tools is returned, so callers can rely on
|
|
9
|
+
* `registerTool` being present.
|
|
10
|
+
*
|
|
11
|
+
* @returns The model context, or `null` outside a supporting browser.
|
|
12
|
+
*/
|
|
13
|
+
const getModelContext = () => {
|
|
14
|
+
if (typeof navigator === "undefined") return null;
|
|
15
|
+
const navigatorHost = navigator;
|
|
16
|
+
const documentHost = typeof document === "undefined" ? void 0 : document;
|
|
17
|
+
return [
|
|
18
|
+
navigatorHost.modelContextTesting,
|
|
19
|
+
navigatorHost.modelContext,
|
|
20
|
+
documentHost?.modelContext
|
|
21
|
+
].find((candidate) => typeof candidate?.registerTool === "function") ?? null;
|
|
22
|
+
};
|
|
23
|
+
/** Whether the current browser exposes a usable WebMCP entry point. */
|
|
24
|
+
const isWebMCPAvailable = () => getModelContext() !== null;
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { getModelContext, isWebMCPAvailable };
|
|
28
|
+
//# sourceMappingURL=getModelContext.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getModelContext.mjs","names":[],"sources":["../../../src/webmcp/getModelContext.ts"],"sourcesContent":["import type { ModelContext, ModelContextHost } from './types';\n\n/**\n * Resolves the WebMCP entry point exposed by the current browser, if any.\n *\n * Candidates are probed in order: `navigator.modelContextTesting` (Chrome with\n * the `#enable-webmcp-testing` flag), `navigator.modelContext` (Chrome early\n * preview / origin trial) and `document.modelContext` (W3C draft). Only an\n * object able to register tools is returned, so callers can rely on\n * `registerTool` being present.\n *\n * @returns The model context, or `null` outside a supporting browser.\n */\nexport const getModelContext = (): ModelContext | null => {\n if (typeof navigator === 'undefined') return null;\n\n const navigatorHost = navigator as Navigator & ModelContextHost;\n const documentHost =\n typeof document === 'undefined'\n ? undefined\n : (document as Document & ModelContextHost);\n\n const candidates: (ModelContext | undefined)[] = [\n navigatorHost.modelContextTesting,\n navigatorHost.modelContext,\n documentHost?.modelContext,\n ];\n\n return (\n candidates.find(\n (candidate) => typeof candidate?.registerTool === 'function'\n ) ?? null\n );\n};\n\n/** Whether the current browser exposes a usable WebMCP entry point. */\nexport const isWebMCPAvailable = (): boolean => getModelContext() !== null;\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,wBAA6C;CACxD,IAAI,OAAO,cAAc,aAAa,OAAO;CAE7C,MAAM,gBAAgB;CACtB,MAAM,eACJ,OAAO,aAAa,cAChB,SACC;CAQP,OACE;EANA,cAAc;EACd,cAAc;EACd,cAAc;CAIL,CAAC,CAAC,MACR,cAAc,OAAO,WAAW,iBAAiB,UACpD,KAAK;AAET;;AAGA,MAAa,0BAAmC,gBAAgB,MAAM"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { getModelContext, isWebMCPAvailable } from "./getModelContext.mjs";
|
|
2
|
+
import { formatToolResult, registerWebMCPTools } from "./registerWebMCPTools.mjs";
|
|
3
|
+
import { createRemoteMcpTools, formatRemoteMcpResult } from "./createRemoteMcpTools.mjs";
|
|
4
|
+
|
|
5
|
+
export { createRemoteMcpTools, formatRemoteMcpResult, formatToolResult, getModelContext, isWebMCPAvailable, registerWebMCPTools };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getModelContext } from "./getModelContext.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/webmcp/registerWebMCPTools.ts
|
|
4
|
+
/** Serializes a tool result the way the browser would, for logging and errors. */
|
|
5
|
+
const formatToolResult = (result) => typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
6
|
+
/**
|
|
7
|
+
* Wraps `execute` so a thrown error reaches the agent as a readable message
|
|
8
|
+
* instead of a rejected promise the browser may surface opaquely.
|
|
9
|
+
*/
|
|
10
|
+
const toSafeTool = (tool) => ({
|
|
11
|
+
...tool,
|
|
12
|
+
execute: async (input, options) => {
|
|
13
|
+
try {
|
|
14
|
+
return await tool.execute(input, options);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
17
|
+
return `Tool "${tool.name}" failed: ${message}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Registers tools with the WebMCP API and returns a function undoing it.
|
|
23
|
+
*
|
|
24
|
+
* Unregistration goes through `unregisterTool(name)` when the browser has it,
|
|
25
|
+
* and through the `AbortSignal` handed to `registerTool` otherwise. Without a
|
|
26
|
+
* model context the call is a no-op returning a no-op, so callers do not need
|
|
27
|
+
* to feature-detect.
|
|
28
|
+
*
|
|
29
|
+
* @param tools - Tools to expose. Names must be unique within the page.
|
|
30
|
+
* @param modelContext - Defaults to the entry point of the current browser.
|
|
31
|
+
* @returns A cleanup function removing every tool this call registered.
|
|
32
|
+
*/
|
|
33
|
+
const registerWebMCPTools = (tools, modelContext = getModelContext()) => {
|
|
34
|
+
if (!modelContext?.registerTool) return () => {};
|
|
35
|
+
const abortController = new AbortController();
|
|
36
|
+
const registeredNames = [];
|
|
37
|
+
for (const tool of tools) try {
|
|
38
|
+
modelContext.registerTool(toSafeTool(tool), { signal: abortController.signal });
|
|
39
|
+
registeredNames.push(tool.name);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.warn(`[WebMCP] Could not register tool "${tool.name}"`, error);
|
|
42
|
+
}
|
|
43
|
+
return () => {
|
|
44
|
+
abortController.abort();
|
|
45
|
+
if (typeof modelContext.unregisterTool !== "function") return;
|
|
46
|
+
for (const name of registeredNames) try {
|
|
47
|
+
modelContext.unregisterTool(name);
|
|
48
|
+
} catch {}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { formatToolResult, registerWebMCPTools };
|
|
54
|
+
//# sourceMappingURL=registerWebMCPTools.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerWebMCPTools.mjs","names":[],"sources":["../../../src/webmcp/registerWebMCPTools.ts"],"sourcesContent":["import { getModelContext } from './getModelContext';\nimport type {\n ModelContext,\n WebMCPTool,\n WebMCPToolExecuteOptions,\n WebMCPToolResult,\n} from './types';\n\n/** Serializes a tool result the way the browser would, for logging and errors. */\nexport const formatToolResult = (result: WebMCPToolResult): string =>\n typeof result === 'string' ? result : JSON.stringify(result, null, 2);\n\n/**\n * Wraps `execute` so a thrown error reaches the agent as a readable message\n * instead of a rejected promise the browser may surface opaquely.\n */\nconst toSafeTool = <TInput>(tool: WebMCPTool<TInput>): WebMCPTool<TInput> => ({\n ...tool,\n execute: async (input: TInput, options?: WebMCPToolExecuteOptions) => {\n try {\n return await tool.execute(input, options);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return `Tool \"${tool.name}\" failed: ${message}`;\n }\n },\n});\n\n/**\n * Registers tools with the WebMCP API and returns a function undoing it.\n *\n * Unregistration goes through `unregisterTool(name)` when the browser has it,\n * and through the `AbortSignal` handed to `registerTool` otherwise. Without a\n * model context the call is a no-op returning a no-op, so callers do not need\n * to feature-detect.\n *\n * @param tools - Tools to expose. Names must be unique within the page.\n * @param modelContext - Defaults to the entry point of the current browser.\n * @returns A cleanup function removing every tool this call registered.\n */\nexport const registerWebMCPTools = (\n tools: WebMCPTool<never>[],\n modelContext: ModelContext | null = getModelContext()\n): (() => void) => {\n if (!modelContext?.registerTool) return () => {};\n\n const abortController = new AbortController();\n const registeredNames: string[] = [];\n\n for (const tool of tools) {\n try {\n void modelContext.registerTool(toSafeTool(tool), {\n signal: abortController.signal,\n });\n registeredNames.push(tool.name);\n } catch (error) {\n console.warn(`[WebMCP] Could not register tool \"${tool.name}\"`, error);\n }\n }\n\n return () => {\n abortController.abort();\n\n if (typeof modelContext.unregisterTool !== 'function') return;\n\n for (const name of registeredNames) {\n try {\n void modelContext.unregisterTool(name);\n } catch {\n // Already gone (page-level clearContext, abort handled it, …).\n }\n }\n };\n};\n"],"mappings":";;;;AASA,MAAa,oBAAoB,WAC/B,OAAO,WAAW,WAAW,SAAS,KAAK,UAAU,QAAQ,MAAM,CAAC;;;;;AAMtE,MAAM,cAAsB,UAAkD;CAC5E,GAAG;CACH,SAAS,OAAO,OAAe,YAAuC;EACpE,IAAI;GACF,OAAO,MAAM,KAAK,QAAQ,OAAO,OAAO;EAC1C,SAAS,OAAO;GACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GACrE,OAAO,SAAS,KAAK,KAAK,YAAY;EACxC;CACF;AACF;;;;;;;;;;;;;AAcA,MAAa,uBACX,OACA,eAAoC,gBAAgB,MACnC;CACjB,IAAI,CAAC,cAAc,cAAc,aAAa,CAAC;CAE/C,MAAM,kBAAkB,IAAI,gBAAgB;CAC5C,MAAM,kBAA4B,CAAC;CAEnC,KAAK,MAAM,QAAQ,OACjB,IAAI;EACF,AAAK,aAAa,aAAa,WAAW,IAAI,GAAG,EAC/C,QAAQ,gBAAgB,OAC1B,CAAC;EACD,gBAAgB,KAAK,KAAK,IAAI;CAChC,SAAS,OAAO;EACd,QAAQ,KAAK,qCAAqC,KAAK,KAAK,IAAI,KAAK;CACvE;CAGF,aAAa;EACX,gBAAgB,MAAM;EAEtB,IAAI,OAAO,aAAa,mBAAmB,YAAY;EAEvD,KAAK,MAAM,QAAQ,iBACjB,IAAI;GACF,AAAK,aAAa,eAAe,IAAI;EACvC,QAAQ,CAER;CAEJ;AACF"}
|
|
File without changes
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import { z } from "zod/mini";
|
|
2
2
|
//#region src/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.d.ts
|
|
3
3
|
export declare const QUALIFIER_TYPES: readonly ['none', 'item', 'variant'];
|
|
4
4
|
export type QualifierType = (typeof QUALIFIER_TYPES)[number];
|
|
5
|
-
export declare const useDictionarySchema: (projectId: string) => z.
|
|
6
|
-
key: z.
|
|
7
|
-
projectIds: z.
|
|
8
|
-
qualifierType: z.
|
|
5
|
+
export declare const useDictionarySchema: (projectId: string) => z.ZodMiniObject<{
|
|
6
|
+
key: z.ZodMiniDefault<z.ZodMiniString<string>>;
|
|
7
|
+
projectIds: z.ZodMiniDefault<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
8
|
+
qualifierType: z.ZodMiniDefault<z.ZodMiniEnum<{
|
|
9
9
|
item: "item";
|
|
10
10
|
none: "none";
|
|
11
11
|
variant: "variant";
|
|
12
12
|
}>>;
|
|
13
|
-
item: z.
|
|
14
|
-
variant: z.
|
|
13
|
+
item: z.ZodMiniOptional<z.ZodMiniNumber<unknown>>;
|
|
14
|
+
variant: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
15
15
|
}, z.core.$strip>;
|
|
16
16
|
export type DictionaryFormData = z.infer<ReturnType<typeof useDictionarySchema>>;
|
|
17
17
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryFormSchema.d.ts","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.ts"],"mappings":";;qBAGa;YACD,wBAAwB;qBAEvB,sBAAmB,sBAAqB,EAAA;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useDictionaryFormSchema.d.ts","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.ts"],"mappings":";;qBAGa;YACD,wBAAwB;qBAEvB,sBAAmB,sBAAqB,EAAA;;;;;;;;;;GAmCpD,EAAA,KAAA;YAEW,qBAAqB,EAAE,MACjC,kBAAkB"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import { z } from "zod/mini";
|
|
2
2
|
//#region src/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts
|
|
3
|
-
export declare const useDictionaryDetailsSchema: (projectId: string) => z.
|
|
4
|
-
title: z.
|
|
5
|
-
key: z.
|
|
6
|
-
description: z.
|
|
7
|
-
projectIds: z.
|
|
8
|
-
tags: z.
|
|
9
|
-
location: z.
|
|
3
|
+
export declare const useDictionaryDetailsSchema: (projectId: string) => z.ZodMiniObject<{
|
|
4
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
5
|
+
key: z.ZodMiniDefault<z.ZodMiniString<string>>;
|
|
6
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
7
|
+
projectIds: z.ZodMiniDefault<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
8
|
+
tags: z.ZodMiniDefault<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
9
|
+
location: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
10
10
|
hybrid: "hybrid";
|
|
11
11
|
local: "local";
|
|
12
12
|
plugin: "plugin";
|
|
13
13
|
remote: "remote";
|
|
14
14
|
}>>;
|
|
15
|
-
importMode: z.
|
|
15
|
+
importMode: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
16
16
|
dynamic: "dynamic";
|
|
17
17
|
fetch: "fetch";
|
|
18
18
|
static: "static";
|
|
19
19
|
}>>;
|
|
20
|
-
filePath: z.
|
|
20
|
+
filePath: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
21
21
|
}, z.core.$strip>;
|
|
22
22
|
export type DictionaryDetailsFormData = z.infer<ReturnType<typeof useDictionaryDetailsSchema>>;
|
|
23
23
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDetailsSchema.d.ts","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.ts"],"mappings":";;qBAGa,6BAA0B,sBAAqB,EAAA;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useDictionaryDetailsSchema.d.ts","names":[],"sources":["../../../../../src/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.ts"],"mappings":";;qBAGa,6BAA0B,sBAAqB,EAAA;;;;;;;;;;;;;;;;;;GA8F3D,EAAA,KAAA;YAEW,4BAA4B,EAAE,MACxC,kBAAkB"}
|
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
import { HTMLAttributes } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { ZodMiniObject, z } from "zod/mini";
|
|
3
3
|
import { FormProviderProps, UseFormProps } from "react-hook-form";
|
|
4
4
|
//#region src/components/Form/FormBase.d.ts
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Declarative WebMCP registration: a form carrying `toolname` becomes a tool
|
|
7
|
+
* browser agents can fill and submit, its controls' `name` attributes forming
|
|
8
|
+
* the input schema.
|
|
9
|
+
*
|
|
10
|
+
* @see https://github.com/webmachinelearning/webmcp/blob/main/declarative-api-explainer.md
|
|
11
|
+
*/
|
|
12
|
+
export type FormWebMCPProps = {
|
|
13
|
+
/** Tool name exposed to agents (verb + noun, e.g. `subscribeToNewsletter`). */
|
|
14
|
+
toolName?: string;
|
|
15
|
+
/** What submitting the form does, for the agent. */
|
|
16
|
+
toolDescription?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Lets an agent submit without the user reviewing the filled form first.
|
|
19
|
+
* Leave unset for anything consequential (payments, messages, sign-ups).
|
|
20
|
+
*/
|
|
21
|
+
toolAutoSubmit?: boolean;
|
|
22
|
+
};
|
|
23
|
+
type FormProps<T extends ZodMiniObject> = HTMLAttributes<HTMLFormElement> & FormProviderProps<z.infer<T>> & FormWebMCPProps & {
|
|
6
24
|
schema?: T;
|
|
7
25
|
onSubmit?: (data: z.infer<T>) => void | Promise<void>;
|
|
8
26
|
onSubmitSuccess?: (data: z.infer<T>) => void | Promise<void>;
|
|
9
27
|
onSubmitError?: (error: Error) => void | Promise<void>;
|
|
10
28
|
autoComplete?: boolean;
|
|
11
29
|
};
|
|
12
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Maps the camelCase props onto the lowercase attributes the browser reads.
|
|
32
|
+
* Typed as a plain record: React's JSX types do not know these attributes yet.
|
|
33
|
+
*/
|
|
34
|
+
export declare const getFormWebMCPAttributes: ({ toolName, toolDescription, toolAutoSubmit }: FormWebMCPProps) => Record<string, string | undefined>;
|
|
35
|
+
export declare const Form: <T extends ZodMiniObject>({ schema, onSubmit: onSubmitProp, onSubmitSuccess: onSubmitSuccessProp, onSubmitError: onSubmitErrorProp, className, children, autoComplete, method, toolName, toolDescription, toolAutoSubmit, ...props }: FormProps<T> & {
|
|
13
36
|
method?: string;
|
|
14
37
|
}) => import("react").JSX.Element;
|
|
15
|
-
export declare const useForm: <T extends
|
|
38
|
+
export declare const useForm: <T extends ZodMiniObject>(schema: T, props?: UseFormProps<z.infer<T>>) => {
|
|
16
39
|
form: import("react-hook-form").UseFormReturn<z.infer<T>, any, z.infer<T>>;
|
|
17
40
|
isSubmitting: boolean;
|
|
18
41
|
isSubmitted: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormBase.d.ts","names":[],"sources":["../../../../src/components/Form/FormBase.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormBase.d.ts","names":[],"sources":["../../../../src/components/Form/FormBase.tsx"],"mappings":";;;;;;;;;;;YAqBY;;EAEV;;EAEA;;;;;EAKA;;KAGG,UAAU,UAAU,iBAAiB,eAAe,mBACvD,kBAAkB,EAAE,MAAM,MAC1B;EACE,SAAS;EACT,YAAY,MAAM,EAAE,MAAM,cAAc;EACxC,mBAAmB,MAAM,EAAE,MAAM,cAAc;EAC/C,iBAAiB,OAAO,iBAAiB;EACzC;;;;;;qBAOS,4BAAuB,UAAA,iBAAA,kBAIjC,oBAAkB;qBAqBR,OAAQ,UAAU,iBAAa,QAAA,UAAA,cAAA,iBAAA,qBAAA,eAAA,mBAAA,WAAA,UAAA,cAAA,QAAA,UAAA,iBAAA,mBAAA,SAazC,UAAU;EAAO;sBAAiB,IAAA;qBA6DxB,UAAW,UAAU,eAAa,QACrC,GAAC,QACD,aAAa,EAAE,MAAM"}
|
|
@@ -11,6 +11,7 @@ export type FormElementProps<T extends ElementType> = {
|
|
|
11
11
|
showErrorMessage?: boolean;
|
|
12
12
|
focus?: boolean;
|
|
13
13
|
layoutClassName?: string;
|
|
14
|
+
toolParamDescription?: string;
|
|
14
15
|
} & Omit<FormItemLayoutProps, 'children'>;
|
|
15
16
|
/**
|
|
16
17
|
* FormElement is a component that allows you to create a form element with a label, description, error message, and validation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormElement.d.ts","names":[],"sources":["../../../../../src/components/Form/elements/FormElement.tsx"],"mappings":";;;;YAWY,iBAAiB,UAAU;EACrC;EACA,SAAS;EACT,QAAQ;EACR;EACA;EACA;EACA;EACA;IACE,KAAK;;;;;;;;
|
|
1
|
+
{"version":3,"file":"FormElement.d.ts","names":[],"sources":["../../../../../src/components/Form/elements/FormElement.tsx"],"mappings":";;;;YAWY,iBAAiB,UAAU;EACrC;EACA,SAAS;EACT,QAAQ;EACR;EACA;EACA;EACA;EACA;EACA;IACE,KAAK;;;;;;;;qBAuFI,cAAe,UAAU,aAAW,OACxC,iBAAiB,KAAK,eAAe,uBAAE,IAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FC, HTMLProps } from "react";
|
|
2
|
-
import { z } from "zod";
|
|
2
|
+
import { z } from "zod/mini";
|
|
3
3
|
//#region src/components/Form/elements/FormElementWrapper.d.ts
|
|
4
4
|
type FormElementWrapperProps = HTMLProps<HTMLFormElement> & {
|
|
5
|
-
schema?: z.
|
|
6
|
-
values?: z.infer<z.
|
|
5
|
+
schema?: z.ZodMiniObject;
|
|
6
|
+
values?: z.infer<z.ZodMiniObject>;
|
|
7
7
|
};
|
|
8
8
|
export declare const FormElementWrapper: FC<FormElementWrapperProps>;
|
|
9
9
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Button } from "../Button/Button.js";
|
|
2
2
|
import "../Button/index.js";
|
|
3
|
-
import { useForm } from "./FormBase.js";
|
|
3
|
+
import { FormWebMCPProps, getFormWebMCPAttributes, useForm } from "./FormBase.js";
|
|
4
4
|
import { Form } from "./Form.js";
|
|
5
5
|
import { FormControl } from "./FormControl.js";
|
|
6
6
|
import { FormDescription } from "./FormDescription.js";
|
|
@@ -22,4 +22,4 @@ import { SearchInputElement } from "./elements/SearchInputElement.js";
|
|
|
22
22
|
import { SelectElement } from "./elements/SelectElement.js";
|
|
23
23
|
import { SwitchSelectorElement } from "./elements/SwitchSelectorElement.js";
|
|
24
24
|
import { TextAreaElement } from "./elements/TextAreaElement.js";
|
|
25
|
-
export { Form, AutoSizedTextAreaElement as FormAutoSizedTextArea, Button as FormButton, CheckboxElement as FormCheckbox, FormControl, FormDescription, EditableFieldInputElement as FormEditableFieldInput, EditableFieldTextAreaElement as FormEditableFieldTextArea, FormElement, FormField, InputElement as FormInput, InputPasswordElement as FormInputPassword, FormItem, FormLabelLayout as FormLabel, FormMessage, MultiSelectElement as FormMultiSelect, OTPElement as FormOTP, SearchInputElement as FormSearchInput, SelectElement as FormSelect, SwitchSelectorElement as FormSwitchSelector, TextAreaElement as FormTextArea, useForm, useFormField };
|
|
25
|
+
export { Form, AutoSizedTextAreaElement as FormAutoSizedTextArea, Button as FormButton, CheckboxElement as FormCheckbox, FormControl, FormDescription, EditableFieldInputElement as FormEditableFieldInput, EditableFieldTextAreaElement as FormEditableFieldTextArea, FormElement, FormField, InputElement as FormInput, InputPasswordElement as FormInputPassword, FormItem, FormLabelLayout as FormLabel, FormMessage, MultiSelectElement as FormMultiSelect, OTPElement as FormOTP, SearchInputElement as FormSearchInput, SelectElement as FormSelect, SwitchSelectorElement as FormSwitchSelector, TextAreaElement as FormTextArea, type FormWebMCPProps, getFormWebMCPAttributes, useForm, useFormField };
|