@burdenoff/microfe-botmanor 2026.1127.5 → 2026.1127.7
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/botlit/components/BotVersionHistoryPanel.js +136 -128
- package/dist/botlit/components/BotVersionHistoryPanel.js.map +1 -1
- package/dist/botlit/components/VersionHistoryPanel.js +129 -110
- package/dist/botlit/components/VersionHistoryPanel.js.map +1 -1
- package/dist/botlit/hooks/internal/workspaceGateway.d.ts +2 -0
- package/dist/botlit/hooks/internal/workspaceGateway.js +6 -2
- package/dist/botlit/hooks/internal/workspaceGateway.js.map +1 -1
- package/dist/botlit/hooks/useAgents.d.ts +1 -6
- package/dist/botlit/hooks/useAgents.js +89 -123
- package/dist/botlit/hooks/useAgents.js.map +1 -1
- package/dist/botlit/hooks/useBotVersions.d.ts +2 -2
- package/dist/botlit/hooks/useBotVersions.js +20 -28
- package/dist/botlit/hooks/useBotVersions.js.map +1 -1
- package/dist/botlit/hooks/usePolicies.d.ts +6 -2
- package/dist/botlit/hooks/usePolicies.js +57 -34
- package/dist/botlit/hooks/usePolicies.js.map +1 -1
- package/dist/botlit/hooks/useRetrievalProfiles.d.ts +5 -1
- package/dist/botlit/hooks/useRetrievalProfiles.js +49 -31
- package/dist/botlit/hooks/useRetrievalProfiles.js.map +1 -1
- package/dist/botlit/pages/AgentDetailPage.js +103 -103
- package/dist/botlit/pages/AgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/BotDetailPage.js +1 -1
- package/dist/botlit/pages/BotDetailPage.js.map +1 -1
- package/dist/botlit/pages/PoliciesPage.js +177 -152
- package/dist/botlit/pages/PoliciesPage.js.map +1 -1
- package/dist/botlit/pages/RetrievalProfilesPage.js +171 -154
- package/dist/botlit/pages/RetrievalProfilesPage.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +187 -0
- package/dist/generated/wspace-operations.js +111 -51
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.js +3 -1
- package/dist/generated/wspace-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBotVersions.js","names":["VERSION_FIELDS","
|
|
1
|
+
{"version":3,"file":"useBotVersions.js","names":["VERSION_FIELDS","PUBLISH_BOT_APP_VERSION_DOCUMENT","ROLLBACK_BOT_APP_VERSION_DOCUMENT","NO_VERSIONS","sortVersionsNewestFirst","versions","a","b","useBotVersions","variables","useMemo","botId","useWorkspacePaginatedQuery","ListBotmanorAppVersionsPageDocument","data","usePublishBotVersion","useWorkspaceMutation","changelog","useRollbackBotVersion"],"sources":["../../../src/botlit/hooks/useBotVersions.ts"],"sourcesContent":["/**\n * Bot app version history (BOFF-15360)\n * @module botlit/hooks\n *\n * A bot keeps a DRAFT version that every configuration change rewrites, a\n * PUBLISHED version that is live, and HISTORICAL ones. These hooks list the\n * versions of one bot, publish its draft with a changelog and roll back to an\n * earlier version (the server records the rollback as a new published version).\n */\n\nimport { gql } from '@apollo/client';\nimport { useMemo } from 'react';\nimport {\n ListBotmanorAppVersionsPageDocument,\n type ListBotmanorAppVersionsPageQuery,\n} from '../../generated/wspace-operations';\n\nimport {\n useWorkspaceMutation,\n useWorkspacePaginatedQuery,\n type PaginatedQueryResult,\n} from './internal/workspaceGateway';\n\nexport type BotVersionStatus = 'DRAFT' | 'PUBLISHED' | 'HISTORICAL';\n\nexport interface BotVersionRecord {\n id: string;\n botAppId: string;\n version: string;\n status: BotVersionStatus | string;\n changelog?: string | null;\n createdAt?: string | null;\n publishedAt?: string | null;\n}\n\ninterface PublishBotAppVersionData {\n publishBotAppVersion?: BotVersionRecord | null;\n}\n\ninterface RollbackBotAppVersionData {\n rollbackBotAppVersion?: BotVersionRecord | null;\n}\n\nconst VERSION_FIELDS = `\n id\n botAppId\n version\n status\n changelog\n createdAt\n publishedAt\n`;\n\nconst PUBLISH_BOT_APP_VERSION_DOCUMENT = gql`\n mutation PublishBotAppVersion($botAppId: ID!, $versionId: ID!, $changelog: String) {\n publishBotAppVersion(botAppId: $botAppId, versionId: $versionId, changelog: $changelog) {\n ${VERSION_FIELDS}\n }\n }\n`;\n\nconst ROLLBACK_BOT_APP_VERSION_DOCUMENT = gql`\n mutation RollbackBotAppVersion($botAppId: ID!, $targetVersionId: ID!) {\n rollbackBotAppVersion(botAppId: $botAppId, targetVersionId: $targetVersionId) {\n ${VERSION_FIELDS}\n }\n }\n`;\n\nconst NO_VERSIONS: BotVersionRecord[] = [];\n\n/** Newest first, whatever order the server returned. */\nexport function sortVersionsNewestFirst(versions: readonly BotVersionRecord[]): BotVersionRecord[] {\n return [...versions].sort((a, b) =>\n a.createdAt && b.createdAt ? b.createdAt.localeCompare(a.createdAt) : 0\n );\n}\n\ntype BotVersionListItem =\n ListBotmanorAppVersionsPageQuery['listBotmanorAppVersionsPage']['items'][number];\n\nexport function useBotVersions(\n botId: string | undefined\n): PaginatedQueryResult<BotVersionRecord[]> {\n const variables = useMemo(() => ({ botAppId: botId }), [botId]);\n return useWorkspacePaginatedQuery<\n ListBotmanorAppVersionsPageQuery,\n BotVersionListItem,\n BotVersionRecord[]\n >({\n document: ListBotmanorAppVersionsPageDocument,\n variables,\n pageSize: 50,\n extractRows: (data) => data?.listBotmanorAppVersionsPage.items,\n extractNextOffset: (data) => data?.listBotmanorAppVersionsPage.nextOffset ?? null,\n select: sortVersionsNewestFirst,\n fallback: NO_VERSIONS,\n enabled: Boolean(botId),\n errorMessage: 'Failed to load bot versions',\n });\n}\n\nexport interface PublishBotVersionInput {\n botId: string;\n versionId: string;\n changelog?: string;\n}\n\nexport function usePublishBotVersion() {\n return useWorkspaceMutation<PublishBotAppVersionData, PublishBotVersionInput, BotVersionRecord>({\n document: PUBLISH_BOT_APP_VERSION_DOCUMENT,\n variables: ({ botId, versionId, changelog }) => ({\n botAppId: botId,\n versionId,\n changelog: changelog?.trim() || undefined,\n }),\n select: (data) => data?.publishBotAppVersion ?? undefined,\n errorMessage: 'Failed to publish the bot version',\n });\n}\n\nexport interface RollbackBotVersionInput {\n botId: string;\n targetVersionId: string;\n}\n\nexport function useRollbackBotVersion() {\n return useWorkspaceMutation<RollbackBotAppVersionData, RollbackBotVersionInput, BotVersionRecord>(\n {\n document: ROLLBACK_BOT_APP_VERSION_DOCUMENT,\n variables: ({ botId, targetVersionId }) => ({ botAppId: botId, targetVersionId }),\n select: (data) => data?.rollbackBotAppVersion ?? undefined,\n errorMessage: 'Failed to roll back the bot version',\n }\n );\n}\n"],"mappings":";;;;;AA2CA,IAAMA,IAAiB,sFAUjBC,IAAmC,CAAG;;;QAGpCD,EAAe;;;GAKjBE,IAAoC,CAAG;;;QAGrCF,EAAe;;;GAKjBG,IAAkC,CAAC;AAGzC,SAAgBC,EAAwB,GAA2D;CACjG,OAAO,CAAC,GAAGC,CAAQ,CAAC,CAAC,MAAM,GAAG,MAC5BC,EAAE,aAAaC,EAAE,YAAYA,EAAE,UAAU,cAAcD,EAAE,SAAS,IAAI,CACxE;AACF;AAKA,SAAgBE,EACd,GAC0C;CAC1C,IAAMC,IAAYC,SAAe,EAAE,UAAUC,EAAM,IAAI,CAACA,CAAK,CAAC;CAC9D,OAAOC,EAIL;EACA,UAAUC;EACV;EACA,UAAU;EACV,cAAc,MAASC,GAAM,4BAA4B;EACzD,oBAAoB,MAASA,GAAM,4BAA4B,cAAc;EAC7E,QAAQV;EACR,UAAUD;EACV,SAAS,EAAQQ;EACjB,cAAc;CAChB,CAAC;AACH;AAQA,SAAgBI,IAAuB;CACrC,OAAOC,EAAyF;EAC9F,UAAUf;EACV,YAAY,EAAE,UAAO,cAAW,oBAAiB;GAC/C,UAAUU;GACV;GACA,WAAWM,GAAW,KAAK,KAAK,KAAA;EAClC;EACA,SAAS,MAASH,GAAM,wBAAwB,KAAA;EAChD,cAAc;CAChB,CAAC;AACH;AAOA,SAAgBI,IAAwB;CACtC,OAAOF,EACL;EACE,UAAUd;EACV,YAAY,EAAE,UAAO,0BAAuB;GAAE,UAAUS;GAAO;EAAgB;EAC/E,SAAS,MAASG,GAAM,yBAAyB,KAAA;EACjD,cAAc;CAChB,CACF;AACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListBotmanorPoliciesPageQuery } from '../../generated/wspace-operations';
|
|
2
|
+
import { CreatePolicyInput, PolicyType, UpdatePolicyInput } from '../../generated/wspace-types';
|
|
2
3
|
import { GraphQLInput } from './internal/mutationInput';
|
|
3
|
-
import { QueryResult } from './internal/workspaceGateway';
|
|
4
|
+
import { PaginatedQueryResult, QueryResult } from './internal/workspaceGateway';
|
|
4
5
|
export interface PolicyRecord {
|
|
5
6
|
id: string;
|
|
6
7
|
name: string;
|
|
@@ -42,6 +43,8 @@ export declare const policyKeys: {
|
|
|
42
43
|
};
|
|
43
44
|
export declare function usePolicies(filter?: PolicyFilterVariables): QueryResult<PolicyRecord[]>;
|
|
44
45
|
export declare function usePoliciesByType(type: string): QueryResult<PolicyRecord[]>;
|
|
46
|
+
type PolicyListItem = ListBotmanorPoliciesPageQuery['listBotmanorPoliciesPage']['items'][number];
|
|
47
|
+
export declare function usePoliciesPage(search: string, type: PolicyType | null): PaginatedQueryResult<PolicyListItem[]>;
|
|
45
48
|
export declare function usePolicy(policyId: string | undefined): QueryResult<PolicyRecord | null>;
|
|
46
49
|
export declare function useCreatePolicy(): {
|
|
47
50
|
create: (input: CreatePolicyVariables) => Promise<PolicyRecord>;
|
|
@@ -58,3 +61,4 @@ export declare function useDeletePolicy(): {
|
|
|
58
61
|
loading: boolean;
|
|
59
62
|
error: Error | undefined;
|
|
60
63
|
};
|
|
64
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CreatePolicyDocument as e, DeletePolicyDocument as t, GetPolicyDocument as n,
|
|
2
|
-
import { buildMutationInput as
|
|
3
|
-
import { useWorkspaceId as
|
|
4
|
-
import { useCallback as
|
|
1
|
+
import { CreatePolicyDocument as e, DeletePolicyDocument as t, GetPolicyDocument as n, ListBotmanorPoliciesPageDocument as r, ListPoliciesDocument as i, UpdatePolicyDocument as a } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { buildMutationInput as o, fieldsOf as s } from "./internal/mutationInput.js";
|
|
3
|
+
import { useWorkspaceId as c, useWorkspaceMutation as l, useWorkspacePaginatedQuery as u, useWorkspaceQuery as d } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useCallback as f, useMemo as p } from "react";
|
|
5
5
|
// src/botlit/hooks/usePolicies.ts
|
|
6
|
-
var
|
|
6
|
+
var m = 100, h = s({
|
|
7
7
|
bucketId: !0,
|
|
8
8
|
config: !0,
|
|
9
9
|
description: !0,
|
|
@@ -14,7 +14,7 @@ var f = 100, p = o({
|
|
|
14
14
|
type: !0,
|
|
15
15
|
visibility: !0,
|
|
16
16
|
workspaceId: !0
|
|
17
|
-
}),
|
|
17
|
+
}), g = s({
|
|
18
18
|
bucketId: !0,
|
|
19
19
|
config: !0,
|
|
20
20
|
description: !0,
|
|
@@ -24,44 +24,67 @@ var f = 100, p = o({
|
|
|
24
24
|
tags: !0,
|
|
25
25
|
type: !0,
|
|
26
26
|
visibility: !0
|
|
27
|
-
}),
|
|
28
|
-
function
|
|
29
|
-
return e?.listPolicies ??
|
|
27
|
+
}), _ = [];
|
|
28
|
+
function v(e) {
|
|
29
|
+
return e?.listPolicies ?? _;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
let t =
|
|
31
|
+
function y(e) {
|
|
32
|
+
let t = c(), { search: n, type: r, status: a, visibility: o, bucketId: s } = e ?? {}, l = p(() => ({
|
|
33
33
|
filters: {
|
|
34
34
|
workspaceId: t,
|
|
35
35
|
search: n || void 0,
|
|
36
|
-
type:
|
|
36
|
+
type: r,
|
|
37
37
|
status: a,
|
|
38
38
|
visibility: o,
|
|
39
|
-
bucketId:
|
|
39
|
+
bucketId: s
|
|
40
40
|
},
|
|
41
41
|
pagination: {
|
|
42
|
-
limit:
|
|
42
|
+
limit: m,
|
|
43
43
|
offset: 0
|
|
44
44
|
}
|
|
45
45
|
}), [
|
|
46
46
|
t,
|
|
47
47
|
n,
|
|
48
|
-
|
|
48
|
+
r,
|
|
49
49
|
a,
|
|
50
50
|
o,
|
|
51
|
-
|
|
51
|
+
s
|
|
52
52
|
]);
|
|
53
|
-
return
|
|
54
|
-
document:
|
|
55
|
-
variables:
|
|
56
|
-
select:
|
|
57
|
-
fallback:
|
|
53
|
+
return d({
|
|
54
|
+
document: i,
|
|
55
|
+
variables: l,
|
|
56
|
+
select: v,
|
|
57
|
+
fallback: _,
|
|
58
58
|
enabled: !!t,
|
|
59
59
|
errorMessage: "Failed to load policies"
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
var b = [];
|
|
63
|
+
function x(e, t) {
|
|
64
|
+
let n = c(), i = p(() => ({ filters: {
|
|
65
|
+
workspaceId: n,
|
|
66
|
+
search: e || void 0,
|
|
67
|
+
type: t ?? void 0
|
|
68
|
+
} }), [
|
|
69
|
+
n,
|
|
70
|
+
e,
|
|
71
|
+
t
|
|
72
|
+
]);
|
|
73
|
+
return u({
|
|
74
|
+
document: r,
|
|
75
|
+
variables: i,
|
|
76
|
+
pageSize: 50,
|
|
77
|
+
extractRows: (e) => e?.listBotmanorPoliciesPage.items,
|
|
78
|
+
extractNextOffset: (e) => e?.listBotmanorPoliciesPage.nextOffset ?? null,
|
|
79
|
+
select: (e) => e,
|
|
80
|
+
fallback: b,
|
|
81
|
+
enabled: !!n,
|
|
82
|
+
errorMessage: "Failed to load policies"
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function S(e) {
|
|
86
|
+
let t = p(() => ({ id: e ?? "" }), [e]);
|
|
87
|
+
return d({
|
|
65
88
|
document: n,
|
|
66
89
|
variables: t,
|
|
67
90
|
select: (e) => e?.getPolicy ?? null,
|
|
@@ -70,11 +93,11 @@ function v(e) {
|
|
|
70
93
|
errorMessage: "Failed to load policy"
|
|
71
94
|
});
|
|
72
95
|
}
|
|
73
|
-
function
|
|
74
|
-
let t =
|
|
96
|
+
function C() {
|
|
97
|
+
let t = c(), n = f((e) => ({ input: o({
|
|
75
98
|
...e,
|
|
76
99
|
workspaceId: t
|
|
77
|
-
},
|
|
100
|
+
}, h) }), [t]), [r, i] = l({
|
|
78
101
|
document: e,
|
|
79
102
|
variables: n,
|
|
80
103
|
select: (e) => e?.createPolicy,
|
|
@@ -86,12 +109,12 @@ function y() {
|
|
|
86
109
|
error: i.error
|
|
87
110
|
};
|
|
88
111
|
}
|
|
89
|
-
function
|
|
90
|
-
let [e, t] =
|
|
91
|
-
document:
|
|
112
|
+
function w() {
|
|
113
|
+
let [e, t] = l({
|
|
114
|
+
document: a,
|
|
92
115
|
variables: ({ policyId: e, input: t }) => ({
|
|
93
116
|
id: e,
|
|
94
|
-
input:
|
|
117
|
+
input: o(t, g)
|
|
95
118
|
}),
|
|
96
119
|
select: (e) => e?.updatePolicy,
|
|
97
120
|
errorMessage: "Failed to update policy"
|
|
@@ -102,8 +125,8 @@ function b() {
|
|
|
102
125
|
error: t.error
|
|
103
126
|
};
|
|
104
127
|
}
|
|
105
|
-
function
|
|
106
|
-
let [e, n] =
|
|
128
|
+
function T() {
|
|
129
|
+
let [e, n] = l({
|
|
107
130
|
document: t,
|
|
108
131
|
variables: (e) => ({ id: e }),
|
|
109
132
|
select: (e) => e?.deletePolicy,
|
|
@@ -115,6 +138,6 @@ function x() {
|
|
|
115
138
|
error: n.error
|
|
116
139
|
};
|
|
117
140
|
}
|
|
118
|
-
export {
|
|
141
|
+
export { C as useCreatePolicy, T as useDeletePolicy, y as usePolicies, x as usePoliciesPage, S as usePolicy, w as useUpdatePolicy };
|
|
119
142
|
|
|
120
143
|
//# sourceMappingURL=usePolicies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePolicies.js","names":["LIST_LIMIT","CREATE_POLICY_FIELDS","fieldsOf","UPDATE_POLICY_FIELDS","NO_POLICIES","selectPolicies","data","usePolicies","workspaceId","useWorkspaceId","filter","variables","useMemo","search","type","status","visibility","bucketId","useWorkspaceQuery","ListPoliciesDocument","usePolicy","policyId","GetPolicyDocument","useCreatePolicy","useCallback","buildMutationInput","input","create","state","useWorkspaceMutation","CreatePolicyDocument","useUpdatePolicy","update","UpdatePolicyDocument","useDeletePolicy","remove","DeletePolicyDocument"],"sources":["../../../src/botlit/hooks/usePolicies.ts"],"sourcesContent":["/**\n * Policies Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listPolicies` / `getPolicy` operations and the\n * create/update/delete mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreatePolicyDocument,\n DeletePolicyDocument,\n GetPolicyDocument,\n ListPoliciesDocument,\n UpdatePolicyDocument,\n type CreatePolicyMutation,\n type DeletePolicyMutation,\n type GetPolicyQuery,\n type ListPoliciesQuery,\n type UpdatePolicyMutation,\n} from '../../generated/wspace-operations';\nimport type {
|
|
1
|
+
{"version":3,"file":"usePolicies.js","names":["LIST_LIMIT","CREATE_POLICY_FIELDS","fieldsOf","UPDATE_POLICY_FIELDS","NO_POLICIES","selectPolicies","data","usePolicies","workspaceId","useWorkspaceId","filter","variables","useMemo","search","type","status","visibility","bucketId","useWorkspaceQuery","ListPoliciesDocument","NO_POLICY_LIST_ITEMS","usePoliciesPage","useWorkspacePaginatedQuery","ListBotmanorPoliciesPageDocument","rows","usePolicy","policyId","GetPolicyDocument","useCreatePolicy","useCallback","buildMutationInput","input","create","state","useWorkspaceMutation","CreatePolicyDocument","useUpdatePolicy","update","UpdatePolicyDocument","useDeletePolicy","remove","DeletePolicyDocument"],"sources":["../../../src/botlit/hooks/usePolicies.ts"],"sourcesContent":["/**\n * Policies Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listPolicies` / `getPolicy` operations and the\n * create/update/delete mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreatePolicyDocument,\n DeletePolicyDocument,\n GetPolicyDocument,\n ListPoliciesDocument,\n ListBotmanorPoliciesPageDocument,\n UpdatePolicyDocument,\n type ListBotmanorPoliciesPageQuery,\n type ListBotmanorPoliciesPageQueryVariables,\n type CreatePolicyMutation,\n type DeletePolicyMutation,\n type GetPolicyQuery,\n type ListPoliciesQuery,\n type UpdatePolicyMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreatePolicyInput,\n PolicyType,\n UpdatePolicyInput,\n} from '../../generated/wspace-types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspacePaginatedQuery,\n type PaginatedQueryResult,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n\nexport interface PolicyRecord {\n id: string;\n name: string;\n type: string;\n status: string;\n visibility: string;\n description?: string | null;\n bucketId?: string | null;\n config?: Record<string, unknown> | null;\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface PolicyFilterVariables {\n search?: string;\n type?: string;\n status?: string;\n visibility?: string;\n bucketId?: string;\n}\n\n/** `CreatePolicyInput` minus the `workspaceId` the hook supplies. */\nexport type CreatePolicyVariables = Omit<GraphQLInput<CreatePolicyInput>, 'workspaceId'>;\n\nexport interface UpdatePolicyVariables {\n policyId: string;\n input: GraphQLInput<UpdatePolicyInput>;\n}\n\nconst CREATE_POLICY_FIELDS = fieldsOf<CreatePolicyInput>({\n bucketId: true,\n config: true,\n description: true,\n metadata: true,\n name: true,\n status: true,\n tags: true,\n type: true,\n visibility: true,\n workspaceId: true,\n});\n\nconst UPDATE_POLICY_FIELDS = fieldsOf<UpdatePolicyInput>({\n bucketId: true,\n config: true,\n description: true,\n metadata: true,\n name: true,\n status: true,\n tags: true,\n type: true,\n visibility: true,\n});\n\nconst NO_POLICIES: PolicyRecord[] = [];\n\nfunction selectPolicies(data: ListPoliciesQuery | undefined): PolicyRecord[] {\n return data?.listPolicies ?? NO_POLICIES;\n}\n\nexport const policyKeys = {\n all: ['policies'] as const,\n lists: () => [...policyKeys.all, 'list'] as const,\n list: (filter?: PolicyFilterVariables) => [...policyKeys.lists(), filter] as const,\n details: () => [...policyKeys.all, 'detail'] as const,\n detail: (id: string) => [...policyKeys.details(), id] as const,\n byType: (type: string) => [...policyKeys.all, 'type', type] as const,\n};\n\nexport function usePolicies(filter?: PolicyFilterVariables): QueryResult<PolicyRecord[]> {\n const workspaceId = useWorkspaceId();\n const { search, type, status, visibility, bucketId } = filter ?? {};\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n search: search || undefined,\n type,\n status,\n visibility,\n bucketId,\n },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search, type, status, visibility, bucketId]\n );\n\n return useWorkspaceQuery<ListPoliciesQuery, PolicyRecord[]>({\n document: ListPoliciesDocument,\n variables,\n select: selectPolicies,\n fallback: NO_POLICIES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load policies',\n });\n}\n\nexport function usePoliciesByType(type: string): QueryResult<PolicyRecord[]> {\n return usePolicies({ type });\n}\n\ntype PolicyListItem = ListBotmanorPoliciesPageQuery['listBotmanorPoliciesPage']['items'][number];\nconst NO_POLICY_LIST_ITEMS: PolicyListItem[] = [];\n\nexport function usePoliciesPage(\n search: string,\n type: PolicyType | null\n): PaginatedQueryResult<PolicyListItem[]> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo<ListBotmanorPoliciesPageQueryVariables>(\n () => ({ filters: { workspaceId, search: search || undefined, type: type ?? undefined } }),\n [workspaceId, search, type]\n );\n\n return useWorkspacePaginatedQuery<\n ListBotmanorPoliciesPageQuery,\n PolicyListItem,\n PolicyListItem[]\n >({\n document: ListBotmanorPoliciesPageDocument,\n variables,\n pageSize: 50,\n extractRows: (data) => data?.listBotmanorPoliciesPage.items,\n extractNextOffset: (data) => data?.listBotmanorPoliciesPage.nextOffset ?? null,\n select: (rows) => rows,\n fallback: NO_POLICY_LIST_ITEMS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load policies',\n });\n}\n\nexport function usePolicy(policyId: string | undefined): QueryResult<PolicyRecord | null> {\n const variables = useMemo(() => ({ id: policyId ?? '' }), [policyId]);\n\n return useWorkspaceQuery<GetPolicyQuery, PolicyRecord | null>({\n document: GetPolicyDocument,\n variables,\n select: (data) => data?.getPolicy ?? null,\n fallback: null,\n enabled: Boolean(policyId),\n errorMessage: 'Failed to load policy',\n });\n}\n\nexport function useCreatePolicy() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreatePolicyVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_POLICY_FIELDS),\n }),\n [workspaceId]\n );\n\n const [create, state] = useWorkspaceMutation<\n CreatePolicyMutation,\n CreatePolicyVariables,\n PolicyRecord\n >({\n document: CreatePolicyDocument,\n variables,\n select: (data) => data?.createPolicy,\n errorMessage: 'Failed to create policy',\n });\n\n return { create, loading: state.loading, error: state.error };\n}\n\nexport function useUpdatePolicy() {\n const [update, state] = useWorkspaceMutation<\n UpdatePolicyMutation,\n UpdatePolicyVariables,\n PolicyRecord\n >({\n document: UpdatePolicyDocument,\n variables: ({ policyId, input }) => ({\n id: policyId,\n input: buildMutationInput(input, UPDATE_POLICY_FIELDS),\n }),\n select: (data) => data?.updatePolicy,\n errorMessage: 'Failed to update policy',\n });\n\n return { update, loading: state.loading, error: state.error };\n}\n\nexport function useDeletePolicy() {\n const [remove, state] = useWorkspaceMutation<DeletePolicyMutation, string, boolean>({\n document: DeletePolicyDocument,\n variables: (policyId) => ({ id: policyId }),\n select: (data) => data?.deletePolicy,\n errorMessage: 'Failed to delete policy',\n });\n\n return { remove, loading: state.loading, error: state.error };\n}\n"],"mappings":";;;;;AAuCA,IAAMA,IAAa,KAqCbC,IAAuBC,EAA4B;CACvD,UAAU;CACV,QAAQ;CACR,aAAa;CACb,UAAU;CACV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,CAACA,CAAQ,CAAC;CAEpE,OAAOR,EAAuD;EAC5D,UAAUS;EACV;EACA,SAAS,MAASrB,GAAM,aAAa;EACrC,UAAU;EACV,SAAS,EAAQoB;EACjB,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBE,IAAkB;CAChC,IAAMpB,IAAcC,EAAe,GAE7BE,IAAYkB,GACf,OAAkC,EACjC,OAAOC,EAAmB;EAAE,GAAGC;EAAO;CAAY,GAAG9B,CAAoB,EAC3E,IACA,CAACO,CAAW,CACd,GAEM,CAACwB,GAAQC,KAASC,EAItB;EACA,UAAUC;EACV;EACA,SAAS,MAAS7B,GAAM;EACxB,cAAc;CAChB,CAAC;CAED,OAAO;EAAE;EAAQ,SAAS2B,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC9D;AAEA,SAAgBG,IAAkB;CAChC,IAAM,CAACC,GAAQJ,KAASC,EAItB;EACA,UAAUI;EACV,YAAY,EAAE,aAAU,gBAAa;GACnC,IAAIZ;GACJ,OAAOI,EAAmBC,GAAO5B,CAAoB;EACvD;EACA,SAAS,MAASG,GAAM;EACxB,cAAc;CAChB,CAAC;CAED,OAAO;EAAE;EAAQ,SAAS2B,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC9D;AAEA,SAAgBM,IAAkB;CAChC,IAAM,CAACC,GAAQP,KAASC,EAA4D;EAClF,UAAUO;EACV,YAAY,OAAc,EAAE,IAAIf,EAAS;EACzC,SAAS,MAASpB,GAAM;EACxB,cAAc;CAChB,CAAC;CAED,OAAO;EAAE;EAAQ,SAAS2B,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC9D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ListBotmanorRetrievalProfilesPageQuery } from '../../generated/wspace-operations';
|
|
1
2
|
import { CreateRetrievalProfileInput, UpdateRetrievalProfileInput } from '../../generated/wspace-types';
|
|
2
3
|
import { GraphQLInput } from './internal/mutationInput';
|
|
3
|
-
import { QueryResult } from './internal/workspaceGateway';
|
|
4
|
+
import { PaginatedQueryResult, QueryResult } from './internal/workspaceGateway';
|
|
4
5
|
export interface RetrievalProfileRecord {
|
|
5
6
|
id: string;
|
|
6
7
|
name: string;
|
|
@@ -57,6 +58,8 @@ export declare const retrievalProfileKeys: {
|
|
|
57
58
|
detail: (id: string) => readonly ["retrieval-profiles", "detail", string];
|
|
58
59
|
};
|
|
59
60
|
export declare function useRetrievalProfiles(filter?: RetrievalProfileFilterVariables): QueryResult<RetrievalProfileRecord[]>;
|
|
61
|
+
type RetrievalProfileListItem = ListBotmanorRetrievalProfilesPageQuery['listBotmanorRetrievalProfilesPage']['items'][number];
|
|
62
|
+
export declare function useRetrievalProfilesPage(search: string): PaginatedQueryResult<RetrievalProfileListItem[]>;
|
|
60
63
|
export declare function useRetrievalProfile(profileId: string | undefined): QueryResult<RetrievalProfileRecord | null>;
|
|
61
64
|
export declare function useCreateRetrievalProfile(): {
|
|
62
65
|
create: (input: CreateRetrievalProfileVariables) => Promise<RetrievalProfileRecord>;
|
|
@@ -73,3 +76,4 @@ export declare function useDeleteRetrievalProfile(): {
|
|
|
73
76
|
loading: boolean;
|
|
74
77
|
error: Error | undefined;
|
|
75
78
|
};
|
|
79
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CreateRetrievalProfileDocument as e, DeleteRetrievalProfileDocument as t, GetRetrievalProfileDocument as n,
|
|
2
|
-
import { buildMutationInput as
|
|
3
|
-
import { useWorkspaceId as
|
|
4
|
-
import { useCallback as
|
|
1
|
+
import { CreateRetrievalProfileDocument as e, DeleteRetrievalProfileDocument as t, GetRetrievalProfileDocument as n, ListBotmanorRetrievalProfilesPageDocument as r, ListRetrievalProfilesDocument as i, UpdateRetrievalProfileDocument as a } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { buildMutationInput as o, fieldsOf as s } from "./internal/mutationInput.js";
|
|
3
|
+
import { useWorkspaceId as c, useWorkspaceMutation as l, useWorkspacePaginatedQuery as u, useWorkspaceQuery as d } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useCallback as f, useMemo as p } from "react";
|
|
5
5
|
// src/botlit/hooks/useRetrievalProfiles.ts
|
|
6
|
-
var
|
|
6
|
+
var m = 100, h = s({
|
|
7
7
|
bucketId: !0,
|
|
8
8
|
citationFormat: !0,
|
|
9
9
|
citationsRequired: !0,
|
|
@@ -28,7 +28,7 @@ var f = 100, p = o({
|
|
|
28
28
|
topK: !0,
|
|
29
29
|
visibility: !0,
|
|
30
30
|
workspaceId: !0
|
|
31
|
-
}),
|
|
31
|
+
}), g = s({
|
|
32
32
|
bucketId: !0,
|
|
33
33
|
citationFormat: !0,
|
|
34
34
|
citationsRequired: !0,
|
|
@@ -52,42 +52,60 @@ var f = 100, p = o({
|
|
|
52
52
|
testQueries: !0,
|
|
53
53
|
topK: !0,
|
|
54
54
|
visibility: !0
|
|
55
|
-
}),
|
|
56
|
-
function
|
|
57
|
-
return e?.listRetrievalProfiles ??
|
|
55
|
+
}), _ = [];
|
|
56
|
+
function v(e) {
|
|
57
|
+
return e?.listRetrievalProfiles ?? _;
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
let t =
|
|
59
|
+
function y(e) {
|
|
60
|
+
let t = c(), { search: n, status: r, strategyMode: a, bucketId: o } = e ?? {}, s = p(() => ({
|
|
61
61
|
filters: {
|
|
62
62
|
workspaceId: t,
|
|
63
63
|
search: n || void 0,
|
|
64
|
-
status:
|
|
64
|
+
status: r,
|
|
65
65
|
strategyMode: a,
|
|
66
66
|
bucketId: o
|
|
67
67
|
},
|
|
68
68
|
pagination: {
|
|
69
|
-
limit:
|
|
69
|
+
limit: m,
|
|
70
70
|
offset: 0
|
|
71
71
|
}
|
|
72
72
|
}), [
|
|
73
73
|
t,
|
|
74
74
|
n,
|
|
75
|
-
|
|
75
|
+
r,
|
|
76
76
|
a,
|
|
77
77
|
o
|
|
78
78
|
]);
|
|
79
|
-
return
|
|
79
|
+
return d({
|
|
80
|
+
document: i,
|
|
81
|
+
variables: s,
|
|
82
|
+
select: v,
|
|
83
|
+
fallback: _,
|
|
84
|
+
enabled: !!t,
|
|
85
|
+
errorMessage: "Failed to load retrieval profiles"
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
var b = [];
|
|
89
|
+
function x(e) {
|
|
90
|
+
let t = c(), n = p(() => ({ filters: {
|
|
91
|
+
workspaceId: t,
|
|
92
|
+
search: e || void 0
|
|
93
|
+
} }), [t, e]);
|
|
94
|
+
return u({
|
|
80
95
|
document: r,
|
|
81
|
-
variables:
|
|
82
|
-
|
|
83
|
-
|
|
96
|
+
variables: n,
|
|
97
|
+
pageSize: 50,
|
|
98
|
+
extractRows: (e) => e?.listBotmanorRetrievalProfilesPage.items,
|
|
99
|
+
extractNextOffset: (e) => e?.listBotmanorRetrievalProfilesPage.nextOffset ?? null,
|
|
100
|
+
select: (e) => e,
|
|
101
|
+
fallback: b,
|
|
84
102
|
enabled: !!t,
|
|
85
103
|
errorMessage: "Failed to load retrieval profiles"
|
|
86
104
|
});
|
|
87
105
|
}
|
|
88
|
-
function
|
|
89
|
-
let t =
|
|
90
|
-
return
|
|
106
|
+
function S(e) {
|
|
107
|
+
let t = p(() => ({ id: e ?? "" }), [e]);
|
|
108
|
+
return d({
|
|
91
109
|
document: n,
|
|
92
110
|
variables: t,
|
|
93
111
|
select: (e) => e?.getRetrievalProfile ?? null,
|
|
@@ -96,11 +114,11 @@ function v(e) {
|
|
|
96
114
|
errorMessage: "Failed to load retrieval profile"
|
|
97
115
|
});
|
|
98
116
|
}
|
|
99
|
-
function
|
|
100
|
-
let t =
|
|
117
|
+
function C() {
|
|
118
|
+
let t = c(), n = f((e) => ({ input: o({
|
|
101
119
|
...e,
|
|
102
120
|
workspaceId: t
|
|
103
|
-
},
|
|
121
|
+
}, h) }), [t]), [r, i] = l({
|
|
104
122
|
document: e,
|
|
105
123
|
variables: n,
|
|
106
124
|
select: (e) => e?.createRetrievalProfile,
|
|
@@ -112,12 +130,12 @@ function y() {
|
|
|
112
130
|
error: i.error
|
|
113
131
|
};
|
|
114
132
|
}
|
|
115
|
-
function
|
|
116
|
-
let [e, t] =
|
|
117
|
-
document:
|
|
133
|
+
function w() {
|
|
134
|
+
let [e, t] = l({
|
|
135
|
+
document: a,
|
|
118
136
|
variables: ({ profileId: e, input: t }) => ({
|
|
119
137
|
id: e,
|
|
120
|
-
input:
|
|
138
|
+
input: o(t, g)
|
|
121
139
|
}),
|
|
122
140
|
select: (e) => e?.updateRetrievalProfile,
|
|
123
141
|
errorMessage: "Failed to update retrieval profile"
|
|
@@ -128,8 +146,8 @@ function b() {
|
|
|
128
146
|
error: t.error
|
|
129
147
|
};
|
|
130
148
|
}
|
|
131
|
-
function
|
|
132
|
-
let [e, n] =
|
|
149
|
+
function T() {
|
|
150
|
+
let [e, n] = l({
|
|
133
151
|
document: t,
|
|
134
152
|
variables: (e) => ({ id: e }),
|
|
135
153
|
select: (e) => e?.deleteRetrievalProfile,
|
|
@@ -141,6 +159,6 @@ function x() {
|
|
|
141
159
|
error: n.error
|
|
142
160
|
};
|
|
143
161
|
}
|
|
144
|
-
export {
|
|
162
|
+
export { C as useCreateRetrievalProfile, T as useDeleteRetrievalProfile, S as useRetrievalProfile, y as useRetrievalProfiles, x as useRetrievalProfilesPage, w as useUpdateRetrievalProfile };
|
|
145
163
|
|
|
146
164
|
//# sourceMappingURL=useRetrievalProfiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRetrievalProfiles.js","names":["LIST_LIMIT","CREATE_PROFILE_FIELDS","fieldsOf","UPDATE_PROFILE_FIELDS","NO_PROFILES","selectProfiles","data","useRetrievalProfiles","workspaceId","useWorkspaceId","filter","variables","useMemo","search","status","strategyMode","bucketId","useWorkspaceQuery","ListRetrievalProfilesDocument","useRetrievalProfile","profileId","GetRetrievalProfileDocument","useCreateRetrievalProfile","useCallback","buildMutationInput","input","create","state","useWorkspaceMutation","CreateRetrievalProfileDocument","useUpdateRetrievalProfile","update","UpdateRetrievalProfileDocument","useDeleteRetrievalProfile","remove","DeleteRetrievalProfileDocument"],"sources":["../../../src/botlit/hooks/useRetrievalProfiles.ts"],"sourcesContent":["/**\n * Retrieval Profiles Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listRetrievalProfiles` / `getRetrievalProfile` operations\n * and the create/update/delete mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateRetrievalProfileDocument,\n DeleteRetrievalProfileDocument,\n GetRetrievalProfileDocument,\n ListRetrievalProfilesDocument,\n UpdateRetrievalProfileDocument,\n type CreateRetrievalProfileMutation,\n type DeleteRetrievalProfileMutation,\n type GetRetrievalProfileQuery,\n type ListRetrievalProfilesQuery,\n type UpdateRetrievalProfileMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateRetrievalProfileInput,\n UpdateRetrievalProfileInput,\n} from '../../generated/wspace-types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n\nexport interface RetrievalProfileRecord {\n id: string;\n name: string;\n status: string;\n visibility: string;\n strategyMode: string;\n topK: number;\n snippetMaxChars: number;\n minSources: number;\n citationsRequired: boolean;\n showSources: boolean;\n noAnswerIfBelowThreshold: boolean;\n multiHop: string;\n queryRewrite: string;\n reranker: string;\n description?: string | null;\n bucketId?: string | null;\n citationFormat?: string | null;\n hybridWeights?: Record<string, unknown> | null;\n minRelevanceScore?: number | null;\n multiHopDepth?: number | null;\n rerankerModelPolicyId?: string | null;\n testQueries?: Record<string, unknown> | null;\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface RetrievalProfileFilterVariables {\n search?: string;\n status?: string;\n strategyMode?: string;\n bucketId?: string;\n}\n\n/**\n * `CreateRetrievalProfileInput` minus the `workspaceId` the hook supplies.\n * The service's input is FLAT — there is no nested `strategy`/`grounding`/\n * `thresholds` object anywhere in the schema.\n */\nexport type CreateRetrievalProfileVariables = Omit<\n GraphQLInput<CreateRetrievalProfileInput>,\n 'workspaceId'\n>;\n\nexport interface UpdateRetrievalProfileVariables {\n profileId: string;\n input: GraphQLInput<UpdateRetrievalProfileInput>;\n}\n\nconst CREATE_PROFILE_FIELDS = fieldsOf<CreateRetrievalProfileInput>({\n bucketId: true,\n citationFormat: true,\n citationsRequired: true,\n description: true,\n hybridWeights: true,\n metadata: true,\n minRelevanceScore: true,\n minSources: true,\n multiHop: true,\n multiHopDepth: true,\n name: true,\n noAnswerIfBelowThreshold: true,\n queryRewrite: true,\n reranker: true,\n rerankerModelPolicyId: true,\n showSources: true,\n snippetMaxChars: true,\n status: true,\n strategyMode: true,\n tags: true,\n testQueries: true,\n topK: true,\n visibility: true,\n workspaceId: true,\n});\n\nconst UPDATE_PROFILE_FIELDS = fieldsOf<UpdateRetrievalProfileInput>({\n bucketId: true,\n citationFormat: true,\n citationsRequired: true,\n description: true,\n hybridWeights: true,\n metadata: true,\n minRelevanceScore: true,\n minSources: true,\n multiHop: true,\n multiHopDepth: true,\n name: true,\n noAnswerIfBelowThreshold: true,\n queryRewrite: true,\n reranker: true,\n rerankerModelPolicyId: true,\n showSources: true,\n snippetMaxChars: true,\n status: true,\n strategyMode: true,\n tags: true,\n testQueries: true,\n topK: true,\n visibility: true,\n});\n\nconst NO_PROFILES: RetrievalProfileRecord[] = [];\n\nfunction selectProfiles(data: ListRetrievalProfilesQuery | undefined): RetrievalProfileRecord[] {\n return data?.listRetrievalProfiles ?? NO_PROFILES;\n}\n\nexport const retrievalProfileKeys = {\n all: ['retrieval-profiles'] as const,\n lists: () => [...retrievalProfileKeys.all, 'list'] as const,\n list: (filter?: RetrievalProfileFilterVariables) =>\n [...retrievalProfileKeys.lists(), filter] as const,\n details: () => [...retrievalProfileKeys.all, 'detail'] as const,\n detail: (id: string) => [...retrievalProfileKeys.details(), id] as const,\n};\n\nexport function useRetrievalProfiles(\n filter?: RetrievalProfileFilterVariables\n): QueryResult<RetrievalProfileRecord[]> {\n const workspaceId = useWorkspaceId();\n const { search, status, strategyMode, bucketId } = filter ?? {};\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n search: search || undefined,\n status,\n strategyMode,\n bucketId,\n },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search, status, strategyMode, bucketId]\n );\n\n return useWorkspaceQuery<ListRetrievalProfilesQuery, RetrievalProfileRecord[]>({\n document: ListRetrievalProfilesDocument,\n variables,\n select: selectProfiles,\n fallback: NO_PROFILES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load retrieval profiles',\n });\n}\n\nexport function useRetrievalProfile(\n profileId: string | undefined\n): QueryResult<RetrievalProfileRecord | null> {\n const variables = useMemo(() => ({ id: profileId ?? '' }), [profileId]);\n\n return useWorkspaceQuery<GetRetrievalProfileQuery, RetrievalProfileRecord | null>({\n document: GetRetrievalProfileDocument,\n variables,\n select: (data) => data?.getRetrievalProfile ?? null,\n fallback: null,\n enabled: Boolean(profileId),\n errorMessage: 'Failed to load retrieval profile',\n });\n}\n\nexport function useCreateRetrievalProfile() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateRetrievalProfileVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_PROFILE_FIELDS),\n }),\n [workspaceId]\n );\n\n const [create, state] = useWorkspaceMutation<\n CreateRetrievalProfileMutation,\n CreateRetrievalProfileVariables,\n RetrievalProfileRecord\n >({\n document: CreateRetrievalProfileDocument,\n variables,\n select: (data) => data?.createRetrievalProfile,\n errorMessage: 'Failed to create retrieval profile',\n });\n\n return { create, loading: state.loading, error: state.error };\n}\n\nexport function useUpdateRetrievalProfile() {\n const [update, state] = useWorkspaceMutation<\n UpdateRetrievalProfileMutation,\n UpdateRetrievalProfileVariables,\n RetrievalProfileRecord\n >({\n document: UpdateRetrievalProfileDocument,\n variables: ({ profileId, input }) => ({\n id: profileId,\n input: buildMutationInput(input, UPDATE_PROFILE_FIELDS),\n }),\n select: (data) => data?.updateRetrievalProfile,\n errorMessage: 'Failed to update retrieval profile',\n });\n\n return { update, loading: state.loading, error: state.error };\n}\n\nexport function useDeleteRetrievalProfile() {\n const [remove, state] = useWorkspaceMutation<DeleteRetrievalProfileMutation, string, boolean>({\n document: DeleteRetrievalProfileDocument,\n variables: (profileId) => ({ id: profileId }),\n select: (data) => data?.deleteRetrievalProfile,\n errorMessage: 'Failed to delete retrieval profile',\n });\n\n return { remove, loading: state.loading, error: state.error };\n}\n"],"mappings":";;;;;AAiCA,IAAMA,IAAa,KAyDbC,IAAwBC,EAAsC;CAClE,UAAU;CACV,gBAAgB;CAChB,mBAAmB;CACnB,aAAa;CACb,eAAe;CACf,UAAU;CACV,mBAAmB;CACnB,YAAY;CACZ,UAAU;CACV,eAAe;CACf,MAAM;CACN,0BAA0B;CAC1B,cAAc;CACd,UAAU;CACV,uBAAuB;CACvB,aAAa;CACb,iBAAiB;CACjB,QAAQ;CACR,cAAc;CACd,MAAM;CACN,aAAa;CACb,MAAM;CACN,YAAY;CACZ,aAAa;AACf,CAAC,GAEKC,IAAwBD,EAAsC;CAClE,UAAU;CACV,gBAAgB;CAChB,mBAAmB;CACnB,aAAa;CACb,eAAe;CACf,UAAU;CACV,mBAAmB;CACnB,YAAY;CACZ,UAAU;CACV,eAAe;CACf,MAAM;CACN,0BAA0B;CAC1B,cAAc;CACd,UAAU;CACV,uBAAuB;CACvB,aAAa;CACb,iBAAiB;CACjB,QAAQ;CACR,cAAc;CACd,MAAM;CACN,aAAa;CACb,MAAM;CACN,YAAY;AACd,CAAC,GAEKE,IAAwC,CAAC;AAE/C,SAASC,EAAe,GAAwE;CAC9F,OAAOC,GAAM,yBAAyBF;AACxC;AAWA,SAAgBG,EACd,GACuC;CACvC,IAAMC,IAAcC,EAAe,GAC7B,EAAE,WAAQ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C,EAAsE;EAC5F,UAAUO;EACV,YAAY,OAAe,EAAE,IAAIf,EAAU;EAC3C,SAAS,MAASd,GAAM;EACxB,cAAc;CAChB,CAAC;CAED,OAAO;EAAE;EAAQ,SAASqB,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC9D"}
|
|
1
|
+
{"version":3,"file":"useRetrievalProfiles.js","names":["LIST_LIMIT","CREATE_PROFILE_FIELDS","fieldsOf","UPDATE_PROFILE_FIELDS","NO_PROFILES","selectProfiles","data","useRetrievalProfiles","workspaceId","useWorkspaceId","filter","variables","useMemo","search","status","strategyMode","bucketId","useWorkspaceQuery","ListRetrievalProfilesDocument","NO_RETRIEVALPROFILE_LIST_ITEMS","useRetrievalProfilesPage","useWorkspacePaginatedQuery","ListBotmanorRetrievalProfilesPageDocument","rows","useRetrievalProfile","profileId","GetRetrievalProfileDocument","useCreateRetrievalProfile","useCallback","buildMutationInput","input","create","state","useWorkspaceMutation","CreateRetrievalProfileDocument","useUpdateRetrievalProfile","update","UpdateRetrievalProfileDocument","useDeleteRetrievalProfile","remove","DeleteRetrievalProfileDocument"],"sources":["../../../src/botlit/hooks/useRetrievalProfiles.ts"],"sourcesContent":["/**\n * Retrieval Profiles Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listRetrievalProfiles` / `getRetrievalProfile` operations\n * and the create/update/delete mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateRetrievalProfileDocument,\n DeleteRetrievalProfileDocument,\n GetRetrievalProfileDocument,\n ListRetrievalProfilesDocument,\n ListBotmanorRetrievalProfilesPageDocument,\n UpdateRetrievalProfileDocument,\n type ListBotmanorRetrievalProfilesPageQuery,\n type ListBotmanorRetrievalProfilesPageQueryVariables,\n type CreateRetrievalProfileMutation,\n type DeleteRetrievalProfileMutation,\n type GetRetrievalProfileQuery,\n type ListRetrievalProfilesQuery,\n type UpdateRetrievalProfileMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateRetrievalProfileInput,\n UpdateRetrievalProfileInput,\n} from '../../generated/wspace-types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspacePaginatedQuery,\n type PaginatedQueryResult,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n\nexport interface RetrievalProfileRecord {\n id: string;\n name: string;\n status: string;\n visibility: string;\n strategyMode: string;\n topK: number;\n snippetMaxChars: number;\n minSources: number;\n citationsRequired: boolean;\n showSources: boolean;\n noAnswerIfBelowThreshold: boolean;\n multiHop: string;\n queryRewrite: string;\n reranker: string;\n description?: string | null;\n bucketId?: string | null;\n citationFormat?: string | null;\n hybridWeights?: Record<string, unknown> | null;\n minRelevanceScore?: number | null;\n multiHopDepth?: number | null;\n rerankerModelPolicyId?: string | null;\n testQueries?: Record<string, unknown> | null;\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface RetrievalProfileFilterVariables {\n search?: string;\n status?: string;\n strategyMode?: string;\n bucketId?: string;\n}\n\n/**\n * `CreateRetrievalProfileInput` minus the `workspaceId` the hook supplies.\n * The service's input is FLAT — there is no nested `strategy`/`grounding`/\n * `thresholds` object anywhere in the schema.\n */\nexport type CreateRetrievalProfileVariables = Omit<\n GraphQLInput<CreateRetrievalProfileInput>,\n 'workspaceId'\n>;\n\nexport interface UpdateRetrievalProfileVariables {\n profileId: string;\n input: GraphQLInput<UpdateRetrievalProfileInput>;\n}\n\nconst CREATE_PROFILE_FIELDS = fieldsOf<CreateRetrievalProfileInput>({\n bucketId: true,\n citationFormat: true,\n citationsRequired: true,\n description: true,\n hybridWeights: true,\n metadata: true,\n minRelevanceScore: true,\n minSources: true,\n multiHop: true,\n multiHopDepth: true,\n name: true,\n noAnswerIfBelowThreshold: true,\n queryRewrite: true,\n reranker: true,\n rerankerModelPolicyId: true,\n showSources: true,\n snippetMaxChars: true,\n status: true,\n strategyMode: true,\n tags: true,\n testQueries: true,\n topK: true,\n visibility: true,\n workspaceId: true,\n});\n\nconst UPDATE_PROFILE_FIELDS = fieldsOf<UpdateRetrievalProfileInput>({\n bucketId: true,\n citationFormat: true,\n citationsRequired: true,\n description: true,\n hybridWeights: true,\n metadata: true,\n minRelevanceScore: true,\n minSources: true,\n multiHop: true,\n multiHopDepth: true,\n name: true,\n noAnswerIfBelowThreshold: true,\n queryRewrite: true,\n reranker: true,\n rerankerModelPolicyId: true,\n showSources: true,\n snippetMaxChars: true,\n status: true,\n strategyMode: true,\n tags: true,\n testQueries: true,\n topK: true,\n visibility: true,\n});\n\nconst NO_PROFILES: RetrievalProfileRecord[] = [];\n\nfunction selectProfiles(data: ListRetrievalProfilesQuery | undefined): RetrievalProfileRecord[] {\n return data?.listRetrievalProfiles ?? NO_PROFILES;\n}\n\nexport const retrievalProfileKeys = {\n all: ['retrieval-profiles'] as const,\n lists: () => [...retrievalProfileKeys.all, 'list'] as const,\n list: (filter?: RetrievalProfileFilterVariables) =>\n [...retrievalProfileKeys.lists(), filter] as const,\n details: () => [...retrievalProfileKeys.all, 'detail'] as const,\n detail: (id: string) => [...retrievalProfileKeys.details(), id] as const,\n};\n\nexport function useRetrievalProfiles(\n filter?: RetrievalProfileFilterVariables\n): QueryResult<RetrievalProfileRecord[]> {\n const workspaceId = useWorkspaceId();\n const { search, status, strategyMode, bucketId } = filter ?? {};\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n search: search || undefined,\n status,\n strategyMode,\n bucketId,\n },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search, status, strategyMode, bucketId]\n );\n\n return useWorkspaceQuery<ListRetrievalProfilesQuery, RetrievalProfileRecord[]>({\n document: ListRetrievalProfilesDocument,\n variables,\n select: selectProfiles,\n fallback: NO_PROFILES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load retrieval profiles',\n });\n}\n\ntype RetrievalProfileListItem =\n ListBotmanorRetrievalProfilesPageQuery['listBotmanorRetrievalProfilesPage']['items'][number];\nconst NO_RETRIEVALPROFILE_LIST_ITEMS: RetrievalProfileListItem[] = [];\n\nexport function useRetrievalProfilesPage(\n search: string\n): PaginatedQueryResult<RetrievalProfileListItem[]> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo<ListBotmanorRetrievalProfilesPageQueryVariables>(\n () => ({ filters: { workspaceId, search: search || undefined } }),\n [workspaceId, search]\n );\n\n return useWorkspacePaginatedQuery<\n ListBotmanorRetrievalProfilesPageQuery,\n RetrievalProfileListItem,\n RetrievalProfileListItem[]\n >({\n document: ListBotmanorRetrievalProfilesPageDocument,\n variables,\n pageSize: 50,\n extractRows: (data) => data?.listBotmanorRetrievalProfilesPage.items,\n extractNextOffset: (data) => data?.listBotmanorRetrievalProfilesPage.nextOffset ?? null,\n select: (rows) => rows,\n fallback: NO_RETRIEVALPROFILE_LIST_ITEMS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load retrieval profiles',\n });\n}\n\nexport function useRetrievalProfile(\n profileId: string | undefined\n): QueryResult<RetrievalProfileRecord | null> {\n const variables = useMemo(() => ({ id: profileId ?? '' }), [profileId]);\n\n return useWorkspaceQuery<GetRetrievalProfileQuery, RetrievalProfileRecord | null>({\n document: GetRetrievalProfileDocument,\n variables,\n select: (data) => data?.getRetrievalProfile ?? null,\n fallback: null,\n enabled: Boolean(profileId),\n errorMessage: 'Failed to load retrieval profile',\n });\n}\n\nexport function useCreateRetrievalProfile() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateRetrievalProfileVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_PROFILE_FIELDS),\n }),\n [workspaceId]\n );\n\n const [create, state] = useWorkspaceMutation<\n CreateRetrievalProfileMutation,\n CreateRetrievalProfileVariables,\n RetrievalProfileRecord\n >({\n document: CreateRetrievalProfileDocument,\n variables,\n select: (data) => data?.createRetrievalProfile,\n errorMessage: 'Failed to create retrieval profile',\n });\n\n return { create, loading: state.loading, error: state.error };\n}\n\nexport function useUpdateRetrievalProfile() {\n const [update, state] = useWorkspaceMutation<\n UpdateRetrievalProfileMutation,\n UpdateRetrievalProfileVariables,\n RetrievalProfileRecord\n >({\n document: UpdateRetrievalProfileDocument,\n variables: ({ profileId, input }) => ({\n id: profileId,\n input: buildMutationInput(input, UPDATE_PROFILE_FIELDS),\n }),\n select: (data) => data?.updateRetrievalProfile,\n errorMessage: 'Failed to update retrieval profile',\n });\n\n return { update, loading: state.loading, error: state.error };\n}\n\nexport function useDeleteRetrievalProfile() {\n const [remove, state] = useWorkspaceMutation<DeleteRetrievalProfileMutation, string, boolean>({\n document: DeleteRetrievalProfileDocument,\n variables: (profileId) => ({ id: profileId }),\n select: (data) => data?.deleteRetrievalProfile,\n errorMessage: 'Failed to delete retrieval profile',\n });\n\n return { remove, loading: state.loading, error: state.error };\n}\n"],"mappings":";;;;;AAsCA,IAAMA,IAAa,KAyDbC,IAAwBC,EAAsC;CAClE,UAAU;CACV,gBAAgB;CAChB,mBAAmB;CACnB,aAAa;CACb,eAAe;CACf,UAAU;CACV,mBAAmB;CACnB,YAAY;CACZ,UAAU;CACV,eAAe;CACf,MAAM;CACN,0BAA0B;CAC1B,cAAc;CACd,UAAU;CACV,uBAAuB;CACvB,aAAa;CACb,iBAAiB;CACjB,QAAQ;CACR,cAAc;CACd,MAAM;CACN,aAAa;CACb,MAAM;CACN,YAAY;CACZ,aAAa;AACf,CAAC,GAEKC,IAAwBD,EAAsC;CAClE,UAAU;CACV,gBAAgB;CAChB,mBAAmB;CACnB,aAAa;CACb,eAAe;CACf,UAAU;CACV,mBAAmB;CACnB,YAAY;CACZ,UAAU;CACV,eAAe;CACf,MAAM;CACN,0BAA0B;CAC1B,cAAc;CACd,UAAU;CACV,uBAAuB;CACvB,aAAa;CACb,iBAAiB;CACjB,QAAQ;CACR,cAAc;CACd,MAAM;CACN,a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