@burdenoff/microfe-botmanor 2026.1109.1 → 2026.1110.1
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/BotlitRoutes.js +34 -45
- package/dist/botlit/BotlitRoutes.js.map +1 -1
- package/dist/botlit/components/Badge.js +2 -2
- package/dist/botlit/components/Badge.js.map +1 -1
- package/dist/botlit/components/ChannelSelectorSheet.js +4 -4
- package/dist/botlit/components/ChannelSelectorSheet.js.map +1 -1
- package/dist/botlit/components/LoadMore.d.ts +9 -0
- package/dist/botlit/components/LoadMore.js +22 -0
- package/dist/botlit/components/LoadMore.js.map +1 -0
- package/dist/botlit/components/index.d.ts +1 -0
- package/dist/botlit/hooks/index.d.ts +1 -2
- package/dist/botlit/hooks/index.js +15 -16
- package/dist/botlit/hooks/internal/workspaceGateway.d.ts +47 -0
- package/dist/botlit/hooks/internal/workspaceGateway.js +59 -1
- package/dist/botlit/hooks/internal/workspaceGateway.js.map +1 -1
- package/dist/botlit/hooks/useAgents.d.ts +2 -6
- package/dist/botlit/hooks/useAgents.js +71 -95
- package/dist/botlit/hooks/useAgents.js.map +1 -1
- package/dist/botlit/hooks/useBots.d.ts +2 -6
- package/dist/botlit/hooks/useBots.js +51 -75
- package/dist/botlit/hooks/useBots.js.map +1 -1
- package/dist/botlit/hooks/useBuckets.d.ts +5 -0
- package/dist/botlit/hooks/useBuckets.js +72 -38
- package/dist/botlit/hooks/useBuckets.js.map +1 -1
- package/dist/botlit/hooks/useExecutions.d.ts +2 -2
- package/dist/botlit/hooks/useExecutions.js +30 -34
- package/dist/botlit/hooks/useExecutions.js.map +1 -1
- package/dist/botlit/hooks/useStore.d.ts +3 -3
- package/dist/botlit/hooks/useStore.js +41 -50
- package/dist/botlit/hooks/useStore.js.map +1 -1
- package/dist/botlit/index.d.ts +0 -1
- package/dist/botlit/index.js +5 -6
- package/dist/botlit/pages/A2AAgentDetailPage.js +1 -1
- package/dist/botlit/pages/A2AAgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/AgentDetailPage.js +1 -1
- package/dist/botlit/pages/AgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/AgentsListPage.js +157 -156
- package/dist/botlit/pages/AgentsListPage.js.map +1 -1
- package/dist/botlit/pages/BotChannelsTab.js +24 -24
- package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
- package/dist/botlit/pages/BotsListPage.js +147 -146
- package/dist/botlit/pages/BotsListPage.js.map +1 -1
- package/dist/botlit/pages/BucketDetailPage.d.ts +2 -0
- package/dist/botlit/pages/BucketDetailPage.js +251 -0
- package/dist/botlit/pages/BucketDetailPage.js.map +1 -0
- package/dist/botlit/pages/BucketsPage.js +3 -3
- package/dist/botlit/pages/BucketsPage.js.map +1 -1
- package/dist/botlit/pages/ChannelDetailPage.js +2 -2
- package/dist/botlit/pages/ChannelDetailPage.js.map +1 -1
- package/dist/botlit/pages/ExecutionsPage.js +141 -134
- package/dist/botlit/pages/ExecutionsPage.js.map +1 -1
- package/dist/botlit/pages/InstalledPackagesPage.js +43 -36
- package/dist/botlit/pages/InstalledPackagesPage.js.map +1 -1
- package/dist/botlit/pages/MCPServersPage.js +1 -1
- package/dist/botlit/pages/MCPServersPage.js.map +1 -1
- package/dist/botlit/pages/SettingsPage.js +2 -2
- package/dist/botlit/pages/SettingsPage.js.map +1 -1
- package/dist/botlit/pages/SkillDetailPage.js +1 -1
- package/dist/botlit/pages/SkillDetailPage.js.map +1 -1
- package/dist/botlit/pages/StorePackageDetailPage.js +1 -1
- package/dist/botlit/pages/StorePackageDetailPage.js.map +1 -1
- package/dist/botlit/pages/StorePage.js +150 -143
- package/dist/botlit/pages/StorePage.js.map +1 -1
- package/dist/botlit/pages/index.d.ts +1 -2
- package/dist/generated/wspace-operations.js +67 -67
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/index.js +5 -6
- package/package.json +1 -1
- package/dist/botlit/hooks/useConversations.d.ts +0 -42
- package/dist/botlit/hooks/useConversations.js +0 -63
- package/dist/botlit/hooks/useConversations.js.map +0 -1
- package/dist/botlit/pages/ConversationDetailPage.d.ts +0 -2
- package/dist/botlit/pages/ConversationsPage.d.ts +0 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CreateBucketDocument as e, DeleteBucketDocument as t,
|
|
2
|
-
import { buildMutationInput as
|
|
3
|
-
import { useWorkspaceId as
|
|
4
|
-
import { useCallback as
|
|
1
|
+
import { CreateBucketDocument as e, DeleteBucketDocument as t, GetBucketDocument as n, ListBucketsDocument as r, UpdateBucketDocument as i } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { buildMutationInput as a, fieldsOf as o } from "./internal/mutationInput.js";
|
|
3
|
+
import { useWorkspaceId as s, useWorkspaceMutation as c, useWorkspaceQuery as l } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useCallback as u, useMemo as d } from "react";
|
|
5
5
|
// src/botlit/hooks/useBuckets.ts
|
|
6
|
-
var
|
|
6
|
+
var f = 100, p = o({
|
|
7
7
|
color: !0,
|
|
8
8
|
context: !0,
|
|
9
9
|
description: !0,
|
|
@@ -13,7 +13,7 @@ var d = 100, f = a({
|
|
|
13
13
|
parentBucketId: !0,
|
|
14
14
|
slug: !0,
|
|
15
15
|
workspaceId: !0
|
|
16
|
-
}),
|
|
16
|
+
}), m = o({
|
|
17
17
|
color: !0,
|
|
18
18
|
context: !0,
|
|
19
19
|
description: !0,
|
|
@@ -22,11 +22,14 @@ var d = 100, f = a({
|
|
|
22
22
|
name: !0,
|
|
23
23
|
parentBucketId: !0,
|
|
24
24
|
slug: !0
|
|
25
|
-
}),
|
|
26
|
-
function g(e) {
|
|
27
|
-
return e?.listBuckets ?? m;
|
|
28
|
-
}
|
|
25
|
+
}), h = [], g = [];
|
|
29
26
|
function _(e) {
|
|
27
|
+
return e?.listBuckets ?? h;
|
|
28
|
+
}
|
|
29
|
+
function v(e) {
|
|
30
|
+
return e?.getBucket ?? null;
|
|
31
|
+
}
|
|
32
|
+
function y(e) {
|
|
30
33
|
let t = /* @__PURE__ */ new Map();
|
|
31
34
|
for (let n of e) t.set(n.id, {
|
|
32
35
|
...n,
|
|
@@ -45,74 +48,105 @@ function _(e) {
|
|
|
45
48
|
};
|
|
46
49
|
return i(n), n;
|
|
47
50
|
}
|
|
48
|
-
function
|
|
49
|
-
let t =
|
|
51
|
+
function b(e) {
|
|
52
|
+
let t = s(), n = e?.search, i = d(() => ({
|
|
50
53
|
filters: {
|
|
51
54
|
workspaceId: t,
|
|
52
|
-
search:
|
|
55
|
+
search: n || void 0
|
|
53
56
|
},
|
|
54
57
|
pagination: {
|
|
55
|
-
limit:
|
|
58
|
+
limit: f,
|
|
56
59
|
offset: 0
|
|
57
60
|
}
|
|
58
|
-
}), [t,
|
|
59
|
-
return
|
|
60
|
-
document:
|
|
61
|
+
}), [t, n]);
|
|
62
|
+
return l({
|
|
63
|
+
document: r,
|
|
61
64
|
variables: i,
|
|
62
|
-
select:
|
|
63
|
-
fallback:
|
|
65
|
+
select: _,
|
|
66
|
+
fallback: h,
|
|
64
67
|
enabled: !!t,
|
|
65
68
|
errorMessage: "Failed to load buckets"
|
|
66
69
|
});
|
|
67
70
|
}
|
|
68
|
-
function
|
|
69
|
-
let e =
|
|
71
|
+
function x() {
|
|
72
|
+
let e = s(), t = d(() => ({
|
|
70
73
|
filters: { workspaceId: e },
|
|
71
74
|
pagination: {
|
|
72
|
-
limit:
|
|
75
|
+
limit: f,
|
|
73
76
|
offset: 0
|
|
74
77
|
}
|
|
75
|
-
}), [e]),
|
|
76
|
-
return
|
|
77
|
-
document:
|
|
78
|
+
}), [e]), n = u((e) => y(e?.listBuckets ?? h), []);
|
|
79
|
+
return l({
|
|
80
|
+
document: r,
|
|
78
81
|
variables: t,
|
|
79
|
-
select:
|
|
80
|
-
fallback:
|
|
82
|
+
select: n,
|
|
83
|
+
fallback: g,
|
|
81
84
|
enabled: !!e,
|
|
82
85
|
errorMessage: "Failed to load the bucket tree"
|
|
83
86
|
});
|
|
84
87
|
}
|
|
85
|
-
function
|
|
86
|
-
let t =
|
|
88
|
+
function S(e) {
|
|
89
|
+
let t = s(), n = d(() => ({
|
|
90
|
+
filters: {
|
|
91
|
+
workspaceId: t,
|
|
92
|
+
parentBucketId: e ?? ""
|
|
93
|
+
},
|
|
94
|
+
pagination: {
|
|
95
|
+
limit: f,
|
|
96
|
+
offset: 0
|
|
97
|
+
}
|
|
98
|
+
}), [t, e]);
|
|
99
|
+
return l({
|
|
100
|
+
document: r,
|
|
101
|
+
variables: n,
|
|
102
|
+
select: _,
|
|
103
|
+
fallback: h,
|
|
104
|
+
enabled: !!(t && e),
|
|
105
|
+
errorMessage: "Failed to load sub-buckets"
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function C(e) {
|
|
109
|
+
let t = d(() => ({ id: e ?? "" }), [e]);
|
|
110
|
+
return l({
|
|
111
|
+
document: n,
|
|
112
|
+
variables: t,
|
|
113
|
+
select: v,
|
|
114
|
+
fallback: null,
|
|
115
|
+
enabled: !!e,
|
|
116
|
+
errorMessage: "Failed to load bucket"
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function w() {
|
|
120
|
+
let t = s(), n = u((e) => ({ input: a({
|
|
87
121
|
...e,
|
|
88
122
|
workspaceId: t
|
|
89
|
-
},
|
|
90
|
-
return
|
|
123
|
+
}, p) }), [t]);
|
|
124
|
+
return c({
|
|
91
125
|
document: e,
|
|
92
126
|
variables: n,
|
|
93
127
|
select: (e) => e?.createBucket,
|
|
94
128
|
errorMessage: "Failed to create bucket"
|
|
95
129
|
});
|
|
96
130
|
}
|
|
97
|
-
function
|
|
98
|
-
return
|
|
99
|
-
document:
|
|
131
|
+
function T() {
|
|
132
|
+
return c({
|
|
133
|
+
document: i,
|
|
100
134
|
variables: ({ bucketId: e, input: t }) => ({
|
|
101
135
|
id: e,
|
|
102
|
-
input:
|
|
136
|
+
input: a(t, m)
|
|
103
137
|
}),
|
|
104
138
|
select: (e) => e?.updateBucket,
|
|
105
139
|
errorMessage: "Failed to update bucket"
|
|
106
140
|
});
|
|
107
141
|
}
|
|
108
|
-
function
|
|
109
|
-
return
|
|
142
|
+
function E() {
|
|
143
|
+
return c({
|
|
110
144
|
document: t,
|
|
111
145
|
variables: (e) => ({ id: e }),
|
|
112
146
|
select: (e) => e?.deleteBucket,
|
|
113
147
|
errorMessage: "Failed to delete bucket"
|
|
114
148
|
});
|
|
115
149
|
}
|
|
116
|
-
export {
|
|
150
|
+
export { y as buildBucketTree, C as useBucket, x as useBucketTree, b as useBuckets, S as useChildBuckets, w as useCreateBucket, E as useDeleteBucket, T as useUpdateBucket };
|
|
117
151
|
|
|
118
152
|
//# sourceMappingURL=useBuckets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBuckets.js","names":["LIST_LIMIT","CREATE_BUCKET_FIELDS","fieldsOf","UPDATE_BUCKET_FIELDS","NO_BUCKETS","NO_BUCKET_TREE","selectBuckets","data","buildBucketTree","nodes","bucket","buckets","roots","node","parent","byName","a","b","sortRecursively","child","list","useBuckets","workspaceId","useWorkspaceId","search","filter","variables","useMemo","useWorkspaceQuery","ListBucketsDocument","useBucketTree","select","useCallback","useCreateBucket","buildMutationInput","input","useWorkspaceMutation","CreateBucketDocument","useUpdateBucket","UpdateBucketDocument","bucketId","useDeleteBucket","DeleteBucketDocument"],"sources":["../../../src/botlit/hooks/useBuckets.ts"],"sourcesContent":["/**\n * Buckets Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listBuckets` / `getBucket` / `createBucket` / `updateBucket`\n * / `deleteBucket` operations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateBucketDocument,\n DeleteBucketDocument,\n GetBucketDocument,\n ListBucketsDocument,\n UpdateBucketDocument,\n type CreateBucketMutation,\n type DeleteBucketMutation,\n type GetBucketQuery,\n type ListBucketsQuery,\n type UpdateBucketMutation,\n} from '../../generated/wspace-operations';\nimport type { CreateBucketInput, UpdateBucketInput } from '../../generated/wspace-types';\nimport type { BaseFilter } from '../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 BucketRecord {\n id: string;\n name: string;\n slug: string;\n path: string;\n description?: string | null;\n color?: string | null;\n icon?: string | null;\n parentBucketId?: string | null;\n metadata?: Record<string, unknown> | null;\n deletedAt?: string | null;\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\n/** A bucket plus its resolved children — the shape the tree view renders. */\nexport interface BucketTreeNode extends BucketRecord {\n children: BucketTreeNode[];\n}\n\n/**\n * `CreateBucketInput` minus the `workspaceId`/`context` the hook supplies.\n */\nexport type CreateBucketVariables = Omit<\n GraphQLInput<CreateBucketInput>,\n 'workspaceId' | 'context'\n>;\n\nexport interface UpdateBucketVariables {\n bucketId: string;\n input: GraphQLInput<UpdateBucketInput>;\n}\n\nconst CREATE_BUCKET_FIELDS = fieldsOf<CreateBucketInput>({\n color: true,\n context: true,\n description: true,\n icon: true,\n metadata: true,\n name: true,\n parentBucketId: true,\n slug: true,\n workspaceId: true,\n});\n\nconst UPDATE_BUCKET_FIELDS = fieldsOf<UpdateBucketInput>({\n color: true,\n context: true,\n description: true,\n icon: true,\n metadata: true,\n name: true,\n parentBucketId: true,\n slug: true,\n});\n\nconst NO_BUCKETS: BucketRecord[] = [];\nconst NO_BUCKET_TREE: BucketTreeNode[] = [];\n\nfunction selectBuckets(data: ListBucketsQuery | undefined): BucketRecord[] {\n return data?.listBuckets ?? NO_BUCKETS;\n}\n\nfunction selectBucket(data: GetBucketQuery | undefined): BucketRecord | null {\n return data?.getBucket ?? null;\n}\n\n/**\n * Builds the parent → children tree. Buckets whose parent is not in the result\n * set (filtered out, or not readable) are surfaced at the root rather than\n * silently dropped.\n */\nexport function buildBucketTree(buckets: readonly BucketRecord[]): BucketTreeNode[] {\n const nodes = new Map<string, BucketTreeNode>();\n for (const bucket of buckets) {\n nodes.set(bucket.id, { ...bucket, children: [] });\n }\n\n const roots: BucketTreeNode[] = [];\n for (const bucket of buckets) {\n const node = nodes.get(bucket.id);\n if (!node) continue;\n const parent = bucket.parentBucketId ? nodes.get(bucket.parentBucketId) : undefined;\n if (parent && parent !== node) {\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n }\n\n const byName = (a: BucketTreeNode, b: BucketTreeNode) => a.name.localeCompare(b.name);\n const sortRecursively = (list: BucketTreeNode[]) => {\n list.sort(byName);\n for (const child of list) sortRecursively(child.children);\n };\n sortRecursively(roots);\n\n return roots;\n}\n\nexport const bucketKeys = {\n all: ['buckets'] as const,\n lists: () => [...bucketKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...bucketKeys.lists(), filter] as const,\n tree: () => [...bucketKeys.all, 'tree'] as const,\n details: () => [...bucketKeys.all, 'detail'] as const,\n detail: (id: string) => [...bucketKeys.details(), id] as const,\n};\n\nexport function useBuckets(filter?: BaseFilter): QueryResult<BucketRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search;\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId, search: search || undefined },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search]\n );\n\n return useWorkspaceQuery<ListBucketsQuery, BucketRecord[]>({\n document: ListBucketsDocument,\n variables,\n select: selectBuckets,\n fallback: NO_BUCKETS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load buckets',\n });\n}\n\n/**\n * The bucket hierarchy. Derived from `listBuckets` — the service exposes the\n * parent link on every bucket, so no separate tree operation is needed.\n */\nexport function useBucketTree(): QueryResult<BucketTreeNode[]> {\n const workspaceId = useWorkspaceId();\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId]\n );\n\n const select = useCallback(\n (data: ListBucketsQuery | undefined) => buildBucketTree(data?.listBuckets ?? NO_BUCKETS),\n []\n );\n\n return useWorkspaceQuery<ListBucketsQuery, BucketTreeNode[]>({\n document: ListBucketsDocument,\n variables,\n select,\n fallback: NO_BUCKET_TREE,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load the bucket tree',\n });\n}\n\nexport function useBucket(bucketId: string | undefined): QueryResult<BucketRecord | null> {\n const variables = useMemo(() => ({ id: bucketId ?? '' }), [bucketId]);\n\n return useWorkspaceQuery<GetBucketQuery, BucketRecord | null>({\n document: GetBucketDocument,\n variables,\n select: selectBucket,\n fallback: null,\n enabled: Boolean(bucketId),\n errorMessage: 'Failed to load bucket',\n });\n}\n\nexport function useCreateBucket() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateBucketVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_BUCKET_FIELDS),\n }),\n [workspaceId]\n );\n\n return useWorkspaceMutation<CreateBucketMutation, CreateBucketVariables, BucketRecord>({\n document: CreateBucketDocument,\n variables,\n select: (data) => data?.createBucket,\n errorMessage: 'Failed to create bucket',\n });\n}\n\nexport function useUpdateBucket() {\n return useWorkspaceMutation<UpdateBucketMutation, UpdateBucketVariables, BucketRecord>({\n document: UpdateBucketDocument,\n variables: ({ bucketId, input }) => ({\n id: bucketId,\n input: buildMutationInput(input, UPDATE_BUCKET_FIELDS),\n }),\n select: (data) => data?.updateBucket,\n errorMessage: 'Failed to update bucket',\n });\n}\n\nexport function useDeleteBucket() {\n return useWorkspaceMutation<DeleteBucketMutation, string, boolean>({\n document: DeleteBucketDocument,\n variables: (bucketId) => ({ id: bucketId }),\n select: (data) => data?.deleteBucket,\n errorMessage: 'Failed to delete bucket',\n });\n}\n"],"mappings":";;;;;AA+BA,IAAMA,IAAa,KAsCbC,IAAuBC,EAA4B;CACvD,OAAO;CACP,SAAS;CACT,aAAa;CACb,MAAM;CACN,UAAU;CACV,MAAM;CACN,gBAAgB;CAChB,MAAM;C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QkB;EACjB,cAAc;CAChB,CAAC;AACH;AAMA,SAAgBQ,IAA+C;CAC7D,IAAMR,IAAcC,EAAe,GAE7BG,IAAYC,SACT;EACL,SAAS,EAAE,eAAY;EACvB,YAAY;GAAE,OAAO3B;GAAY,QAAQ;EAAE;CAC7C,IACA,CAACsB,CAAW,CACd,GAEMS,IAASC,GACZ,MAAuCxB,EAAgBD,GAAM,eAAeH,CAAU,GACvF,CAAC,CACH;CAEA,OAAOwB,EAAsD;EAC3D,UAAUC;EACV;EACA;EACA,UAAUxB;EACV,SAAS,EAAQiB;EACjB,cAAc;CAChB,CAAC;AACH;AAeA,SAAgBW,IAAkB;CAChC,IAAMX,IAAcC,EAAe,GAE7BG,IAAYM,GACf,OAAkC,EACjC,OAAOE,EAAmB;EAAE,GAAGC;EAAO;CAAY,GAAGlC,CAAoB,EAC3E,IACA,CAACqB,CAAW,CACd;CAEA,OAAOc,EAAgF;EACrF,UAAUC;EACV;EACA,SAAS,MAAS9B,GAAM;EACxB,cAAc;CAChB,CAAC;AACH;AAEA,SAAgB+B,IAAkB;CAChC,OAAOF,EAAgF;EACrF,UAAUG;EACV,YAAY,EAAE,aAAU,gBAAa;GACnC,IAAIC;GACJ,OAAON,EAAmBC,GAAOhC,CAAoB;EACvD;EACA,SAAS,MAASI,GAAM;EACxB,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBkC,IAAkB;CAChC,OAAOL,EAA4D;EACjE,UAAUM;EACV,YAAY,OAAc,EAAE,IAAIF,EAAS;EACzC,SAAS,MAASjC,GAAM;EACxB,cAAc;CAChB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"useBuckets.js","names":["LIST_LIMIT","CREATE_BUCKET_FIELDS","fieldsOf","UPDATE_BUCKET_FIELDS","NO_BUCKETS","NO_BUCKET_TREE","selectBuckets","data","selectBucket","buildBucketTree","nodes","bucket","buckets","roots","node","parent","byName","a","b","sortRecursively","child","list","useBuckets","workspaceId","useWorkspaceId","search","filter","variables","useMemo","useWorkspaceQuery","ListBucketsDocument","useBucketTree","select","useCallback","useChildBuckets","parentBucketId","useBucket","bucketId","GetBucketDocument","useCreateBucket","buildMutationInput","input","useWorkspaceMutation","CreateBucketDocument","useUpdateBucket","UpdateBucketDocument","useDeleteBucket","DeleteBucketDocument"],"sources":["../../../src/botlit/hooks/useBuckets.ts"],"sourcesContent":["/**\n * Buckets Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listBuckets` / `getBucket` / `createBucket` / `updateBucket`\n * / `deleteBucket` operations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateBucketDocument,\n DeleteBucketDocument,\n GetBucketDocument,\n ListBucketsDocument,\n UpdateBucketDocument,\n type CreateBucketMutation,\n type DeleteBucketMutation,\n type GetBucketQuery,\n type ListBucketsQuery,\n type UpdateBucketMutation,\n} from '../../generated/wspace-operations';\nimport type { CreateBucketInput, UpdateBucketInput } from '../../generated/wspace-types';\nimport type { BaseFilter } from '../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 BucketRecord {\n id: string;\n name: string;\n slug: string;\n path: string;\n description?: string | null;\n color?: string | null;\n icon?: string | null;\n parentBucketId?: string | null;\n metadata?: Record<string, unknown> | null;\n deletedAt?: string | null;\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\n/** A bucket plus its resolved children — the shape the tree view renders. */\nexport interface BucketTreeNode extends BucketRecord {\n children: BucketTreeNode[];\n}\n\n/**\n * `CreateBucketInput` minus the `workspaceId`/`context` the hook supplies.\n */\nexport type CreateBucketVariables = Omit<\n GraphQLInput<CreateBucketInput>,\n 'workspaceId' | 'context'\n>;\n\nexport interface UpdateBucketVariables {\n bucketId: string;\n input: GraphQLInput<UpdateBucketInput>;\n}\n\nconst CREATE_BUCKET_FIELDS = fieldsOf<CreateBucketInput>({\n color: true,\n context: true,\n description: true,\n icon: true,\n metadata: true,\n name: true,\n parentBucketId: true,\n slug: true,\n workspaceId: true,\n});\n\nconst UPDATE_BUCKET_FIELDS = fieldsOf<UpdateBucketInput>({\n color: true,\n context: true,\n description: true,\n icon: true,\n metadata: true,\n name: true,\n parentBucketId: true,\n slug: true,\n});\n\nconst NO_BUCKETS: BucketRecord[] = [];\nconst NO_BUCKET_TREE: BucketTreeNode[] = [];\n\nfunction selectBuckets(data: ListBucketsQuery | undefined): BucketRecord[] {\n return data?.listBuckets ?? NO_BUCKETS;\n}\n\nfunction selectBucket(data: GetBucketQuery | undefined): BucketRecord | null {\n return data?.getBucket ?? null;\n}\n\n/**\n * Builds the parent → children tree. Buckets whose parent is not in the result\n * set (filtered out, or not readable) are surfaced at the root rather than\n * silently dropped.\n */\nexport function buildBucketTree(buckets: readonly BucketRecord[]): BucketTreeNode[] {\n const nodes = new Map<string, BucketTreeNode>();\n for (const bucket of buckets) {\n nodes.set(bucket.id, { ...bucket, children: [] });\n }\n\n const roots: BucketTreeNode[] = [];\n for (const bucket of buckets) {\n const node = nodes.get(bucket.id);\n if (!node) continue;\n const parent = bucket.parentBucketId ? nodes.get(bucket.parentBucketId) : undefined;\n if (parent && parent !== node) {\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n }\n\n const byName = (a: BucketTreeNode, b: BucketTreeNode) => a.name.localeCompare(b.name);\n const sortRecursively = (list: BucketTreeNode[]) => {\n list.sort(byName);\n for (const child of list) sortRecursively(child.children);\n };\n sortRecursively(roots);\n\n return roots;\n}\n\nexport const bucketKeys = {\n all: ['buckets'] as const,\n lists: () => [...bucketKeys.all, 'list'] as const,\n list: (filter?: BaseFilter) => [...bucketKeys.lists(), filter] as const,\n tree: () => [...bucketKeys.all, 'tree'] as const,\n details: () => [...bucketKeys.all, 'detail'] as const,\n detail: (id: string) => [...bucketKeys.details(), id] as const,\n};\n\nexport function useBuckets(filter?: BaseFilter): QueryResult<BucketRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search;\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId, search: search || undefined },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, search]\n );\n\n return useWorkspaceQuery<ListBucketsQuery, BucketRecord[]>({\n document: ListBucketsDocument,\n variables,\n select: selectBuckets,\n fallback: NO_BUCKETS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load buckets',\n });\n}\n\n/**\n * The bucket hierarchy. Derived from `listBuckets` — the service exposes the\n * parent link on every bucket, so no separate tree operation is needed.\n */\nexport function useBucketTree(): QueryResult<BucketTreeNode[]> {\n const workspaceId = useWorkspaceId();\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId]\n );\n\n const select = useCallback(\n (data: ListBucketsQuery | undefined) => buildBucketTree(data?.listBuckets ?? NO_BUCKETS),\n []\n );\n\n return useWorkspaceQuery<ListBucketsQuery, BucketTreeNode[]>({\n document: ListBucketsDocument,\n variables,\n select,\n fallback: NO_BUCKET_TREE,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load the bucket tree',\n });\n}\n\n/**\n * Direct children of one bucket, resolved via the `parentBucketId` filter on\n * `listBuckets`. Powers the sub-bucket section of the bucket detail page.\n */\nexport function useChildBuckets(parentBucketId: string | undefined): QueryResult<BucketRecord[]> {\n const workspaceId = useWorkspaceId();\n\n const variables = useMemo(\n () => ({\n filters: { workspaceId, parentBucketId: parentBucketId ?? '' },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, parentBucketId]\n );\n\n return useWorkspaceQuery<ListBucketsQuery, BucketRecord[]>({\n document: ListBucketsDocument,\n variables,\n select: selectBuckets,\n fallback: NO_BUCKETS,\n enabled: Boolean(workspaceId && parentBucketId),\n errorMessage: 'Failed to load sub-buckets',\n });\n}\n\nexport function useBucket(bucketId: string | undefined): QueryResult<BucketRecord | null> {\n const variables = useMemo(() => ({ id: bucketId ?? '' }), [bucketId]);\n\n return useWorkspaceQuery<GetBucketQuery, BucketRecord | null>({\n document: GetBucketDocument,\n variables,\n select: selectBucket,\n fallback: null,\n enabled: Boolean(bucketId),\n errorMessage: 'Failed to load bucket',\n });\n}\n\nexport function useCreateBucket() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateBucketVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_BUCKET_FIELDS),\n }),\n [workspaceId]\n );\n\n return useWorkspaceMutation<CreateBucketMutation, CreateBucketVariables, BucketRecord>({\n document: CreateBucketDocument,\n variables,\n select: (data) => data?.createBucket,\n errorMessage: 'Failed to create bucket',\n });\n}\n\nexport function useUpdateBucket() {\n return useWorkspaceMutation<UpdateBucketMutation, UpdateBucketVariables, BucketRecord>({\n document: UpdateBucketDocument,\n variables: ({ bucketId, input }) => ({\n id: bucketId,\n input: buildMutationInput(input, UPDATE_BUCKET_FIELDS),\n }),\n select: (data) => data?.updateBucket,\n errorMessage: 'Failed to update bucket',\n });\n}\n\nexport function useDeleteBucket() {\n return useWorkspaceMutation<DeleteBucketMutation, string, boolean>({\n document: DeleteBucketDocument,\n variables: (bucketId) => ({ id: bucketId }),\n select: (data) => data?.deleteBucket,\n errorMessage: 'Failed to delete bucket',\n });\n}\n"],"mappings":";;;;;AA+BA,IAAMA,IAAa,KAsCbC,IAAuBC,EAA4B;CACvD,OAAO;CACP,SAAS;CACT,aAAa;CACb,MAAM;CACN,UAAU;CACV,MAAM;CACN,gBAAgB;CAChB,MAAM;CACN,aAAa;AACf,CAAC,GAEKC,IAAuBD,EAA4B;CACvD,OAAO;CACP,SAAS;CACT,aAAa;CACb,MAAM;CACN,UAAU;CACV,MAAM;CACN,gBAAgB;CAChB,MAAM;AACR,CAAC,GAEKE,IAA6B,CAAC,GAC9BC,IAAmC,CAAC;AAE1C,SAASC,EAAc,GAAoD;CACzE,OAAOC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uC,IAAkB;CAChC,OAAOJ,EAA4D;EACjE,UAAUK;EACV,YAAY,OAAc,EAAE,IAAIV,EAAS;EACzC,SAAS,MAAS9B,GAAM;EACxB,cAAc;CAChB,CAAC;AACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CreateExecutionInput, ExecutionStatus } from '../../generated/wspace-types';
|
|
2
2
|
import { GraphQLInput } from './internal/mutationInput';
|
|
3
|
-
import { QueryResult } from './internal/workspaceGateway';
|
|
3
|
+
import { PaginatedQueryResult, QueryResult } from './internal/workspaceGateway';
|
|
4
4
|
export interface ExecutionRecord {
|
|
5
5
|
id: string;
|
|
6
6
|
status: string;
|
|
@@ -61,7 +61,7 @@ export declare const executionKeys: {
|
|
|
61
61
|
detail: (id: string) => readonly ["executions", "detail", string];
|
|
62
62
|
metrics: () => readonly ["executions", "metrics"];
|
|
63
63
|
};
|
|
64
|
-
export declare function useExecutions(filter?: ExecutionsFilter):
|
|
64
|
+
export declare function useExecutions(filter?: ExecutionsFilter): PaginatedQueryResult<ExecutionRecord[]>;
|
|
65
65
|
export declare function useExecution(executionId: string | undefined): QueryResult<ExecutionRecord | null>;
|
|
66
66
|
/**
|
|
67
67
|
* Token/cost metrics for the workspace, optionally narrowed to an agent, app or
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CreateExecutionDocument as e, GetExecutionDocument as t, ListExecutionsDocument as n } from "../../generated/wspace-operations.js";
|
|
2
2
|
import { buildMutationInput as r, fieldsOf as i } from "./internal/mutationInput.js";
|
|
3
|
-
import { useWorkspaceId as a, useWorkspaceMutation as o,
|
|
4
|
-
import { useCallback as
|
|
3
|
+
import { useWorkspaceId as a, useWorkspaceMutation as o, useWorkspacePaginatedQuery as s, useWorkspaceQuery as c } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useCallback as l, useMemo as u } from "react";
|
|
5
5
|
// src/botlit/hooks/useExecutions.ts
|
|
6
|
-
var
|
|
6
|
+
var d = 100, f = i({
|
|
7
7
|
agentId: !0,
|
|
8
8
|
appId: !0,
|
|
9
9
|
conversationId: !0,
|
|
@@ -11,47 +11,43 @@ var u = 100, d = i({
|
|
|
11
11
|
metadata: !0,
|
|
12
12
|
type: !0,
|
|
13
13
|
workspaceId: !0
|
|
14
|
-
}),
|
|
15
|
-
function
|
|
14
|
+
}), p = /* @__PURE__ */ new Set(["COMPLETED"]), m = [];
|
|
15
|
+
function h(e, t) {
|
|
16
16
|
return e.id.toLowerCase().includes(t) || (e.agentId ?? "").toLowerCase().includes(t) || (e.appId ?? "").toLowerCase().includes(t) || e.input.toLowerCase().includes(t);
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
let t = a(), r = e?.search?.trim().toLowerCase() ?? "", i = e?.status, o = i?.length === 1 ? i[0] : void 0,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
pagination: {
|
|
29
|
-
limit: u,
|
|
30
|
-
offset: 0
|
|
31
|
-
}
|
|
32
|
-
}), [
|
|
18
|
+
function g(e) {
|
|
19
|
+
let t = a(), r = e?.search?.trim().toLowerCase() ?? "", i = e?.status, o = i?.length === 1 ? i[0] : void 0, c = i?.join(",") ?? "", { agentId: f, appId: p, conversationId: g, type: _ } = e ?? {}, v = u(() => ({ filters: {
|
|
20
|
+
workspaceId: t,
|
|
21
|
+
status: o,
|
|
22
|
+
agentId: f,
|
|
23
|
+
appId: p,
|
|
24
|
+
conversationId: g,
|
|
25
|
+
type: _
|
|
26
|
+
} }), [
|
|
33
27
|
t,
|
|
34
28
|
o,
|
|
35
29
|
f,
|
|
36
|
-
|
|
30
|
+
p,
|
|
37
31
|
g,
|
|
38
32
|
_
|
|
39
|
-
]), y =
|
|
40
|
-
let t =
|
|
41
|
-
return r ?
|
|
42
|
-
}, [r,
|
|
33
|
+
]), y = l((e) => {
|
|
34
|
+
let t = c ? new Set(c.split(",")) : void 0, n = t && t.size > 1 ? e.filter((e) => t.has(e.status)) : e;
|
|
35
|
+
return r ? n.filter((e) => h(e, r)) : n;
|
|
36
|
+
}, [r, c]);
|
|
43
37
|
return s({
|
|
44
38
|
document: n,
|
|
45
39
|
variables: v,
|
|
40
|
+
pageSize: d,
|
|
41
|
+
extractRows: (e) => e?.listExecutions ?? m,
|
|
46
42
|
select: y,
|
|
47
|
-
fallback:
|
|
43
|
+
fallback: m,
|
|
48
44
|
enabled: !!t,
|
|
49
45
|
errorMessage: "Failed to load executions"
|
|
50
46
|
});
|
|
51
47
|
}
|
|
52
|
-
function
|
|
53
|
-
let n =
|
|
54
|
-
return
|
|
48
|
+
function _(e) {
|
|
49
|
+
let n = u(() => ({ id: e ?? "" }), [e]);
|
|
50
|
+
return c({
|
|
55
51
|
document: t,
|
|
56
52
|
variables: n,
|
|
57
53
|
select: (e) => e?.getExecution ?? null,
|
|
@@ -60,9 +56,9 @@ function g(e) {
|
|
|
60
56
|
errorMessage: "Failed to load execution"
|
|
61
57
|
});
|
|
62
58
|
}
|
|
63
|
-
function
|
|
59
|
+
function v(e) {
|
|
64
60
|
let t = e.length, n = 0, r = 0, i = 0, a = 0, o = 0, s = 0;
|
|
65
|
-
for (let t of e)
|
|
61
|
+
for (let t of e) p.has(t.status) && (n += 1), (t.status === "FAILED" || t.status === "TIMEOUT") && (r += 1), typeof t.duration == "number" && (i += t.duration, a += 1), o += t.cost ?? 0, s += t.tokensUsed ?? 0;
|
|
66
62
|
return {
|
|
67
63
|
total: t,
|
|
68
64
|
succeeded: n,
|
|
@@ -73,14 +69,14 @@ function _(e) {
|
|
|
73
69
|
totalTokens: s
|
|
74
70
|
};
|
|
75
71
|
}
|
|
76
|
-
function
|
|
72
|
+
function y() {
|
|
77
73
|
return o({
|
|
78
74
|
document: e,
|
|
79
|
-
variables: ({ input: e }) => ({ input: r(e,
|
|
75
|
+
variables: ({ input: e }) => ({ input: r(e, f) }),
|
|
80
76
|
select: (e) => e?.createExecution,
|
|
81
77
|
errorMessage: "Failed to start execution"
|
|
82
78
|
});
|
|
83
79
|
}
|
|
84
|
-
export {
|
|
80
|
+
export { v as summariseExecutions, y as useCreateExecution, _ as useExecution, g as useExecutions };
|
|
85
81
|
|
|
86
82
|
//# sourceMappingURL=useExecutions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExecutions.js","names":["LIST_LIMIT","CREATE_EXECUTION_FIELDS","fieldsOf","SUCCESS_STATUSES","NO_EXECUTIONS","matchesSearch","execution","needle","useExecutions","workspaceId","useWorkspaceId","search","filter","statuses","singleStatus","statusKey","variables","useMemo","agentId","appId","conversationId","type","select","useCallback","rows","data","wanted","narrowed","row","useWorkspaceQuery","ListExecutionsDocument","useExecution","executionId","GetExecutionDocument","summariseExecutions","total","executions","succeeded","failed","durationSum","durationCount","totalCost","totalTokens","useCreateExecution","useWorkspaceMutation","CreateExecutionDocument","buildMutationInput","input"],"sources":["../../../src/botlit/hooks/useExecutions.ts"],"sourcesContent":["/**\n * Executions Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listExecutions` / `getExecution` / `getExecutionMetrics`\n * operations plus the `createExecution` / `updateExecutionStatus` mutations on\n * wspace-botlit-svc.\n *\n * Note on filtering: `ExecutionFilterInput` accepts a SINGLE status and has no\n * free-text field, so multi-status selections and search are narrowed on the\n * client over the fetched page.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateExecutionDocument,\n GetExecutionDocument,\n GetExecutionMetricsDocument,\n ListExecutionsDocument,\n UpdateExecutionStatusDocument,\n type CreateExecutionMutation,\n type GetExecutionMetricsQuery,\n type GetExecutionQuery,\n type ListExecutionsQuery,\n type UpdateExecutionStatusMutation,\n} from '../../generated/wspace-operations';\nimport type { CreateExecutionInput, ExecutionStatus } 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 ExecutionRecord {\n id: string;\n status: string;\n type: string;\n input: string;\n output?: string | null;\n agentId?: string | null;\n appId?: string | null;\n conversationId?: string | null;\n cost?: number | null;\n duration?: number | null;\n tokensUsed?: number | null;\n errorCode?: string | null;\n errorMessage?: string | null;\n errorDetails?: Record<string, unknown> | null;\n metadata?: Record<string, unknown> | null;\n completedAt?: string | null;\n createdAt: string;\n workspaceId: string;\n}\n\nexport interface ExecutionMetricsRecord {\n executionId: string;\n cost: number;\n inputTokens: number;\n outputTokens: number;\n totalTokens: number;\n ragChunks: number;\n toolCalls: number;\n}\n\nexport interface ExecutionsFilter {\n search?: string;\n status?: string[];\n agentId?: string;\n appId?: string;\n conversationId?: string;\n type?: string;\n}\n\nexport interface ExecutionMetricsFilter {\n agentId?: string;\n appId?: string;\n startDate?: string;\n endDate?: string;\n}\n\nexport interface CreateExecutionVariables {\n input: GraphQLInput<CreateExecutionInput>;\n}\n\nconst CREATE_EXECUTION_FIELDS = fieldsOf<CreateExecutionInput>({\n agentId: true,\n appId: true,\n conversationId: true,\n input: true,\n metadata: true,\n type: true,\n workspaceId: true,\n});\n\nexport interface UpdateExecutionStatusVariables {\n id: string;\n status: ExecutionStatus;\n output?: string;\n error?: Record<string, unknown>;\n}\n\n/** Terminal statuses that count as a successful run. */\nconst SUCCESS_STATUSES = new Set(['COMPLETED']);\n\nconst NO_EXECUTIONS: ExecutionRecord[] = [];\n\nexport const executionKeys = {\n all: ['executions'] as const,\n lists: () => [...executionKeys.all, 'list'] as const,\n list: (filter?: ExecutionsFilter) => [...executionKeys.lists(), filter] as const,\n details: () => [...executionKeys.all, 'detail'] as const,\n detail: (id: string) => [...executionKeys.details(), id] as const,\n metrics: () => [...executionKeys.all, 'metrics'] as const,\n};\n\nfunction matchesSearch(execution: ExecutionRecord, needle: string): boolean {\n return (\n execution.id.toLowerCase().includes(needle) ||\n (execution.agentId ?? '').toLowerCase().includes(needle) ||\n (execution.appId ?? '').toLowerCase().includes(needle) ||\n execution.input.toLowerCase().includes(needle)\n );\n}\n\nexport function useExecutions(filter?: ExecutionsFilter): QueryResult<ExecutionRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search?.trim().toLowerCase() ?? '';\n const statuses = filter?.status;\n const singleStatus = statuses?.length === 1 ? statuses[0] : undefined;\n const statusKey = statuses?.join(',') ?? '';\n const { agentId, appId, conversationId, type } = filter ?? {};\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n status: singleStatus,\n agentId,\n appId,\n conversationId,\n type,\n },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [workspaceId, singleStatus, agentId, appId, conversationId, type]\n );\n\n const select = useCallback(\n (data: ListExecutionsQuery | undefined): ExecutionRecord[] => {\n const rows: ExecutionRecord[] = data?.listExecutions ?? NO_EXECUTIONS;\n const wanted = statusKey ? new Set(statusKey.split(',')) : undefined;\n const narrowed =\n // A single status is already applied server-side.\n wanted && wanted.size > 1 ? rows.filter((row) => wanted.has(row.status)) : rows;\n return search ? narrowed.filter((row) => matchesSearch(row, search)) : narrowed;\n },\n [search, statusKey]\n );\n\n return useWorkspaceQuery<ListExecutionsQuery, ExecutionRecord[]>({\n document: ListExecutionsDocument,\n variables,\n select,\n fallback: NO_EXECUTIONS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load executions',\n });\n}\n\nexport function useExecution(executionId: string | undefined): QueryResult<ExecutionRecord | null> {\n const variables = useMemo(() => ({ id: executionId ?? '' }), [executionId]);\n\n return useWorkspaceQuery<GetExecutionQuery, ExecutionRecord | null>({\n document: GetExecutionDocument,\n variables,\n select: (data) => data?.getExecution ?? null,\n fallback: null,\n enabled: Boolean(executionId),\n errorMessage: 'Failed to load execution',\n });\n}\n\n/**\n * Token/cost metrics for the workspace, optionally narrowed to an agent, app or\n * date window. Returns `null` when the service has nothing recorded yet.\n */\nexport function useExecutionMetrics(\n filter?: ExecutionMetricsFilter\n): QueryResult<ExecutionMetricsRecord | null> {\n const workspaceId = useWorkspaceId();\n const { agentId, appId, startDate, endDate } = filter ?? {};\n\n const variables = useMemo(\n () => ({ filter: { workspaceId, agentId, appId, startDate, endDate } }),\n [workspaceId, agentId, appId, startDate, endDate]\n );\n\n return useWorkspaceQuery<GetExecutionMetricsQuery, ExecutionMetricsRecord | null>({\n document: GetExecutionMetricsDocument,\n variables,\n select: (data) => data?.getExecutionMetrics ?? null,\n fallback: null,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load execution metrics',\n });\n}\n\nexport interface ExecutionRollup {\n total: number;\n succeeded: number;\n failed: number;\n successRate: number;\n avgDurationMs: number;\n totalCost: number;\n totalTokens: number;\n}\n\n/**\n * Rolls a list of executions up into the headline numbers shown above the table.\n * Derived purely from the rows that were actually loaded — no server aggregate\n * exists for this, so callers must label it as such.\n */\nexport function summariseExecutions(executions: readonly ExecutionRecord[]): ExecutionRollup {\n const total = executions.length;\n let succeeded = 0;\n let failed = 0;\n let durationSum = 0;\n let durationCount = 0;\n let totalCost = 0;\n let totalTokens = 0;\n\n for (const execution of executions) {\n if (SUCCESS_STATUSES.has(execution.status)) succeeded += 1;\n if (execution.status === 'FAILED' || execution.status === 'TIMEOUT') failed += 1;\n if (typeof execution.duration === 'number') {\n durationSum += execution.duration;\n durationCount += 1;\n }\n totalCost += execution.cost ?? 0;\n totalTokens += execution.tokensUsed ?? 0;\n }\n\n return {\n total,\n succeeded,\n failed,\n successRate: total > 0 ? succeeded / total : 0,\n avgDurationMs: durationCount > 0 ? durationSum / durationCount : 0,\n totalCost,\n totalTokens,\n };\n}\n\nexport function useCreateExecution() {\n return useWorkspaceMutation<CreateExecutionMutation, CreateExecutionVariables, ExecutionRecord>({\n document: CreateExecutionDocument,\n variables: ({ input }) => ({ input: buildMutationInput(input, CREATE_EXECUTION_FIELDS) }),\n select: (data) => data?.createExecution,\n errorMessage: 'Failed to start execution',\n });\n}\n\nexport function useUpdateExecutionStatus() {\n return useWorkspaceMutation<\n UpdateExecutionStatusMutation,\n UpdateExecutionStatusVariables,\n ExecutionRecord\n >({\n document: UpdateExecutionStatusDocument,\n variables: ({ id, status, output, error }) => ({\n id,\n input: {\n status,\n output,\n // The subgraph takes the failure as a message plus a JSON detail blob\n // (UpdateExecutionStatusInput); pass the caller's object through whole.\n errorMessage: typeof error?.message === 'string' ? error.message : undefined,\n errorDetails: error,\n },\n }),\n select: (data) => data?.updateExecutionStatus,\n errorMessage: 'Failed to update execution status',\n });\n}\n"],"mappings":";;;;;AAmCA,IAAMA,IAAa,KAqDbC,IAA0BC,EAA+B;CAC7D,SAAS;CACT,OAAO;CACP,gBAAgB;CAChB,OAAO;CACP,UAAU;CACV,MAAM;CACN,aAAa;AACf,CAAC,GAUKC,oBAAmB,IAAI,IAAI,CAAC,WAAW,CAAC,GAExCC,IAAmC,CAAC;AAW1C,SAASC,EAAc,GAA4B,GAAyB;CAC1E,OACEC,EAAU,GAAG,YAAY,CAAC,CAAC,SAASC,CAAM,MACzCD,EAAU,WAAW,GAAA,CAAI,YAAY,CAAC,CAAC,SAASC,CAAM,MACtDD,EAAU,SAAS,GAAA,CAAI,YAAY,CAAC,CAAC,SAASC,CAAM,KACrDD,EAAU,MAAM,YAAY,CAAC,CAAC,SAASC,CAAM;AAEjD;AAEA,SAAgBC,EAAc,GAA2D;CACvF,IAAMC,IAAcC,EAAe,GAC7BC,IAASC,GAAQ,QAAQ,KAAK,CAAC,CAAC,YAAY,KAAK,IACjDC,IAAWD,GAAQ,QACnBE,IAAeD,GAAU,WAAW,IAAIA,EAAS,KAAK,KAAA,GACtDE,IAAYF,GAAU,KAAK,GAAG,KAAK,IACnC,EAAE,YAAS,UAAO,mBAAgB,YAASD,KAAU,CAAC,GAEtDI,IAAYC,SACT;EACL,SAAS;GACP;GACA,QAAQH;GACR;GACA;GACA;GACA;EACF;EACA,YAAY;GAAE,OAAOd;GAAY,QAAQ;EAAE;CAC7C,IACA;EAACS;EAAaK;EAAcI;EAASC;EAAOC;EAAgBC;CAA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AqB;CACnC,OAAOC,EAAyF;EAC9F,UAAUC;EACV,YAAY,EAAE,gBAAa,EAAE,OAAOC,EAAmBC,GAAO9C,CAAuB,EAAE;EACvF,SAAS,MAASwB,GAAM;EACxB,cAAc;CAChB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"useExecutions.js","names":["LIST_LIMIT","CREATE_EXECUTION_FIELDS","fieldsOf","SUCCESS_STATUSES","NO_EXECUTIONS","matchesSearch","execution","needle","useExecutions","workspaceId","useWorkspaceId","search","filter","statuses","singleStatus","statusKey","variables","useMemo","agentId","appId","conversationId","type","select","useCallback","wanted","narrowed","rows","row","useWorkspacePaginatedQuery","ListExecutionsDocument","data","useExecution","executionId","useWorkspaceQuery","GetExecutionDocument","summariseExecutions","total","executions","succeeded","failed","durationSum","durationCount","totalCost","totalTokens","useCreateExecution","useWorkspaceMutation","CreateExecutionDocument","buildMutationInput","input"],"sources":["../../../src/botlit/hooks/useExecutions.ts"],"sourcesContent":["/**\n * Executions Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listExecutions` / `getExecution` / `getExecutionMetrics`\n * operations plus the `createExecution` / `updateExecutionStatus` mutations on\n * wspace-botlit-svc.\n *\n * Note on filtering: `ExecutionFilterInput` accepts a SINGLE status and has no\n * free-text field, so multi-status selections and search are narrowed on the\n * client over every loaded page (see `loadMore`).\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateExecutionDocument,\n GetExecutionDocument,\n GetExecutionMetricsDocument,\n ListExecutionsDocument,\n UpdateExecutionStatusDocument,\n type CreateExecutionMutation,\n type GetExecutionMetricsQuery,\n type GetExecutionQuery,\n type ListExecutionsQuery,\n type UpdateExecutionStatusMutation,\n} from '../../generated/wspace-operations';\nimport type { CreateExecutionInput, ExecutionStatus } from '../../generated/wspace-types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n\nexport interface ExecutionRecord {\n id: string;\n status: string;\n type: string;\n input: string;\n output?: string | null;\n agentId?: string | null;\n appId?: string | null;\n conversationId?: string | null;\n cost?: number | null;\n duration?: number | null;\n tokensUsed?: number | null;\n errorCode?: string | null;\n errorMessage?: string | null;\n errorDetails?: Record<string, unknown> | null;\n metadata?: Record<string, unknown> | null;\n completedAt?: string | null;\n createdAt: string;\n workspaceId: string;\n}\n\nexport interface ExecutionMetricsRecord {\n executionId: string;\n cost: number;\n inputTokens: number;\n outputTokens: number;\n totalTokens: number;\n ragChunks: number;\n toolCalls: number;\n}\n\nexport interface ExecutionsFilter {\n search?: string;\n status?: string[];\n agentId?: string;\n appId?: string;\n conversationId?: string;\n type?: string;\n}\n\nexport interface ExecutionMetricsFilter {\n agentId?: string;\n appId?: string;\n startDate?: string;\n endDate?: string;\n}\n\nexport interface CreateExecutionVariables {\n input: GraphQLInput<CreateExecutionInput>;\n}\n\nconst CREATE_EXECUTION_FIELDS = fieldsOf<CreateExecutionInput>({\n agentId: true,\n appId: true,\n conversationId: true,\n input: true,\n metadata: true,\n type: true,\n workspaceId: true,\n});\n\nexport interface UpdateExecutionStatusVariables {\n id: string;\n status: ExecutionStatus;\n output?: string;\n error?: Record<string, unknown>;\n}\n\n/** Terminal statuses that count as a successful run. */\nconst SUCCESS_STATUSES = new Set(['COMPLETED']);\n\nconst NO_EXECUTIONS: ExecutionRecord[] = [];\n\nexport const executionKeys = {\n all: ['executions'] as const,\n lists: () => [...executionKeys.all, 'list'] as const,\n list: (filter?: ExecutionsFilter) => [...executionKeys.lists(), filter] as const,\n details: () => [...executionKeys.all, 'detail'] as const,\n detail: (id: string) => [...executionKeys.details(), id] as const,\n metrics: () => [...executionKeys.all, 'metrics'] as const,\n};\n\nfunction matchesSearch(execution: ExecutionRecord, needle: string): boolean {\n return (\n execution.id.toLowerCase().includes(needle) ||\n (execution.agentId ?? '').toLowerCase().includes(needle) ||\n (execution.appId ?? '').toLowerCase().includes(needle) ||\n execution.input.toLowerCase().includes(needle)\n );\n}\n\nexport function useExecutions(filter?: ExecutionsFilter): PaginatedQueryResult<ExecutionRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search?.trim().toLowerCase() ?? '';\n const statuses = filter?.status;\n const singleStatus = statuses?.length === 1 ? statuses[0] : undefined;\n const statusKey = statuses?.join(',') ?? '';\n const { agentId, appId, conversationId, type } = filter ?? {};\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n status: singleStatus,\n agentId,\n appId,\n conversationId,\n type,\n },\n }),\n [workspaceId, singleStatus, agentId, appId, conversationId, type]\n );\n\n const select = useCallback(\n (rows: ExecutionRecord[]): ExecutionRecord[] => {\n const wanted = statusKey ? new Set(statusKey.split(',')) : undefined;\n const narrowed =\n // A single status is already applied server-side.\n wanted && wanted.size > 1 ? rows.filter((row) => wanted.has(row.status)) : rows;\n return search ? narrowed.filter((row) => matchesSearch(row, search)) : narrowed;\n },\n [search, statusKey]\n );\n\n return useWorkspacePaginatedQuery<ListExecutionsQuery, ExecutionRecord, ExecutionRecord[]>({\n document: ListExecutionsDocument,\n variables,\n pageSize: LIST_LIMIT,\n extractRows: (data) => data?.listExecutions ?? NO_EXECUTIONS,\n select,\n fallback: NO_EXECUTIONS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load executions',\n });\n}\n\nexport function useExecution(executionId: string | undefined): QueryResult<ExecutionRecord | null> {\n const variables = useMemo(() => ({ id: executionId ?? '' }), [executionId]);\n\n return useWorkspaceQuery<GetExecutionQuery, ExecutionRecord | null>({\n document: GetExecutionDocument,\n variables,\n select: (data) => data?.getExecution ?? null,\n fallback: null,\n enabled: Boolean(executionId),\n errorMessage: 'Failed to load execution',\n });\n}\n\n/**\n * Token/cost metrics for the workspace, optionally narrowed to an agent, app or\n * date window. Returns `null` when the service has nothing recorded yet.\n */\nexport function useExecutionMetrics(\n filter?: ExecutionMetricsFilter\n): QueryResult<ExecutionMetricsRecord | null> {\n const workspaceId = useWorkspaceId();\n const { agentId, appId, startDate, endDate } = filter ?? {};\n\n const variables = useMemo(\n () => ({ filter: { workspaceId, agentId, appId, startDate, endDate } }),\n [workspaceId, agentId, appId, startDate, endDate]\n );\n\n return useWorkspaceQuery<GetExecutionMetricsQuery, ExecutionMetricsRecord | null>({\n document: GetExecutionMetricsDocument,\n variables,\n select: (data) => data?.getExecutionMetrics ?? null,\n fallback: null,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load execution metrics',\n });\n}\n\nexport interface ExecutionRollup {\n total: number;\n succeeded: number;\n failed: number;\n successRate: number;\n avgDurationMs: number;\n totalCost: number;\n totalTokens: number;\n}\n\n/**\n * Rolls a list of executions up into the headline numbers shown above the table.\n * Derived purely from the rows that were actually loaded — no server aggregate\n * exists for this, so callers must label it as such.\n */\nexport function summariseExecutions(executions: readonly ExecutionRecord[]): ExecutionRollup {\n const total = executions.length;\n let succeeded = 0;\n let failed = 0;\n let durationSum = 0;\n let durationCount = 0;\n let totalCost = 0;\n let totalTokens = 0;\n\n for (const execution of executions) {\n if (SUCCESS_STATUSES.has(execution.status)) succeeded += 1;\n if (execution.status === 'FAILED' || execution.status === 'TIMEOUT') failed += 1;\n if (typeof execution.duration === 'number') {\n durationSum += execution.duration;\n durationCount += 1;\n }\n totalCost += execution.cost ?? 0;\n totalTokens += execution.tokensUsed ?? 0;\n }\n\n return {\n total,\n succeeded,\n failed,\n successRate: total > 0 ? succeeded / total : 0,\n avgDurationMs: durationCount > 0 ? durationSum / durationCount : 0,\n totalCost,\n totalTokens,\n };\n}\n\nexport function useCreateExecution() {\n return useWorkspaceMutation<CreateExecutionMutation, CreateExecutionVariables, ExecutionRecord>({\n document: CreateExecutionDocument,\n variables: ({ input }) => ({ input: buildMutationInput(input, CREATE_EXECUTION_FIELDS) }),\n select: (data) => data?.createExecution,\n errorMessage: 'Failed to start execution',\n });\n}\n\nexport function useUpdateExecutionStatus() {\n return useWorkspaceMutation<\n UpdateExecutionStatusMutation,\n UpdateExecutionStatusVariables,\n ExecutionRecord\n >({\n document: UpdateExecutionStatusDocument,\n variables: ({ id, status, output, error }) => ({\n id,\n input: {\n status,\n output,\n // The subgraph takes the failure as a message plus a JSON detail blob\n // (UpdateExecutionStatusInput); pass the caller's object through whole.\n errorMessage: typeof error?.message === 'string' ? error.message : undefined,\n errorDetails: error,\n },\n }),\n select: (data) => data?.updateExecutionStatus,\n errorMessage: 'Failed to update execution status',\n });\n}\n"],"mappings":";;;;;AAqCA,IAAMA,IAAa,KAqDbC,IAA0BC,EAA+B;CAC7D,SAAS;CACT,OAAO;CACP,gBAAgB;CAChB,OAAO;CACP,UAAU;CACV,MAAM;CACN,aAAa;AACf,CAAC,GAUKC,oBAAmB,IAAI,IAAI,CAAC,WAAW,CAAC,GAExCC,IAAmC,CAAC;AAW1C,SAASC,EAAc,GAA4B,GAAyB;CAC1E,OACEC,EAAU,GAAG,YAAY,CAAC,CAAC,SAASC,CAAM,MACzCD,EAAU,WAAW,GAAA,CAAI,YAAY,CAAC,CAAC,SAASC,CAAM,MACtDD,EAAU,SAAS,GAAA,CAAI,YAAY,CAAC,CAAC,SAASC,CAAM,KACrDD,EAAU,MAAM,YAAY,CAAC,CAAC,SAASC,CAAM;AAEjD;AAEA,SAAgBC,EAAc,GAAoE;CAChG,IAAMC,IAAcC,EAAe,GAC7BC,IAASC,GAAQ,QAAQ,KAAK,CAAC,CAAC,YAAY,KAAK,IACjDC,IAAWD,GAAQ,QACnBE,IAAeD,GAAU,WAAW,IAAIA,EAAS,KAAK,KAAA,GACtDE,IAAYF,GAAU,KAAK,GAAG,KAAK,IACnC,EAAE,YAAS,UAAO,mBAAgB,YAASD,KAAU,CAAC,GAEtDI,IAAYC,SACT,EACL,SAAS;EACP;EACA,QAAQH;EACR;EACA;EACA;EACA;CACF,EACF,IACA;EAACL;EAAaK;EAAcI;EAASC;EAAOC;EAAgBC;CAAI,CAClE,GA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AqB;CACnC,OAAOC,EAAyF;EAC9F,UAAUC;EACV,YAAY,EAAE,gBAAa,EAAE,OAAOC,EAAmBC,GAAO/C,CAAuB,EAAE;EACvF,SAAS,MAAS6B,GAAM;EACxB,cAAc;CAChB,CAAC;AACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ForkInstalledPackageInput, InstallPackageInput, UpdateInstalledPackageInput } from '../../generated/wspace-types';
|
|
2
2
|
import { GraphQLInput } from './internal/mutationInput';
|
|
3
|
-
import { QueryResult } from './internal/workspaceGateway';
|
|
3
|
+
import { PaginatedQueryResult, QueryResult } from './internal/workspaceGateway';
|
|
4
4
|
export interface StorePackageRecord {
|
|
5
5
|
id: string;
|
|
6
6
|
slug: string;
|
|
@@ -69,10 +69,10 @@ export declare const storeKeys: {
|
|
|
69
69
|
installedList: () => readonly ["store", "installed", "list"];
|
|
70
70
|
installedDetail: (id: string) => readonly ["store", "installed", "detail", string];
|
|
71
71
|
};
|
|
72
|
-
export declare function useStorePackages(filter?: StoreFilter):
|
|
72
|
+
export declare function useStorePackages(filter?: StoreFilter): PaginatedQueryResult<StorePackageRecord[]>;
|
|
73
73
|
/** Store packages are addressed by slug in the UI, so this resolves by slug. */
|
|
74
74
|
export declare function useStorePackage(slug: string | undefined): QueryResult<StorePackageRecord | null>;
|
|
75
|
-
export declare function useInstalledPackages():
|
|
75
|
+
export declare function useInstalledPackages(): PaginatedQueryResult<InstalledPackageRecord[]>;
|
|
76
76
|
export declare function useInstalledPackage(packageId: string | undefined): QueryResult<InstalledPackageRecord | null>;
|
|
77
77
|
/**
|
|
78
78
|
* Installed packages whose store listing now publishes a different version.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { GetStorePackageBySlugDocument as e, InstallPackageDocument as t, ListInstalledPackagesDocument as n, ListStorePackagesDocument as r, UninstallPackageDocument as i, UpdateInstalledPackageDocument as a } from "../../generated/wspace-operations.js";
|
|
2
2
|
import { buildMutationInput as o, fieldsOf as s } from "./internal/mutationInput.js";
|
|
3
|
-
import { useWorkspaceId as c, useWorkspaceMutation as l,
|
|
4
|
-
import { useCallback as
|
|
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/useStore.ts
|
|
6
|
-
var
|
|
6
|
+
var m = 100, h = s({
|
|
7
7
|
bindings: !0,
|
|
8
8
|
metadata: !0,
|
|
9
9
|
mode: !0,
|
|
@@ -11,7 +11,7 @@ var p = 100, m = s({
|
|
|
11
11
|
pinnedByEnv: !0,
|
|
12
12
|
version: !0,
|
|
13
13
|
workspaceId: !0
|
|
14
|
-
}),
|
|
14
|
+
}), g = s({
|
|
15
15
|
bindings: !0,
|
|
16
16
|
installedVersion: !0,
|
|
17
17
|
metadata: !0,
|
|
@@ -24,55 +24,50 @@ s({
|
|
|
24
24
|
newName: !0,
|
|
25
25
|
workspaceId: !0
|
|
26
26
|
});
|
|
27
|
-
var
|
|
28
|
-
function
|
|
27
|
+
var _ = [], v = [];
|
|
28
|
+
function y(e, t) {
|
|
29
29
|
let n = e?.manifest?.[t];
|
|
30
30
|
return n && typeof n == "object" && !Array.isArray(n) ? n : void 0;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
let n =
|
|
32
|
+
function b(e, t) {
|
|
33
|
+
let n = y(e, "package")?.[t];
|
|
34
34
|
return typeof n == "string" ? n : void 0;
|
|
35
35
|
}
|
|
36
|
-
function b(e) {
|
|
37
|
-
return y(e, "name") ?? e?.slug ?? "";
|
|
38
|
-
}
|
|
39
36
|
function x(e) {
|
|
40
|
-
return
|
|
37
|
+
return b(e, "name") ?? e?.slug ?? "";
|
|
41
38
|
}
|
|
42
39
|
function S(e) {
|
|
43
|
-
return e
|
|
40
|
+
return b(e, "description");
|
|
44
41
|
}
|
|
45
42
|
function C(e) {
|
|
46
|
-
return e?.
|
|
43
|
+
return e?.listStorePackages ?? _;
|
|
47
44
|
}
|
|
48
45
|
function w(e) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
let t = S(e);
|
|
60
|
-
if (t.length === 0) return t;
|
|
61
|
-
let n = [...t];
|
|
62
|
-
return i === "name" ? n.sort((e, t) => b(e).localeCompare(b(t))) : n.sort((e, t) => (t.publishedAt ?? "").localeCompare(e.publishedAt ?? "")), n;
|
|
46
|
+
return e?.listInstalledPackages ?? v;
|
|
47
|
+
}
|
|
48
|
+
function T(e) {
|
|
49
|
+
let t = e?.search?.trim() ?? "", n = e?.kind?.[0], i = e?.sortBy ?? "recent", a = p(() => ({ filters: {
|
|
50
|
+
search: t || void 0,
|
|
51
|
+
kind: n
|
|
52
|
+
} }), [t, n]), o = f((e) => {
|
|
53
|
+
if (e.length === 0) return e;
|
|
54
|
+
let t = [...e];
|
|
55
|
+
return i === "name" ? t.sort((e, t) => x(e).localeCompare(x(t))) : t.sort((e, t) => (t.publishedAt ?? "").localeCompare(e.publishedAt ?? "")), t;
|
|
63
56
|
}, [i]);
|
|
64
57
|
return u({
|
|
65
58
|
document: r,
|
|
66
59
|
variables: a,
|
|
60
|
+
pageSize: m,
|
|
61
|
+
extractRows: C,
|
|
67
62
|
select: o,
|
|
68
|
-
fallback:
|
|
63
|
+
fallback: _,
|
|
69
64
|
enabled: !0,
|
|
70
65
|
errorMessage: "Failed to load store packages"
|
|
71
66
|
});
|
|
72
67
|
}
|
|
73
|
-
function
|
|
74
|
-
let n =
|
|
75
|
-
return
|
|
68
|
+
function E(t) {
|
|
69
|
+
let n = p(() => ({ slug: t ?? "" }), [t]);
|
|
70
|
+
return d({
|
|
76
71
|
document: e,
|
|
77
72
|
variables: n,
|
|
78
73
|
select: (e) => e?.getStorePackageBySlug ?? null,
|
|
@@ -81,28 +76,24 @@ function T(t) {
|
|
|
81
76
|
errorMessage: "Failed to load store package"
|
|
82
77
|
});
|
|
83
78
|
}
|
|
84
|
-
function
|
|
85
|
-
let e = c(), t =
|
|
86
|
-
filters: { workspaceId: e ?? "" },
|
|
87
|
-
pagination: {
|
|
88
|
-
limit: p,
|
|
89
|
-
offset: 0
|
|
90
|
-
}
|
|
91
|
-
}), [e]);
|
|
79
|
+
function D() {
|
|
80
|
+
let e = c(), t = p(() => ({ filters: { workspaceId: e ?? "" } }), [e]);
|
|
92
81
|
return u({
|
|
93
82
|
document: n,
|
|
94
83
|
variables: t,
|
|
95
|
-
|
|
96
|
-
|
|
84
|
+
pageSize: m,
|
|
85
|
+
extractRows: w,
|
|
86
|
+
select: (e) => e,
|
|
87
|
+
fallback: v,
|
|
97
88
|
enabled: !!e,
|
|
98
89
|
errorMessage: "Failed to load installed packages"
|
|
99
90
|
});
|
|
100
91
|
}
|
|
101
|
-
function
|
|
102
|
-
let e = c(), n =
|
|
92
|
+
function O() {
|
|
93
|
+
let e = c(), n = f((t) => ({ input: o({
|
|
103
94
|
...t,
|
|
104
95
|
workspaceId: e
|
|
105
|
-
},
|
|
96
|
+
}, h) }), [e]), [r, i] = l({
|
|
106
97
|
document: t,
|
|
107
98
|
variables: n,
|
|
108
99
|
select: (e) => e?.installPackage,
|
|
@@ -114,12 +105,12 @@ function D() {
|
|
|
114
105
|
error: i.error
|
|
115
106
|
};
|
|
116
107
|
}
|
|
117
|
-
function
|
|
108
|
+
function k() {
|
|
118
109
|
let [e, t] = l({
|
|
119
110
|
document: a,
|
|
120
111
|
variables: ({ installedId: e, input: t }) => ({
|
|
121
112
|
id: e,
|
|
122
|
-
input: o(t,
|
|
113
|
+
input: o(t, g)
|
|
123
114
|
}),
|
|
124
115
|
select: (e) => e?.updateInstalledPackage,
|
|
125
116
|
errorMessage: "Failed to update installed package"
|
|
@@ -130,7 +121,7 @@ function O() {
|
|
|
130
121
|
error: t.error
|
|
131
122
|
};
|
|
132
123
|
}
|
|
133
|
-
function
|
|
124
|
+
function A() {
|
|
134
125
|
let [e, t] = l({
|
|
135
126
|
document: i,
|
|
136
127
|
variables: (e) => ({ id: e }),
|
|
@@ -143,7 +134,7 @@ function k() {
|
|
|
143
134
|
error: t.error
|
|
144
135
|
};
|
|
145
136
|
}
|
|
146
|
-
function
|
|
137
|
+
function j() {
|
|
147
138
|
let [e, t] = l({
|
|
148
139
|
document: a,
|
|
149
140
|
variables: ({ installedId: e, environment: t, version: n, pinnedByEnv: r }) => ({
|
|
@@ -162,6 +153,6 @@ function A() {
|
|
|
162
153
|
error: t.error
|
|
163
154
|
};
|
|
164
155
|
}
|
|
165
|
-
export {
|
|
156
|
+
export { S as storePackageDescription, x as storePackageName, O as useInstallPackage, D as useInstalledPackages, j as usePinPackageVersion, E as useStorePackage, T as useStorePackages, A as useUninstallPackage, k as useUpdateInstalledPackage };
|
|
166
157
|
|
|
167
158
|
//# sourceMappingURL=useStore.js.map
|