@nurama/sdk 0.0.0-stage → 1.4.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +1080 -2
- package/dist/BotClient.d.ts +66 -0
- package/dist/BotClient.d.ts.map +1 -0
- package/dist/BotClient.js +68 -0
- package/dist/BotClient.js.map +1 -0
- package/dist/NuramaClient.d.ts +480 -0
- package/dist/NuramaClient.d.ts.map +1 -0
- package/dist/NuramaClient.js +902 -0
- package/dist/NuramaClient.js.map +1 -0
- package/dist/browser/nurama-bot-sdk.js +12051 -0
- package/dist/browser/nurama-bot-sdk.min.js +1 -0
- package/dist/browser/nurama-sdk.js +12003 -0
- package/dist/browser/nurama-sdk.min.js +1 -0
- package/dist/routes/ai.d.ts +280 -0
- package/dist/routes/ai.d.ts.map +1 -0
- package/dist/routes/ai.js +173 -0
- package/dist/routes/ai.js.map +1 -0
- package/dist/routes/asset.d.ts +493 -0
- package/dist/routes/asset.d.ts.map +1 -0
- package/dist/routes/asset.js +848 -0
- package/dist/routes/asset.js.map +1 -0
- package/dist/routes/auth.d.ts +218 -0
- package/dist/routes/auth.d.ts.map +1 -0
- package/dist/routes/auth.js +454 -0
- package/dist/routes/auth.js.map +1 -0
- package/dist/routes/blogPosts.d.ts +17 -0
- package/dist/routes/blogPosts.d.ts.map +1 -0
- package/dist/routes/blogPosts.js +29 -0
- package/dist/routes/blogPosts.js.map +1 -0
- package/dist/routes/board.d.ts +187 -0
- package/dist/routes/board.d.ts.map +1 -0
- package/dist/routes/board.js +270 -0
- package/dist/routes/board.js.map +1 -0
- package/dist/routes/bot.d.ts +202 -0
- package/dist/routes/bot.d.ts.map +1 -0
- package/dist/routes/bot.js +229 -0
- package/dist/routes/bot.js.map +1 -0
- package/dist/routes/chat.d.ts +842 -0
- package/dist/routes/chat.d.ts.map +1 -0
- package/dist/routes/chat.js +863 -0
- package/dist/routes/chat.js.map +1 -0
- package/dist/routes/chatAi.d.ts +51 -0
- package/dist/routes/chatAi.d.ts.map +1 -0
- package/dist/routes/chatAi.js +109 -0
- package/dist/routes/chatAi.js.map +1 -0
- package/dist/routes/config.d.ts +11 -0
- package/dist/routes/config.d.ts.map +1 -0
- package/dist/routes/config.js +24 -0
- package/dist/routes/config.js.map +1 -0
- package/dist/routes/convo.d.ts +169 -0
- package/dist/routes/convo.d.ts.map +1 -0
- package/dist/routes/convo.js +284 -0
- package/dist/routes/convo.js.map +1 -0
- package/dist/routes/credits.d.ts +82 -0
- package/dist/routes/credits.d.ts.map +1 -0
- package/dist/routes/credits.js +49 -0
- package/dist/routes/credits.js.map +1 -0
- package/dist/routes/device.d.ts +74 -0
- package/dist/routes/device.d.ts.map +1 -0
- package/dist/routes/device.js +122 -0
- package/dist/routes/device.js.map +1 -0
- package/dist/routes/folder.d.ts +75 -0
- package/dist/routes/folder.d.ts.map +1 -0
- package/dist/routes/folder.js +99 -0
- package/dist/routes/folder.js.map +1 -0
- package/dist/routes/invite.d.ts +61 -0
- package/dist/routes/invite.d.ts.map +1 -0
- package/dist/routes/invite.js +86 -0
- package/dist/routes/invite.js.map +1 -0
- package/dist/routes/joinLink.d.ts +88 -0
- package/dist/routes/joinLink.d.ts.map +1 -0
- package/dist/routes/joinLink.js +205 -0
- package/dist/routes/joinLink.js.map +1 -0
- package/dist/routes/membership.d.ts +116 -0
- package/dist/routes/membership.d.ts.map +1 -0
- package/dist/routes/membership.js +183 -0
- package/dist/routes/membership.js.map +1 -0
- package/dist/routes/notification.d.ts +103 -0
- package/dist/routes/notification.d.ts.map +1 -0
- package/dist/routes/notification.js +89 -0
- package/dist/routes/notification.js.map +1 -0
- package/dist/routes/oauthGrant.d.ts +45 -0
- package/dist/routes/oauthGrant.d.ts.map +1 -0
- package/dist/routes/oauthGrant.js +32 -0
- package/dist/routes/oauthGrant.js.map +1 -0
- package/dist/routes/payment.d.ts +56 -0
- package/dist/routes/payment.d.ts.map +1 -0
- package/dist/routes/payment.js +78 -0
- package/dist/routes/payment.js.map +1 -0
- package/dist/routes/product.d.ts +43 -0
- package/dist/routes/product.d.ts.map +1 -0
- package/dist/routes/product.js +53 -0
- package/dist/routes/product.js.map +1 -0
- package/dist/routes/project.d.ts +821 -0
- package/dist/routes/project.d.ts.map +1 -0
- package/dist/routes/project.js +1153 -0
- package/dist/routes/project.js.map +1 -0
- package/dist/routes/public.d.ts +269 -0
- package/dist/routes/public.d.ts.map +1 -0
- package/dist/routes/public.js +412 -0
- package/dist/routes/public.js.map +1 -0
- package/dist/routes/scratch.d.ts +70 -0
- package/dist/routes/scratch.d.ts.map +1 -0
- package/dist/routes/scratch.js +67 -0
- package/dist/routes/scratch.js.map +1 -0
- package/dist/routes/settings.d.ts +102 -0
- package/dist/routes/settings.d.ts.map +1 -0
- package/dist/routes/settings.js +94 -0
- package/dist/routes/settings.js.map +1 -0
- package/dist/routes/shortlink.d.ts +79 -0
- package/dist/routes/shortlink.d.ts.map +1 -0
- package/dist/routes/shortlink.js +25 -0
- package/dist/routes/shortlink.js.map +1 -0
- package/dist/routes/socket.d.ts +108 -0
- package/dist/routes/socket.d.ts.map +1 -0
- package/dist/routes/socket.js +573 -0
- package/dist/routes/socket.js.map +1 -0
- package/dist/routes/storage.d.ts +44 -0
- package/dist/routes/storage.d.ts.map +1 -0
- package/dist/routes/storage.js +49 -0
- package/dist/routes/storage.js.map +1 -0
- package/dist/routes/subscription.d.ts +184 -0
- package/dist/routes/subscription.d.ts.map +1 -0
- package/dist/routes/subscription.js +219 -0
- package/dist/routes/subscription.js.map +1 -0
- package/dist/routes/supportChat.d.ts +40 -0
- package/dist/routes/supportChat.d.ts.map +1 -0
- package/dist/routes/supportChat.js +53 -0
- package/dist/routes/supportChat.js.map +1 -0
- package/dist/routes/supportTicket.d.ts +89 -0
- package/dist/routes/supportTicket.d.ts.map +1 -0
- package/dist/routes/supportTicket.js +54 -0
- package/dist/routes/supportTicket.js.map +1 -0
- package/dist/routes/tag.d.ts +72 -0
- package/dist/routes/tag.d.ts.map +1 -0
- package/dist/routes/tag.js +81 -0
- package/dist/routes/tag.js.map +1 -0
- package/dist/routes/task.d.ts +252 -0
- package/dist/routes/task.d.ts.map +1 -0
- package/dist/routes/task.js +284 -0
- package/dist/routes/task.js.map +1 -0
- package/dist/routes/taskRelation.d.ts +80 -0
- package/dist/routes/taskRelation.d.ts.map +1 -0
- package/dist/routes/taskRelation.js +71 -0
- package/dist/routes/taskRelation.js.map +1 -0
- package/dist/routes/token.d.ts +97 -0
- package/dist/routes/token.d.ts.map +1 -0
- package/dist/routes/token.js +73 -0
- package/dist/routes/token.js.map +1 -0
- package/dist/routes/user.d.ts +112 -0
- package/dist/routes/user.d.ts.map +1 -0
- package/dist/routes/user.js +151 -0
- package/dist/routes/user.js.map +1 -0
- package/dist/routes/version.d.ts +42 -0
- package/dist/routes/version.d.ts.map +1 -0
- package/dist/routes/version.js +38 -0
- package/dist/routes/version.js.map +1 -0
- package/dist/routes/webhook.d.ts +170 -0
- package/dist/routes/webhook.d.ts.map +1 -0
- package/dist/routes/webhook.js +173 -0
- package/dist/routes/webhook.js.map +1 -0
- package/dist/routes/workspace.d.ts +120 -0
- package/dist/routes/workspace.d.ts.map +1 -0
- package/dist/routes/workspace.js +199 -0
- package/dist/routes/workspace.js.map +1 -0
- package/dist/utils/uploadSessionManager.d.ts +133 -0
- package/dist/utils/uploadSessionManager.d.ts.map +1 -0
- package/dist/utils/uploadSessionManager.js +321 -0
- package/dist/utils/uploadSessionManager.js.map +1 -0
- package/dist/utils/urlParams.d.ts +35 -0
- package/dist/utils/urlParams.d.ts.map +1 -0
- package/dist/utils/urlParams.js +146 -0
- package/dist/utils/urlParams.js.map +1 -0
- package/dist/version.d.ts +15 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +12 -0
- package/dist/version.js.map +1 -0
- package/package.json +87 -3
- package/src/BotClient.ts +113 -0
- package/src/NuramaClient.ts +1253 -0
- package/src/bot-browser-entry.js +15 -0
- package/src/browser-entry.js +20 -0
- package/src/routes/ai.ts +378 -0
- package/src/routes/asset.ts +1104 -0
- package/src/routes/auth.ts +587 -0
- package/src/routes/blogPosts.ts +29 -0
- package/src/routes/board.ts +403 -0
- package/src/routes/bot.ts +356 -0
- package/src/routes/chat.ts +1292 -0
- package/src/routes/chatAi.ts +125 -0
- package/src/routes/config.ts +31 -0
- package/src/routes/convo.ts +321 -0
- package/src/routes/credits.ts +112 -0
- package/src/routes/device.ts +133 -0
- package/src/routes/folder.ts +154 -0
- package/src/routes/invite.ts +133 -0
- package/src/routes/joinLink.ts +233 -0
- package/src/routes/membership.ts +237 -0
- package/src/routes/notification.ts +166 -0
- package/src/routes/oauthGrant.ts +64 -0
- package/src/routes/payment.ts +104 -0
- package/src/routes/product.ts +67 -0
- package/src/routes/project.ts +1528 -0
- package/src/routes/public.ts +496 -0
- package/src/routes/scratch.ts +94 -0
- package/src/routes/settings.ts +152 -0
- package/src/routes/shortlink.ts +90 -0
- package/src/routes/socket.ts +757 -0
- package/src/routes/storage.ts +83 -0
- package/src/routes/subscription.ts +307 -0
- package/src/routes/supportChat.ts +62 -0
- package/src/routes/supportTicket.ts +114 -0
- package/src/routes/tag.ts +131 -0
- package/src/routes/task.ts +431 -0
- package/src/routes/taskRelation.ts +125 -0
- package/src/routes/token.ts +152 -0
- package/src/routes/user.ts +214 -0
- package/src/routes/version.ts +62 -0
- package/src/routes/webhook.ts +295 -0
- package/src/routes/workspace.ts +223 -0
- package/src/utils/uploadSessionManager.ts +407 -0
- package/src/utils/urlParams.ts +181 -0
- package/src/version.ts +22 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
import type {
|
|
3
|
+
AiChatListTopicsParams,
|
|
4
|
+
AiChatListTopicsResponse,
|
|
5
|
+
AiChatCreateTopicRequest,
|
|
6
|
+
AiChatCreateTopicResponse,
|
|
7
|
+
AiChatGetTopicResponse,
|
|
8
|
+
AiChatUpdateTopicRequest,
|
|
9
|
+
} from '@nurama/types';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Topic-CRUD methods for AI chat. Message send + list happens through
|
|
13
|
+
* the regular chat endpoints on `nuramaClient.chat`:
|
|
14
|
+
*
|
|
15
|
+
* - send: `nuramaClient.chat.createMessage(topic.chatId, …)`
|
|
16
|
+
* - list: `nuramaClient.chat.getMessages(topic.chatId, …)`
|
|
17
|
+
*
|
|
18
|
+
* The backend's `chat.service.createMessage` detects `chatType === 'ai'`
|
|
19
|
+
* and fires the AI orchestrator as a tail call so the same path that
|
|
20
|
+
* powers every other chat surface (attachments, mentions, link previews,
|
|
21
|
+
* link‐preview generation, notifications) carries AI chat too.
|
|
22
|
+
*
|
|
23
|
+
* Each topic is private to its creator. Topic scope is one of:
|
|
24
|
+
* - 'workspace' → cross-project chat in the workspace
|
|
25
|
+
* - 'project' → bound to a single project
|
|
26
|
+
* - 'social' → personal chat with no resource backing
|
|
27
|
+
*
|
|
28
|
+
* All endpoints below require:
|
|
29
|
+
* - workspace AI add-on subscription
|
|
30
|
+
* - `aiChatEnabled` resolved true (workspace setting + project override)
|
|
31
|
+
* - caller has project / workspace read access for scoped topics
|
|
32
|
+
*
|
|
33
|
+
* Credit-balance gating happens server-side on the regular chat
|
|
34
|
+
* `createMessage` path when the target chat is an AI chat.
|
|
35
|
+
*/
|
|
36
|
+
export default function createAiChatMethods(client: NuramaClient) {
|
|
37
|
+
const buildQuery = (params: Record<string, unknown>): string => {
|
|
38
|
+
const search = new URLSearchParams();
|
|
39
|
+
for (const [key, value] of Object.entries(params)) {
|
|
40
|
+
if (value === undefined || value === null || value === '') continue;
|
|
41
|
+
search.set(key, String(value));
|
|
42
|
+
}
|
|
43
|
+
const query = search.toString();
|
|
44
|
+
return query ? `?${query}` : '';
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
/** List the caller's topics for a scope (workspace, project, or social). */
|
|
49
|
+
async listTopics(params: AiChatListTopicsParams): Promise<AiChatListTopicsResponse> {
|
|
50
|
+
if (!params?.workspaceId) throw new Error('workspaceId is required.');
|
|
51
|
+
if (!params?.scopeType) throw new Error('scopeType is required.');
|
|
52
|
+
if (params.scopeType !== 'social' && !params.scopeId) {
|
|
53
|
+
throw new Error('scopeId is required for workspace/project scope.');
|
|
54
|
+
}
|
|
55
|
+
return client._request({
|
|
56
|
+
endpoint: `/v1/ai/chat/topics${buildQuery(params as unknown as Record<string, unknown>)}`,
|
|
57
|
+
method: 'GET',
|
|
58
|
+
sendJWT: true,
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Create a new (empty) topic. After this resolves, send the first
|
|
64
|
+
* message through `nuramaClient.chat.createMessage(topic.chatId, …)`.
|
|
65
|
+
*/
|
|
66
|
+
async createTopic(data: AiChatCreateTopicRequest): Promise<AiChatCreateTopicResponse> {
|
|
67
|
+
if (!data?.workspaceId) throw new Error('workspaceId is required.');
|
|
68
|
+
if (!data?.scopeType) throw new Error('scopeType is required.');
|
|
69
|
+
if (data.scopeType !== 'social' && !data.scopeId) {
|
|
70
|
+
throw new Error('scopeId is required for workspace/project scope.');
|
|
71
|
+
}
|
|
72
|
+
return client._request({
|
|
73
|
+
endpoint: '/v1/ai/chat/topics',
|
|
74
|
+
method: 'POST',
|
|
75
|
+
body: data,
|
|
76
|
+
sendJWT: true,
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
async getTopic(
|
|
81
|
+
topicId: string,
|
|
82
|
+
params: { workspaceId: string },
|
|
83
|
+
): Promise<AiChatGetTopicResponse> {
|
|
84
|
+
if (!topicId) throw new Error('topicId is required.');
|
|
85
|
+
return client._request({
|
|
86
|
+
endpoint: `/v1/ai/chat/topics/${encodeURIComponent(topicId)}${buildQuery(params)}`,
|
|
87
|
+
method: 'GET',
|
|
88
|
+
sendJWT: true,
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
async updateTopic(
|
|
93
|
+
topicId: string,
|
|
94
|
+
data: AiChatUpdateTopicRequest,
|
|
95
|
+
): Promise<AiChatGetTopicResponse> {
|
|
96
|
+
if (!topicId) throw new Error('topicId is required.');
|
|
97
|
+
return client._request({
|
|
98
|
+
endpoint: `/v1/ai/chat/topics/${encodeURIComponent(topicId)}`,
|
|
99
|
+
method: 'PATCH',
|
|
100
|
+
body: data,
|
|
101
|
+
sendJWT: true,
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Soft-delete a topic. The backend flips the topic + its backing
|
|
107
|
+
* chat + every chat-scoped attachment asset to `pendingDelete`;
|
|
108
|
+
* the file-management sweeper handles the actual S3 + DB cleanup
|
|
109
|
+
* asynchronously. The caller can drop the row from their local
|
|
110
|
+
* list immediately — there's no "undo" surface for this.
|
|
111
|
+
*/
|
|
112
|
+
async deleteTopic(
|
|
113
|
+
topicId: string,
|
|
114
|
+
params: { workspaceId: string },
|
|
115
|
+
): Promise<AiChatGetTopicResponse> {
|
|
116
|
+
if (!topicId) throw new Error('topicId is required.');
|
|
117
|
+
return client._request({
|
|
118
|
+
endpoint: `/v1/ai/chat/topics/${encodeURIComponent(topicId)}${buildQuery(params)}`,
|
|
119
|
+
method: 'DELETE',
|
|
120
|
+
sendJWT: true,
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
};
|
|
125
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// import { Config } from '@nurama/types'; // Removed temporarily due to import resolution issues
|
|
2
|
+
import type NuramaClient from '../NuramaClient'; // Use type import for client
|
|
3
|
+
|
|
4
|
+
// Define the shape of the returned object
|
|
5
|
+
export interface ConfigMethods {
|
|
6
|
+
getConfig: () => Promise<any>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates methods related to configuration endpoints.
|
|
11
|
+
* @param client - The NuramaClient instance.
|
|
12
|
+
* @returns An object with configuration-related methods.
|
|
13
|
+
*/
|
|
14
|
+
export default function createConfigMethods(client: NuramaClient): ConfigMethods {
|
|
15
|
+
return {
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves the application configuration.
|
|
18
|
+
*
|
|
19
|
+
* @returns {Promise<any>} A promise that resolves with the configuration object.
|
|
20
|
+
* @throws {ApiError} Throws an ApiError if the request fails.
|
|
21
|
+
*/
|
|
22
|
+
getConfig: async (): Promise<any> => {
|
|
23
|
+
// client._log('[DEBUG] Fetching application configuration'); // Logging is handled by _request
|
|
24
|
+
return client._request<any>({
|
|
25
|
+
endpoint: '/v1/config',
|
|
26
|
+
method: 'GET',
|
|
27
|
+
sendJWT: false, // This endpoint does not require authentication
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
import {
|
|
3
|
+
type StartConvoRequest,
|
|
4
|
+
type StartConvoResponse,
|
|
5
|
+
type GetConvoResponse,
|
|
6
|
+
type JoinConvoResponse,
|
|
7
|
+
type LeaveConvoResponse,
|
|
8
|
+
type CompleteConvoResponse,
|
|
9
|
+
type UpdateConvoRequest,
|
|
10
|
+
type UpdateConvoResponse,
|
|
11
|
+
type GetScopeConvosResponse,
|
|
12
|
+
type PromoteConvoArtifactRequest,
|
|
13
|
+
type PromoteConvoArtifactResponse,
|
|
14
|
+
type Convo,
|
|
15
|
+
} from '@nurama/types';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Defines convo (video/audio chat) related methods for the NuramaClient.
|
|
19
|
+
* Handles starting, joining, and managing real-time conversations.
|
|
20
|
+
* @param {NuramaClient} client - The NuramaClient instance.
|
|
21
|
+
* @returns {object} An object containing the convo-related methods.
|
|
22
|
+
*/
|
|
23
|
+
export default function createConvoMethods(client: NuramaClient) {
|
|
24
|
+
return {
|
|
25
|
+
/**
|
|
26
|
+
* Start a new conversation (video or audio).
|
|
27
|
+
* Requires authentication.
|
|
28
|
+
* @param {StartConvoRequest} data - Conversation start data.
|
|
29
|
+
* @returns {Promise<StartConvoResponse>} The created conversation and room details.
|
|
30
|
+
* @example
|
|
31
|
+
* const result = await client.convo.startConvo({
|
|
32
|
+
* chatId: '507f1f77bcf86cd799439011',
|
|
33
|
+
* chatType: 'chat',
|
|
34
|
+
* convoType: 'video'
|
|
35
|
+
* });
|
|
36
|
+
*/
|
|
37
|
+
async startConvo(data: StartConvoRequest): Promise<StartConvoResponse> {
|
|
38
|
+
if (!data.chatId || !data.chatType || !data.convoType) {
|
|
39
|
+
throw new Error('chatId, chatType, and convoType are required.');
|
|
40
|
+
}
|
|
41
|
+
return client._request<StartConvoResponse>({
|
|
42
|
+
method: 'POST',
|
|
43
|
+
endpoint: '/v1/convos',
|
|
44
|
+
body: data,
|
|
45
|
+
sendJWT: true,
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get a specific conversation by ID.
|
|
51
|
+
* Requires authentication and permission to view the conversation.
|
|
52
|
+
* @param {string} convoId - The conversation ID.
|
|
53
|
+
* @returns {Promise<GetConvoResponse>} The conversation details.
|
|
54
|
+
* @example
|
|
55
|
+
* const result = await client.convo.getConvo('507f1f77bcf86cd799439011');
|
|
56
|
+
*/
|
|
57
|
+
async getConvo(convoId: string): Promise<GetConvoResponse> {
|
|
58
|
+
if (!convoId) {
|
|
59
|
+
throw new Error('convoId is required.');
|
|
60
|
+
}
|
|
61
|
+
return client._request<GetConvoResponse>({
|
|
62
|
+
method: 'GET',
|
|
63
|
+
endpoint: `/v1/convos/${convoId}`,
|
|
64
|
+
sendJWT: true,
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Join an active conversation.
|
|
70
|
+
* Returns the conversation details and a Daily.co meeting token for the user.
|
|
71
|
+
* Requires authentication and permission to join the conversation.
|
|
72
|
+
* @param {string} convoId - The conversation ID.
|
|
73
|
+
* @returns {Promise<JoinConvoResponse>} The conversation and meeting token.
|
|
74
|
+
* @example
|
|
75
|
+
* const result = await client.convo.joinConvo('507f1f77bcf86cd799439011');
|
|
76
|
+
* // Use result.token to join the Daily.co call
|
|
77
|
+
* // Use result.convo.dailyRoomUrl as the room URL
|
|
78
|
+
*/
|
|
79
|
+
async joinConvo(convoId: string): Promise<JoinConvoResponse> {
|
|
80
|
+
if (!convoId) {
|
|
81
|
+
throw new Error('convoId is required.');
|
|
82
|
+
}
|
|
83
|
+
return client._request<JoinConvoResponse>({
|
|
84
|
+
method: 'PUT',
|
|
85
|
+
endpoint: `/v1/convos/${convoId}/join`,
|
|
86
|
+
sendJWT: true,
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Rejoin an active conversation (page refresh / reconnect).
|
|
92
|
+
* Only returns a new meeting token if the user is already an active participant.
|
|
93
|
+
* No notifications are sent.
|
|
94
|
+
* @param {string} convoId - The conversation ID.
|
|
95
|
+
* @returns {Promise<JoinConvoResponse>} The conversation and meeting token.
|
|
96
|
+
*/
|
|
97
|
+
async rejoinConvo(convoId: string): Promise<JoinConvoResponse> {
|
|
98
|
+
if (!convoId) {
|
|
99
|
+
throw new Error('convoId is required.');
|
|
100
|
+
}
|
|
101
|
+
return client._request<JoinConvoResponse>({
|
|
102
|
+
method: 'PUT',
|
|
103
|
+
endpoint: `/v1/convos/${convoId}/rejoin`,
|
|
104
|
+
sendJWT: true,
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Leave an active conversation.
|
|
110
|
+
* Removes the user from the active participants list.
|
|
111
|
+
* Requires authentication.
|
|
112
|
+
* @param {string} convoId - The conversation ID.
|
|
113
|
+
* @returns {Promise<LeaveConvoResponse>} The updated conversation.
|
|
114
|
+
* @example
|
|
115
|
+
* const result = await client.convo.leaveConvo('507f1f77bcf86cd799439011');
|
|
116
|
+
*/
|
|
117
|
+
async leaveConvo(convoId: string): Promise<LeaveConvoResponse> {
|
|
118
|
+
if (!convoId) {
|
|
119
|
+
throw new Error('convoId is required.');
|
|
120
|
+
}
|
|
121
|
+
return client._request<LeaveConvoResponse>({
|
|
122
|
+
method: 'PUT',
|
|
123
|
+
endpoint: `/v1/convos/${convoId}/leave`,
|
|
124
|
+
sendJWT: true,
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Mark a conversation as complete.
|
|
130
|
+
* Ends the conversation and triggers recording/transcript processing if enabled.
|
|
131
|
+
* Requires authentication and permission to complete the conversation.
|
|
132
|
+
* @param {string} convoId - The conversation ID.
|
|
133
|
+
* @returns {Promise<CompleteConvoResponse>} The completed conversation.
|
|
134
|
+
* @example
|
|
135
|
+
* const result = await client.convo.completeConvo('507f1f77bcf86cd799439011');
|
|
136
|
+
*/
|
|
137
|
+
async completeConvo(convoId: string): Promise<CompleteConvoResponse> {
|
|
138
|
+
if (!convoId) {
|
|
139
|
+
throw new Error('convoId is required.');
|
|
140
|
+
}
|
|
141
|
+
return client._request<CompleteConvoResponse>({
|
|
142
|
+
method: 'PUT',
|
|
143
|
+
endpoint: `/v1/convos/${convoId}/complete`,
|
|
144
|
+
sendJWT: true,
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Delete/cancel a conversation.
|
|
150
|
+
* Only the creator can delete a conversation.
|
|
151
|
+
* Requires authentication and permission to delete the conversation.
|
|
152
|
+
* @param {string} convoId - The conversation ID.
|
|
153
|
+
* @returns {Promise<void>} Resolves with no value; the API responds 204.
|
|
154
|
+
* @example
|
|
155
|
+
* await client.convo.deleteConvo('507f1f77bcf86cd799439011');
|
|
156
|
+
*/
|
|
157
|
+
async deleteConvo(convoId: string): Promise<void> {
|
|
158
|
+
if (!convoId) {
|
|
159
|
+
throw new Error('convoId is required.');
|
|
160
|
+
}
|
|
161
|
+
await client._request<null>({
|
|
162
|
+
method: 'DELETE',
|
|
163
|
+
endpoint: `/v1/convos/${convoId}`,
|
|
164
|
+
sendJWT: true,
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Update a conversation's subject and/or description.
|
|
170
|
+
* Only the conversation starter can update these fields.
|
|
171
|
+
* Requires authentication.
|
|
172
|
+
* @param {string} convoId - The conversation ID.
|
|
173
|
+
* @param {UpdateConvoRequest} data - Update data containing subject and/or description.
|
|
174
|
+
* @returns {Promise<UpdateConvoResponse>} The updated conversation.
|
|
175
|
+
* @example
|
|
176
|
+
* const result = await client.convo.updateConvo('507f1f77bcf86cd799439011', {
|
|
177
|
+
* subject: 'Weekly Team Sync',
|
|
178
|
+
* description: 'Discussing project updates and roadmap'
|
|
179
|
+
* });
|
|
180
|
+
*/
|
|
181
|
+
async updateConvo(convoId: string, data: UpdateConvoRequest): Promise<UpdateConvoResponse> {
|
|
182
|
+
if (!convoId) {
|
|
183
|
+
throw new Error('convoId is required.');
|
|
184
|
+
}
|
|
185
|
+
return client._request<UpdateConvoResponse>({
|
|
186
|
+
method: 'PATCH',
|
|
187
|
+
endpoint: `/v1/convos/${convoId}`,
|
|
188
|
+
body: data,
|
|
189
|
+
sendJWT: true,
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* List the convos that have taken place in a chat, newest first.
|
|
195
|
+
* Requires read access to the chat.
|
|
196
|
+
* @param {string} chatId - The chat ID.
|
|
197
|
+
* @param {object} [params] - Optional filter.
|
|
198
|
+
* @param {'active'|'completed'|'cancelled'} [params.status] - Only convos in this status.
|
|
199
|
+
* @returns {Promise<Convo[]>} Convos for the chat.
|
|
200
|
+
*/
|
|
201
|
+
async getChatConvos(chatId: string, params?: { status?: 'active' | 'completed' | 'cancelled' }): Promise<Convo[]> {
|
|
202
|
+
if (!chatId) throw new Error('chatId is required.');
|
|
203
|
+
return client._request<Convo[]>({
|
|
204
|
+
method: 'GET',
|
|
205
|
+
endpoint: `/v1/chats/${chatId}/convos`,
|
|
206
|
+
params,
|
|
207
|
+
sendJWT: true,
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* List every convo across all chats in a project (the "Convos drawer"), newest first.
|
|
213
|
+
* Requires `canGetProject` on the project.
|
|
214
|
+
* @param {string} projectId - The project ID.
|
|
215
|
+
* @param {object} [params] - Optional filters.
|
|
216
|
+
* @param {'creator'|'reviewer'} [params.visibility] - Only convos from chats with this visibility.
|
|
217
|
+
* @param {'active'|'completed'|'cancelled'} [params.status] - Only convos in this status.
|
|
218
|
+
* @returns {Promise<Convo[]>} Convos for the project.
|
|
219
|
+
*/
|
|
220
|
+
async getProjectConvos(
|
|
221
|
+
projectId: string,
|
|
222
|
+
params?: { visibility?: 'creator' | 'reviewer'; status?: 'active' | 'completed' | 'cancelled' },
|
|
223
|
+
): Promise<Convo[]> {
|
|
224
|
+
if (!projectId) throw new Error('projectId is required.');
|
|
225
|
+
return client._request<Convo[]>({
|
|
226
|
+
method: 'GET',
|
|
227
|
+
endpoint: `/v1/projects/${projectId}/convos`,
|
|
228
|
+
params,
|
|
229
|
+
sendJWT: true,
|
|
230
|
+
});
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Get conversations for a scope (project).
|
|
235
|
+
* Returns paginated list of conversations with cursor-based pagination.
|
|
236
|
+
* Active conversations are returned first.
|
|
237
|
+
* Requires authentication and permission to view conversations.
|
|
238
|
+
* @param {string} scopeId - The scope (project) ID.
|
|
239
|
+
* @param {object} params - Query parameters.
|
|
240
|
+
* @param {string[]} params.visibility - Array of visibility levels ('creator', 'reviewer').
|
|
241
|
+
* @param {string} [params.status] - Filter by status ('active', 'completed', 'cancelled').
|
|
242
|
+
* @param {string} [params.search] - Search query for participant names.
|
|
243
|
+
* @param {number} [params.limit=20] - Number of results per page.
|
|
244
|
+
* @param {string} [params.cursor] - Cursor for pagination.
|
|
245
|
+
* @param {boolean} [params.includeCounts] - Include total counts.
|
|
246
|
+
* @returns {Promise<GetScopeConvosResponse>} Paginated conversation list.
|
|
247
|
+
* @example
|
|
248
|
+
* const result = await client.convo.getScopeConvos('507f1f77bcf86cd799439011', {
|
|
249
|
+
* visibility: ['creator', 'reviewer'],
|
|
250
|
+
* status: 'active',
|
|
251
|
+
* limit: 20
|
|
252
|
+
* });
|
|
253
|
+
*/
|
|
254
|
+
/**
|
|
255
|
+
* Promote a convo's recording or transcript to a standalone asset.
|
|
256
|
+
*
|
|
257
|
+
* Additive: the artifact stays bundled with the convo as well, so calling
|
|
258
|
+
* this twice returns the first asset with `alreadyPromoted: true` rather
|
|
259
|
+
* than making a second copy.
|
|
260
|
+
*
|
|
261
|
+
* Only the convo's starter may promote. A transcript is promoted as a text
|
|
262
|
+
* document built from the transcript text, not the raw .vtt.
|
|
263
|
+
* @param {string} convoId - The conversation ID.
|
|
264
|
+
* @param {'recording'|'transcript'} kind - Which artifact to promote.
|
|
265
|
+
* @param {string} dailyId - The provider's id for the artifact, taken from
|
|
266
|
+
* the convo's `recordings` / `transcripts` entries.
|
|
267
|
+
* @param {PromoteConvoArtifactRequest} [data] - Optional display name.
|
|
268
|
+
* @returns {Promise<PromoteConvoArtifactResponse>} The asset, and whether it already existed.
|
|
269
|
+
* @example
|
|
270
|
+
* const { asset } = await client.convo.promoteConvoArtifact(convoId, 'recording', rec.dailyId);
|
|
271
|
+
*/
|
|
272
|
+
async promoteConvoArtifact(
|
|
273
|
+
convoId: string,
|
|
274
|
+
kind: 'recording' | 'transcript',
|
|
275
|
+
dailyId: string,
|
|
276
|
+
data?: PromoteConvoArtifactRequest,
|
|
277
|
+
): Promise<PromoteConvoArtifactResponse> {
|
|
278
|
+
if (!convoId) throw new Error('convoId is required.');
|
|
279
|
+
if (!dailyId) throw new Error('dailyId is required.');
|
|
280
|
+
return client._request<PromoteConvoArtifactResponse>({
|
|
281
|
+
method: 'POST',
|
|
282
|
+
endpoint: `/v1/convos/${convoId}/artifacts/${kind}/${dailyId}/promote`,
|
|
283
|
+
body: data ?? {},
|
|
284
|
+
sendJWT: true,
|
|
285
|
+
});
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
async getScopeConvos(
|
|
289
|
+
scopeId: string,
|
|
290
|
+
params: {
|
|
291
|
+
visibility: string[];
|
|
292
|
+
status?: string;
|
|
293
|
+
search?: string;
|
|
294
|
+
limit?: number;
|
|
295
|
+
cursor?: string;
|
|
296
|
+
includeCounts?: boolean;
|
|
297
|
+
}
|
|
298
|
+
): Promise<GetScopeConvosResponse> {
|
|
299
|
+
if (!scopeId) {
|
|
300
|
+
throw new Error('scopeId is required.');
|
|
301
|
+
}
|
|
302
|
+
if (!params.visibility || params.visibility.length === 0) {
|
|
303
|
+
throw new Error('visibility array is required and must not be empty.');
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const queryParams = new URLSearchParams();
|
|
307
|
+
params.visibility.forEach((vis) => queryParams.append('visibility[]', vis));
|
|
308
|
+
if (params.status) queryParams.append('status', params.status);
|
|
309
|
+
if (params.search) queryParams.append('search', params.search);
|
|
310
|
+
if (params.limit) queryParams.append('limit', params.limit.toString());
|
|
311
|
+
if (params.cursor) queryParams.append('cursor', params.cursor);
|
|
312
|
+
if (params.includeCounts) queryParams.append('includeCounts', 'true');
|
|
313
|
+
|
|
314
|
+
return client._request<GetScopeConvosResponse>({
|
|
315
|
+
method: 'GET',
|
|
316
|
+
endpoint: `/v1/convos/scope/${scopeId}?${queryParams.toString()}`,
|
|
317
|
+
sendJWT: true,
|
|
318
|
+
});
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
|
|
3
|
+
export interface GetBalanceResponse {
|
|
4
|
+
/** Total spendable balance — sum of planBalance + purchasedBalance. */
|
|
5
|
+
balance: number;
|
|
6
|
+
/**
|
|
7
|
+
* Plan-granted credits for the current billing cycle. Refreshed (SET, not
|
|
8
|
+
* added) on every Stripe renewal. Unspent plan credits do NOT carry over.
|
|
9
|
+
*/
|
|
10
|
+
planBalance: number;
|
|
11
|
+
/**
|
|
12
|
+
* Purchased credits — accumulated from one-off top-ups, auto-top-ups, admin
|
|
13
|
+
* grants. Carries over indefinitely.
|
|
14
|
+
*/
|
|
15
|
+
purchasedBalance: number;
|
|
16
|
+
/**
|
|
17
|
+
* True when the workspace has at least one prior manual top-up
|
|
18
|
+
* (`subscriptionGrant` order). Powers the FE auto-top-up enable gate —
|
|
19
|
+
* users must top up manually once before auto top-up can be enabled.
|
|
20
|
+
*/
|
|
21
|
+
hasPriorTopUp?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface UsageReportParams {
|
|
25
|
+
/** ISO date string. Server defaults to 30 days ago when omitted. */
|
|
26
|
+
startDate?: string;
|
|
27
|
+
/** ISO date string. Server defaults to "now" when omitted. */
|
|
28
|
+
endDate?: string;
|
|
29
|
+
/** Narrow the per-integration breakdown to a single user's calls. */
|
|
30
|
+
userId?: string;
|
|
31
|
+
/** Narrow the per-user breakdown to a single integration point. */
|
|
32
|
+
integrationPoint?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface UsageReportUserRow {
|
|
36
|
+
userId: string;
|
|
37
|
+
displayName: string | null;
|
|
38
|
+
avatar: unknown | null;
|
|
39
|
+
color: string | null;
|
|
40
|
+
billedCredits: number;
|
|
41
|
+
callCount: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface UsageReportIntegrationRow {
|
|
45
|
+
integrationPoint: string;
|
|
46
|
+
billedCredits: number;
|
|
47
|
+
callCount: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface UsageReportResponse {
|
|
51
|
+
total: {
|
|
52
|
+
billedCredits: number;
|
|
53
|
+
callCount: number;
|
|
54
|
+
tokensIn: number;
|
|
55
|
+
tokensOut: number;
|
|
56
|
+
};
|
|
57
|
+
byUser: UsageReportUserRow[];
|
|
58
|
+
byIntegration: UsageReportIntegrationRow[];
|
|
59
|
+
filters: {
|
|
60
|
+
startDate: string;
|
|
61
|
+
endDate: string;
|
|
62
|
+
userId: string | null;
|
|
63
|
+
integrationPoint: string | null;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Service-agnostic Nurama Credit balance + usage endpoints.
|
|
69
|
+
*
|
|
70
|
+
* The `/v1/credits/*` route shape and SDK namespace are deliberately
|
|
71
|
+
* decoupled from any single service's naming so future services (convos,
|
|
72
|
+
* etc.) can draw from the same balance without callers having to know
|
|
73
|
+
* where the spend originated. Today the metered data is AI-only because
|
|
74
|
+
* AI is the only service that's metered, but the contract is stable.
|
|
75
|
+
*/
|
|
76
|
+
export default function createCreditsMethods(client: NuramaClient) {
|
|
77
|
+
return {
|
|
78
|
+
/**
|
|
79
|
+
* Get the workspace's spendable credit balance.
|
|
80
|
+
*/
|
|
81
|
+
async getBalance(workspaceId: string): Promise<GetBalanceResponse> {
|
|
82
|
+
if (!workspaceId) throw new Error('workspaceId is required.');
|
|
83
|
+
return client._request({
|
|
84
|
+
endpoint: `/v1/credits/balance?workspaceId=${encodeURIComponent(workspaceId)}`,
|
|
85
|
+
method: 'GET',
|
|
86
|
+
sendJWT: true,
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the workspace's credit usage report. Same shape as the AI usage
|
|
92
|
+
* report — today the data is AI-only because AI is the only service
|
|
93
|
+
* that's metered.
|
|
94
|
+
*/
|
|
95
|
+
async getUsageReport(
|
|
96
|
+
workspaceId: string,
|
|
97
|
+
params: UsageReportParams = {},
|
|
98
|
+
): Promise<UsageReportResponse> {
|
|
99
|
+
if (!workspaceId) throw new Error('workspaceId is required.');
|
|
100
|
+
const query = new URLSearchParams({ workspaceId });
|
|
101
|
+
if (params.startDate) query.set('startDate', params.startDate);
|
|
102
|
+
if (params.endDate) query.set('endDate', params.endDate);
|
|
103
|
+
if (params.userId) query.set('userId', params.userId);
|
|
104
|
+
if (params.integrationPoint) query.set('integrationPoint', params.integrationPoint);
|
|
105
|
+
return client._request({
|
|
106
|
+
endpoint: `/v1/credits/usage?${query.toString()}`,
|
|
107
|
+
method: 'GET',
|
|
108
|
+
sendJWT: true,
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|