@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,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines convo (video/audio chat) related methods for the NuramaClient.
|
|
3
|
+
* Handles starting, joining, and managing real-time conversations.
|
|
4
|
+
* @param {NuramaClient} client - The NuramaClient instance.
|
|
5
|
+
* @returns {object} An object containing the convo-related methods.
|
|
6
|
+
*/
|
|
7
|
+
export default function createConvoMethods(client) {
|
|
8
|
+
return {
|
|
9
|
+
/**
|
|
10
|
+
* Start a new conversation (video or audio).
|
|
11
|
+
* Requires authentication.
|
|
12
|
+
* @param {StartConvoRequest} data - Conversation start data.
|
|
13
|
+
* @returns {Promise<StartConvoResponse>} The created conversation and room details.
|
|
14
|
+
* @example
|
|
15
|
+
* const result = await client.convo.startConvo({
|
|
16
|
+
* chatId: '507f1f77bcf86cd799439011',
|
|
17
|
+
* chatType: 'chat',
|
|
18
|
+
* convoType: 'video'
|
|
19
|
+
* });
|
|
20
|
+
*/
|
|
21
|
+
async startConvo(data) {
|
|
22
|
+
if (!data.chatId || !data.chatType || !data.convoType) {
|
|
23
|
+
throw new Error('chatId, chatType, and convoType are required.');
|
|
24
|
+
}
|
|
25
|
+
return client._request({
|
|
26
|
+
method: 'POST',
|
|
27
|
+
endpoint: '/v1/convos',
|
|
28
|
+
body: data,
|
|
29
|
+
sendJWT: true,
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Get a specific conversation by ID.
|
|
34
|
+
* Requires authentication and permission to view the conversation.
|
|
35
|
+
* @param {string} convoId - The conversation ID.
|
|
36
|
+
* @returns {Promise<GetConvoResponse>} The conversation details.
|
|
37
|
+
* @example
|
|
38
|
+
* const result = await client.convo.getConvo('507f1f77bcf86cd799439011');
|
|
39
|
+
*/
|
|
40
|
+
async getConvo(convoId) {
|
|
41
|
+
if (!convoId) {
|
|
42
|
+
throw new Error('convoId is required.');
|
|
43
|
+
}
|
|
44
|
+
return client._request({
|
|
45
|
+
method: 'GET',
|
|
46
|
+
endpoint: `/v1/convos/${convoId}`,
|
|
47
|
+
sendJWT: true,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Join an active conversation.
|
|
52
|
+
* Returns the conversation details and a Daily.co meeting token for the user.
|
|
53
|
+
* Requires authentication and permission to join the conversation.
|
|
54
|
+
* @param {string} convoId - The conversation ID.
|
|
55
|
+
* @returns {Promise<JoinConvoResponse>} The conversation and meeting token.
|
|
56
|
+
* @example
|
|
57
|
+
* const result = await client.convo.joinConvo('507f1f77bcf86cd799439011');
|
|
58
|
+
* // Use result.token to join the Daily.co call
|
|
59
|
+
* // Use result.convo.dailyRoomUrl as the room URL
|
|
60
|
+
*/
|
|
61
|
+
async joinConvo(convoId) {
|
|
62
|
+
if (!convoId) {
|
|
63
|
+
throw new Error('convoId is required.');
|
|
64
|
+
}
|
|
65
|
+
return client._request({
|
|
66
|
+
method: 'PUT',
|
|
67
|
+
endpoint: `/v1/convos/${convoId}/join`,
|
|
68
|
+
sendJWT: true,
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* Rejoin an active conversation (page refresh / reconnect).
|
|
73
|
+
* Only returns a new meeting token if the user is already an active participant.
|
|
74
|
+
* No notifications are sent.
|
|
75
|
+
* @param {string} convoId - The conversation ID.
|
|
76
|
+
* @returns {Promise<JoinConvoResponse>} The conversation and meeting token.
|
|
77
|
+
*/
|
|
78
|
+
async rejoinConvo(convoId) {
|
|
79
|
+
if (!convoId) {
|
|
80
|
+
throw new Error('convoId is required.');
|
|
81
|
+
}
|
|
82
|
+
return client._request({
|
|
83
|
+
method: 'PUT',
|
|
84
|
+
endpoint: `/v1/convos/${convoId}/rejoin`,
|
|
85
|
+
sendJWT: true,
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* Leave an active conversation.
|
|
90
|
+
* Removes the user from the active participants list.
|
|
91
|
+
* Requires authentication.
|
|
92
|
+
* @param {string} convoId - The conversation ID.
|
|
93
|
+
* @returns {Promise<LeaveConvoResponse>} The updated conversation.
|
|
94
|
+
* @example
|
|
95
|
+
* const result = await client.convo.leaveConvo('507f1f77bcf86cd799439011');
|
|
96
|
+
*/
|
|
97
|
+
async leaveConvo(convoId) {
|
|
98
|
+
if (!convoId) {
|
|
99
|
+
throw new Error('convoId is required.');
|
|
100
|
+
}
|
|
101
|
+
return client._request({
|
|
102
|
+
method: 'PUT',
|
|
103
|
+
endpoint: `/v1/convos/${convoId}/leave`,
|
|
104
|
+
sendJWT: true,
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* Mark a conversation as complete.
|
|
109
|
+
* Ends the conversation and triggers recording/transcript processing if enabled.
|
|
110
|
+
* Requires authentication and permission to complete the conversation.
|
|
111
|
+
* @param {string} convoId - The conversation ID.
|
|
112
|
+
* @returns {Promise<CompleteConvoResponse>} The completed conversation.
|
|
113
|
+
* @example
|
|
114
|
+
* const result = await client.convo.completeConvo('507f1f77bcf86cd799439011');
|
|
115
|
+
*/
|
|
116
|
+
async completeConvo(convoId) {
|
|
117
|
+
if (!convoId) {
|
|
118
|
+
throw new Error('convoId is required.');
|
|
119
|
+
}
|
|
120
|
+
return client._request({
|
|
121
|
+
method: 'PUT',
|
|
122
|
+
endpoint: `/v1/convos/${convoId}/complete`,
|
|
123
|
+
sendJWT: true,
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
/**
|
|
127
|
+
* Delete/cancel a conversation.
|
|
128
|
+
* Only the creator can delete a conversation.
|
|
129
|
+
* Requires authentication and permission to delete the conversation.
|
|
130
|
+
* @param {string} convoId - The conversation ID.
|
|
131
|
+
* @returns {Promise<void>} Resolves with no value; the API responds 204.
|
|
132
|
+
* @example
|
|
133
|
+
* await client.convo.deleteConvo('507f1f77bcf86cd799439011');
|
|
134
|
+
*/
|
|
135
|
+
async deleteConvo(convoId) {
|
|
136
|
+
if (!convoId) {
|
|
137
|
+
throw new Error('convoId is required.');
|
|
138
|
+
}
|
|
139
|
+
await client._request({
|
|
140
|
+
method: 'DELETE',
|
|
141
|
+
endpoint: `/v1/convos/${convoId}`,
|
|
142
|
+
sendJWT: true,
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
/**
|
|
146
|
+
* Update a conversation's subject and/or description.
|
|
147
|
+
* Only the conversation starter can update these fields.
|
|
148
|
+
* Requires authentication.
|
|
149
|
+
* @param {string} convoId - The conversation ID.
|
|
150
|
+
* @param {UpdateConvoRequest} data - Update data containing subject and/or description.
|
|
151
|
+
* @returns {Promise<UpdateConvoResponse>} The updated conversation.
|
|
152
|
+
* @example
|
|
153
|
+
* const result = await client.convo.updateConvo('507f1f77bcf86cd799439011', {
|
|
154
|
+
* subject: 'Weekly Team Sync',
|
|
155
|
+
* description: 'Discussing project updates and roadmap'
|
|
156
|
+
* });
|
|
157
|
+
*/
|
|
158
|
+
async updateConvo(convoId, data) {
|
|
159
|
+
if (!convoId) {
|
|
160
|
+
throw new Error('convoId is required.');
|
|
161
|
+
}
|
|
162
|
+
return client._request({
|
|
163
|
+
method: 'PATCH',
|
|
164
|
+
endpoint: `/v1/convos/${convoId}`,
|
|
165
|
+
body: data,
|
|
166
|
+
sendJWT: true,
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
/**
|
|
170
|
+
* List the convos that have taken place in a chat, newest first.
|
|
171
|
+
* Requires read access to the chat.
|
|
172
|
+
* @param {string} chatId - The chat ID.
|
|
173
|
+
* @param {object} [params] - Optional filter.
|
|
174
|
+
* @param {'active'|'completed'|'cancelled'} [params.status] - Only convos in this status.
|
|
175
|
+
* @returns {Promise<Convo[]>} Convos for the chat.
|
|
176
|
+
*/
|
|
177
|
+
async getChatConvos(chatId, params) {
|
|
178
|
+
if (!chatId)
|
|
179
|
+
throw new Error('chatId is required.');
|
|
180
|
+
return client._request({
|
|
181
|
+
method: 'GET',
|
|
182
|
+
endpoint: `/v1/chats/${chatId}/convos`,
|
|
183
|
+
params,
|
|
184
|
+
sendJWT: true,
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
/**
|
|
188
|
+
* List every convo across all chats in a project (the "Convos drawer"), newest first.
|
|
189
|
+
* Requires `canGetProject` on the project.
|
|
190
|
+
* @param {string} projectId - The project ID.
|
|
191
|
+
* @param {object} [params] - Optional filters.
|
|
192
|
+
* @param {'creator'|'reviewer'} [params.visibility] - Only convos from chats with this visibility.
|
|
193
|
+
* @param {'active'|'completed'|'cancelled'} [params.status] - Only convos in this status.
|
|
194
|
+
* @returns {Promise<Convo[]>} Convos for the project.
|
|
195
|
+
*/
|
|
196
|
+
async getProjectConvos(projectId, params) {
|
|
197
|
+
if (!projectId)
|
|
198
|
+
throw new Error('projectId is required.');
|
|
199
|
+
return client._request({
|
|
200
|
+
method: 'GET',
|
|
201
|
+
endpoint: `/v1/projects/${projectId}/convos`,
|
|
202
|
+
params,
|
|
203
|
+
sendJWT: true,
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
/**
|
|
207
|
+
* Get conversations for a scope (project).
|
|
208
|
+
* Returns paginated list of conversations with cursor-based pagination.
|
|
209
|
+
* Active conversations are returned first.
|
|
210
|
+
* Requires authentication and permission to view conversations.
|
|
211
|
+
* @param {string} scopeId - The scope (project) ID.
|
|
212
|
+
* @param {object} params - Query parameters.
|
|
213
|
+
* @param {string[]} params.visibility - Array of visibility levels ('creator', 'reviewer').
|
|
214
|
+
* @param {string} [params.status] - Filter by status ('active', 'completed', 'cancelled').
|
|
215
|
+
* @param {string} [params.search] - Search query for participant names.
|
|
216
|
+
* @param {number} [params.limit=20] - Number of results per page.
|
|
217
|
+
* @param {string} [params.cursor] - Cursor for pagination.
|
|
218
|
+
* @param {boolean} [params.includeCounts] - Include total counts.
|
|
219
|
+
* @returns {Promise<GetScopeConvosResponse>} Paginated conversation list.
|
|
220
|
+
* @example
|
|
221
|
+
* const result = await client.convo.getScopeConvos('507f1f77bcf86cd799439011', {
|
|
222
|
+
* visibility: ['creator', 'reviewer'],
|
|
223
|
+
* status: 'active',
|
|
224
|
+
* limit: 20
|
|
225
|
+
* });
|
|
226
|
+
*/
|
|
227
|
+
/**
|
|
228
|
+
* Promote a convo's recording or transcript to a standalone asset.
|
|
229
|
+
*
|
|
230
|
+
* Additive: the artifact stays bundled with the convo as well, so calling
|
|
231
|
+
* this twice returns the first asset with `alreadyPromoted: true` rather
|
|
232
|
+
* than making a second copy.
|
|
233
|
+
*
|
|
234
|
+
* Only the convo's starter may promote. A transcript is promoted as a text
|
|
235
|
+
* document built from the transcript text, not the raw .vtt.
|
|
236
|
+
* @param {string} convoId - The conversation ID.
|
|
237
|
+
* @param {'recording'|'transcript'} kind - Which artifact to promote.
|
|
238
|
+
* @param {string} dailyId - The provider's id for the artifact, taken from
|
|
239
|
+
* the convo's `recordings` / `transcripts` entries.
|
|
240
|
+
* @param {PromoteConvoArtifactRequest} [data] - Optional display name.
|
|
241
|
+
* @returns {Promise<PromoteConvoArtifactResponse>} The asset, and whether it already existed.
|
|
242
|
+
* @example
|
|
243
|
+
* const { asset } = await client.convo.promoteConvoArtifact(convoId, 'recording', rec.dailyId);
|
|
244
|
+
*/
|
|
245
|
+
async promoteConvoArtifact(convoId, kind, dailyId, data) {
|
|
246
|
+
if (!convoId)
|
|
247
|
+
throw new Error('convoId is required.');
|
|
248
|
+
if (!dailyId)
|
|
249
|
+
throw new Error('dailyId is required.');
|
|
250
|
+
return client._request({
|
|
251
|
+
method: 'POST',
|
|
252
|
+
endpoint: `/v1/convos/${convoId}/artifacts/${kind}/${dailyId}/promote`,
|
|
253
|
+
body: data ?? {},
|
|
254
|
+
sendJWT: true,
|
|
255
|
+
});
|
|
256
|
+
},
|
|
257
|
+
async getScopeConvos(scopeId, params) {
|
|
258
|
+
if (!scopeId) {
|
|
259
|
+
throw new Error('scopeId is required.');
|
|
260
|
+
}
|
|
261
|
+
if (!params.visibility || params.visibility.length === 0) {
|
|
262
|
+
throw new Error('visibility array is required and must not be empty.');
|
|
263
|
+
}
|
|
264
|
+
const queryParams = new URLSearchParams();
|
|
265
|
+
params.visibility.forEach((vis) => queryParams.append('visibility[]', vis));
|
|
266
|
+
if (params.status)
|
|
267
|
+
queryParams.append('status', params.status);
|
|
268
|
+
if (params.search)
|
|
269
|
+
queryParams.append('search', params.search);
|
|
270
|
+
if (params.limit)
|
|
271
|
+
queryParams.append('limit', params.limit.toString());
|
|
272
|
+
if (params.cursor)
|
|
273
|
+
queryParams.append('cursor', params.cursor);
|
|
274
|
+
if (params.includeCounts)
|
|
275
|
+
queryParams.append('includeCounts', 'true');
|
|
276
|
+
return client._request({
|
|
277
|
+
method: 'GET',
|
|
278
|
+
endpoint: `/v1/convos/scope/${scopeId}?${queryParams.toString()}`,
|
|
279
|
+
sendJWT: true,
|
|
280
|
+
});
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=convo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convo.js","sourceRoot":"","sources":["../../src/routes/convo.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,MAAoB;IAC7D,OAAO;QACL;;;;;;;;;;;WAWG;QACH,KAAK,CAAC,UAAU,CAAC,IAAuB;YACtC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACtD,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;YACnE,CAAC;YACD,OAAO,MAAM,CAAC,QAAQ,CAAqB;gBACzC,MAAM,EAAE,MAAM;gBACd,QAAQ,EAAE,YAAY;gBACtB,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;;;;;WAOG;QACH,KAAK,CAAC,QAAQ,CAAC,OAAe;YAC5B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;YAC1C,CAAC;YACD,OAAO,MAAM,CAAC,QAAQ,CAAmB;gBACvC,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,cAAc,OAAO,EAAE;gBACjC,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;;;;;;;;WAUG;QACH,KAAK,CAAC,SAAS,CAAC,OA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,KAAK;gBAAE,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YACvE,IAAI,MAAM,CAAC,MAAM;gBAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YAC/D,IAAI,MAAM,CAAC,aAAa;gBAAE,WAAW,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;YAEtE,OAAO,MAAM,CAAC,QAAQ,CAAyB;gBAC7C,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,oBAAoB,OAAO,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE;gBACjE,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
export interface GetBalanceResponse {
|
|
3
|
+
/** Total spendable balance — sum of planBalance + purchasedBalance. */
|
|
4
|
+
balance: number;
|
|
5
|
+
/**
|
|
6
|
+
* Plan-granted credits for the current billing cycle. Refreshed (SET, not
|
|
7
|
+
* added) on every Stripe renewal. Unspent plan credits do NOT carry over.
|
|
8
|
+
*/
|
|
9
|
+
planBalance: number;
|
|
10
|
+
/**
|
|
11
|
+
* Purchased credits — accumulated from one-off top-ups, auto-top-ups, admin
|
|
12
|
+
* grants. Carries over indefinitely.
|
|
13
|
+
*/
|
|
14
|
+
purchasedBalance: number;
|
|
15
|
+
/**
|
|
16
|
+
* True when the workspace has at least one prior manual top-up
|
|
17
|
+
* (`subscriptionGrant` order). Powers the FE auto-top-up enable gate —
|
|
18
|
+
* users must top up manually once before auto top-up can be enabled.
|
|
19
|
+
*/
|
|
20
|
+
hasPriorTopUp?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface UsageReportParams {
|
|
23
|
+
/** ISO date string. Server defaults to 30 days ago when omitted. */
|
|
24
|
+
startDate?: string;
|
|
25
|
+
/** ISO date string. Server defaults to "now" when omitted. */
|
|
26
|
+
endDate?: string;
|
|
27
|
+
/** Narrow the per-integration breakdown to a single user's calls. */
|
|
28
|
+
userId?: string;
|
|
29
|
+
/** Narrow the per-user breakdown to a single integration point. */
|
|
30
|
+
integrationPoint?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface UsageReportUserRow {
|
|
33
|
+
userId: string;
|
|
34
|
+
displayName: string | null;
|
|
35
|
+
avatar: unknown | null;
|
|
36
|
+
color: string | null;
|
|
37
|
+
billedCredits: number;
|
|
38
|
+
callCount: number;
|
|
39
|
+
}
|
|
40
|
+
export interface UsageReportIntegrationRow {
|
|
41
|
+
integrationPoint: string;
|
|
42
|
+
billedCredits: number;
|
|
43
|
+
callCount: number;
|
|
44
|
+
}
|
|
45
|
+
export interface UsageReportResponse {
|
|
46
|
+
total: {
|
|
47
|
+
billedCredits: number;
|
|
48
|
+
callCount: number;
|
|
49
|
+
tokensIn: number;
|
|
50
|
+
tokensOut: number;
|
|
51
|
+
};
|
|
52
|
+
byUser: UsageReportUserRow[];
|
|
53
|
+
byIntegration: UsageReportIntegrationRow[];
|
|
54
|
+
filters: {
|
|
55
|
+
startDate: string;
|
|
56
|
+
endDate: string;
|
|
57
|
+
userId: string | null;
|
|
58
|
+
integrationPoint: string | null;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Service-agnostic Nurama Credit balance + usage endpoints.
|
|
63
|
+
*
|
|
64
|
+
* The `/v1/credits/*` route shape and SDK namespace are deliberately
|
|
65
|
+
* decoupled from any single service's naming so future services (convos,
|
|
66
|
+
* etc.) can draw from the same balance without callers having to know
|
|
67
|
+
* where the spend originated. Today the metered data is AI-only because
|
|
68
|
+
* AI is the only service that's metered, but the contract is stable.
|
|
69
|
+
*/
|
|
70
|
+
export default function createCreditsMethods(client: NuramaClient): {
|
|
71
|
+
/**
|
|
72
|
+
* Get the workspace's spendable credit balance.
|
|
73
|
+
*/
|
|
74
|
+
getBalance(workspaceId: string): Promise<GetBalanceResponse>;
|
|
75
|
+
/**
|
|
76
|
+
* Get the workspace's credit usage report. Same shape as the AI usage
|
|
77
|
+
* report — today the data is AI-only because AI is the only service
|
|
78
|
+
* that's metered.
|
|
79
|
+
*/
|
|
80
|
+
getUsageReport(workspaceId: string, params?: UsageReportParams): Promise<UsageReportResponse>;
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=credits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credits.d.ts","sourceRoot":"","sources":["../../src/routes/credits.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE;QACL,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,aAAa,EAAE,yBAAyB,EAAE,CAAC;IAC3C,OAAO,EAAE;QACP,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;KACjC,CAAC;CACH;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,MAAM,EAAE,YAAY;IAE7D;;OAEG;4BAC2B,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IASlE;;;;OAIG;gCAEY,MAAM,WACX,iBAAiB,GACxB,OAAO,CAAC,mBAAmB,CAAC;EAclC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service-agnostic Nurama Credit balance + usage endpoints.
|
|
3
|
+
*
|
|
4
|
+
* The `/v1/credits/*` route shape and SDK namespace are deliberately
|
|
5
|
+
* decoupled from any single service's naming so future services (convos,
|
|
6
|
+
* etc.) can draw from the same balance without callers having to know
|
|
7
|
+
* where the spend originated. Today the metered data is AI-only because
|
|
8
|
+
* AI is the only service that's metered, but the contract is stable.
|
|
9
|
+
*/
|
|
10
|
+
export default function createCreditsMethods(client) {
|
|
11
|
+
return {
|
|
12
|
+
/**
|
|
13
|
+
* Get the workspace's spendable credit balance.
|
|
14
|
+
*/
|
|
15
|
+
async getBalance(workspaceId) {
|
|
16
|
+
if (!workspaceId)
|
|
17
|
+
throw new Error('workspaceId is required.');
|
|
18
|
+
return client._request({
|
|
19
|
+
endpoint: `/v1/credits/balance?workspaceId=${encodeURIComponent(workspaceId)}`,
|
|
20
|
+
method: 'GET',
|
|
21
|
+
sendJWT: true,
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* Get the workspace's credit usage report. Same shape as the AI usage
|
|
26
|
+
* report — today the data is AI-only because AI is the only service
|
|
27
|
+
* that's metered.
|
|
28
|
+
*/
|
|
29
|
+
async getUsageReport(workspaceId, params = {}) {
|
|
30
|
+
if (!workspaceId)
|
|
31
|
+
throw new Error('workspaceId is required.');
|
|
32
|
+
const query = new URLSearchParams({ workspaceId });
|
|
33
|
+
if (params.startDate)
|
|
34
|
+
query.set('startDate', params.startDate);
|
|
35
|
+
if (params.endDate)
|
|
36
|
+
query.set('endDate', params.endDate);
|
|
37
|
+
if (params.userId)
|
|
38
|
+
query.set('userId', params.userId);
|
|
39
|
+
if (params.integrationPoint)
|
|
40
|
+
query.set('integrationPoint', params.integrationPoint);
|
|
41
|
+
return client._request({
|
|
42
|
+
endpoint: `/v1/credits/usage?${query.toString()}`,
|
|
43
|
+
method: 'GET',
|
|
44
|
+
sendJWT: true,
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=credits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credits.js","sourceRoot":"","sources":["../../src/routes/credits.ts"],"names":[],"mappings":"AAkEA;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,MAAoB;IAC/D,OAAO;QACL;;WAEG;QACH,KAAK,CAAC,UAAU,CAAC,WAAmB;YAClC,IAAI,CAAC,WAAW;gBAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAC9D,OAAO,MAAM,CAAC,QAAQ,CAAC;gBACrB,QAAQ,EAAE,mCAAmC,kBAAkB,CAAC,WAAW,CAAC,EAAE;gBAC9E,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;;WAIG;QACH,KAAK,CAAC,cAAc,CAClB,WAAmB,EACnB,SAA4B,EAAE;YAE9B,IAAI,CAAC,WAAW;gBAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAC9D,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;YACnD,IAAI,MAAM,CAAC,SAAS;gBAAE,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;YAC/D,IAAI,MAAM,CAAC,OAAO;gBAAE,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YACzD,IAAI,MAAM,CAAC,MAAM;gBAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YACtD,IAAI,MAAM,CAAC,gBAAgB;gBAAE,KAAK,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;YACpF,OAAO,MAAM,CAAC,QAAQ,CAAC;gBACrB,QAAQ,EAAE,qBAAqB,KAAK,CAAC,QAAQ,EAAE,EAAE;gBACjD,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
import { type Device, type RegisterDeviceBody, type UpdateDeviceBody, type GetUserDevicesQuery } from '@nurama/types';
|
|
3
|
+
/**
|
|
4
|
+
* Defines device-related methods for the NuramaClient.
|
|
5
|
+
* Handles device registration and management for push notifications.
|
|
6
|
+
* @param {NuramaClient} client - The NuramaClient instance.
|
|
7
|
+
* @returns {object} An object containing the device-related methods.
|
|
8
|
+
*/
|
|
9
|
+
export default function createDeviceMethods(client: NuramaClient): {
|
|
10
|
+
/**
|
|
11
|
+
* Register a new device for push notifications.
|
|
12
|
+
* If the same push token is registered again, the existing device will be updated.
|
|
13
|
+
* Requires authentication.
|
|
14
|
+
* @param {RegisterDeviceBody} deviceData - Device registration data.
|
|
15
|
+
* @returns {Promise<Device>} The registered device object.
|
|
16
|
+
* @example
|
|
17
|
+
* const device = await client.device.registerDevice({
|
|
18
|
+
* deviceType: 'ios',
|
|
19
|
+
* pushToken: 'ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]',
|
|
20
|
+
* bundleId: 'com.nurama.mobile',
|
|
21
|
+
* deviceInfo: {
|
|
22
|
+
* appVersion: '1.0.0',
|
|
23
|
+
* osVersion: '17.0',
|
|
24
|
+
* deviceModel: 'iPhone 15',
|
|
25
|
+
* deviceName: "John's iPhone"
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
*/
|
|
29
|
+
registerDevice(deviceData: RegisterDeviceBody): Promise<Device>;
|
|
30
|
+
/**
|
|
31
|
+
* Get all devices for the authenticated user.
|
|
32
|
+
* Requires authentication.
|
|
33
|
+
* @param {GetUserDevicesQuery} [filters] - Optional filters (status, deviceType).
|
|
34
|
+
* @returns {Promise<Device[]>} Array of device objects.
|
|
35
|
+
* @example
|
|
36
|
+
* const devices = await client.device.getUserDevices({ status: 'active' });
|
|
37
|
+
*/
|
|
38
|
+
getUserDevices(filters?: GetUserDevicesQuery): Promise<Device[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Get a specific device by ID.
|
|
41
|
+
* Users can only access their own devices.
|
|
42
|
+
* Requires authentication.
|
|
43
|
+
* @param {string} deviceId - The device ID.
|
|
44
|
+
* @returns {Promise<Device>} The device object.
|
|
45
|
+
* @example
|
|
46
|
+
* const device = await client.device.getDevice('507f1f77bcf86cd799439011');
|
|
47
|
+
*/
|
|
48
|
+
getDevice(deviceId: string): Promise<Device>;
|
|
49
|
+
/**
|
|
50
|
+
* Update device information.
|
|
51
|
+
* Users can only update their own devices.
|
|
52
|
+
* Requires authentication.
|
|
53
|
+
* @param {string} deviceId - The device ID.
|
|
54
|
+
* @param {UpdateDeviceBody} updateData - Data to update (pushToken, deviceInfo, status, subscribedChannels).
|
|
55
|
+
* @returns {Promise<Device>} The updated device object.
|
|
56
|
+
* @example
|
|
57
|
+
* const device = await client.device.updateDevice('507f1f77bcf86cd799439011', {
|
|
58
|
+
* deviceInfo: { appVersion: '1.1.0' },
|
|
59
|
+
* status: 'active'
|
|
60
|
+
* });
|
|
61
|
+
*/
|
|
62
|
+
updateDevice(deviceId: string, updateData: UpdateDeviceBody): Promise<Device>;
|
|
63
|
+
/**
|
|
64
|
+
* Delete a device.
|
|
65
|
+
* Users can only delete their own devices.
|
|
66
|
+
* Requires authentication.
|
|
67
|
+
* @param {string} deviceId - The device ID.
|
|
68
|
+
* @returns {Promise<void>}
|
|
69
|
+
* @example
|
|
70
|
+
* await client.device.deleteDevice('507f1f77bcf86cd799439011');
|
|
71
|
+
*/
|
|
72
|
+
deleteDevice(deviceId: string): Promise<void>;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=device.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/routes/device.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EACL,KAAK,MAAM,EACX,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,MAAM,EAAE,YAAY;IAE5D;;;;;;;;;;;;;;;;;;OAkBG;+BAC8B,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAYrE;;;;;;;OAOG;6BAC4B,mBAAmB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAStE;;;;;;;;OAQG;wBACuB,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAWlD;;;;;;;;;;;;OAYG;2BAC0B,MAAM,cAAc,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAenF;;;;;;;;OAQG;2BAC0B,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;EAWtD"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines device-related methods for the NuramaClient.
|
|
3
|
+
* Handles device registration and management for push notifications.
|
|
4
|
+
* @param {NuramaClient} client - The NuramaClient instance.
|
|
5
|
+
* @returns {object} An object containing the device-related methods.
|
|
6
|
+
*/
|
|
7
|
+
export default function createDeviceMethods(client) {
|
|
8
|
+
return {
|
|
9
|
+
/**
|
|
10
|
+
* Register a new device for push notifications.
|
|
11
|
+
* If the same push token is registered again, the existing device will be updated.
|
|
12
|
+
* Requires authentication.
|
|
13
|
+
* @param {RegisterDeviceBody} deviceData - Device registration data.
|
|
14
|
+
* @returns {Promise<Device>} The registered device object.
|
|
15
|
+
* @example
|
|
16
|
+
* const device = await client.device.registerDevice({
|
|
17
|
+
* deviceType: 'ios',
|
|
18
|
+
* pushToken: 'ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]',
|
|
19
|
+
* bundleId: 'com.nurama.mobile',
|
|
20
|
+
* deviceInfo: {
|
|
21
|
+
* appVersion: '1.0.0',
|
|
22
|
+
* osVersion: '17.0',
|
|
23
|
+
* deviceModel: 'iPhone 15',
|
|
24
|
+
* deviceName: "John's iPhone"
|
|
25
|
+
* }
|
|
26
|
+
* });
|
|
27
|
+
*/
|
|
28
|
+
async registerDevice(deviceData) {
|
|
29
|
+
if (!deviceData.deviceType || !deviceData.pushToken) {
|
|
30
|
+
throw new Error('deviceType and pushToken are required.');
|
|
31
|
+
}
|
|
32
|
+
return client._request({
|
|
33
|
+
method: 'POST',
|
|
34
|
+
endpoint: '/v1/devices',
|
|
35
|
+
body: deviceData,
|
|
36
|
+
sendJWT: true,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* Get all devices for the authenticated user.
|
|
41
|
+
* Requires authentication.
|
|
42
|
+
* @param {GetUserDevicesQuery} [filters] - Optional filters (status, deviceType).
|
|
43
|
+
* @returns {Promise<Device[]>} Array of device objects.
|
|
44
|
+
* @example
|
|
45
|
+
* const devices = await client.device.getUserDevices({ status: 'active' });
|
|
46
|
+
*/
|
|
47
|
+
async getUserDevices(filters) {
|
|
48
|
+
return client._request({
|
|
49
|
+
method: 'GET',
|
|
50
|
+
endpoint: '/v1/devices',
|
|
51
|
+
params: filters,
|
|
52
|
+
sendJWT: true,
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Get a specific device by ID.
|
|
57
|
+
* Users can only access their own devices.
|
|
58
|
+
* Requires authentication.
|
|
59
|
+
* @param {string} deviceId - The device ID.
|
|
60
|
+
* @returns {Promise<Device>} The device object.
|
|
61
|
+
* @example
|
|
62
|
+
* const device = await client.device.getDevice('507f1f77bcf86cd799439011');
|
|
63
|
+
*/
|
|
64
|
+
async getDevice(deviceId) {
|
|
65
|
+
if (!deviceId) {
|
|
66
|
+
throw new Error('deviceId is required.');
|
|
67
|
+
}
|
|
68
|
+
return client._request({
|
|
69
|
+
method: 'GET',
|
|
70
|
+
endpoint: `/v1/devices/${deviceId}`,
|
|
71
|
+
sendJWT: true,
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Update device information.
|
|
76
|
+
* Users can only update their own devices.
|
|
77
|
+
* Requires authentication.
|
|
78
|
+
* @param {string} deviceId - The device ID.
|
|
79
|
+
* @param {UpdateDeviceBody} updateData - Data to update (pushToken, deviceInfo, status, subscribedChannels).
|
|
80
|
+
* @returns {Promise<Device>} The updated device object.
|
|
81
|
+
* @example
|
|
82
|
+
* const device = await client.device.updateDevice('507f1f77bcf86cd799439011', {
|
|
83
|
+
* deviceInfo: { appVersion: '1.1.0' },
|
|
84
|
+
* status: 'active'
|
|
85
|
+
* });
|
|
86
|
+
*/
|
|
87
|
+
async updateDevice(deviceId, updateData) {
|
|
88
|
+
if (!deviceId) {
|
|
89
|
+
throw new Error('deviceId is required.');
|
|
90
|
+
}
|
|
91
|
+
if (Object.keys(updateData).length === 0) {
|
|
92
|
+
throw new Error('At least one field must be provided to update the device.');
|
|
93
|
+
}
|
|
94
|
+
return client._request({
|
|
95
|
+
method: 'PUT',
|
|
96
|
+
endpoint: `/v1/devices/${deviceId}`,
|
|
97
|
+
body: updateData,
|
|
98
|
+
sendJWT: true,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
/**
|
|
102
|
+
* Delete a device.
|
|
103
|
+
* Users can only delete their own devices.
|
|
104
|
+
* Requires authentication.
|
|
105
|
+
* @param {string} deviceId - The device ID.
|
|
106
|
+
* @returns {Promise<void>}
|
|
107
|
+
* @example
|
|
108
|
+
* await client.device.deleteDevice('507f1f77bcf86cd799439011');
|
|
109
|
+
*/
|
|
110
|
+
async deleteDevice(deviceId) {
|
|
111
|
+
if (!deviceId) {
|
|
112
|
+
throw new Error('deviceId is required.');
|
|
113
|
+
}
|
|
114
|
+
return client._request({
|
|
115
|
+
method: 'DELETE',
|
|
116
|
+
endpoint: `/v1/devices/${deviceId}`,
|
|
117
|
+
sendJWT: true,
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=device.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device.js","sourceRoot":"","sources":["../../src/routes/device.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,MAAoB;IAC9D,OAAO;QACL;;;;;;;;;;;;;;;;;;WAkBG;QACH,KAAK,CAAC,cAAc,CAAC,UAA8B;YACjD,IAAI,CAAC,UAAU,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;gBACpD,MAAM,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