@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,237 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
import {
|
|
3
|
+
type Membership,
|
|
4
|
+
type MembershipReport,
|
|
5
|
+
type Mentionable,
|
|
6
|
+
} from '@nurama/types';
|
|
7
|
+
|
|
8
|
+
// --- Common Interfaces (Should be shared) ---
|
|
9
|
+
export interface PaginationParams {
|
|
10
|
+
limit?: number;
|
|
11
|
+
page?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SortParams {
|
|
15
|
+
sort?: Record<string, 1 | -1>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// --- Request Body Interfaces ---
|
|
19
|
+
export interface AddRemoveRoleData {
|
|
20
|
+
membershipId: string;
|
|
21
|
+
role: string; // Consider using a type/enum based on invitableRoles
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// --- Query Parameter Interfaces ---
|
|
25
|
+
export interface GetWorkspaceMembershipParams extends PaginationParams, SortParams {
|
|
26
|
+
nameSearch?: string | null;
|
|
27
|
+
isBillable?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface GetProjectMembershipParams extends PaginationParams, SortParams {
|
|
31
|
+
nameSearch?: string | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// --- Last Seen Interfaces ---
|
|
35
|
+
export interface GetLastSeenData {
|
|
36
|
+
userIds: string[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface LastSeenResult {
|
|
40
|
+
userId: string;
|
|
41
|
+
resourceId: string;
|
|
42
|
+
resourceType: 'workspace' | 'project';
|
|
43
|
+
lastSeen: string | null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface GetLastSeenResponse {
|
|
47
|
+
results: LastSeenResult[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// --- Response Interfaces ---
|
|
51
|
+
export type MembershipResponse = Membership; // Use Membership type for single responses
|
|
52
|
+
export type PaginatedMembershipResponse = MembershipReport; // Use MembershipReport for paginated results
|
|
53
|
+
export type MentionableUserResponse = Mentionable; // Use Mentionable type
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Defines membership-related methods for the NuramaClient.
|
|
57
|
+
* @param {NuramaClient} client - The NuramaClient instance.
|
|
58
|
+
* @returns {object} An object containing the membership-related methods.
|
|
59
|
+
*/
|
|
60
|
+
export default function createMembershipMethods(client: NuramaClient) {
|
|
61
|
+
return {
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves the membership records for the currently authenticated user.
|
|
64
|
+
* @returns {Promise<MembershipResponse[]>} An array of the user's membership records.
|
|
65
|
+
*/
|
|
66
|
+
async getMyMemberships(): Promise<MembershipResponse[]> {
|
|
67
|
+
return client._request<MembershipResponse[]>({
|
|
68
|
+
method: 'GET',
|
|
69
|
+
endpoint: '/v1/memberships/',
|
|
70
|
+
sendJWT: true,
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Retrieves memberships associated with a specific workspace.
|
|
76
|
+
* Requires permission to get workspace members.
|
|
77
|
+
* @param {string} workspaceId - The ID of the workspace.
|
|
78
|
+
* @param {GetWorkspaceMembershipParams} [params] - Query parameters for pagination, sorting, filtering.
|
|
79
|
+
* @returns {Promise<PaginatedMembershipResponse>} Paginated list of workspace memberships.
|
|
80
|
+
*/
|
|
81
|
+
async getWorkspaceMemberships(workspaceId: string, params?: GetWorkspaceMembershipParams): Promise<PaginatedMembershipResponse> {
|
|
82
|
+
if (!workspaceId) throw new Error('workspaceId is required.');
|
|
83
|
+
return client._request<PaginatedMembershipResponse>({
|
|
84
|
+
method: 'GET',
|
|
85
|
+
endpoint: `/v1/memberships/workspace/${workspaceId}`,
|
|
86
|
+
params: params,
|
|
87
|
+
sendJWT: true,
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Retrieves memberships associated with a specific project.
|
|
93
|
+
* Requires permission based on user's role in the project/workspace.
|
|
94
|
+
* @param {string} projectId - The ID of the project.
|
|
95
|
+
* @param {GetProjectMembershipParams} [params] - Query parameters for pagination, sorting, filtering.
|
|
96
|
+
* @returns {Promise<PaginatedMembershipResponse>} Paginated list of project memberships.
|
|
97
|
+
*/
|
|
98
|
+
async getProjectMemberships(projectId: string, params?: GetProjectMembershipParams): Promise<PaginatedMembershipResponse> {
|
|
99
|
+
if (!projectId) throw new Error('projectId is required.');
|
|
100
|
+
return client._request<PaginatedMembershipResponse>({
|
|
101
|
+
method: 'GET',
|
|
102
|
+
endpoint: `/v1/memberships/project/${projectId}`,
|
|
103
|
+
params: params,
|
|
104
|
+
sendJWT: true,
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Deletes a specific membership record by its ID.
|
|
110
|
+
* Requires specific permissions to delete others' memberships.
|
|
111
|
+
* @param {string} membershipId - The ID of the membership record to delete.
|
|
112
|
+
* @returns {Promise<void>}
|
|
113
|
+
*/
|
|
114
|
+
async deleteMembership(membershipId: string): Promise<void> {
|
|
115
|
+
if (!membershipId) throw new Error('membershipId is required.');
|
|
116
|
+
return client._request({
|
|
117
|
+
method: 'DELETE',
|
|
118
|
+
endpoint: `/v1/memberships/${membershipId}`,
|
|
119
|
+
sendJWT: true,
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Allows the authenticated user to leave a resource (delete their own membership).
|
|
125
|
+
* Cannot be used to remove ownership roles.
|
|
126
|
+
* @param {string} resourceId - The ID of the resource (workspace or project) to leave.
|
|
127
|
+
* @returns {Promise<void>}
|
|
128
|
+
*/
|
|
129
|
+
async leaveResource(resourceId: string): Promise<void> {
|
|
130
|
+
if (!resourceId) throw new Error('resourceId is required.');
|
|
131
|
+
return client._request({
|
|
132
|
+
method: 'DELETE',
|
|
133
|
+
endpoint: `/v1/memberships/leave/${resourceId}`,
|
|
134
|
+
sendJWT: true,
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Adds a role to an existing membership record.
|
|
140
|
+
* Requires permission to add roles.
|
|
141
|
+
* @param {AddRemoveRoleData} data - Object containing membershipId and the role to add.
|
|
142
|
+
* @returns {Promise<MembershipResponse>} The updated membership object.
|
|
143
|
+
*/
|
|
144
|
+
async addRole(data: AddRemoveRoleData): Promise<MembershipResponse> {
|
|
145
|
+
if (!data || !data.membershipId || !data.role) {
|
|
146
|
+
throw new Error('membershipId and role are required.');
|
|
147
|
+
}
|
|
148
|
+
return client._request<MembershipResponse>({
|
|
149
|
+
method: 'POST',
|
|
150
|
+
endpoint: '/v1/memberships/add-role',
|
|
151
|
+
body: data,
|
|
152
|
+
sendJWT: true,
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Removes a role from an existing membership record.
|
|
158
|
+
* Requires permission to remove roles. Cannot remove ownership roles.
|
|
159
|
+
* @param {AddRemoveRoleData} data - Object containing membershipId and the role to remove.
|
|
160
|
+
* @returns {Promise<MembershipResponse>} The updated membership object.
|
|
161
|
+
*/
|
|
162
|
+
async removeRole(data: AddRemoveRoleData): Promise<MembershipResponse> {
|
|
163
|
+
if (!data || !data.membershipId || !data.role) {
|
|
164
|
+
throw new Error('membershipId and role are required.');
|
|
165
|
+
}
|
|
166
|
+
return client._request<MembershipResponse>({
|
|
167
|
+
method: 'POST',
|
|
168
|
+
endpoint: '/v1/memberships/remove-role',
|
|
169
|
+
body: data,
|
|
170
|
+
sendJWT: true,
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Retrieves a list of users mentionable within a project based on visibility.
|
|
176
|
+
* Requires permission to get mentionable users.
|
|
177
|
+
* @param {string} projectId - The ID of the project.
|
|
178
|
+
* @param {'creator' | 'reviewer' | 'all'} visibility - The visibility scope. Pass 'all' to get users from both creator and reviewer visibilities (e.g. for boards visible to both).
|
|
179
|
+
* @returns {Promise<MentionableUserResponse[]>} An array of mentionable user objects.
|
|
180
|
+
*/
|
|
181
|
+
async getProjectMentionableUsers(projectId: string, visibility: 'creator' | 'reviewer' | 'all'): Promise<MentionableUserResponse[]> {
|
|
182
|
+
if (!projectId) throw new Error('projectId is required.');
|
|
183
|
+
if (!visibility) throw new Error('visibility is required.');
|
|
184
|
+
return client._request<MentionableUserResponse[]>({
|
|
185
|
+
method: 'GET',
|
|
186
|
+
endpoint: `/v1/memberships/mentionable/project/${projectId}/${visibility}`,
|
|
187
|
+
sendJWT: true,
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Retrieves resource-specific last seen timestamps for multiple users in a workspace.
|
|
193
|
+
* Requires permission to get workspace members.
|
|
194
|
+
* @param {string} workspaceId - The ID of the workspace.
|
|
195
|
+
* @param {GetLastSeenData} data - Object containing array of user IDs (1-100).
|
|
196
|
+
* @returns {Promise<GetLastSeenResponse>} Object with results array containing last seen data.
|
|
197
|
+
*/
|
|
198
|
+
async getWorkspaceLastSeen(workspaceId: string, data: GetLastSeenData): Promise<GetLastSeenResponse> {
|
|
199
|
+
if (!workspaceId) throw new Error('workspaceId is required.');
|
|
200
|
+
if (!data || !data.userIds || !Array.isArray(data.userIds) || data.userIds.length === 0) {
|
|
201
|
+
throw new Error('userIds array is required and must contain at least one user ID.');
|
|
202
|
+
}
|
|
203
|
+
if (data.userIds.length > 100) {
|
|
204
|
+
throw new Error('userIds array cannot contain more than 100 user IDs.');
|
|
205
|
+
}
|
|
206
|
+
return client._request<GetLastSeenResponse>({
|
|
207
|
+
method: 'POST',
|
|
208
|
+
endpoint: `/v1/memberships/workspace/${workspaceId}/last-seen`,
|
|
209
|
+
body: data,
|
|
210
|
+
sendJWT: true,
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Retrieves resource-specific last seen timestamps for multiple users in a project.
|
|
216
|
+
* Requires permission to get project members.
|
|
217
|
+
* @param {string} projectId - The ID of the project.
|
|
218
|
+
* @param {GetLastSeenData} data - Object containing array of user IDs (1-100).
|
|
219
|
+
* @returns {Promise<GetLastSeenResponse>} Object with results array containing last seen data.
|
|
220
|
+
*/
|
|
221
|
+
async getProjectLastSeen(projectId: string, data: GetLastSeenData): Promise<GetLastSeenResponse> {
|
|
222
|
+
if (!projectId) throw new Error('projectId is required.');
|
|
223
|
+
if (!data || !data.userIds || !Array.isArray(data.userIds) || data.userIds.length === 0) {
|
|
224
|
+
throw new Error('userIds array is required and must contain at least one user ID.');
|
|
225
|
+
}
|
|
226
|
+
if (data.userIds.length > 100) {
|
|
227
|
+
throw new Error('userIds array cannot contain more than 100 user IDs.');
|
|
228
|
+
}
|
|
229
|
+
return client._request<GetLastSeenResponse>({
|
|
230
|
+
method: 'POST',
|
|
231
|
+
endpoint: `/v1/memberships/project/${projectId}/last-seen`,
|
|
232
|
+
body: data,
|
|
233
|
+
sendJWT: true,
|
|
234
|
+
});
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
import {
|
|
3
|
+
type Notification,
|
|
4
|
+
type PaginatedResult,
|
|
5
|
+
type CursorPaginatedResult,
|
|
6
|
+
} from '@nurama/types';
|
|
7
|
+
|
|
8
|
+
// Combine pagination metadata with a results array
|
|
9
|
+
// (Should be defined centrally or imported if used across multiple route files)
|
|
10
|
+
export type PaginatedResponse<T> = (PaginatedResult | CursorPaginatedResult) & {
|
|
11
|
+
results?: T[];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// --- Common Interfaces (Should be shared) ---
|
|
15
|
+
export interface PaginationParams {
|
|
16
|
+
limit?: number;
|
|
17
|
+
// Cursor specific
|
|
18
|
+
cursor?: string;
|
|
19
|
+
paginateReverse?: boolean;
|
|
20
|
+
includeCounts?: boolean;
|
|
21
|
+
includeCursorRecord?: boolean;
|
|
22
|
+
startAt?: string;
|
|
23
|
+
includeStartAtRecord?: boolean;
|
|
24
|
+
// Index specific
|
|
25
|
+
page?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface SortParams {
|
|
29
|
+
sort?: Record<string, 1 | -1>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// --- Request Body Interfaces ---
|
|
33
|
+
export interface BaseNotificationParams {
|
|
34
|
+
channels: string[];
|
|
35
|
+
types?: string[]; // Consider using a specific type based on notificationTypes
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface GetNotificationsData extends BaseNotificationParams, PaginationParams, SortParams {
|
|
39
|
+
paginate?: 'cursor' | 'index';
|
|
40
|
+
// Index specific pagination params from validation
|
|
41
|
+
createdAfter?: number;
|
|
42
|
+
createdBefore?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface GetNewNotificationsData extends BaseNotificationParams, PaginationParams {
|
|
46
|
+
paginate?: 'cursor' | 'index';
|
|
47
|
+
updateLastSeen?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface GetNewNotificationCountData extends BaseNotificationParams {}
|
|
51
|
+
|
|
52
|
+
export interface ChannelQuery {
|
|
53
|
+
channels: string[];
|
|
54
|
+
types?: string[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface GetNewNotificationCountBulkData {
|
|
58
|
+
channelQueries: ChannelQuery[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface GetUsersLastNotificationsSeenData extends BaseNotificationParams {}
|
|
62
|
+
|
|
63
|
+
export interface UpdateUsersLastSeenData extends BaseNotificationParams {}
|
|
64
|
+
|
|
65
|
+
// --- Response Interfaces (using 'any' for now) ---
|
|
66
|
+
|
|
67
|
+
//type NotificationResponse = any;
|
|
68
|
+
export type PaginatedNotificationResponse = PaginatedResponse<Notification>;
|
|
69
|
+
export type NotificationCountResponse = { count: number };
|
|
70
|
+
export type NotificationCountBulkResponse = ({ channels: string[], types?: string[], count: number })[];
|
|
71
|
+
export type LastSeenResponse = { channels: string[], lastSeen: number, types?: string[] }; // Defined based on comments/tests
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Defines notification-related methods for the NuramaClient.
|
|
76
|
+
* @param {NuramaClient} client - The NuramaClient instance.
|
|
77
|
+
* @returns {object} An object containing the notification-related methods.
|
|
78
|
+
*/
|
|
79
|
+
export default function createNotificationMethods(client: NuramaClient) {
|
|
80
|
+
return {
|
|
81
|
+
/**
|
|
82
|
+
* Retrieves notifications for specified channels, with optional filtering and pagination.
|
|
83
|
+
* @param {GetNotificationsData} data - Request body containing channels, types, and pagination/sorting options.
|
|
84
|
+
* @returns {Promise<PaginatedNotificationResponse>} Paginated list of notifications.
|
|
85
|
+
*/
|
|
86
|
+
async getNotifications(data: GetNotificationsData): Promise<PaginatedNotificationResponse> {
|
|
87
|
+
return client._request<PaginatedNotificationResponse>({
|
|
88
|
+
method: 'POST',
|
|
89
|
+
endpoint: '/v1/notifications/',
|
|
90
|
+
body: data,
|
|
91
|
+
sendJWT: true,
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Retrieves new notifications since the user's last viewed timestamp for the specified channels.
|
|
97
|
+
* Optionally updates the last viewed timestamp.
|
|
98
|
+
* @param {GetNewNotificationsData} data - Request body containing channels, types, pagination, and update flag.
|
|
99
|
+
* @returns {Promise<PaginatedNotificationResponse>} Paginated list of new notifications.
|
|
100
|
+
*/
|
|
101
|
+
async getNewNotifications(data: GetNewNotificationsData): Promise<PaginatedNotificationResponse> {
|
|
102
|
+
return client._request<PaginatedNotificationResponse>({
|
|
103
|
+
method: 'POST',
|
|
104
|
+
endpoint: '/v1/notifications/new',
|
|
105
|
+
body: data,
|
|
106
|
+
sendJWT: true,
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Gets the count of new (unread) notifications for the specified channels.
|
|
112
|
+
* @param {GetNewNotificationCountData} data - Request body containing channels and optional types.
|
|
113
|
+
* @returns {Promise<NotificationCountResponse>} Object containing the count of new notifications.
|
|
114
|
+
*/
|
|
115
|
+
async getNewNotificationCount(data: GetNewNotificationCountData): Promise<NotificationCountResponse> {
|
|
116
|
+
return client._request<NotificationCountResponse>({
|
|
117
|
+
method: 'POST',
|
|
118
|
+
endpoint: '/v1/notifications/count',
|
|
119
|
+
body: data,
|
|
120
|
+
sendJWT: true,
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Gets the count of new notifications for multiple channel/type queries in a single request.
|
|
126
|
+
* @param {GetNewNotificationCountBulkData} data - Request body containing an array of channel queries.
|
|
127
|
+
* @returns {Promise<NotificationCountBulkResponse>} Array of objects, each containing channels, types (if provided), and count.
|
|
128
|
+
*/
|
|
129
|
+
async getNewNotificationCountBulk(data: GetNewNotificationCountBulkData): Promise<NotificationCountBulkResponse> {
|
|
130
|
+
return client._request<NotificationCountBulkResponse>({
|
|
131
|
+
method: 'POST',
|
|
132
|
+
endpoint: '/v1/notifications/count/bulk',
|
|
133
|
+
body: data,
|
|
134
|
+
sendJWT: true,
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Retrieves the last seen timestamp record for the specified channels and optional types.
|
|
140
|
+
* @param {GetUsersLastNotificationsSeenData} data - Request body containing channels and optional types.
|
|
141
|
+
* @returns {Promise<LastSeenResponse>} The last seen record object.
|
|
142
|
+
*/
|
|
143
|
+
async getUsersLastNotificationsSeen(data: GetUsersLastNotificationsSeenData): Promise<LastSeenResponse> {
|
|
144
|
+
return client._request<LastSeenResponse>({
|
|
145
|
+
method: 'POST',
|
|
146
|
+
endpoint: '/v1/notifications/last-seen',
|
|
147
|
+
body: data,
|
|
148
|
+
sendJWT: true,
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Updates (or creates) the last seen timestamp for the user for the specified channels and optional types.
|
|
154
|
+
* @param {UpdateUsersLastSeenData} data - Request body containing channels and optional types.
|
|
155
|
+
* @returns {Promise<LastSeenResponse>} The updated (or created) last seen record object.
|
|
156
|
+
*/
|
|
157
|
+
async updateUsersLastSeen(data: UpdateUsersLastSeenData): Promise<LastSeenResponse> {
|
|
158
|
+
return client._request<LastSeenResponse>({
|
|
159
|
+
method: 'PUT',
|
|
160
|
+
endpoint: '/v1/notifications/last-seen',
|
|
161
|
+
body: data,
|
|
162
|
+
sendJWT: true,
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One application a user has authorised over OAuth.
|
|
5
|
+
*
|
|
6
|
+
* A grant is the record of consent: the scopes approved, and the tie binding
|
|
7
|
+
* every token issued under it. Revoking one withdraws the application's
|
|
8
|
+
* access.
|
|
9
|
+
*/
|
|
10
|
+
export interface OAuthGrantSummary {
|
|
11
|
+
/** Opaque identifier; pass to `revokeGrant`. */
|
|
12
|
+
grantId: string;
|
|
13
|
+
clientId: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* The application's name.
|
|
16
|
+
*
|
|
17
|
+
* Chosen by the application itself when `verified` is false — treat it as
|
|
18
|
+
* display text from an untrusted source, never as identification.
|
|
19
|
+
*/
|
|
20
|
+
clientName: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Whether Nurama configured this application.
|
|
23
|
+
*
|
|
24
|
+
* False for one that registered itself through Dynamic Client Registration:
|
|
25
|
+
* it picked its own name and nobody reviewed it.
|
|
26
|
+
*/
|
|
27
|
+
verified: boolean;
|
|
28
|
+
/** Scopes the user approved, from the backend's token-scope registry. */
|
|
29
|
+
scopes: string[];
|
|
30
|
+
grantedAt: string;
|
|
31
|
+
expiresAt: string | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default function createOAuthGrantMethods(client: NuramaClient) {
|
|
35
|
+
return {
|
|
36
|
+
/**
|
|
37
|
+
* List the applications the caller has authorised, newest first.
|
|
38
|
+
* Expired grants are omitted by the server.
|
|
39
|
+
*/
|
|
40
|
+
async listGrants(): Promise<OAuthGrantSummary[]> {
|
|
41
|
+
const res = await client._request<{ results: OAuthGrantSummary[] }>({
|
|
42
|
+
method: 'GET',
|
|
43
|
+
endpoint: '/v1/oauth-grants',
|
|
44
|
+
sendJWT: true,
|
|
45
|
+
bypassCache: true,
|
|
46
|
+
});
|
|
47
|
+
return res.results;
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Withdraw an application's access: the grant and every token issued
|
|
52
|
+
* under it. An access token already in flight stays valid until it
|
|
53
|
+
* expires, so revocation is not instantaneous for a request under way.
|
|
54
|
+
*/
|
|
55
|
+
async revokeGrant(grantId: string): Promise<void> {
|
|
56
|
+
if (!grantId) throw new Error('grantId is required.');
|
|
57
|
+
return client._request<void>({
|
|
58
|
+
method: 'DELETE',
|
|
59
|
+
endpoint: `/v1/oauth-grants/${grantId}`,
|
|
60
|
+
sendJWT: true,
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
|
|
3
|
+
// --- Request Body Interfaces ---
|
|
4
|
+
export interface StripeCheckoutRequest {
|
|
5
|
+
resourceId: string;
|
|
6
|
+
productId: string;
|
|
7
|
+
currency: 'usd' | 'gbp';
|
|
8
|
+
billingPeriod: 'month' | 'year';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ManualCheckoutRequest {
|
|
12
|
+
resourceId: string;
|
|
13
|
+
productId: string;
|
|
14
|
+
currency: 'usd' | 'gbp';
|
|
15
|
+
billingPeriod: 'month' | 'year';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// --- Response Interfaces ---
|
|
19
|
+
export interface StripeCheckoutResponse {
|
|
20
|
+
url: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface StripeCustomerResponse {
|
|
24
|
+
customerId: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface StripePortalResponse {
|
|
28
|
+
url: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Defines payment-related methods for the NuramaClient.
|
|
33
|
+
* @param {NuramaClient} client - The NuramaClient instance.
|
|
34
|
+
* @returns {object} An object containing the payment-related methods.
|
|
35
|
+
*/
|
|
36
|
+
export default function createPaymentMethods(client: NuramaClient) {
|
|
37
|
+
return {
|
|
38
|
+
/**
|
|
39
|
+
* Create a Stripe subscription checkout session.
|
|
40
|
+
* Requires authentication and permission.
|
|
41
|
+
* @param {StripeCheckoutRequest} checkoutData - The checkout request data.
|
|
42
|
+
* @returns {Promise<StripeCheckoutResponse>} Object containing the Stripe checkout session URL.
|
|
43
|
+
*/
|
|
44
|
+
async createStripeCheckout(checkoutData: StripeCheckoutRequest): Promise<StripeCheckoutResponse> {
|
|
45
|
+
if (!checkoutData.resourceId) throw new Error('resourceId is required.');
|
|
46
|
+
if (!checkoutData.productId) throw new Error('productId is required.');
|
|
47
|
+
if (!checkoutData.currency) throw new Error('currency is required.');
|
|
48
|
+
if (!checkoutData.billingPeriod) throw new Error('billingPeriod is required.');
|
|
49
|
+
|
|
50
|
+
return client._request<StripeCheckoutResponse>({
|
|
51
|
+
method: 'POST',
|
|
52
|
+
endpoint: '/v1/payments/stripe/checkout',
|
|
53
|
+
body: checkoutData,
|
|
54
|
+
sendJWT: true,
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Create a manual subscription without Stripe processing.
|
|
60
|
+
* Requires authentication and permission.
|
|
61
|
+
* @param {ManualCheckoutRequest} checkoutData - The manual checkout request data.
|
|
62
|
+
* @returns {Promise<any>} The created subscription object.
|
|
63
|
+
*/
|
|
64
|
+
async createManualCheckout(checkoutData: ManualCheckoutRequest): Promise<any> {
|
|
65
|
+
if (!checkoutData.resourceId) throw new Error('resourceId is required.');
|
|
66
|
+
if (!checkoutData.productId) throw new Error('productId is required.');
|
|
67
|
+
if (!checkoutData.currency) throw new Error('currency is required.');
|
|
68
|
+
if (!checkoutData.billingPeriod) throw new Error('billingPeriod is required.');
|
|
69
|
+
|
|
70
|
+
return client._request<any>({
|
|
71
|
+
method: 'POST',
|
|
72
|
+
endpoint: '/v1/payments/manual/checkout',
|
|
73
|
+
body: checkoutData,
|
|
74
|
+
sendJWT: true,
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Create a new Stripe customer for the authenticated user.
|
|
80
|
+
* Requires authentication and permission.
|
|
81
|
+
* @returns {Promise<StripeCustomerResponse>} Object containing the Stripe customer ID.
|
|
82
|
+
*/
|
|
83
|
+
async createStripeCustomer(): Promise<StripeCustomerResponse> {
|
|
84
|
+
return client._request<StripeCustomerResponse>({
|
|
85
|
+
method: 'POST',
|
|
86
|
+
endpoint: '/v1/payments/stripe/customer',
|
|
87
|
+
sendJWT: true,
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Generate a URL for the Stripe customer portal for subscription management.
|
|
93
|
+
* Requires authentication and permission.
|
|
94
|
+
* @returns {Promise<StripePortalResponse>} Object containing the Stripe portal session URL.
|
|
95
|
+
*/
|
|
96
|
+
async getStripePortalUrl(): Promise<StripePortalResponse> {
|
|
97
|
+
return client._request<StripePortalResponse>({
|
|
98
|
+
method: 'GET',
|
|
99
|
+
endpoint: '/v1/payments/stripe/portal',
|
|
100
|
+
sendJWT: true,
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
import { type Product } from '@nurama/types'; // Import Product type
|
|
3
|
+
|
|
4
|
+
// --- Query Parameter Interfaces ---
|
|
5
|
+
export interface GetWorkspaceProductsParams {
|
|
6
|
+
productType?: 'basePlan' | 'addSeat' | 'addStorage' | 'addCredits' | 'enableBoards';
|
|
7
|
+
paymentProvider?: 'stripe' | 'manualInvoice';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// --- Response Interfaces ---
|
|
11
|
+
export type ProductResponse = Product;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Defines product-related methods for the NuramaClient.
|
|
15
|
+
* @param {NuramaClient} client - The NuramaClient instance.
|
|
16
|
+
* @returns {object} An object containing the product-related methods.
|
|
17
|
+
*/
|
|
18
|
+
export default function createProductMethods(client: NuramaClient) {
|
|
19
|
+
return {
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves available products for a specific workspace, considering restrictions.
|
|
22
|
+
* Requires authentication and permission.
|
|
23
|
+
* @param {string} workspaceId - The ID of the workspace.
|
|
24
|
+
* @param {GetWorkspaceProductsParams} [params] - Optional query parameters.
|
|
25
|
+
* @returns {Promise<ProductResponse[]>} An array of available product objects.
|
|
26
|
+
*/
|
|
27
|
+
async getWorkspaceProducts(workspaceId: string, params?: GetWorkspaceProductsParams): Promise<ProductResponse[]> {
|
|
28
|
+
if (!workspaceId) throw new Error('workspaceId is required.');
|
|
29
|
+
return client._request<ProductResponse[]>({
|
|
30
|
+
method: 'GET',
|
|
31
|
+
endpoint: `/v1/products/workspace/${workspaceId}`,
|
|
32
|
+
params,
|
|
33
|
+
sendJWT: true,
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* List active starter-package "plans" available to the caller,
|
|
39
|
+
* scoped by user-level restrictions but NOT bound to a workspace.
|
|
40
|
+
* Used by the post-signup plan-selection overlay before any
|
|
41
|
+
* workspace exists.
|
|
42
|
+
* @returns {Promise<ProductResponse[]>} Active starter-package plans.
|
|
43
|
+
*/
|
|
44
|
+
async listPlans(): Promise<ProductResponse[]> {
|
|
45
|
+
return client._request<ProductResponse[]>({
|
|
46
|
+
method: 'GET',
|
|
47
|
+
endpoint: '/v1/products/plans',
|
|
48
|
+
sendJWT: true,
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Suggested billing currency for the caller, derived server-side from
|
|
54
|
+
* the CDN geo header. A *default* for the currency selector only — the
|
|
55
|
+
* user can override. Falls back to `usd` with no geo header.
|
|
56
|
+
*/
|
|
57
|
+
async getSuggestedCurrency(): Promise<{ currency: SupportedCurrency; country: string | null; locked?: boolean; supported: SupportedCurrency[] }> {
|
|
58
|
+
return client._request<{ currency: SupportedCurrency; country: string | null; supported: SupportedCurrency[] }>({
|
|
59
|
+
method: 'GET',
|
|
60
|
+
endpoint: '/v1/products/suggested-currency',
|
|
61
|
+
sendJWT: true,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type SupportedCurrency = 'gbp' | 'usd' | 'eur';
|