@arbidocs/react 0.3.7 → 0.3.9
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/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ function useDocuments(workspaceId, options) {
|
|
|
42
42
|
const arbi = useArbi();
|
|
43
43
|
return reactQuery.useQuery({
|
|
44
44
|
queryKey: arbiQueryKeys.documents(workspaceId ?? ""),
|
|
45
|
-
queryFn: () => arbi.documents.list(
|
|
45
|
+
queryFn: () => arbi.documents.list(),
|
|
46
46
|
enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
|
|
47
47
|
});
|
|
48
48
|
}
|
|
@@ -50,7 +50,7 @@ function useConversations(workspaceId, options) {
|
|
|
50
50
|
const arbi = useArbi();
|
|
51
51
|
return reactQuery.useQuery({
|
|
52
52
|
queryKey: arbiQueryKeys.conversations(workspaceId ?? ""),
|
|
53
|
-
queryFn: () => arbi.conversations.list(
|
|
53
|
+
queryFn: () => arbi.conversations.list(),
|
|
54
54
|
enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
|
|
55
55
|
});
|
|
56
56
|
}
|
|
@@ -58,7 +58,7 @@ function useTags(workspaceId, options) {
|
|
|
58
58
|
const arbi = useArbi();
|
|
59
59
|
return reactQuery.useQuery({
|
|
60
60
|
queryKey: arbiQueryKeys.tags(workspaceId ?? ""),
|
|
61
|
-
queryFn: () => arbi.tags.list(
|
|
61
|
+
queryFn: () => arbi.tags.list(),
|
|
62
62
|
enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
|
|
63
63
|
});
|
|
64
64
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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,IACnC,OAAA,EAAS,MAAM,IAAA,CAAK,UAAA,CAAW,IAAA,EAAK;AAAA,IACpC,OAAA,EAAS,OAAA,EAAS,OAAA,IAAW,IAAA,CAAK;AAAA,GACnC,CAAA;AACH;AAGO,SAAS,YAAA,CAAa,aAAiC,OAAA,EAAiC;AAC7F,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,OAAOA,mBAAA,CAAS;AAAA,IACd,QAAA,EAAU,aAAA,CAAc,SAAA,CAAU,WAAA,IAAe,EAAE,CAAA;AAAA,IACnD,OAAA,EAAS,MAAM,IAAA,CAAK,SAAA,CAAU,
|
|
1
|
+
{"version":3,"sources":["../src/ArbiProvider.tsx","../src/useArbi.ts","../src/hooks.ts"],"names":["createContext","useMemo","Arbi","useContext","useQuery","useMutation"],"mappings":";;;;;;;;AAYO,IAAM,WAAA,GAAcA,oBAA2B,IAAI,CAAA;AAMnD,SAAS,YAAA,CAAa,EAAE,QAAA,EAAU,GAAG,SAAQ,EAAsB;AACxE,EAAA,MAAM,IAAA,GAAOC,aAAA;AAAA,IACX,MAAM,IAAIC,YAAA,CAAK,OAAO,CAAA;AAAA;AAAA;AAAA,IAGtB,CAAC,OAAA,CAAQ,GAAA,EAAK,OAAA,CAAQ,gBAAA,EAAkB,QAAQ,WAAW;AAAA,GAC7D;AAEA,EAAA,sCAAQ,WAAA,CAAY,QAAA,EAAZ,EAAqB,KAAA,EAAO,MAAO,QAAA,EAAS,CAAA;AACtD;ACnBO,SAAS,OAAA,GAAgB;AAC9B,EAAA,MAAM,IAAA,GAAOC,iBAAW,WAAW,CAAA;AACnC,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,MAAM,IAAI,MAAM,iDAAiD,CAAA;AAAA,EACnE;AACA,EAAA,OAAO,IAAA;AACT;ACJO,IAAM,aAAA,GAAgB;AAAA,EAC3B,UAAA,EAAY,MAAM,CAAC,MAAA,EAAQ,YAAY,CAAA;AAAA,EACvC,WAAW,CAAC,WAAA,KAAw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CAAK;AAAA,GAC9D,CAAA;AACH;AAGO,SAAS,OAAA,CAAQ,aAAiC,OAAA,EAAiC;AACxF,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,OAAOA,mBAAA,CAAS;AAAA,IACd,QAAA,EAAU,aAAA,CAAc,IAAA,CAAK,WAAA,IAAe,EAAE,CAAA;AAAA,IAC9C,OAAA,EAAS,MAAM,IAAA,CAAK,IAAA,CAAK,IAAA,EAAK;AAAA,IAC9B,UAAU,OAAA,EAAS,OAAA,IAAW,SAAS,CAAC,CAAC,eAAe,IAAA,CAAK;AAAA,GAC9D,CAAA;AACH;AAGO,SAAS,iBAAA,GAAoB;AAClC,EAAA,MAAM,OAAO,OAAA,EAAQ;AAErB,EAAA,OAAOC,sBAAA,CAcL;AAAA,IACA,UAAA,EAAY,CAAC,EAAE,QAAA,EAAU,GAAG,OAAA,EAAQ,KAAM,IAAA,CAAK,SAAA,CAAU,KAAA,CAAM,QAAA,EAAU,OAAO;AAAA,GACjF,CAAA;AACH;AAGO,SAAS,UAAU,OAAA,EAAiC;AACzD,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,OAAOD,mBAAA,CAAS;AAAA,IACd,QAAA,EAAU,cAAc,MAAA,EAAO;AAAA,IAC/B,OAAA,EAAS,MAAM,IAAA,CAAK,MAAA,CAAO,KAAA,EAAM;AAAA,IACjC,SAAS,OAAA,EAAS;AAAA,GACnB,CAAA;AACH","file":"index.cjs","sourcesContent":["/**\n * ArbiProvider — React context that holds an Arbi instance.\n *\n * Usage:\n * <ArbiProvider url=\"https://arbi.mycompany.com\">\n * <App />\n * </ArbiProvider>\n */\n\nimport { createContext, useMemo, type ReactNode } from 'react'\nimport { Arbi, type ArbiOptions } from '@arbidocs/core/browser'\n\nexport const ArbiContext = createContext<Arbi | null>(null)\n\nexport interface ArbiProviderProps extends ArbiOptions {\n children: ReactNode\n}\n\nexport function ArbiProvider({ children, ...options }: ArbiProviderProps) {\n const arbi = useMemo(\n () => new Arbi(options),\n // Stable on url + deploymentDomain — re-creating the instance on every render would be wrong\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [options.url, options.deploymentDomain, options.credentials]\n )\n\n return <ArbiContext.Provider value={arbi}>{children}</ArbiContext.Provider>\n}\n","/**\n * Hook to access the Arbi instance from the nearest ArbiProvider.\n */\n\nimport { useContext } from 'react'\nimport type { Arbi } from '@arbidocs/core/browser'\nimport { ArbiContext } from './ArbiProvider'\n\nexport function useArbi(): Arbi {\n const arbi = useContext(ArbiContext)\n if (!arbi) {\n throw new Error('useArbi() must be used within an <ArbiProvider>')\n }\n return arbi\n}\n","/**\n * React Query hooks that use the Arbi instance from context.\n */\n\nimport { useQuery, useMutation } from '@tanstack/react-query'\nimport type { SSEStreamResult } from '@arbidocs/core/browser'\nimport { useArbi } from './useArbi'\n\n// ── Query keys ──────────────────────────────────────────────────────────────\n\nexport const arbiQueryKeys = {\n workspaces: () => ['arbi', 'workspaces'] as const,\n documents: (workspaceId: string) => ['arbi', 'documents', workspaceId] as const,\n conversations: (workspaceId: string) => ['arbi', 'conversations', workspaceId] as const,\n tags: (workspaceId: string) => ['arbi', 'tags', workspaceId] as const,\n health: () => ['arbi', 'health'] as const,\n}\n\n// ── Hooks ───────────────────────────────────────────────────────────────────\n\n/** List the logged-in user's workspaces. */\nexport function useWorkspaces(options?: { enabled?: boolean }) {\n const arbi = useArbi()\n return useQuery({\n queryKey: arbiQueryKeys.workspaces(),\n queryFn: () => arbi.workspaces.list(),\n enabled: options?.enabled ?? arbi.isLoggedIn,\n })\n}\n\n/** List documents in a workspace. */\nexport function useDocuments(workspaceId: string | undefined, options?: { enabled?: boolean }) {\n const arbi = useArbi()\n return useQuery({\n queryKey: arbiQueryKeys.documents(workspaceId ?? ''),\n queryFn: () => arbi.documents.list(),\n enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace,\n })\n}\n\n/** List conversations in a workspace. */\nexport function useConversations(workspaceId: string | undefined, options?: { enabled?: boolean }) {\n const arbi = useArbi()\n return useQuery({\n queryKey: arbiQueryKeys.conversations(workspaceId ?? ''),\n queryFn: () => arbi.conversations.list(),\n enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace,\n })\n}\n\n/** List tags in a workspace. */\nexport function useTags(workspaceId: string | undefined, options?: { enabled?: boolean }) {\n const arbi = useArbi()\n return useQuery({\n queryKey: arbiQueryKeys.tags(workspaceId ?? ''),\n queryFn: () => arbi.tags.list(),\n enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace,\n })\n}\n\n/** Send a streaming query to the RAG assistant. Returns a mutation. */\nexport function useAssistantQuery() {\n const arbi = useArbi()\n\n return useMutation<\n SSEStreamResult,\n Error,\n {\n question: string\n docIds: string[]\n previousResponseId?: string | null\n model?: string\n onToken?: (content: string) => void\n onStreamStart?: (data: { assistant_message_ext_id?: string }) => void\n onAgentStep?: (data: { focus?: string; status?: string }) => void\n onError?: (message: string) => void\n onComplete?: () => void\n }\n >({\n mutationFn: ({ question, ...options }) => arbi.assistant.query(question, options),\n })\n}\n\n/** Check backend health. */\nexport function useHealth(options?: { enabled?: boolean }) {\n const arbi = useArbi()\n return useQuery({\n queryKey: arbiQueryKeys.health(),\n queryFn: () => arbi.health.check(),\n enabled: options?.enabled,\n })\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -105,8 +105,8 @@ declare function useTags(workspaceId: string | undefined, options?: {
|
|
|
105
105
|
declare function useAssistantQuery(): _tanstack_react_query.UseMutationResult<SSEStreamResult, Error, {
|
|
106
106
|
question: string;
|
|
107
107
|
docIds: string[];
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
previousResponseId?: string | null;
|
|
109
|
+
model?: string;
|
|
110
110
|
onToken?: (content: string) => void;
|
|
111
111
|
onStreamStart?: (data: {
|
|
112
112
|
assistant_message_ext_id?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -105,8 +105,8 @@ declare function useTags(workspaceId: string | undefined, options?: {
|
|
|
105
105
|
declare function useAssistantQuery(): _tanstack_react_query.UseMutationResult<SSEStreamResult, Error, {
|
|
106
106
|
question: string;
|
|
107
107
|
docIds: string[];
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
previousResponseId?: string | null;
|
|
109
|
+
model?: string;
|
|
110
110
|
onToken?: (content: string) => void;
|
|
111
111
|
onStreamStart?: (data: {
|
|
112
112
|
assistant_message_ext_id?: string;
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ function useDocuments(workspaceId, options) {
|
|
|
41
41
|
const arbi = useArbi();
|
|
42
42
|
return useQuery({
|
|
43
43
|
queryKey: arbiQueryKeys.documents(workspaceId ?? ""),
|
|
44
|
-
queryFn: () => arbi.documents.list(
|
|
44
|
+
queryFn: () => arbi.documents.list(),
|
|
45
45
|
enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -49,7 +49,7 @@ function useConversations(workspaceId, options) {
|
|
|
49
49
|
const arbi = useArbi();
|
|
50
50
|
return useQuery({
|
|
51
51
|
queryKey: arbiQueryKeys.conversations(workspaceId ?? ""),
|
|
52
|
-
queryFn: () => arbi.conversations.list(
|
|
52
|
+
queryFn: () => arbi.conversations.list(),
|
|
53
53
|
enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
|
|
54
54
|
});
|
|
55
55
|
}
|
|
@@ -57,7 +57,7 @@ function useTags(workspaceId, options) {
|
|
|
57
57
|
const arbi = useArbi();
|
|
58
58
|
return useQuery({
|
|
59
59
|
queryKey: arbiQueryKeys.tags(workspaceId ?? ""),
|
|
60
|
-
queryFn: () => arbi.tags.list(
|
|
60
|
+
queryFn: () => arbi.tags.list(),
|
|
61
61
|
enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
|
|
62
62
|
});
|
|
63
63
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ArbiProvider.tsx","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EAAA,OAAO,QAAA,CAAS;AAAA,IACd,QAAA,EAAU,aAAA,CAAc,IAAA,CAAK,WAAA,IAAe,EAAE,CAAA;AAAA,IAC9C,OAAA,EAAS,MAAM,IAAA,CAAK,IAAA,CAAK,IAAA,EAAK;AAAA,IAC9B,UAAU,OAAA,EAAS,OAAA,IAAW,SAAS,CAAC,CAAC,eAAe,IAAA,CAAK;AAAA,GAC9D,CAAA;AACH;AAGO,SAAS,iBAAA,GAAoB;AAClC,EAAA,MAAM,OAAO,OAAA,EAAQ;AAErB,EAAA,OAAO,WAAA,CAcL;AAAA,IACA,UAAA,EAAY,CAAC,EAAE,QAAA,EAAU,GAAG,OAAA,EAAQ,KAAM,IAAA,CAAK,SAAA,CAAU,KAAA,CAAM,QAAA,EAAU,OAAO;AAAA,GACjF,CAAA;AACH;AAGO,SAAS,UAAU,OAAA,EAAiC;AACzD,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,OAAO,QAAA,CAAS;AAAA,IACd,QAAA,EAAU,cAAc,MAAA,EAAO;AAAA,IAC/B,OAAA,EAAS,MAAM,IAAA,CAAK,MAAA,CAAO,KAAA,EAAM;AAAA,IACjC,SAAS,OAAA,EAAS;AAAA,GACnB,CAAA;AACH","file":"index.js","sourcesContent":["/**\n * ArbiProvider — React context that holds an Arbi instance.\n *\n * Usage:\n * <ArbiProvider url=\"https://arbi.mycompany.com\">\n * <App />\n * </ArbiProvider>\n */\n\nimport { createContext, useMemo, type ReactNode } from 'react'\nimport { Arbi, type ArbiOptions } from '@arbidocs/core/browser'\n\nexport const ArbiContext = createContext<Arbi | null>(null)\n\nexport interface ArbiProviderProps extends ArbiOptions {\n children: ReactNode\n}\n\nexport function ArbiProvider({ children, ...options }: ArbiProviderProps) {\n const arbi = useMemo(\n () => new Arbi(options),\n // Stable on url + deploymentDomain — re-creating the instance on every render would be wrong\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [options.url, options.deploymentDomain, options.credentials]\n )\n\n return <ArbiContext.Provider value={arbi}>{children}</ArbiContext.Provider>\n}\n","/**\n * Hook to access the Arbi instance from the nearest ArbiProvider.\n */\n\nimport { useContext } from 'react'\nimport type { Arbi } from '@arbidocs/core/browser'\nimport { ArbiContext } from './ArbiProvider'\n\nexport function useArbi(): Arbi {\n const arbi = useContext(ArbiContext)\n if (!arbi) {\n throw new Error('useArbi() must be used within an <ArbiProvider>')\n }\n return arbi\n}\n","/**\n * React Query hooks that use the Arbi instance from context.\n */\n\nimport { useQuery, useMutation } from '@tanstack/react-query'\nimport type { SSEStreamResult } from '@arbidocs/core/browser'\nimport { useArbi } from './useArbi'\n\n// ── Query keys ──────────────────────────────────────────────────────────────\n\nexport const arbiQueryKeys = {\n workspaces: () => ['arbi', 'workspaces'] as const,\n documents: (workspaceId: string) => ['arbi', 'documents', workspaceId] as const,\n conversations: (workspaceId: string) => ['arbi', 'conversations', workspaceId] as const,\n tags: (workspaceId: string) => ['arbi', 'tags', workspaceId] as const,\n health: () => ['arbi', 'health'] as const,\n}\n\n// ── Hooks ───────────────────────────────────────────────────────────────────\n\n/** List the logged-in user's workspaces. */\nexport function useWorkspaces(options?: { enabled?: boolean }) {\n const arbi = useArbi()\n return useQuery({\n queryKey: arbiQueryKeys.workspaces(),\n queryFn: () => arbi.workspaces.list(),\n enabled: options?.enabled ?? arbi.isLoggedIn,\n })\n}\n\n/** List documents in a workspace. */\nexport function useDocuments(workspaceId: string | undefined, options?: { enabled?: boolean }) {\n const arbi = useArbi()\n return useQuery({\n queryKey: arbiQueryKeys.documents(workspaceId ?? ''),\n queryFn: () => arbi.documents.list(),\n enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace,\n })\n}\n\n/** List conversations in a workspace. */\nexport function useConversations(workspaceId: string | undefined, options?: { enabled?: boolean }) {\n const arbi = useArbi()\n return useQuery({\n queryKey: arbiQueryKeys.conversations(workspaceId ?? ''),\n queryFn: () => arbi.conversations.list(),\n enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace,\n })\n}\n\n/** List tags in a workspace. */\nexport function useTags(workspaceId: string | undefined, options?: { enabled?: boolean }) {\n const arbi = useArbi()\n return useQuery({\n queryKey: arbiQueryKeys.tags(workspaceId ?? ''),\n queryFn: () => arbi.tags.list(),\n enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace,\n })\n}\n\n/** Send a streaming query to the RAG assistant. Returns a mutation. */\nexport function useAssistantQuery() {\n const arbi = useArbi()\n\n return useMutation<\n SSEStreamResult,\n Error,\n {\n question: string\n docIds: string[]\n previousResponseId?: string | null\n model?: string\n onToken?: (content: string) => void\n onStreamStart?: (data: { assistant_message_ext_id?: string }) => void\n onAgentStep?: (data: { focus?: string; status?: string }) => void\n onError?: (message: string) => void\n onComplete?: () => void\n }\n >({\n mutationFn: ({ question, ...options }) => arbi.assistant.query(question, options),\n })\n}\n\n/** Check backend health. */\nexport function useHealth(options?: { enabled?: boolean }) {\n const arbi = useArbi()\n return useQuery({\n queryKey: arbiQueryKeys.health(),\n queryFn: () => arbi.health.check(),\n enabled: options?.enabled,\n })\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arbidocs/react",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "React hooks and provider for the ARBI SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"typecheck": "tsc --noEmit"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@arbidocs/core": "0.3.
|
|
26
|
-
"@arbidocs/sdk": "0.3.
|
|
25
|
+
"@arbidocs/core": "0.3.9",
|
|
26
|
+
"@arbidocs/sdk": "0.3.9",
|
|
27
27
|
"@tanstack/react-query": ">=5"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"repository": {
|
|
49
49
|
"type": "git",
|
|
50
|
-
"url": "git+https://github.com/
|
|
50
|
+
"url": "git+https://github.com/arbicity/ARBI-frontend.git",
|
|
51
51
|
"directory": "packages/arbi-react"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|