@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,133 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
import {
|
|
3
|
+
type Device,
|
|
4
|
+
type RegisterDeviceBody,
|
|
5
|
+
type UpdateDeviceBody,
|
|
6
|
+
type GetUserDevicesQuery,
|
|
7
|
+
} from '@nurama/types';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Defines device-related methods for the NuramaClient.
|
|
11
|
+
* Handles device registration and management for push notifications.
|
|
12
|
+
* @param {NuramaClient} client - The NuramaClient instance.
|
|
13
|
+
* @returns {object} An object containing the device-related methods.
|
|
14
|
+
*/
|
|
15
|
+
export default function createDeviceMethods(client: NuramaClient) {
|
|
16
|
+
return {
|
|
17
|
+
/**
|
|
18
|
+
* Register a new device for push notifications.
|
|
19
|
+
* If the same push token is registered again, the existing device will be updated.
|
|
20
|
+
* Requires authentication.
|
|
21
|
+
* @param {RegisterDeviceBody} deviceData - Device registration data.
|
|
22
|
+
* @returns {Promise<Device>} The registered device object.
|
|
23
|
+
* @example
|
|
24
|
+
* const device = await client.device.registerDevice({
|
|
25
|
+
* deviceType: 'ios',
|
|
26
|
+
* pushToken: 'ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]',
|
|
27
|
+
* bundleId: 'com.nurama.mobile',
|
|
28
|
+
* deviceInfo: {
|
|
29
|
+
* appVersion: '1.0.0',
|
|
30
|
+
* osVersion: '17.0',
|
|
31
|
+
* deviceModel: 'iPhone 15',
|
|
32
|
+
* deviceName: "John's iPhone"
|
|
33
|
+
* }
|
|
34
|
+
* });
|
|
35
|
+
*/
|
|
36
|
+
async registerDevice(deviceData: RegisterDeviceBody): Promise<Device> {
|
|
37
|
+
if (!deviceData.deviceType || !deviceData.pushToken) {
|
|
38
|
+
throw new Error('deviceType and pushToken are required.');
|
|
39
|
+
}
|
|
40
|
+
return client._request<Device>({
|
|
41
|
+
method: 'POST',
|
|
42
|
+
endpoint: '/v1/devices',
|
|
43
|
+
body: deviceData,
|
|
44
|
+
sendJWT: true,
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get all devices for the authenticated user.
|
|
50
|
+
* Requires authentication.
|
|
51
|
+
* @param {GetUserDevicesQuery} [filters] - Optional filters (status, deviceType).
|
|
52
|
+
* @returns {Promise<Device[]>} Array of device objects.
|
|
53
|
+
* @example
|
|
54
|
+
* const devices = await client.device.getUserDevices({ status: 'active' });
|
|
55
|
+
*/
|
|
56
|
+
async getUserDevices(filters?: GetUserDevicesQuery): Promise<Device[]> {
|
|
57
|
+
return client._request<Device[]>({
|
|
58
|
+
method: 'GET',
|
|
59
|
+
endpoint: '/v1/devices',
|
|
60
|
+
params: filters,
|
|
61
|
+
sendJWT: true,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get a specific device by ID.
|
|
67
|
+
* Users can only access their own devices.
|
|
68
|
+
* Requires authentication.
|
|
69
|
+
* @param {string} deviceId - The device ID.
|
|
70
|
+
* @returns {Promise<Device>} The device object.
|
|
71
|
+
* @example
|
|
72
|
+
* const device = await client.device.getDevice('507f1f77bcf86cd799439011');
|
|
73
|
+
*/
|
|
74
|
+
async getDevice(deviceId: string): Promise<Device> {
|
|
75
|
+
if (!deviceId) {
|
|
76
|
+
throw new Error('deviceId is required.');
|
|
77
|
+
}
|
|
78
|
+
return client._request<Device>({
|
|
79
|
+
method: 'GET',
|
|
80
|
+
endpoint: `/v1/devices/${deviceId}`,
|
|
81
|
+
sendJWT: true,
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Update device information.
|
|
87
|
+
* Users can only update their own devices.
|
|
88
|
+
* Requires authentication.
|
|
89
|
+
* @param {string} deviceId - The device ID.
|
|
90
|
+
* @param {UpdateDeviceBody} updateData - Data to update (pushToken, deviceInfo, status, subscribedChannels).
|
|
91
|
+
* @returns {Promise<Device>} The updated device object.
|
|
92
|
+
* @example
|
|
93
|
+
* const device = await client.device.updateDevice('507f1f77bcf86cd799439011', {
|
|
94
|
+
* deviceInfo: { appVersion: '1.1.0' },
|
|
95
|
+
* status: 'active'
|
|
96
|
+
* });
|
|
97
|
+
*/
|
|
98
|
+
async updateDevice(deviceId: string, updateData: UpdateDeviceBody): Promise<Device> {
|
|
99
|
+
if (!deviceId) {
|
|
100
|
+
throw new Error('deviceId is required.');
|
|
101
|
+
}
|
|
102
|
+
if (Object.keys(updateData).length === 0) {
|
|
103
|
+
throw new Error('At least one field must be provided to update the device.');
|
|
104
|
+
}
|
|
105
|
+
return client._request<Device>({
|
|
106
|
+
method: 'PUT',
|
|
107
|
+
endpoint: `/v1/devices/${deviceId}`,
|
|
108
|
+
body: updateData,
|
|
109
|
+
sendJWT: true,
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Delete a device.
|
|
115
|
+
* Users can only delete their own devices.
|
|
116
|
+
* Requires authentication.
|
|
117
|
+
* @param {string} deviceId - The device ID.
|
|
118
|
+
* @returns {Promise<void>}
|
|
119
|
+
* @example
|
|
120
|
+
* await client.device.deleteDevice('507f1f77bcf86cd799439011');
|
|
121
|
+
*/
|
|
122
|
+
async deleteDevice(deviceId: string): Promise<void> {
|
|
123
|
+
if (!deviceId) {
|
|
124
|
+
throw new Error('deviceId is required.');
|
|
125
|
+
}
|
|
126
|
+
return client._request<void>({
|
|
127
|
+
method: 'DELETE',
|
|
128
|
+
endpoint: `/v1/devices/${deviceId}`,
|
|
129
|
+
sendJWT: true,
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
import {
|
|
3
|
+
type Folder,
|
|
4
|
+
type Asset,
|
|
5
|
+
type PaginatedResult,
|
|
6
|
+
type CursorPaginatedResult,
|
|
7
|
+
} from '@nurama/types';
|
|
8
|
+
|
|
9
|
+
// Combine pagination metadata with a results array
|
|
10
|
+
// (Should be defined centrally or imported if used across multiple route files)
|
|
11
|
+
export type PaginatedResponse<T> = (PaginatedResult | CursorPaginatedResult) & {
|
|
12
|
+
results?: T[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// --- Common Interfaces (Consider moving to a shared file if used elsewhere) ---
|
|
16
|
+
export interface PaginationParams {
|
|
17
|
+
limit?: number;
|
|
18
|
+
page?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SortParams {
|
|
22
|
+
sort?: Record<string, 1 | -1>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// --- Request Body Interfaces ---
|
|
26
|
+
export interface UpdateFolderData {
|
|
27
|
+
name?: string;
|
|
28
|
+
color?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface UpdateFolderIconData {
|
|
32
|
+
name: string;
|
|
33
|
+
checksum: string;
|
|
34
|
+
sizeInMB: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
export interface TagFolderData {
|
|
40
|
+
tagId: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface UntagFolderData {
|
|
44
|
+
tagId: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// --- Query Parameter Interfaces ---
|
|
48
|
+
export interface GetFoldersAssetsParams extends PaginationParams, SortParams {
|
|
49
|
+
visibility?: 'creator' | 'reviewer';
|
|
50
|
+
chats?: boolean;
|
|
51
|
+
messages?: number;
|
|
52
|
+
replies?: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// --- Response Interfaces ---
|
|
56
|
+
export type FolderResponse = Folder; // Use Folder type
|
|
57
|
+
export type AssetResponse = Asset; // Use Asset type
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Defines folder-related methods for the NuramaClient.
|
|
61
|
+
* @param {NuramaClient} client - The NuramaClient instance.
|
|
62
|
+
* @returns {object} An object containing the folder-related methods.
|
|
63
|
+
*/
|
|
64
|
+
export default function createFolderMethods(client: NuramaClient) {
|
|
65
|
+
return {
|
|
66
|
+
/** Fetch a single folder by id. */
|
|
67
|
+
async getFolder(folderId: string): Promise<FolderResponse> {
|
|
68
|
+
if (!folderId) throw new Error('folderId is required.');
|
|
69
|
+
return client._request<FolderResponse>({
|
|
70
|
+
method: 'GET',
|
|
71
|
+
endpoint: `/v1/folders/${folderId}`,
|
|
72
|
+
sendJWT: true,
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Updates a folder's name and/or color.
|
|
78
|
+
* @param {string} folderId - The ID of the folder to update.
|
|
79
|
+
* @param {UpdateFolderData} data - Data containing the name and/or color to update.
|
|
80
|
+
* @returns {Promise<FolderResponse>} The updated folder object.
|
|
81
|
+
*/
|
|
82
|
+
async updateFolder(folderId: string, data: UpdateFolderData): Promise<FolderResponse> {
|
|
83
|
+
if (!folderId) throw new Error('folderId is required.');
|
|
84
|
+
return client._request<FolderResponse>({
|
|
85
|
+
method: 'PUT',
|
|
86
|
+
endpoint: `/v1/folders/${folderId}`,
|
|
87
|
+
body: data,
|
|
88
|
+
sendJWT: true,
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Updates a folder's icon.
|
|
94
|
+
* @param {string} folderId - The ID of the folder to update.
|
|
95
|
+
* @param {UpdateFolderIconData} data - Icon file data including name, checksum, and size.
|
|
96
|
+
* @returns {Promise<any>} Object containing the updated folder and signed upload URLs.
|
|
97
|
+
*/
|
|
98
|
+
async updateFolderIcon(folderId: string, data: UpdateFolderIconData): Promise<any> {
|
|
99
|
+
if (!folderId) throw new Error('folderId is required.');
|
|
100
|
+
return client._request<any>({
|
|
101
|
+
method: 'PUT',
|
|
102
|
+
endpoint: `/v1/folders/${folderId}/icon`,
|
|
103
|
+
body: data,
|
|
104
|
+
sendJWT: true,
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/** List the assets that live directly inside a folder (does not recurse). */
|
|
109
|
+
async getFoldersAssets(folderId: string, params?: GetFoldersAssetsParams): Promise<PaginatedResponse<AssetResponse>> {
|
|
110
|
+
if (!folderId) throw new Error('folderId is required.');
|
|
111
|
+
return client._request<PaginatedResponse<AssetResponse>>({
|
|
112
|
+
method: 'GET',
|
|
113
|
+
endpoint: `/v1/folders/${folderId}/assets`,
|
|
114
|
+
params: params,
|
|
115
|
+
sendJWT: true,
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Tags a folder with a specific tag.
|
|
121
|
+
* @param {string} folderId - The ID of the folder to tag.
|
|
122
|
+
* @param {TagFolderData} tagData - Data containing the tag ID.
|
|
123
|
+
* @returns {Promise<FolderResponse>} The updated folder object.
|
|
124
|
+
*/
|
|
125
|
+
async tagFolder(folderId: string, tagData: TagFolderData): Promise<FolderResponse> {
|
|
126
|
+
if (!folderId) throw new Error('folderId is required.');
|
|
127
|
+
if (!tagData.tagId) throw new Error('tagId is required.');
|
|
128
|
+
return client._request<FolderResponse>({
|
|
129
|
+
method: 'PUT',
|
|
130
|
+
endpoint: `/v1/folders/${folderId}/tag`,
|
|
131
|
+
body: tagData,
|
|
132
|
+
sendJWT: true,
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Untags a folder by removing a specific tag.
|
|
138
|
+
* @param {string} folderId - The ID of the folder to untag.
|
|
139
|
+
* @param {UntagFolderData} untagData - Data containing the tag ID to remove.
|
|
140
|
+
* @returns {Promise<FolderResponse>} The updated folder object.
|
|
141
|
+
*/
|
|
142
|
+
async untagFolder(folderId: string, untagData: UntagFolderData): Promise<FolderResponse> {
|
|
143
|
+
if (!folderId) throw new Error('folderId is required.');
|
|
144
|
+
if (!untagData.tagId) throw new Error('tagId is required.');
|
|
145
|
+
return client._request<FolderResponse>({
|
|
146
|
+
method: 'PUT',
|
|
147
|
+
endpoint: `/v1/folders/${folderId}/untag`,
|
|
148
|
+
body: untagData,
|
|
149
|
+
sendJWT: true,
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
};
|
|
154
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
import {
|
|
3
|
+
type Invite,
|
|
4
|
+
type Membership,
|
|
5
|
+
type PaginatedResult,
|
|
6
|
+
type CursorPaginatedResult,
|
|
7
|
+
} from '@nurama/types';
|
|
8
|
+
|
|
9
|
+
// Combine pagination metadata with a results array
|
|
10
|
+
// (Should be defined centrally or imported if used across multiple route files)
|
|
11
|
+
export type PaginatedResponse<T> = (PaginatedResult | CursorPaginatedResult) & {
|
|
12
|
+
results?: T[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// --- Request Body Interfaces ---
|
|
16
|
+
export interface InviteUserToResourceData {
|
|
17
|
+
inviteeEmail: string;
|
|
18
|
+
resourceType: string; // e.g., 'workspace', 'project'
|
|
19
|
+
resourceId: string;
|
|
20
|
+
role: string; // Use a specific type/enum if possible based on `invitableRoles`
|
|
21
|
+
/** Optional workspace-level roles granted alongside the primary role
|
|
22
|
+
* (subset of the backend `additionalRoles`, e.g. workspaceChatMember,
|
|
23
|
+
* workspaceAdmin). Applied to the workspace membership on accept. */
|
|
24
|
+
additionalRoles?: string[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// --- Query Parameter Interfaces ---
|
|
28
|
+
export type InviteStatus = 'active' | 'canceled' | 'accepted';
|
|
29
|
+
|
|
30
|
+
export interface GetUsersInvitesParams {
|
|
31
|
+
inviteType?: 'all' | 'inviter' | 'invitee';
|
|
32
|
+
status?: InviteStatus | InviteStatus[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface GetInvitesToResourceParams {
|
|
36
|
+
status?: InviteStatus | InviteStatus[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// --- Response Interfaces ---
|
|
40
|
+
export type InviteResponse = Invite;
|
|
41
|
+
// Assuming the response for getInvites might be complex depending on params
|
|
42
|
+
export type PaginatedInvitesResponse = PaginatedResponse<Invite> | { inviter: Invite[], invitee: Invite[] } | Invite[];
|
|
43
|
+
export type AcceptInviteResponse = {
|
|
44
|
+
membership: Membership; // Use Membership type
|
|
45
|
+
invite: Invite; // Use Invite type
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Defines invite-related methods for the NuramaClient.
|
|
50
|
+
* @param {NuramaClient} client - The NuramaClient instance.
|
|
51
|
+
* @returns {object} An object containing the invite-related methods.
|
|
52
|
+
*/
|
|
53
|
+
export default function createInviteMethods(client: NuramaClient) {
|
|
54
|
+
return {
|
|
55
|
+
/**
|
|
56
|
+
* Invite a user (by email) to a workspace or project at a given role.
|
|
57
|
+
* Triggers an invitation email; the recipient accepts via the link.
|
|
58
|
+
*/
|
|
59
|
+
async inviteUser(data: InviteUserToResourceData): Promise<InviteResponse> {
|
|
60
|
+
return client._request<InviteResponse>({
|
|
61
|
+
method: 'POST',
|
|
62
|
+
endpoint: '/v1/invites',
|
|
63
|
+
body: data,
|
|
64
|
+
sendJWT: true,
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
/** List invites the current user has issued (pending, accepted, expired). */
|
|
69
|
+
async getInvites(params?: GetUsersInvitesParams): Promise<PaginatedInvitesResponse> {
|
|
70
|
+
return client._request<PaginatedInvitesResponse>({
|
|
71
|
+
method: 'GET',
|
|
72
|
+
endpoint: '/v1/invites',
|
|
73
|
+
params: params,
|
|
74
|
+
sendJWT: true,
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Look up an invite by id. Public — no auth — so the recipient can
|
|
80
|
+
* preview the invite (target resource, role, inviter) before signing
|
|
81
|
+
* up or logging in.
|
|
82
|
+
*/
|
|
83
|
+
async getInviteById(inviteId: string): Promise<InviteResponse> {
|
|
84
|
+
if (!inviteId) throw new Error('inviteId is required.');
|
|
85
|
+
return client._request<InviteResponse>({
|
|
86
|
+
method: 'GET',
|
|
87
|
+
endpoint: `/v1/invites/${inviteId}`,
|
|
88
|
+
sendJWT: false, // Public route - no authentication required
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/** Revoke a pending invite. */
|
|
93
|
+
async cancelInvite(inviteId: string): Promise<InviteResponse> {
|
|
94
|
+
if (!inviteId) throw new Error('inviteId is required.');
|
|
95
|
+
return client._request<InviteResponse>({
|
|
96
|
+
method: 'DELETE',
|
|
97
|
+
endpoint: `/v1/invites/${inviteId}`,
|
|
98
|
+
sendJWT: true,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
/** List pending invites attached to a workspace or project resource. */
|
|
103
|
+
async getInvitesForResource(resourceId: string, params?: GetInvitesToResourceParams): Promise<InviteResponse[]> {
|
|
104
|
+
if (!resourceId) throw new Error('resourceId is required.');
|
|
105
|
+
return client._request<InviteResponse[]>({
|
|
106
|
+
method: 'GET',
|
|
107
|
+
endpoint: `/v1/invites/resource/${resourceId}`,
|
|
108
|
+
params: params,
|
|
109
|
+
sendJWT: true,
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
/** Accept an invite for the authenticated user. Creates the membership. */
|
|
114
|
+
async acceptInvite(inviteId: string): Promise<AcceptInviteResponse> {
|
|
115
|
+
if (!inviteId) throw new Error('inviteId is required.');
|
|
116
|
+
return client._request<AcceptInviteResponse>({
|
|
117
|
+
method: 'POST',
|
|
118
|
+
endpoint: `/v1/invites/accept/${inviteId}`,
|
|
119
|
+
sendJWT: true,
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
/** Re-send a pending invite email (does not extend or reissue the token). */
|
|
124
|
+
async resendInvite(inviteId: string): Promise<InviteResponse> {
|
|
125
|
+
if (!inviteId) throw new Error('inviteId is required.');
|
|
126
|
+
return client._request<InviteResponse>({
|
|
127
|
+
method: 'POST',
|
|
128
|
+
endpoint: `/v1/invites/resend/${inviteId}`,
|
|
129
|
+
sendJWT: true,
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import NuramaClient from '../NuramaClient.js';
|
|
2
|
+
import {
|
|
3
|
+
type JoinLink,
|
|
4
|
+
type JoinLinkPreview,
|
|
5
|
+
type CreateJoinLinkPayload,
|
|
6
|
+
type UpdateJoinLinkPayload,
|
|
7
|
+
type RedeemJoinLinkResult,
|
|
8
|
+
type ListJoinRequestsResponse,
|
|
9
|
+
type ListMyJoinRequestsResponse,
|
|
10
|
+
type ApproveJoinRequestResponse,
|
|
11
|
+
type RejectJoinRequestRequest,
|
|
12
|
+
type RejectJoinRequestResponse,
|
|
13
|
+
type UpdateJoinRequestCooldownRequest,
|
|
14
|
+
type ProjectJoinRequest,
|
|
15
|
+
type ListBansResponse,
|
|
16
|
+
type CreateResourceBanRequest,
|
|
17
|
+
type ResourceBan,
|
|
18
|
+
} from '@nurama/types';
|
|
19
|
+
|
|
20
|
+
// --- Query Parameter Interfaces ---
|
|
21
|
+
export interface GetJoinLinksParams {
|
|
22
|
+
projectId: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// --- Response Interfaces ---
|
|
26
|
+
export type JoinLinkResponse = JoinLink;
|
|
27
|
+
export interface JoinLinksListResponse {
|
|
28
|
+
results: JoinLink[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Defines join-link ("invite link") methods for the NuramaClient. A join link
|
|
33
|
+
* lets people join a project via a shareable URL; management is gated by the
|
|
34
|
+
* caller's grant authority and the workspace plan's per-mode capability
|
|
35
|
+
* (enforced server-side).
|
|
36
|
+
* @param {NuramaClient} client - The NuramaClient instance.
|
|
37
|
+
* @returns {object} An object containing the join-link methods.
|
|
38
|
+
*/
|
|
39
|
+
export default function createJoinLinkMethods(client: NuramaClient) {
|
|
40
|
+
return {
|
|
41
|
+
/** Create a join link for a project. */
|
|
42
|
+
async createJoinLink(data: CreateJoinLinkPayload): Promise<JoinLinkResponse> {
|
|
43
|
+
return client._request<JoinLinkResponse>({
|
|
44
|
+
method: 'POST',
|
|
45
|
+
endpoint: '/v1/join-links',
|
|
46
|
+
body: data,
|
|
47
|
+
sendJWT: true,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/** List a project's join links. */
|
|
52
|
+
async getJoinLinks(params: GetJoinLinksParams): Promise<JoinLinksListResponse> {
|
|
53
|
+
if (!params?.projectId) throw new Error('projectId is required.');
|
|
54
|
+
return client._request<JoinLinksListResponse>({
|
|
55
|
+
method: 'GET',
|
|
56
|
+
endpoint: '/v1/join-links',
|
|
57
|
+
params,
|
|
58
|
+
sendJWT: true,
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
/** The queue of people waiting on a decision for this project. */
|
|
63
|
+
async getJoinRequests(params: { projectId: string }): Promise<ListJoinRequestsResponse> {
|
|
64
|
+
if (!params?.projectId) throw new Error('projectId is required.');
|
|
65
|
+
return client._request<ListJoinRequestsResponse>({
|
|
66
|
+
method: 'GET',
|
|
67
|
+
endpoint: '/v1/join-links/requests',
|
|
68
|
+
params,
|
|
69
|
+
sendJWT: true,
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The caller's own requests still waiting on a decision.
|
|
75
|
+
*
|
|
76
|
+
* Needs no `projectId`: it is scoped server-side to the caller, who is not
|
|
77
|
+
* a member of the projects they are waiting on and so cannot read those
|
|
78
|
+
* projects' queues.
|
|
79
|
+
*/
|
|
80
|
+
async getMyJoinRequests(): Promise<ListMyJoinRequestsResponse> {
|
|
81
|
+
return client._request<ListMyJoinRequestsResponse>({
|
|
82
|
+
method: 'GET',
|
|
83
|
+
endpoint: '/v1/join-links/requests/mine',
|
|
84
|
+
sendJWT: true,
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Approve a request and admit the person.
|
|
90
|
+
*
|
|
91
|
+
* Seats and the link's remaining uses are re-checked here, not when the
|
|
92
|
+
* request was made — a queue outlives the capacity that existed when it was
|
|
93
|
+
* filled, so approval can legitimately fail on a seat limit.
|
|
94
|
+
*/
|
|
95
|
+
async approveJoinRequest(requestId: string, projectId: string): Promise<ApproveJoinRequestResponse> {
|
|
96
|
+
if (!requestId) throw new Error('requestId is required.');
|
|
97
|
+
if (!projectId) throw new Error('projectId is required.');
|
|
98
|
+
return client._request<ApproveJoinRequestResponse>({
|
|
99
|
+
method: 'POST',
|
|
100
|
+
endpoint: `/v1/join-links/requests/${requestId}/approve`,
|
|
101
|
+
body: { projectId },
|
|
102
|
+
sendJWT: true,
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Reject a request, optionally barring the person.
|
|
108
|
+
*
|
|
109
|
+
* Passing `ban` is destructive beyond the refusal: a ban REMOVES an existing
|
|
110
|
+
* membership, so it can take away access the person already had in scope.
|
|
111
|
+
* It is a separate field for that reason, never implied by the rejection.
|
|
112
|
+
*/
|
|
113
|
+
async rejectJoinRequest(requestId: string, data: RejectJoinRequestRequest): Promise<RejectJoinRequestResponse> {
|
|
114
|
+
if (!requestId) throw new Error('requestId is required.');
|
|
115
|
+
if (!data?.projectId) throw new Error('projectId is required.');
|
|
116
|
+
return client._request<RejectJoinRequestResponse>({
|
|
117
|
+
method: 'POST',
|
|
118
|
+
endpoint: `/v1/join-links/requests/${requestId}/reject`,
|
|
119
|
+
body: data,
|
|
120
|
+
sendJWT: true,
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Change or lift the cooldown on a rejected request.
|
|
126
|
+
*
|
|
127
|
+
* Only a rejected request has one; `reapplyAfter: null` lifts it, letting
|
|
128
|
+
* the person ask again straight away. A barred person is refused — the ban
|
|
129
|
+
* already blocks every path, so lifting that is the action that matters.
|
|
130
|
+
*/
|
|
131
|
+
async updateJoinRequestCooldown(
|
|
132
|
+
requestId: string,
|
|
133
|
+
data: UpdateJoinRequestCooldownRequest,
|
|
134
|
+
): Promise<ProjectJoinRequest> {
|
|
135
|
+
if (!requestId) throw new Error('requestId is required.');
|
|
136
|
+
if (!data?.projectId) throw new Error('projectId is required.');
|
|
137
|
+
return client._request<ProjectJoinRequest>({
|
|
138
|
+
method: 'PATCH',
|
|
139
|
+
endpoint: `/v1/join-links/requests/${requestId}/cooldown`,
|
|
140
|
+
body: { projectId: data.projectId, reapplyAfter: data.reapplyAfter ?? null },
|
|
141
|
+
sendJWT: true,
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Bar someone, without a request to refuse.
|
|
147
|
+
*
|
|
148
|
+
* Destructive: the ban REMOVES every membership the person holds in its
|
|
149
|
+
* scope, so a `workspace` ban clears them out of every project in it. An
|
|
150
|
+
* owner cannot be barred, and neither can you bar yourself.
|
|
151
|
+
*/
|
|
152
|
+
async createResourceBan(data: CreateResourceBanRequest): Promise<ResourceBan> {
|
|
153
|
+
if (!data?.projectId) throw new Error('projectId is required.');
|
|
154
|
+
if (!data?.userId) throw new Error('userId is required.');
|
|
155
|
+
if (!data?.scope) throw new Error('scope is required.');
|
|
156
|
+
return client._request<ResourceBan>({
|
|
157
|
+
method: 'POST',
|
|
158
|
+
endpoint: '/v1/join-links/bans',
|
|
159
|
+
body: data,
|
|
160
|
+
sendJWT: true,
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
/** People barred from this project, newest first. */
|
|
165
|
+
async getResourceBans(params: { projectId: string }): Promise<ListBansResponse> {
|
|
166
|
+
if (!params?.projectId) throw new Error('projectId is required.');
|
|
167
|
+
return client._request<ListBansResponse>({
|
|
168
|
+
method: 'GET',
|
|
169
|
+
endpoint: '/v1/join-links/bans',
|
|
170
|
+
params,
|
|
171
|
+
sendJWT: true,
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
/** Lift a ban. It does not restore any membership the ban removed. */
|
|
176
|
+
async liftResourceBan(banId: string): Promise<ResourceBan> {
|
|
177
|
+
if (!banId) throw new Error('banId is required.');
|
|
178
|
+
return client._request<ResourceBan>({
|
|
179
|
+
method: 'DELETE',
|
|
180
|
+
endpoint: `/v1/join-links/bans/${banId}`,
|
|
181
|
+
sendJWT: true,
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
/** Update a join link's settings (role, mode, domains, expiry, enable/disable). */
|
|
186
|
+
async updateJoinLink(linkId: string, data: UpdateJoinLinkPayload): Promise<JoinLinkResponse> {
|
|
187
|
+
if (!linkId) throw new Error('linkId is required.');
|
|
188
|
+
return client._request<JoinLinkResponse>({
|
|
189
|
+
method: 'PATCH',
|
|
190
|
+
endpoint: `/v1/join-links/${linkId}`,
|
|
191
|
+
body: data,
|
|
192
|
+
sendJWT: true,
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Rotate a link's token, invalidating the old URL. Optionally reset expiry.
|
|
198
|
+
* Existing memberships are untouched.
|
|
199
|
+
*/
|
|
200
|
+
async rollJoinLink(linkId: string, expiresAt?: string | null): Promise<JoinLinkResponse> {
|
|
201
|
+
if (!linkId) throw new Error('linkId is required.');
|
|
202
|
+
return client._request<JoinLinkResponse>({
|
|
203
|
+
method: 'POST',
|
|
204
|
+
endpoint: `/v1/join-links/${linkId}/roll`,
|
|
205
|
+
body: expiresAt !== undefined ? { expiresAt } : {},
|
|
206
|
+
sendJWT: true,
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Public preview of a join link by token — no auth — so the join landing
|
|
212
|
+
* page can show "Join <project>" before the visitor signs in.
|
|
213
|
+
*/
|
|
214
|
+
async getJoinByToken(token: string): Promise<JoinLinkPreview> {
|
|
215
|
+
if (!token) throw new Error('token is required.');
|
|
216
|
+
return client._request<JoinLinkPreview>({
|
|
217
|
+
method: 'GET',
|
|
218
|
+
endpoint: `/v1/join/${token}`,
|
|
219
|
+
sendJWT: false, // Public route - no authentication required
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
/** Redeem a join link for the authenticated user. */
|
|
224
|
+
async joinByToken(token: string): Promise<RedeemJoinLinkResult> {
|
|
225
|
+
if (!token) throw new Error('token is required.');
|
|
226
|
+
return client._request<RedeemJoinLinkResult>({
|
|
227
|
+
method: 'POST',
|
|
228
|
+
endpoint: `/v1/join/${token}`,
|
|
229
|
+
sendJWT: true,
|
|
230
|
+
});
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
}
|