@tuturuuu/internal-api 0.0.1 → 0.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/ai-memory.d.ts +76 -0
- package/dist/ai-memory.d.ts.map +1 -0
- package/dist/ai-memory.js +59 -0
- package/dist/ai.d.ts +67 -3
- package/dist/ai.d.ts.map +1 -1
- package/dist/ai.js +121 -0
- package/dist/auth.d.ts +121 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +111 -0
- package/dist/calendar.d.ts +17 -1
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +9 -0
- package/dist/chat-conversations.d.ts +81 -0
- package/dist/chat-conversations.d.ts.map +1 -0
- package/dist/chat-conversations.js +384 -0
- package/dist/chat-internal.d.ts +11 -0
- package/dist/chat-internal.d.ts.map +1 -0
- package/dist/chat-internal.js +39 -0
- package/dist/chat-legacy.d.ts +23 -0
- package/dist/chat-legacy.d.ts.map +1 -0
- package/dist/chat-legacy.js +68 -0
- package/dist/chat-types.d.ts +262 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +2 -0
- package/dist/chat.d.ts +3 -45
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +17 -65
- package/dist/client.d.ts +5 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +50 -5
- package/dist/education.d.ts +288 -2
- package/dist/education.d.ts.map +1 -1
- package/dist/education.js +176 -0
- package/dist/external-project-team.d.ts +51 -0
- package/dist/external-project-team.d.ts.map +1 -0
- package/dist/external-project-team.js +137 -0
- package/dist/external-projects.d.ts +98 -10
- package/dist/external-projects.d.ts.map +1 -1
- package/dist/external-projects.js +92 -33
- package/dist/finance.d.ts +491 -3
- package/dist/finance.d.ts.map +1 -1
- package/dist/finance.js +611 -1
- package/dist/hive.d.ts +739 -0
- package/dist/hive.d.ts.map +1 -0
- package/dist/hive.js +333 -0
- package/dist/index.d.ts +31 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +350 -8
- package/dist/infrastructure.d.ts +955 -1
- package/dist/infrastructure.d.ts.map +1 -1
- package/dist/infrastructure.js +595 -0
- package/dist/inventory.d.ts +355 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +268 -0
- package/dist/mail.d.ts +125 -0
- package/dist/mail.d.ts.map +1 -1
- package/dist/mail.js +112 -1
- package/dist/meet.d.ts +54 -0
- package/dist/meet.d.ts.map +1 -0
- package/dist/meet.js +37 -0
- package/dist/mind.d.ts +55 -0
- package/dist/mind.d.ts.map +1 -0
- package/dist/mind.js +84 -0
- package/dist/posts.d.ts +33 -0
- package/dist/posts.d.ts.map +1 -1
- package/dist/posts.js +42 -0
- package/dist/promotions.d.ts +54 -0
- package/dist/promotions.d.ts.map +1 -1
- package/dist/promotions.js +52 -0
- package/dist/settings.d.ts +28 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +68 -0
- package/dist/storage.d.ts +32 -21
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +52 -32
- package/dist/tasks.d.ts +224 -4
- package/dist/tasks.d.ts.map +1 -1
- package/dist/tasks.js +204 -0
- package/dist/teach.d.ts +130 -0
- package/dist/teach.d.ts.map +1 -0
- package/dist/teach.js +110 -0
- package/dist/topic-announcements.d.ts +235 -0
- package/dist/topic-announcements.d.ts.map +1 -0
- package/dist/topic-announcements.js +182 -0
- package/dist/tulearn.d.ts +223 -0
- package/dist/tulearn.d.ts.map +1 -0
- package/dist/tulearn.js +97 -0
- package/dist/tutoring.d.ts +152 -0
- package/dist/tutoring.d.ts.map +1 -0
- package/dist/tutoring.js +58 -0
- package/dist/user-group-activity.d.ts +54 -0
- package/dist/user-group-activity.d.ts.map +1 -0
- package/dist/user-group-activity.js +11 -0
- package/dist/user-groups.d.ts +35 -0
- package/dist/user-groups.d.ts.map +1 -0
- package/dist/user-groups.js +84 -0
- package/dist/users.d.ts +83 -1
- package/dist/users.d.ts.map +1 -1
- package/dist/users.js +137 -0
- package/dist/workspace-configs.d.ts +2 -0
- package/dist/workspace-configs.d.ts.map +1 -1
- package/dist/workspace-configs.js +3 -1
- package/dist/workspace-user-audit.d.ts +1 -0
- package/dist/workspace-user-audit.d.ts.map +1 -1
- package/dist/workspaces.d.ts +57 -0
- package/dist/workspaces.d.ts.map +1 -1
- package/dist/workspaces.js +58 -1
- package/package.json +59 -6
package/dist/calendar.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TaskWithScheduling } from '@tuturuuu/types';
|
|
1
|
+
import type { CalendarConnection, TaskWithScheduling } from '@tuturuuu/types';
|
|
2
2
|
import type { CalendarEvent } from '@tuturuuu/types/primitives/calendar-event';
|
|
3
3
|
import type { InternalApiClientOptions } from './client';
|
|
4
4
|
export interface WorkspaceCalendarEventUpdatePayload {
|
|
@@ -73,6 +73,22 @@ export interface HabitSkipPayload {
|
|
|
73
73
|
occurrenceDate: string;
|
|
74
74
|
sourceEventId?: string | null;
|
|
75
75
|
}
|
|
76
|
+
export interface CalendarConnectionsResponse {
|
|
77
|
+
connections: CalendarConnection[];
|
|
78
|
+
}
|
|
79
|
+
export declare function listCalendarConnections(wsId: string, options?: InternalApiClientOptions): Promise<{
|
|
80
|
+
auth_token_id: string | null;
|
|
81
|
+
calendar_id: string;
|
|
82
|
+
calendar_name: string;
|
|
83
|
+
color: string | null;
|
|
84
|
+
created_at: string;
|
|
85
|
+
id: string;
|
|
86
|
+
is_enabled: boolean;
|
|
87
|
+
provider: string;
|
|
88
|
+
updated_at: string;
|
|
89
|
+
workspace_calendar_id: string | null;
|
|
90
|
+
ws_id: string;
|
|
91
|
+
}[]>;
|
|
76
92
|
export declare function updateWorkspaceCalendarEvent(wsId: string, eventId: string, payload: WorkspaceCalendarEventUpdatePayload, options?: InternalApiClientOptions): Promise<CalendarEvent>;
|
|
77
93
|
export declare function createWorkspaceCalendarEvent(wsId: string, payload: WorkspaceCalendarEventCreatePayload, options?: InternalApiClientOptions): Promise<CalendarEvent>;
|
|
78
94
|
export declare function listWorkspaceSchedulableTasks(wsId: string, query?: {
|
package/dist/calendar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../src/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../src/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAGzD,MAAM,WAAW,mCAAmC;IAClD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,mCAAmC;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,6BAA6B;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,2BACf,SAAQ,6BAA6B;IACrC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,IAAI,CAAC,EAAE,YAAY,GAAG,YAAY,CAAC;IACnC,KAAK,CAAC,EAAE,eAAe,GAAG,aAAa,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,EA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CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EACxC,OAAO,CAAC,EAAE,wBAAwB,wCAUnC;AAED,wBAAsB,gCAAgC,CACpD,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EACxC,OAAO,CAAC,EAAE,wBAAwB,yCAUnC;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,EACzB,OAAO,CAAC,EAAE,wBAAwB;aAGJ,IAAI;oBAAkB,MAAM;GAW3D;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,EACzB,OAAO,CAAC,EAAE,wBAAwB;aAGJ,IAAI;oBAAkB,MAAM;GAW3D"}
|
package/dist/calendar.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listCalendarConnections = listCalendarConnections;
|
|
3
4
|
exports.updateWorkspaceCalendarEvent = updateWorkspaceCalendarEvent;
|
|
4
5
|
exports.createWorkspaceCalendarEvent = createWorkspaceCalendarEvent;
|
|
5
6
|
exports.listWorkspaceSchedulableTasks = listWorkspaceSchedulableTasks;
|
|
@@ -10,6 +11,14 @@ exports.getWorkspaceHabitScheduleHistory = getWorkspaceHabitScheduleHistory;
|
|
|
10
11
|
exports.createWorkspaceHabitSkip = createWorkspaceHabitSkip;
|
|
11
12
|
exports.revokeWorkspaceHabitSkip = revokeWorkspaceHabitSkip;
|
|
12
13
|
const client_1 = require("./client");
|
|
14
|
+
async function listCalendarConnections(wsId, options) {
|
|
15
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
16
|
+
const response = await client.json('/api/v1/calendar/connections', {
|
|
17
|
+
query: { wsId },
|
|
18
|
+
cache: 'no-store',
|
|
19
|
+
});
|
|
20
|
+
return response.connections ?? [];
|
|
21
|
+
}
|
|
13
22
|
async function updateWorkspaceCalendarEvent(wsId, eventId, payload, options) {
|
|
14
23
|
const client = (0, client_1.getInternalApiClient)(options);
|
|
15
24
|
return client.json(`/api/v1/workspaces/${(0, client_1.encodePathSegment)(wsId)}/calendar/events/${(0, client_1.encodePathSegment)(eventId)}`, {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ChatAiObservability, ChatAiSettings, ChatConversation, ChatConversationPage, ChatFriendRequest, ChatLinkPreview, ChatMessage, ChatUserProfile, CreateChatConversationPayload, DeleteChatConversationResult, GenerateChatConversationTitleResult, SendChatMessagePayload, SendChatMessageResult, SendChatMessageStreamHandlers, UpdateChatAiSettingsPayload, UpdateChatConversationPayload } from './chat-types';
|
|
2
|
+
import { type InternalApiClientOptions } from './client';
|
|
3
|
+
export declare function listWorkspaceChatConversations(workspaceId: string, params?: {
|
|
4
|
+
archived?: 'active' | 'all' | 'archived';
|
|
5
|
+
limit?: number;
|
|
6
|
+
offset?: number;
|
|
7
|
+
}, options?: InternalApiClientOptions): Promise<ChatConversation[]>;
|
|
8
|
+
export declare function listWorkspaceChatConversationsPage(workspaceId: string, params?: {
|
|
9
|
+
archived?: 'active' | 'all' | 'archived';
|
|
10
|
+
limit?: number;
|
|
11
|
+
offset?: number;
|
|
12
|
+
}, options?: InternalApiClientOptions): Promise<ChatConversationPage>;
|
|
13
|
+
export declare function createWorkspaceChatConversation(workspaceId: string, payload: CreateChatConversationPayload, options?: InternalApiClientOptions): Promise<{
|
|
14
|
+
conversation: ChatConversation;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function deleteWorkspaceChatConversation(workspaceId: string, conversationId: string, options?: InternalApiClientOptions): Promise<{
|
|
17
|
+
result: DeleteChatConversationResult;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function updateWorkspaceChatConversation(workspaceId: string, conversationId: string, payload: UpdateChatConversationPayload, options?: InternalApiClientOptions): Promise<{
|
|
20
|
+
conversation: ChatConversation;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function generateWorkspaceChatConversationTitle(workspaceId: string, conversationId: string, options?: InternalApiClientOptions): Promise<GenerateChatConversationTitleResult>;
|
|
23
|
+
export declare function listWorkspaceChatConversationMessages(workspaceId: string, conversationId: string, options?: {
|
|
24
|
+
before?: string;
|
|
25
|
+
limit?: number;
|
|
26
|
+
}, clientOptions?: InternalApiClientOptions): Promise<ChatMessage[]>;
|
|
27
|
+
export declare function sendWorkspaceChatMessage(workspaceId: string, conversationId: string, payload: SendChatMessagePayload, options?: InternalApiClientOptions): Promise<SendChatMessageResult>;
|
|
28
|
+
export declare function sendWorkspaceChatMessageStream(workspaceId: string, conversationId: string, payload: SendChatMessagePayload, handlers?: SendChatMessageStreamHandlers, options?: InternalApiClientOptions): Promise<SendChatMessageResult>;
|
|
29
|
+
export declare function editWorkspaceChatMessage(workspaceId: string, conversationId: string, messageId: string, payload: {
|
|
30
|
+
content: string;
|
|
31
|
+
}, options?: InternalApiClientOptions): Promise<{
|
|
32
|
+
message: ChatMessage;
|
|
33
|
+
}>;
|
|
34
|
+
export declare function deleteWorkspaceChatMessage(workspaceId: string, conversationId: string, messageId: string, options?: InternalApiClientOptions): Promise<{
|
|
35
|
+
message: ChatMessage;
|
|
36
|
+
}>;
|
|
37
|
+
export declare function markWorkspaceChatConversationRead(workspaceId: string, conversationId: string, payload?: {
|
|
38
|
+
messageId?: string | null;
|
|
39
|
+
}, options?: InternalApiClientOptions): Promise<{
|
|
40
|
+
conversation: ChatConversation;
|
|
41
|
+
}>;
|
|
42
|
+
export declare function toggleWorkspaceChatReaction(workspaceId: string, conversationId: string, payload: {
|
|
43
|
+
emoji: string;
|
|
44
|
+
messageId: string;
|
|
45
|
+
}, options?: InternalApiClientOptions): Promise<{
|
|
46
|
+
message: ChatMessage;
|
|
47
|
+
}>;
|
|
48
|
+
export declare function getWorkspaceChatLinkPreviews(workspaceId: string, conversationId: string, urls: string[], options?: InternalApiClientOptions): Promise<ChatLinkPreview[]>;
|
|
49
|
+
export declare function getWorkspaceChatSharedContent(workspaceId: string, conversationId: string, options?: InternalApiClientOptions): Promise<{
|
|
50
|
+
files: import("./chat-types").ChatAttachment[];
|
|
51
|
+
links: import("./chat-types").ChatSharedLink[];
|
|
52
|
+
photos: import("./chat-types").ChatAttachment[];
|
|
53
|
+
}>;
|
|
54
|
+
export declare function getWorkspaceChatAiSettings(workspaceId: string, conversationId: string, options?: InternalApiClientOptions): Promise<ChatAiSettings>;
|
|
55
|
+
export declare function updateWorkspaceChatAiSettings(workspaceId: string, conversationId: string, payload: UpdateChatAiSettingsPayload, options?: InternalApiClientOptions): Promise<{
|
|
56
|
+
settings: ChatAiSettings;
|
|
57
|
+
}>;
|
|
58
|
+
export declare function getWorkspaceChatAiObservability(workspaceId: string, conversationId: string, options?: InternalApiClientOptions): Promise<ChatAiObservability>;
|
|
59
|
+
export declare function searchWorkspaceChatDirectory(workspaceId: string, query: string, options?: InternalApiClientOptions): Promise<ChatUserProfile[]>;
|
|
60
|
+
export declare function searchWorkspaceChatMessages(workspaceId: string, query: string, options?: InternalApiClientOptions): Promise<ChatMessage[]>;
|
|
61
|
+
export declare function listWorkspaceChatFriendRequests(workspaceId: string, options?: InternalApiClientOptions): Promise<{
|
|
62
|
+
accepted: ChatFriendRequest[];
|
|
63
|
+
incoming: ChatFriendRequest[];
|
|
64
|
+
outgoing: ChatFriendRequest[];
|
|
65
|
+
}>;
|
|
66
|
+
export declare function createWorkspaceChatFriendRequest(workspaceId: string, payload: {
|
|
67
|
+
email: string;
|
|
68
|
+
}, options?: InternalApiClientOptions): Promise<{
|
|
69
|
+
queued: true;
|
|
70
|
+
}>;
|
|
71
|
+
export declare function respondWorkspaceChatFriendRequest(workspaceId: string, requestId: string, payload: {
|
|
72
|
+
status: 'accepted' | 'declined';
|
|
73
|
+
}, options?: InternalApiClientOptions): Promise<{
|
|
74
|
+
request: ChatFriendRequest;
|
|
75
|
+
}>;
|
|
76
|
+
export declare function revokeWorkspaceChatFriendRequest(workspaceId: string, requestId: string, options?: InternalApiClientOptions): Promise<{
|
|
77
|
+
request: ChatFriendRequest;
|
|
78
|
+
}>;
|
|
79
|
+
export declare function uploadWorkspaceChatAttachment(workspaceId: string, conversationId: string, file: File, options?: InternalApiClientOptions): Promise<import("./chat-types").ChatAttachmentDraft>;
|
|
80
|
+
export declare function getWorkspaceChatAttachmentSignedUrl(workspaceId: string, conversationId: string, attachmentId: string, options?: InternalApiClientOptions): Promise<string>;
|
|
81
|
+
//# sourceMappingURL=chat-conversations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-conversations.d.ts","sourceRoot":"","sources":["../src/chat-conversations.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EAEjB,eAAe,EACf,WAAW,EAGX,eAAe,EACf,6BAA6B,EAC7B,4BAA4B,EAC5B,mCAAmC,EACnC,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,2BAA2B,EAC3B,6BAA6B,EAC9B,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,UAAU,CAAC;AAKlB,wBAAsB,8BAA8B,CAClD,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE;IACP,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,UAAU,CAAC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,EACD,OAAO,CAAC,EAAE,wBAAwB,+BAQnC;AAED,wBAAsB,kCAAkC,CACtD,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE;IACP,QAAQ,CAAC,EAAE,QAAQ,GAA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 +1,384 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listWorkspaceChatConversations = listWorkspaceChatConversations;
|
|
4
|
+
exports.listWorkspaceChatConversationsPage = listWorkspaceChatConversationsPage;
|
|
5
|
+
exports.createWorkspaceChatConversation = createWorkspaceChatConversation;
|
|
6
|
+
exports.deleteWorkspaceChatConversation = deleteWorkspaceChatConversation;
|
|
7
|
+
exports.updateWorkspaceChatConversation = updateWorkspaceChatConversation;
|
|
8
|
+
exports.generateWorkspaceChatConversationTitle = generateWorkspaceChatConversationTitle;
|
|
9
|
+
exports.listWorkspaceChatConversationMessages = listWorkspaceChatConversationMessages;
|
|
10
|
+
exports.sendWorkspaceChatMessage = sendWorkspaceChatMessage;
|
|
11
|
+
exports.sendWorkspaceChatMessageStream = sendWorkspaceChatMessageStream;
|
|
12
|
+
exports.editWorkspaceChatMessage = editWorkspaceChatMessage;
|
|
13
|
+
exports.deleteWorkspaceChatMessage = deleteWorkspaceChatMessage;
|
|
14
|
+
exports.markWorkspaceChatConversationRead = markWorkspaceChatConversationRead;
|
|
15
|
+
exports.toggleWorkspaceChatReaction = toggleWorkspaceChatReaction;
|
|
16
|
+
exports.getWorkspaceChatLinkPreviews = getWorkspaceChatLinkPreviews;
|
|
17
|
+
exports.getWorkspaceChatSharedContent = getWorkspaceChatSharedContent;
|
|
18
|
+
exports.getWorkspaceChatAiSettings = getWorkspaceChatAiSettings;
|
|
19
|
+
exports.updateWorkspaceChatAiSettings = updateWorkspaceChatAiSettings;
|
|
20
|
+
exports.getWorkspaceChatAiObservability = getWorkspaceChatAiObservability;
|
|
21
|
+
exports.searchWorkspaceChatDirectory = searchWorkspaceChatDirectory;
|
|
22
|
+
exports.searchWorkspaceChatMessages = searchWorkspaceChatMessages;
|
|
23
|
+
exports.listWorkspaceChatFriendRequests = listWorkspaceChatFriendRequests;
|
|
24
|
+
exports.createWorkspaceChatFriendRequest = createWorkspaceChatFriendRequest;
|
|
25
|
+
exports.respondWorkspaceChatFriendRequest = respondWorkspaceChatFriendRequest;
|
|
26
|
+
exports.revokeWorkspaceChatFriendRequest = revokeWorkspaceChatFriendRequest;
|
|
27
|
+
exports.uploadWorkspaceChatAttachment = uploadWorkspaceChatAttachment;
|
|
28
|
+
exports.getWorkspaceChatAttachmentSignedUrl = getWorkspaceChatAttachmentSignedUrl;
|
|
29
|
+
const ai_1 = require("./ai");
|
|
30
|
+
const chat_internal_1 = require("./chat-internal");
|
|
31
|
+
const client_1 = require("./client");
|
|
32
|
+
const AI_CHAT_CONVERSATION_PREFIXES = ['ai-chat-', 'legacy-ai-'];
|
|
33
|
+
const AI_CHAT_FILE_ATTACHMENT_PREFIX = 'ai-file:';
|
|
34
|
+
async function listWorkspaceChatConversations(workspaceId, params, options) {
|
|
35
|
+
const page = await listWorkspaceChatConversationsPage(workspaceId, params, options);
|
|
36
|
+
return page.conversations;
|
|
37
|
+
}
|
|
38
|
+
async function listWorkspaceChatConversationsPage(workspaceId, params, options) {
|
|
39
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
40
|
+
const payload = await client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations`, {
|
|
41
|
+
cache: 'no-store',
|
|
42
|
+
query: {
|
|
43
|
+
archived: params?.archived,
|
|
44
|
+
limit: params?.limit,
|
|
45
|
+
offset: params?.offset,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
const conversations = (payload.conversations ?? []).filter((conversation) => Boolean(conversation?.id && conversation.type));
|
|
49
|
+
return {
|
|
50
|
+
conversations,
|
|
51
|
+
nextOffset: typeof payload.nextOffset === 'number' ? payload.nextOffset : null,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function createWorkspaceChatConversation(workspaceId, payload, options) {
|
|
55
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
56
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations`, {
|
|
57
|
+
body: JSON.stringify(payload),
|
|
58
|
+
cache: 'no-store',
|
|
59
|
+
headers: { 'Content-Type': 'application/json' },
|
|
60
|
+
method: 'POST',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async function deleteWorkspaceChatConversation(workspaceId, conversationId, options) {
|
|
64
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
65
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}`, {
|
|
66
|
+
cache: 'no-store',
|
|
67
|
+
method: 'DELETE',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async function updateWorkspaceChatConversation(workspaceId, conversationId, payload, options) {
|
|
71
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
72
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}`, {
|
|
73
|
+
body: JSON.stringify(payload),
|
|
74
|
+
cache: 'no-store',
|
|
75
|
+
headers: { 'Content-Type': 'application/json' },
|
|
76
|
+
method: 'PATCH',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async function generateWorkspaceChatConversationTitle(workspaceId, conversationId, options) {
|
|
80
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
81
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/title`, {
|
|
82
|
+
cache: 'no-store',
|
|
83
|
+
method: 'POST',
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
async function listWorkspaceChatConversationMessages(workspaceId, conversationId, options, clientOptions) {
|
|
87
|
+
const client = (0, client_1.getInternalApiClient)(clientOptions);
|
|
88
|
+
const payload = await client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/messages`, {
|
|
89
|
+
cache: 'no-store',
|
|
90
|
+
query: {
|
|
91
|
+
before: options?.before,
|
|
92
|
+
limit: options?.limit,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
return payload.messages ?? [];
|
|
96
|
+
}
|
|
97
|
+
async function sendWorkspaceChatMessage(workspaceId, conversationId, payload, options) {
|
|
98
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
99
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/messages`, {
|
|
100
|
+
body: JSON.stringify(payload),
|
|
101
|
+
cache: 'no-store',
|
|
102
|
+
headers: { 'Content-Type': 'application/json' },
|
|
103
|
+
method: 'POST',
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async function sendWorkspaceChatMessageStream(workspaceId, conversationId, payload, handlers = {}, options) {
|
|
107
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
108
|
+
const response = await client.fetch(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/messages`, {
|
|
109
|
+
body: JSON.stringify(payload),
|
|
110
|
+
cache: 'no-store',
|
|
111
|
+
headers: {
|
|
112
|
+
Accept: 'application/x-ndjson',
|
|
113
|
+
'Content-Type': 'application/json',
|
|
114
|
+
},
|
|
115
|
+
method: 'POST',
|
|
116
|
+
});
|
|
117
|
+
if (!response.ok) {
|
|
118
|
+
throw new Error(await readInternalApiErrorMessage(response));
|
|
119
|
+
}
|
|
120
|
+
if (!response.body) {
|
|
121
|
+
return response.json();
|
|
122
|
+
}
|
|
123
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
124
|
+
if (!contentType.includes('application/x-ndjson')) {
|
|
125
|
+
return response.json();
|
|
126
|
+
}
|
|
127
|
+
const messages = [];
|
|
128
|
+
const decoder = new TextDecoder();
|
|
129
|
+
const reader = response.body.getReader();
|
|
130
|
+
let buffer = '';
|
|
131
|
+
let assistantError;
|
|
132
|
+
const processEvent = (event) => {
|
|
133
|
+
if (!event)
|
|
134
|
+
return;
|
|
135
|
+
if (event.type === 'error') {
|
|
136
|
+
if (messages.length > 0) {
|
|
137
|
+
assistantError = event.message || 'Assistant response failed';
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
throw new Error(event.message);
|
|
141
|
+
}
|
|
142
|
+
if (event.type === 'message') {
|
|
143
|
+
messages.push(event.message);
|
|
144
|
+
handlers.onMessage?.(event.message);
|
|
145
|
+
}
|
|
146
|
+
else if (event.type === 'assistant_delta') {
|
|
147
|
+
handlers.onAssistantDelta?.(event.delta);
|
|
148
|
+
}
|
|
149
|
+
else if (event.type === 'assistant_part') {
|
|
150
|
+
handlers.onAssistantPart?.(event.part);
|
|
151
|
+
}
|
|
152
|
+
else if (event.type === 'messages') {
|
|
153
|
+
messages.push(...event.messages);
|
|
154
|
+
handlers.onMessages?.(event.messages);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
while (true) {
|
|
158
|
+
const { done, value } = await reader.read();
|
|
159
|
+
if (value) {
|
|
160
|
+
buffer += decoder.decode(value, { stream: !done });
|
|
161
|
+
const lines = buffer.split('\n');
|
|
162
|
+
buffer = lines.pop() ?? '';
|
|
163
|
+
for (const line of lines) {
|
|
164
|
+
processEvent(parseChatMessageStreamEvent(line));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (done)
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
processEvent(parseChatMessageStreamEvent(buffer));
|
|
171
|
+
const message = messages.at(-1);
|
|
172
|
+
if (!message) {
|
|
173
|
+
throw new Error('No message was returned');
|
|
174
|
+
}
|
|
175
|
+
return assistantError
|
|
176
|
+
? { assistantError, message, messages }
|
|
177
|
+
: { message, messages };
|
|
178
|
+
}
|
|
179
|
+
async function editWorkspaceChatMessage(workspaceId, conversationId, messageId, payload, options) {
|
|
180
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
181
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/messages/${(0, client_1.encodePathSegment)(messageId)}`, {
|
|
182
|
+
body: JSON.stringify(payload),
|
|
183
|
+
cache: 'no-store',
|
|
184
|
+
headers: { 'Content-Type': 'application/json' },
|
|
185
|
+
method: 'PATCH',
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
async function deleteWorkspaceChatMessage(workspaceId, conversationId, messageId, options) {
|
|
189
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
190
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/messages/${(0, client_1.encodePathSegment)(messageId)}`, {
|
|
191
|
+
cache: 'no-store',
|
|
192
|
+
method: 'DELETE',
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async function markWorkspaceChatConversationRead(workspaceId, conversationId, payload, options) {
|
|
196
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
197
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/read`, {
|
|
198
|
+
body: JSON.stringify(payload ?? {}),
|
|
199
|
+
cache: 'no-store',
|
|
200
|
+
headers: { 'Content-Type': 'application/json' },
|
|
201
|
+
method: 'POST',
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
async function toggleWorkspaceChatReaction(workspaceId, conversationId, payload, options) {
|
|
205
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
206
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/reactions`, {
|
|
207
|
+
body: JSON.stringify(payload),
|
|
208
|
+
cache: 'no-store',
|
|
209
|
+
headers: { 'Content-Type': 'application/json' },
|
|
210
|
+
method: 'POST',
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
async function getWorkspaceChatLinkPreviews(workspaceId, conversationId, urls, options) {
|
|
214
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
215
|
+
const payload = await client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/link-previews`, {
|
|
216
|
+
body: JSON.stringify({ urls }),
|
|
217
|
+
cache: 'no-store',
|
|
218
|
+
headers: { 'Content-Type': 'application/json' },
|
|
219
|
+
method: 'POST',
|
|
220
|
+
});
|
|
221
|
+
return payload.previews ?? [];
|
|
222
|
+
}
|
|
223
|
+
async function getWorkspaceChatSharedContent(workspaceId, conversationId, options) {
|
|
224
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
225
|
+
const payload = await client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/shared-content`, { cache: 'no-store' });
|
|
226
|
+
return {
|
|
227
|
+
files: payload.sharedContent?.files ?? [],
|
|
228
|
+
links: payload.sharedContent?.links ?? [],
|
|
229
|
+
photos: payload.sharedContent?.photos ?? [],
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
async function getWorkspaceChatAiSettings(workspaceId, conversationId, options) {
|
|
233
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
234
|
+
const payload = await client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/ai-settings`, { cache: 'no-store' });
|
|
235
|
+
return payload.settings;
|
|
236
|
+
}
|
|
237
|
+
async function updateWorkspaceChatAiSettings(workspaceId, conversationId, payload, options) {
|
|
238
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
239
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/ai-settings`, {
|
|
240
|
+
body: JSON.stringify(payload),
|
|
241
|
+
cache: 'no-store',
|
|
242
|
+
headers: { 'Content-Type': 'application/json' },
|
|
243
|
+
method: 'PATCH',
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
async function getWorkspaceChatAiObservability(workspaceId, conversationId, options) {
|
|
247
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
248
|
+
const payload = await client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/ai-observability`, { cache: 'no-store' });
|
|
249
|
+
return payload.observability;
|
|
250
|
+
}
|
|
251
|
+
async function searchWorkspaceChatDirectory(workspaceId, query, options) {
|
|
252
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
253
|
+
const payload = await client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/directory`, {
|
|
254
|
+
cache: 'no-store',
|
|
255
|
+
query: { q: query },
|
|
256
|
+
});
|
|
257
|
+
return payload.users ?? [];
|
|
258
|
+
}
|
|
259
|
+
async function searchWorkspaceChatMessages(workspaceId, query, options) {
|
|
260
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
261
|
+
const payload = await client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/search`, {
|
|
262
|
+
cache: 'no-store',
|
|
263
|
+
query: { q: query },
|
|
264
|
+
});
|
|
265
|
+
return payload.messages ?? [];
|
|
266
|
+
}
|
|
267
|
+
async function readInternalApiErrorMessage(response) {
|
|
268
|
+
const fallbackMessage = `Internal API request failed: ${response.status}`;
|
|
269
|
+
const text = await response.text().catch(() => '');
|
|
270
|
+
try {
|
|
271
|
+
const data = JSON.parse(text);
|
|
272
|
+
return data.message || data.error || fallbackMessage;
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
return text || fallbackMessage;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function parseChatMessageStreamEvent(line) {
|
|
279
|
+
const trimmed = line.trim();
|
|
280
|
+
if (!trimmed)
|
|
281
|
+
return null;
|
|
282
|
+
try {
|
|
283
|
+
const event = JSON.parse(trimmed);
|
|
284
|
+
return typeof event?.type === 'string' ? event : null;
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
async function listWorkspaceChatFriendRequests(workspaceId, options) {
|
|
291
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
292
|
+
const payload = await client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/friend-requests`, { cache: 'no-store' });
|
|
293
|
+
return {
|
|
294
|
+
accepted: payload.accepted ?? [],
|
|
295
|
+
incoming: payload.incoming ?? [],
|
|
296
|
+
outgoing: payload.outgoing ?? [],
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
async function createWorkspaceChatFriendRequest(workspaceId, payload, options) {
|
|
300
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
301
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/friend-requests`, {
|
|
302
|
+
body: JSON.stringify(payload),
|
|
303
|
+
cache: 'no-store',
|
|
304
|
+
headers: { 'Content-Type': 'application/json' },
|
|
305
|
+
method: 'POST',
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
async function respondWorkspaceChatFriendRequest(workspaceId, requestId, payload, options) {
|
|
309
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
310
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/friend-requests/${(0, client_1.encodePathSegment)(requestId)}`, {
|
|
311
|
+
body: JSON.stringify(payload),
|
|
312
|
+
cache: 'no-store',
|
|
313
|
+
headers: { 'Content-Type': 'application/json' },
|
|
314
|
+
method: 'PATCH',
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
async function revokeWorkspaceChatFriendRequest(workspaceId, requestId, options) {
|
|
318
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
319
|
+
return client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/friend-requests/${(0, client_1.encodePathSegment)(requestId)}`, {
|
|
320
|
+
cache: 'no-store',
|
|
321
|
+
method: 'DELETE',
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
async function uploadWorkspaceChatAttachment(workspaceId, conversationId, file, options) {
|
|
325
|
+
const aiChatId = getAiChatResourceIdFromConversationId(conversationId);
|
|
326
|
+
if (aiChatId) {
|
|
327
|
+
return (0, ai_1.uploadAiChatFile)({
|
|
328
|
+
chatId: aiChatId,
|
|
329
|
+
file,
|
|
330
|
+
workspaceId,
|
|
331
|
+
}, options);
|
|
332
|
+
}
|
|
333
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
334
|
+
const fetchImpl = options?.fetch ?? globalThis.fetch;
|
|
335
|
+
const uploadPayload = await client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/attachments/upload-url`, {
|
|
336
|
+
body: JSON.stringify({
|
|
337
|
+
contentType: file.type || 'application/octet-stream',
|
|
338
|
+
filename: file.name,
|
|
339
|
+
sizeBytes: file.size,
|
|
340
|
+
}),
|
|
341
|
+
cache: 'no-store',
|
|
342
|
+
headers: { 'Content-Type': 'application/json' },
|
|
343
|
+
method: 'POST',
|
|
344
|
+
});
|
|
345
|
+
await (0, chat_internal_1.uploadFileWithSignedUrl)(file, uploadPayload, fetchImpl);
|
|
346
|
+
return uploadPayload.attachment;
|
|
347
|
+
}
|
|
348
|
+
function getAiChatResourceIdFromConversationId(conversationId) {
|
|
349
|
+
for (const prefix of AI_CHAT_CONVERSATION_PREFIXES) {
|
|
350
|
+
if (conversationId.startsWith(prefix)) {
|
|
351
|
+
return conversationId.slice(prefix.length);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
async function getWorkspaceChatAttachmentSignedUrl(workspaceId, conversationId, attachmentId, options) {
|
|
357
|
+
const client = (0, client_1.getInternalApiClient)(options);
|
|
358
|
+
const aiChatFilePath = decodeAiChatFileAttachmentPath(attachmentId);
|
|
359
|
+
if (getAiChatResourceIdFromConversationId(conversationId) && aiChatFilePath) {
|
|
360
|
+
const payload = await client.json('/api/ai/chat/signed-read-url', {
|
|
361
|
+
body: JSON.stringify({ paths: [aiChatFilePath] }),
|
|
362
|
+
cache: 'no-store',
|
|
363
|
+
headers: { 'Content-Type': 'application/json' },
|
|
364
|
+
method: 'POST',
|
|
365
|
+
});
|
|
366
|
+
const signedUrl = payload.urls?.[0]?.signedUrl;
|
|
367
|
+
if (!signedUrl) {
|
|
368
|
+
throw new Error('Attachment URL is unavailable');
|
|
369
|
+
}
|
|
370
|
+
return signedUrl;
|
|
371
|
+
}
|
|
372
|
+
const payload = await client.json(`${(0, chat_internal_1.chatBasePath)(workspaceId)}/conversations/${(0, client_1.encodePathSegment)(conversationId)}/attachments/${(0, client_1.encodePathSegment)(attachmentId)}`, { cache: 'no-store' });
|
|
373
|
+
return payload.signedUrl;
|
|
374
|
+
}
|
|
375
|
+
function decodeAiChatFileAttachmentPath(attachmentId) {
|
|
376
|
+
if (!attachmentId.startsWith(AI_CHAT_FILE_ATTACHMENT_PREFIX))
|
|
377
|
+
return null;
|
|
378
|
+
try {
|
|
379
|
+
return decodeURIComponent(attachmentId.slice(AI_CHAT_FILE_ATTACHMENT_PREFIX.length));
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChatAttachmentDraft } from './chat-types';
|
|
2
|
+
export interface ChatUploadUrlResponse {
|
|
3
|
+
attachment: ChatAttachmentDraft;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
maxSizeBytes: number;
|
|
6
|
+
signedUrl: string;
|
|
7
|
+
token?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function chatBasePath(workspaceId: string): string;
|
|
10
|
+
export declare function uploadFileWithSignedUrl(file: File, payload: ChatUploadUrlResponse, fetchImpl: typeof fetch): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=chat-internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-internal.d.ts","sourceRoot":"","sources":["../src/chat-internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGxD,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,mBAAmB,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,UAE/C;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,OAAO,KAAK,iBAsCxB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chatBasePath = chatBasePath;
|
|
4
|
+
exports.uploadFileWithSignedUrl = uploadFileWithSignedUrl;
|
|
5
|
+
const client_1 = require("./client");
|
|
6
|
+
function chatBasePath(workspaceId) {
|
|
7
|
+
return `/api/v1/workspaces/${(0, client_1.encodePathSegment)(workspaceId)}/chat`;
|
|
8
|
+
}
|
|
9
|
+
async function uploadFileWithSignedUrl(file, payload, fetchImpl) {
|
|
10
|
+
const headers = {
|
|
11
|
+
...(payload.headers ?? {}),
|
|
12
|
+
};
|
|
13
|
+
if (!headers['Content-Type']) {
|
|
14
|
+
headers['Content-Type'] = file.type || 'application/octet-stream';
|
|
15
|
+
}
|
|
16
|
+
if (payload.token) {
|
|
17
|
+
headers.Authorization = `Bearer ${payload.token}`;
|
|
18
|
+
}
|
|
19
|
+
let response = await fetchImpl(payload.signedUrl, {
|
|
20
|
+
body: file,
|
|
21
|
+
cache: 'no-store',
|
|
22
|
+
headers,
|
|
23
|
+
method: 'PUT',
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok && headers['Content-Type']) {
|
|
26
|
+
const fallbackHeaders = { ...headers };
|
|
27
|
+
delete fallbackHeaders['Content-Type'];
|
|
28
|
+
response = await fetchImpl(payload.signedUrl, {
|
|
29
|
+
body: file,
|
|
30
|
+
cache: 'no-store',
|
|
31
|
+
headers: fallbackHeaders,
|
|
32
|
+
method: 'PUT',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
const message = await response.text().catch(() => '');
|
|
37
|
+
throw new Error(`Failed to upload file (${response.status})${message ? `: ${message}` : ''}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { WorkspaceChatChannel, WorkspaceChatMessage, WorkspaceChatParticipant } from './chat-types';
|
|
2
|
+
import { type InternalApiClientOptions } from './client';
|
|
3
|
+
export declare function listWorkspaceChatChannels(workspaceId: string, options?: InternalApiClientOptions): Promise<WorkspaceChatChannel[]>;
|
|
4
|
+
export declare function createWorkspaceChatChannel(workspaceId: string, name: string, options?: InternalApiClientOptions): Promise<{
|
|
5
|
+
channel: WorkspaceChatChannel;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function listWorkspaceChatMessages(workspaceId: string, channelId: string, options?: InternalApiClientOptions): Promise<WorkspaceChatMessage[]>;
|
|
8
|
+
export declare function createWorkspaceChatMessage(workspaceId: string, channelId: string, content: string, options?: InternalApiClientOptions): Promise<{
|
|
9
|
+
message: WorkspaceChatMessage;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function listWorkspaceChatParticipants(workspaceId: string, channelId: string, options?: InternalApiClientOptions): Promise<WorkspaceChatParticipant[]>;
|
|
12
|
+
export declare function upsertWorkspaceChatParticipant(workspaceId: string, channelId: string, payload: {
|
|
13
|
+
last_read_at?: string;
|
|
14
|
+
}, options?: InternalApiClientOptions): Promise<{
|
|
15
|
+
success: true;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function upsertWorkspaceChatTyping(workspaceId: string, channelId: string, options?: InternalApiClientOptions): Promise<{
|
|
18
|
+
success: true;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function deleteWorkspaceChatTyping(workspaceId: string, channelId: string, options?: InternalApiClientOptions): Promise<{
|
|
21
|
+
success: true;
|
|
22
|
+
}>;
|
|
23
|
+
//# sourceMappingURL=chat-legacy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-legacy.d.ts","sourceRoot":"","sources":["../src/chat-legacy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,UAAU,CAAC;AAElB,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,wBAAwB,mCAQnC;AAED,wBAAsB,0BAA0B,CAC9C,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,wBAAwB;aAGJ,oBAAoB;GASnD;AAED,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,wBAAwB,mCAUnC;AAED,wBAAsB,0BAA0B,CAC9C,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,wBAAwB;aAGJ,oBAAoB;GAWnD;AAED,wBAAsB,6BAA6B,CACjD,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,wBAAwB,uCAYnC;AAED,wBAAsB,8BAA8B,CAClD,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAClC,OAAO,CAAC,EAAE,wBAAwB;aAGJ,IAAI;GAWnC;AAED,w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