@ai4b-team/fsaos-gateway-sdk 2.0.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/iife/gateway.js +3 -3
- package/dist/iife/gateway.js.map +3 -3
- package/dist/iife/ui.js +1 -1
- package/dist/index.cjs +66 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -3
- package/dist/index.d.ts +51 -3
- package/dist/index.js +66 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -664,6 +664,33 @@ interface ChannelMessage {
|
|
|
664
664
|
intent_card?: Record<string, unknown>;
|
|
665
665
|
thread_summary?: Array<Record<string, unknown>>;
|
|
666
666
|
}
|
|
667
|
+
/** A parsed card item bundled with channel messages from the kernel v2 response. */
|
|
668
|
+
interface ChannelCard {
|
|
669
|
+
id: string;
|
|
670
|
+
path: string;
|
|
671
|
+
name: string;
|
|
672
|
+
createdAt: string;
|
|
673
|
+
action: string;
|
|
674
|
+
targetId?: string;
|
|
675
|
+
targetPath: string;
|
|
676
|
+
targetDisplayName: string;
|
|
677
|
+
targetDescription: string;
|
|
678
|
+
targetItemType: string;
|
|
679
|
+
/** Derived tool use ID (name without 'card-' prefix). */
|
|
680
|
+
toolId?: string;
|
|
681
|
+
/** Path of the parent message (for child cards). Undefined for sibling cards. */
|
|
682
|
+
parentMessagePath?: string;
|
|
683
|
+
visibility: string;
|
|
684
|
+
}
|
|
685
|
+
/** Full response from fetchChannelMessagesWithCards — includes bundled cards. */
|
|
686
|
+
interface ChannelMessagesResponse {
|
|
687
|
+
messages: ChannelMessage[];
|
|
688
|
+
/** Cards that are direct children of messages in this page. Keyed by message path. */
|
|
689
|
+
messageCards: Map<string, ChannelCard[]>;
|
|
690
|
+
/** Cards that are direct siblings (children of the channel itself). */
|
|
691
|
+
siblingCards: ChannelCard[];
|
|
692
|
+
mode: 'top_level' | 'thread';
|
|
693
|
+
}
|
|
667
694
|
/**
|
|
668
695
|
* Fetch channel messages via the kernel's `get-channel-messages` method.
|
|
669
696
|
*
|
|
@@ -676,6 +703,17 @@ interface ChannelMessage {
|
|
|
676
703
|
* If omitted, returns top-level messages.
|
|
677
704
|
*/
|
|
678
705
|
declare function fetchChannelMessages(channelPath: string, parentMessageId?: string): Promise<ChannelMessage[]>;
|
|
706
|
+
/**
|
|
707
|
+
* Fetch channel messages WITH bundled cards from the kernel v2 response.
|
|
708
|
+
*
|
|
709
|
+
* The kernel's get-channel-messages (v2) returns messages interleaved with
|
|
710
|
+
* their associated cards (both sibling cards and child cards). This function
|
|
711
|
+
* parses both and groups child cards by their parent message path.
|
|
712
|
+
*
|
|
713
|
+
* This eliminates the N+1 query problem where the frontend previously made
|
|
714
|
+
* separate `list` calls for each message to fetch its cards.
|
|
715
|
+
*/
|
|
716
|
+
declare function fetchChannelMessagesWithCards(channelPath: string, parentMessageId?: string): Promise<ChannelMessagesResponse>;
|
|
679
717
|
/** Response shape from fetchChannelMessagesPage. */
|
|
680
718
|
interface ChannelMessagesPage {
|
|
681
719
|
messages: ChannelMessage[];
|
|
@@ -1482,14 +1520,24 @@ interface ChannelMessagesOptions {
|
|
|
1482
1520
|
realtime?: boolean;
|
|
1483
1521
|
enabled?: boolean;
|
|
1484
1522
|
}
|
|
1485
|
-
/**
|
|
1523
|
+
/**
|
|
1524
|
+
* Fetch channel messages via the kernel's `get-channel-messages` method.
|
|
1525
|
+
*
|
|
1526
|
+
* Now uses `fetchChannelMessagesWithCards` to get bundled cards in a single
|
|
1527
|
+
* request, eliminating the N+1 query problem. Cards are returned alongside
|
|
1528
|
+
* messages, grouped by parent message path.
|
|
1529
|
+
*/
|
|
1486
1530
|
declare function useChannelMessages(options: ChannelMessagesOptions): {
|
|
1487
1531
|
messages: ChannelMessage[];
|
|
1532
|
+
/** Cards grouped by parent message path (child cards of messages). */
|
|
1533
|
+
messageCards: Map<string, ChannelCard[]>;
|
|
1534
|
+
/** Cards that are direct siblings of the channel (not nested under a message). */
|
|
1535
|
+
siblingCards: ChannelCard[];
|
|
1488
1536
|
threads: ChannelMessage[];
|
|
1489
1537
|
isLoading: boolean;
|
|
1490
1538
|
isFetching: boolean;
|
|
1491
1539
|
error: Error | null;
|
|
1492
|
-
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<
|
|
1540
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ChannelMessagesResponse, Error>>;
|
|
1493
1541
|
};
|
|
1494
1542
|
/** Options for useInfiniteChannelMessages. */
|
|
1495
1543
|
interface InfiniteChannelMessagesOptions {
|
|
@@ -1875,4 +1923,4 @@ declare function uploadFile(file: File | Blob, options: UploadOptions, onProgres
|
|
|
1875
1923
|
*/
|
|
1876
1924
|
declare function useFileUpload(): UseFileUploadReturn;
|
|
1877
1925
|
|
|
1878
|
-
export { type AccountInfo, type Channel, type ChannelMessage, type ChannelMessagesOptions, type ChannelMessagesPage, type ChannelsOptions, type ComponentOpener, ComponentRenderer, type CreateParams, type DeleteParams, EnforcementDeniedError, type EnforcementPayload, type FieldDescriptor, type FileRef, type GatewayParams, type GatewayResponse, type InfiniteChannelMessagesOptions, type ItemVersionsOptions, type ItemVersionsResult, type ItemsFilter, KernelProvider, type LinkParams, type MoveParams, type Notification, type NotificationsOptions, type OpenEnvelope, type OpenOptions, type PrincipalData, type ResolveParams, type ResolveResponse, type ResolveResultItem, type SessionEntry, type TypeDefinition, type TypeHelpers, type TypeSchema, type UnreadCountsOptions, type UpdateParams, type UploadItem, type UploadOptions, type UploadResult, type UseFileUploadReturn, type VFSEdge, type VFSItem, auth, awaitScopeReady, callTool, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchEdgesForItem, fetchItemHistory, fetchItemVersions, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAssetUrl, getDefaultSort, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isScopeReady, listChildren, mount, mountRealtimeScope, normalizeItem, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, setCachedToken, setScope, setupRequireShim, signal, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAllChannels, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItemVersions, useItems, useLink, useList, useMemberFocus, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useResolve, useScope, useScopeReady, useSearch, useTheme, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, vfsKeys };
|
|
1926
|
+
export { type AccountInfo, type Channel, type ChannelCard, type ChannelMessage, type ChannelMessagesOptions, type ChannelMessagesPage, type ChannelMessagesResponse, type ChannelsOptions, type ComponentOpener, ComponentRenderer, type CreateParams, type DeleteParams, EnforcementDeniedError, type EnforcementPayload, type FieldDescriptor, type FileRef, type GatewayParams, type GatewayResponse, type InfiniteChannelMessagesOptions, type ItemVersionsOptions, type ItemVersionsResult, type ItemsFilter, KernelProvider, type LinkParams, type MoveParams, type Notification, type NotificationsOptions, type OpenEnvelope, type OpenOptions, type PrincipalData, type ResolveParams, type ResolveResponse, type ResolveResultItem, type SessionEntry, type TypeDefinition, type TypeHelpers, type TypeSchema, type UnreadCountsOptions, type UpdateParams, type UploadItem, type UploadOptions, type UploadResult, type UseFileUploadReturn, type VFSEdge, type VFSItem, auth, awaitScopeReady, callTool, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchChannelMessagesWithCards, fetchEdgesForItem, fetchItemHistory, fetchItemVersions, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAssetUrl, getDefaultSort, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isScopeReady, listChildren, mount, mountRealtimeScope, normalizeItem, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, setCachedToken, setScope, setupRequireShim, signal, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAllChannels, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItemVersions, useItems, useLink, useList, useMemberFocus, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useResolve, useScope, useScopeReady, useSearch, useTheme, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, vfsKeys };
|
package/dist/index.d.ts
CHANGED
|
@@ -664,6 +664,33 @@ interface ChannelMessage {
|
|
|
664
664
|
intent_card?: Record<string, unknown>;
|
|
665
665
|
thread_summary?: Array<Record<string, unknown>>;
|
|
666
666
|
}
|
|
667
|
+
/** A parsed card item bundled with channel messages from the kernel v2 response. */
|
|
668
|
+
interface ChannelCard {
|
|
669
|
+
id: string;
|
|
670
|
+
path: string;
|
|
671
|
+
name: string;
|
|
672
|
+
createdAt: string;
|
|
673
|
+
action: string;
|
|
674
|
+
targetId?: string;
|
|
675
|
+
targetPath: string;
|
|
676
|
+
targetDisplayName: string;
|
|
677
|
+
targetDescription: string;
|
|
678
|
+
targetItemType: string;
|
|
679
|
+
/** Derived tool use ID (name without 'card-' prefix). */
|
|
680
|
+
toolId?: string;
|
|
681
|
+
/** Path of the parent message (for child cards). Undefined for sibling cards. */
|
|
682
|
+
parentMessagePath?: string;
|
|
683
|
+
visibility: string;
|
|
684
|
+
}
|
|
685
|
+
/** Full response from fetchChannelMessagesWithCards — includes bundled cards. */
|
|
686
|
+
interface ChannelMessagesResponse {
|
|
687
|
+
messages: ChannelMessage[];
|
|
688
|
+
/** Cards that are direct children of messages in this page. Keyed by message path. */
|
|
689
|
+
messageCards: Map<string, ChannelCard[]>;
|
|
690
|
+
/** Cards that are direct siblings (children of the channel itself). */
|
|
691
|
+
siblingCards: ChannelCard[];
|
|
692
|
+
mode: 'top_level' | 'thread';
|
|
693
|
+
}
|
|
667
694
|
/**
|
|
668
695
|
* Fetch channel messages via the kernel's `get-channel-messages` method.
|
|
669
696
|
*
|
|
@@ -676,6 +703,17 @@ interface ChannelMessage {
|
|
|
676
703
|
* If omitted, returns top-level messages.
|
|
677
704
|
*/
|
|
678
705
|
declare function fetchChannelMessages(channelPath: string, parentMessageId?: string): Promise<ChannelMessage[]>;
|
|
706
|
+
/**
|
|
707
|
+
* Fetch channel messages WITH bundled cards from the kernel v2 response.
|
|
708
|
+
*
|
|
709
|
+
* The kernel's get-channel-messages (v2) returns messages interleaved with
|
|
710
|
+
* their associated cards (both sibling cards and child cards). This function
|
|
711
|
+
* parses both and groups child cards by their parent message path.
|
|
712
|
+
*
|
|
713
|
+
* This eliminates the N+1 query problem where the frontend previously made
|
|
714
|
+
* separate `list` calls for each message to fetch its cards.
|
|
715
|
+
*/
|
|
716
|
+
declare function fetchChannelMessagesWithCards(channelPath: string, parentMessageId?: string): Promise<ChannelMessagesResponse>;
|
|
679
717
|
/** Response shape from fetchChannelMessagesPage. */
|
|
680
718
|
interface ChannelMessagesPage {
|
|
681
719
|
messages: ChannelMessage[];
|
|
@@ -1482,14 +1520,24 @@ interface ChannelMessagesOptions {
|
|
|
1482
1520
|
realtime?: boolean;
|
|
1483
1521
|
enabled?: boolean;
|
|
1484
1522
|
}
|
|
1485
|
-
/**
|
|
1523
|
+
/**
|
|
1524
|
+
* Fetch channel messages via the kernel's `get-channel-messages` method.
|
|
1525
|
+
*
|
|
1526
|
+
* Now uses `fetchChannelMessagesWithCards` to get bundled cards in a single
|
|
1527
|
+
* request, eliminating the N+1 query problem. Cards are returned alongside
|
|
1528
|
+
* messages, grouped by parent message path.
|
|
1529
|
+
*/
|
|
1486
1530
|
declare function useChannelMessages(options: ChannelMessagesOptions): {
|
|
1487
1531
|
messages: ChannelMessage[];
|
|
1532
|
+
/** Cards grouped by parent message path (child cards of messages). */
|
|
1533
|
+
messageCards: Map<string, ChannelCard[]>;
|
|
1534
|
+
/** Cards that are direct siblings of the channel (not nested under a message). */
|
|
1535
|
+
siblingCards: ChannelCard[];
|
|
1488
1536
|
threads: ChannelMessage[];
|
|
1489
1537
|
isLoading: boolean;
|
|
1490
1538
|
isFetching: boolean;
|
|
1491
1539
|
error: Error | null;
|
|
1492
|
-
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<
|
|
1540
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ChannelMessagesResponse, Error>>;
|
|
1493
1541
|
};
|
|
1494
1542
|
/** Options for useInfiniteChannelMessages. */
|
|
1495
1543
|
interface InfiniteChannelMessagesOptions {
|
|
@@ -1875,4 +1923,4 @@ declare function uploadFile(file: File | Blob, options: UploadOptions, onProgres
|
|
|
1875
1923
|
*/
|
|
1876
1924
|
declare function useFileUpload(): UseFileUploadReturn;
|
|
1877
1925
|
|
|
1878
|
-
export { type AccountInfo, type Channel, type ChannelMessage, type ChannelMessagesOptions, type ChannelMessagesPage, type ChannelsOptions, type ComponentOpener, ComponentRenderer, type CreateParams, type DeleteParams, EnforcementDeniedError, type EnforcementPayload, type FieldDescriptor, type FileRef, type GatewayParams, type GatewayResponse, type InfiniteChannelMessagesOptions, type ItemVersionsOptions, type ItemVersionsResult, type ItemsFilter, KernelProvider, type LinkParams, type MoveParams, type Notification, type NotificationsOptions, type OpenEnvelope, type OpenOptions, type PrincipalData, type ResolveParams, type ResolveResponse, type ResolveResultItem, type SessionEntry, type TypeDefinition, type TypeHelpers, type TypeSchema, type UnreadCountsOptions, type UpdateParams, type UploadItem, type UploadOptions, type UploadResult, type UseFileUploadReturn, type VFSEdge, type VFSItem, auth, awaitScopeReady, callTool, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchEdgesForItem, fetchItemHistory, fetchItemVersions, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAssetUrl, getDefaultSort, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isScopeReady, listChildren, mount, mountRealtimeScope, normalizeItem, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, setCachedToken, setScope, setupRequireShim, signal, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAllChannels, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItemVersions, useItems, useLink, useList, useMemberFocus, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useResolve, useScope, useScopeReady, useSearch, useTheme, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, vfsKeys };
|
|
1926
|
+
export { type AccountInfo, type Channel, type ChannelCard, type ChannelMessage, type ChannelMessagesOptions, type ChannelMessagesPage, type ChannelMessagesResponse, type ChannelsOptions, type ComponentOpener, ComponentRenderer, type CreateParams, type DeleteParams, EnforcementDeniedError, type EnforcementPayload, type FieldDescriptor, type FileRef, type GatewayParams, type GatewayResponse, type InfiniteChannelMessagesOptions, type ItemVersionsOptions, type ItemVersionsResult, type ItemsFilter, KernelProvider, type LinkParams, type MoveParams, type Notification, type NotificationsOptions, type OpenEnvelope, type OpenOptions, type PrincipalData, type ResolveParams, type ResolveResponse, type ResolveResultItem, type SessionEntry, type TypeDefinition, type TypeHelpers, type TypeSchema, type UnreadCountsOptions, type UpdateParams, type UploadItem, type UploadOptions, type UploadResult, type UseFileUploadReturn, type VFSEdge, type VFSItem, auth, awaitScopeReady, callTool, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchChannelMessagesWithCards, fetchEdgesForItem, fetchItemHistory, fetchItemVersions, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAssetUrl, getDefaultSort, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isScopeReady, listChildren, mount, mountRealtimeScope, normalizeItem, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, setCachedToken, setScope, setupRequireShim, signal, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAllChannels, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItemVersions, useItems, useLink, useList, useMemberFocus, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useResolve, useScope, useScopeReady, useSearch, useTheme, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, vfsKeys };
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ __export(src_exports, {
|
|
|
30
30
|
emitEvent: () => emitEvent,
|
|
31
31
|
fetchChannelMessages: () => fetchChannelMessages,
|
|
32
32
|
fetchChannelMessagesPage: () => fetchChannelMessagesPage,
|
|
33
|
+
fetchChannelMessagesWithCards: () => fetchChannelMessagesWithCards,
|
|
33
34
|
fetchEdgesForItem: () => fetchEdgesForItem,
|
|
34
35
|
fetchItemHistory: () => fetchItemHistory,
|
|
35
36
|
fetchItemVersions: () => fetchItemVersions,
|
|
@@ -765,6 +766,26 @@ async function fetchItems(filter) {
|
|
|
765
766
|
return { items: [], total_hint: 0 };
|
|
766
767
|
}
|
|
767
768
|
}
|
|
769
|
+
function parseChannelCards(rawItems) {
|
|
770
|
+
return rawItems.filter((i) => i.item_type === "card").map((i) => {
|
|
771
|
+
const td = i.type_data || {};
|
|
772
|
+
return {
|
|
773
|
+
id: i.id || "",
|
|
774
|
+
path: i.path || "",
|
|
775
|
+
name: i.name || (i.path || "").split("/").pop() || "",
|
|
776
|
+
createdAt: i.created_at || "",
|
|
777
|
+
action: td.action || "created",
|
|
778
|
+
targetId: td.target_id || void 0,
|
|
779
|
+
targetPath: td.target_path || "",
|
|
780
|
+
targetDisplayName: td.target_display_name || "",
|
|
781
|
+
targetDescription: td.target_description || "",
|
|
782
|
+
targetItemType: td.target_item_type || "",
|
|
783
|
+
toolId: (i.name || "").startsWith("card-") ? (i.name || "").substring(5) : void 0,
|
|
784
|
+
parentMessagePath: i.parent_message_path || void 0,
|
|
785
|
+
visibility: td.visibility || "private"
|
|
786
|
+
};
|
|
787
|
+
}).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
788
|
+
}
|
|
768
789
|
function parseChannelMessages(rawItems) {
|
|
769
790
|
return rawItems.filter((i) => i.item_type === "message").map((i) => {
|
|
770
791
|
const td = i.type_data || {};
|
|
@@ -803,6 +824,40 @@ async function fetchChannelMessages(channelPath, parentMessageId) {
|
|
|
803
824
|
return [];
|
|
804
825
|
}
|
|
805
826
|
}
|
|
827
|
+
async function fetchChannelMessagesWithCards(channelPath, parentMessageId) {
|
|
828
|
+
try {
|
|
829
|
+
const params = { channel_path: channelPath };
|
|
830
|
+
if (parentMessageId) params.parent_message_id = parentMessageId;
|
|
831
|
+
const response = await gatewayCall("get-channel-messages", params);
|
|
832
|
+
const raw = response;
|
|
833
|
+
const items = raw.messages || [];
|
|
834
|
+
const messages = parseChannelMessages(items);
|
|
835
|
+
const cards = parseChannelCards(items);
|
|
836
|
+
const messageCards = /* @__PURE__ */ new Map();
|
|
837
|
+
const siblingCards = [];
|
|
838
|
+
for (const card of cards) {
|
|
839
|
+
if (card.parentMessagePath) {
|
|
840
|
+
const existing = messageCards.get(card.parentMessagePath) || [];
|
|
841
|
+
existing.push(card);
|
|
842
|
+
messageCards.set(card.parentMessagePath, existing);
|
|
843
|
+
} else {
|
|
844
|
+
siblingCards.push(card);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
return {
|
|
848
|
+
messages,
|
|
849
|
+
messageCards,
|
|
850
|
+
siblingCards,
|
|
851
|
+
mode: raw.mode || "top_level"
|
|
852
|
+
};
|
|
853
|
+
} catch (err) {
|
|
854
|
+
console.error(
|
|
855
|
+
`[gateway] Failed to fetch channel messages with cards for ${channelPath}:`,
|
|
856
|
+
err
|
|
857
|
+
);
|
|
858
|
+
return { messages: [], messageCards: /* @__PURE__ */ new Map(), siblingCards: [], mode: "top_level" };
|
|
859
|
+
}
|
|
860
|
+
}
|
|
806
861
|
async function fetchChannelMessagesPage(channelPath, options) {
|
|
807
862
|
try {
|
|
808
863
|
const params = { channel_path: channelPath };
|
|
@@ -2262,7 +2317,7 @@ function useChannelMessages(options) {
|
|
|
2262
2317
|
const debounceRef = useRef(null);
|
|
2263
2318
|
const query = useQuery({
|
|
2264
2319
|
queryKey: stableKey,
|
|
2265
|
-
queryFn: () =>
|
|
2320
|
+
queryFn: () => fetchChannelMessagesWithCards(channelPath, parentMessageId),
|
|
2266
2321
|
enabled: isEnabled
|
|
2267
2322
|
});
|
|
2268
2323
|
useEffect(() => {
|
|
@@ -2276,7 +2331,7 @@ function useChannelMessages(options) {
|
|
|
2276
2331
|
}, 500);
|
|
2277
2332
|
},
|
|
2278
2333
|
(data) => {
|
|
2279
|
-
return data.item_type === "message" && typeof data.path === "string" && data.path.startsWith(channelPath);
|
|
2334
|
+
return (data.item_type === "message" || data.item_type === "card") && typeof data.path === "string" && data.path.startsWith(channelPath);
|
|
2280
2335
|
}
|
|
2281
2336
|
);
|
|
2282
2337
|
return () => {
|
|
@@ -2284,9 +2339,16 @@ function useChannelMessages(options) {
|
|
|
2284
2339
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
2285
2340
|
};
|
|
2286
2341
|
}, [realtime, isEnabled, channelPath, stableKey, qc]);
|
|
2287
|
-
const
|
|
2342
|
+
const response = query.data;
|
|
2343
|
+
const messages = response?.messages ?? [];
|
|
2344
|
+
const messageCards = response?.messageCards ?? /* @__PURE__ */ new Map();
|
|
2345
|
+
const siblingCards = response?.siblingCards ?? [];
|
|
2288
2346
|
return {
|
|
2289
2347
|
messages,
|
|
2348
|
+
/** Cards grouped by parent message path (child cards of messages). */
|
|
2349
|
+
messageCards,
|
|
2350
|
+
/** Cards that are direct siblings of the channel (not nested under a message). */
|
|
2351
|
+
siblingCards,
|
|
2290
2352
|
threads: useMemo(() => messages.filter((m) => m.reply_count > 0), [messages]),
|
|
2291
2353
|
isLoading: query.isLoading,
|
|
2292
2354
|
isFetching: query.isFetching,
|
|
@@ -3115,6 +3177,6 @@ function useFileUpload() {
|
|
|
3115
3177
|
// src/index.ts
|
|
3116
3178
|
__registerSdkExports(src_exports);
|
|
3117
3179
|
|
|
3118
|
-
export { ComponentRenderer, EnforcementDeniedError, KernelProvider, auth, awaitScopeReady, callTool, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchEdgesForItem, fetchItemHistory, fetchItemVersions, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAssetUrl, getDefaultSort, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isScopeReady, listChildren, mount, mountRealtimeScope, normalizeItem, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, setCachedToken, setScope, setupRequireShim, signal, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAllChannels, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItemVersions, useItems, useLink, useList, useMemberFocus, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useResolve, useScope, useScopeReady, useSearch, useTheme, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, vfsKeys };
|
|
3180
|
+
export { ComponentRenderer, EnforcementDeniedError, KernelProvider, auth, awaitScopeReady, callTool, clearCachedToken, clearSession, createItem, disconnectSSE, disposeVfsRealtimeWs, emitEvent, fetchChannelMessages, fetchChannelMessagesPage, fetchChannelMessagesWithCards, fetchEdgesForItem, fetchItemHistory, fetchItemVersions, fetchItems, fetchMemberFocus, fetchOpenEnvelope, fetchRecentActivity, fetchTypeDefinitions, fetchVfsChildren, fetchVfsChildrenPage, fetchVfsItem, fetchVfsItemById, fetchVfsTree, gatewayCall, getAccessToken, getAssetUrl, getDefaultSort, getRequiredFormFields, getScope, getScopeVersion, getSessionEntry, initSession, initVfsRealtimeWs, interpretSchema, invalidateAllVfs, invalidateChannelMessages, invalidateChildren, invalidateItem, invalidateOpenEnvelope, invalidatePathAndParent, invalidateSubtree, invalidateTypes, isScopeReady, listChildren, mount, mountRealtimeScope, normalizeItem, ping, pushChanges, queryClient, readItem, registerCleanup, resetAllSdkState, resolvePrincipalId, setCachedToken, setScope, setupRequireShim, signal, subscribeScope, subscribeToEvents, subscribeToPath, subscribeToScope, unmountRealtimeScope, updateItem, uploadFile, useAccounts, useAllChannels, useAsset, useAuth, useChannelMessages, useChannels, useChildren, useComponent, useCreate, useDelete, useDmChannels, useEdges, useEventStream, useFileUpload, useInfiniteChannelMessages, useInfiniteChildren, useInfiniteItems, useItem, useItemById, useItemHistory, useItemVersions, useItems, useLink, useList, useMemberFocus, useMove, useMutation, useNotifications, useOpen, usePermission, usePermissions, usePrincipal, useRealtimeQuery, useRecentActivity, useResolve, useScope, useScopeReady, useSearch, useTheme, useTool, useTree, useType, useTypeHelpers, useTypes, useUnreadCounts, useUpdate, vfsKeys };
|
|
3119
3181
|
//# sourceMappingURL=index.js.map
|
|
3120
3182
|
//# sourceMappingURL=index.js.map
|