@nurama/sdk 0.0.0-stage → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +1080 -2
  4. package/dist/BotClient.d.ts +66 -0
  5. package/dist/BotClient.d.ts.map +1 -0
  6. package/dist/BotClient.js +68 -0
  7. package/dist/BotClient.js.map +1 -0
  8. package/dist/NuramaClient.d.ts +448 -0
  9. package/dist/NuramaClient.d.ts.map +1 -0
  10. package/dist/NuramaClient.js +864 -0
  11. package/dist/NuramaClient.js.map +1 -0
  12. package/dist/browser/nurama-bot-sdk.js +11780 -0
  13. package/dist/browser/nurama-bot-sdk.min.js +1 -0
  14. package/dist/browser/nurama-sdk.js +11732 -0
  15. package/dist/browser/nurama-sdk.min.js +1 -0
  16. package/dist/routes/ai.d.ts +280 -0
  17. package/dist/routes/ai.d.ts.map +1 -0
  18. package/dist/routes/ai.js +173 -0
  19. package/dist/routes/ai.js.map +1 -0
  20. package/dist/routes/asset.d.ts +493 -0
  21. package/dist/routes/asset.d.ts.map +1 -0
  22. package/dist/routes/asset.js +848 -0
  23. package/dist/routes/asset.js.map +1 -0
  24. package/dist/routes/auth.d.ts +218 -0
  25. package/dist/routes/auth.d.ts.map +1 -0
  26. package/dist/routes/auth.js +454 -0
  27. package/dist/routes/auth.js.map +1 -0
  28. package/dist/routes/blogPosts.d.ts +17 -0
  29. package/dist/routes/blogPosts.d.ts.map +1 -0
  30. package/dist/routes/blogPosts.js +29 -0
  31. package/dist/routes/blogPosts.js.map +1 -0
  32. package/dist/routes/board.d.ts +187 -0
  33. package/dist/routes/board.d.ts.map +1 -0
  34. package/dist/routes/board.js +270 -0
  35. package/dist/routes/board.js.map +1 -0
  36. package/dist/routes/bot.d.ts +147 -0
  37. package/dist/routes/bot.d.ts.map +1 -0
  38. package/dist/routes/bot.js +157 -0
  39. package/dist/routes/bot.js.map +1 -0
  40. package/dist/routes/chat.d.ts +842 -0
  41. package/dist/routes/chat.d.ts.map +1 -0
  42. package/dist/routes/chat.js +863 -0
  43. package/dist/routes/chat.js.map +1 -0
  44. package/dist/routes/chatAi.d.ts +51 -0
  45. package/dist/routes/chatAi.d.ts.map +1 -0
  46. package/dist/routes/chatAi.js +109 -0
  47. package/dist/routes/chatAi.js.map +1 -0
  48. package/dist/routes/config.d.ts +11 -0
  49. package/dist/routes/config.d.ts.map +1 -0
  50. package/dist/routes/config.js +24 -0
  51. package/dist/routes/config.js.map +1 -0
  52. package/dist/routes/convo.d.ts +169 -0
  53. package/dist/routes/convo.d.ts.map +1 -0
  54. package/dist/routes/convo.js +284 -0
  55. package/dist/routes/convo.js.map +1 -0
  56. package/dist/routes/credits.d.ts +82 -0
  57. package/dist/routes/credits.d.ts.map +1 -0
  58. package/dist/routes/credits.js +49 -0
  59. package/dist/routes/credits.js.map +1 -0
  60. package/dist/routes/device.d.ts +74 -0
  61. package/dist/routes/device.d.ts.map +1 -0
  62. package/dist/routes/device.js +122 -0
  63. package/dist/routes/device.js.map +1 -0
  64. package/dist/routes/folder.d.ts +75 -0
  65. package/dist/routes/folder.d.ts.map +1 -0
  66. package/dist/routes/folder.js +99 -0
  67. package/dist/routes/folder.js.map +1 -0
  68. package/dist/routes/invite.d.ts +61 -0
  69. package/dist/routes/invite.d.ts.map +1 -0
  70. package/dist/routes/invite.js +86 -0
  71. package/dist/routes/invite.js.map +1 -0
  72. package/dist/routes/joinLink.d.ts +38 -0
  73. package/dist/routes/joinLink.d.ts.map +1 -0
  74. package/dist/routes/joinLink.js +81 -0
  75. package/dist/routes/joinLink.js.map +1 -0
  76. package/dist/routes/membership.d.ts +116 -0
  77. package/dist/routes/membership.d.ts.map +1 -0
  78. package/dist/routes/membership.js +183 -0
  79. package/dist/routes/membership.js.map +1 -0
  80. package/dist/routes/notification.d.ts +103 -0
  81. package/dist/routes/notification.d.ts.map +1 -0
  82. package/dist/routes/notification.js +89 -0
  83. package/dist/routes/notification.js.map +1 -0
  84. package/dist/routes/payment.d.ts +56 -0
  85. package/dist/routes/payment.d.ts.map +1 -0
  86. package/dist/routes/payment.js +78 -0
  87. package/dist/routes/payment.js.map +1 -0
  88. package/dist/routes/product.d.ts +43 -0
  89. package/dist/routes/product.d.ts.map +1 -0
  90. package/dist/routes/product.js +53 -0
  91. package/dist/routes/product.js.map +1 -0
  92. package/dist/routes/project.d.ts +821 -0
  93. package/dist/routes/project.d.ts.map +1 -0
  94. package/dist/routes/project.js +1153 -0
  95. package/dist/routes/project.js.map +1 -0
  96. package/dist/routes/public.d.ts +269 -0
  97. package/dist/routes/public.d.ts.map +1 -0
  98. package/dist/routes/public.js +412 -0
  99. package/dist/routes/public.js.map +1 -0
  100. package/dist/routes/scratch.d.ts +70 -0
  101. package/dist/routes/scratch.d.ts.map +1 -0
  102. package/dist/routes/scratch.js +67 -0
  103. package/dist/routes/scratch.js.map +1 -0
  104. package/dist/routes/settings.d.ts +102 -0
  105. package/dist/routes/settings.d.ts.map +1 -0
  106. package/dist/routes/settings.js +94 -0
  107. package/dist/routes/settings.js.map +1 -0
  108. package/dist/routes/shortlink.d.ts +79 -0
  109. package/dist/routes/shortlink.d.ts.map +1 -0
  110. package/dist/routes/shortlink.js +25 -0
  111. package/dist/routes/shortlink.js.map +1 -0
  112. package/dist/routes/socket.d.ts +108 -0
  113. package/dist/routes/socket.d.ts.map +1 -0
  114. package/dist/routes/socket.js +555 -0
  115. package/dist/routes/socket.js.map +1 -0
  116. package/dist/routes/storage.d.ts +44 -0
  117. package/dist/routes/storage.d.ts.map +1 -0
  118. package/dist/routes/storage.js +49 -0
  119. package/dist/routes/storage.js.map +1 -0
  120. package/dist/routes/subscription.d.ts +184 -0
  121. package/dist/routes/subscription.d.ts.map +1 -0
  122. package/dist/routes/subscription.js +219 -0
  123. package/dist/routes/subscription.js.map +1 -0
  124. package/dist/routes/supportChat.d.ts +40 -0
  125. package/dist/routes/supportChat.d.ts.map +1 -0
  126. package/dist/routes/supportChat.js +53 -0
  127. package/dist/routes/supportChat.js.map +1 -0
  128. package/dist/routes/supportTicket.d.ts +89 -0
  129. package/dist/routes/supportTicket.d.ts.map +1 -0
  130. package/dist/routes/supportTicket.js +54 -0
  131. package/dist/routes/supportTicket.js.map +1 -0
  132. package/dist/routes/tag.d.ts +72 -0
  133. package/dist/routes/tag.d.ts.map +1 -0
  134. package/dist/routes/tag.js +81 -0
  135. package/dist/routes/tag.js.map +1 -0
  136. package/dist/routes/task.d.ts +252 -0
  137. package/dist/routes/task.d.ts.map +1 -0
  138. package/dist/routes/task.js +284 -0
  139. package/dist/routes/task.js.map +1 -0
  140. package/dist/routes/taskRelation.d.ts +80 -0
  141. package/dist/routes/taskRelation.d.ts.map +1 -0
  142. package/dist/routes/taskRelation.js +71 -0
  143. package/dist/routes/taskRelation.js.map +1 -0
  144. package/dist/routes/token.d.ts +75 -0
  145. package/dist/routes/token.d.ts.map +1 -0
  146. package/dist/routes/token.js +51 -0
  147. package/dist/routes/token.js.map +1 -0
  148. package/dist/routes/user.d.ts +112 -0
  149. package/dist/routes/user.d.ts.map +1 -0
  150. package/dist/routes/user.js +151 -0
  151. package/dist/routes/user.js.map +1 -0
  152. package/dist/routes/version.d.ts +42 -0
  153. package/dist/routes/version.d.ts.map +1 -0
  154. package/dist/routes/version.js +38 -0
  155. package/dist/routes/version.js.map +1 -0
  156. package/dist/routes/webhook.d.ts +170 -0
  157. package/dist/routes/webhook.d.ts.map +1 -0
  158. package/dist/routes/webhook.js +173 -0
  159. package/dist/routes/webhook.js.map +1 -0
  160. package/dist/routes/workspace.d.ts +120 -0
  161. package/dist/routes/workspace.d.ts.map +1 -0
  162. package/dist/routes/workspace.js +199 -0
  163. package/dist/routes/workspace.js.map +1 -0
  164. package/dist/utils/uploadSessionManager.d.ts +133 -0
  165. package/dist/utils/uploadSessionManager.d.ts.map +1 -0
  166. package/dist/utils/uploadSessionManager.js +321 -0
  167. package/dist/utils/uploadSessionManager.js.map +1 -0
  168. package/dist/utils/urlParams.d.ts +35 -0
  169. package/dist/utils/urlParams.d.ts.map +1 -0
  170. package/dist/utils/urlParams.js +146 -0
  171. package/dist/utils/urlParams.js.map +1 -0
  172. package/dist/version.d.ts +15 -0
  173. package/dist/version.d.ts.map +1 -0
  174. package/dist/version.js +12 -0
  175. package/dist/version.js.map +1 -0
  176. package/package.json +87 -3
  177. package/src/BotClient.ts +113 -0
  178. package/src/NuramaClient.ts +1193 -0
  179. package/src/bot-browser-entry.js +15 -0
  180. package/src/browser-entry.js +20 -0
  181. package/src/routes/ai.ts +378 -0
  182. package/src/routes/asset.ts +1104 -0
  183. package/src/routes/auth.ts +587 -0
  184. package/src/routes/blogPosts.ts +29 -0
  185. package/src/routes/board.ts +403 -0
  186. package/src/routes/bot.ts +257 -0
  187. package/src/routes/chat.ts +1292 -0
  188. package/src/routes/chatAi.ts +125 -0
  189. package/src/routes/config.ts +31 -0
  190. package/src/routes/convo.ts +321 -0
  191. package/src/routes/credits.ts +112 -0
  192. package/src/routes/device.ts +133 -0
  193. package/src/routes/folder.ts +154 -0
  194. package/src/routes/invite.ts +133 -0
  195. package/src/routes/joinLink.ts +100 -0
  196. package/src/routes/membership.ts +237 -0
  197. package/src/routes/notification.ts +166 -0
  198. package/src/routes/payment.ts +104 -0
  199. package/src/routes/product.ts +67 -0
  200. package/src/routes/project.ts +1528 -0
  201. package/src/routes/public.ts +496 -0
  202. package/src/routes/scratch.ts +94 -0
  203. package/src/routes/settings.ts +152 -0
  204. package/src/routes/shortlink.ts +90 -0
  205. package/src/routes/socket.ts +739 -0
  206. package/src/routes/storage.ts +83 -0
  207. package/src/routes/subscription.ts +307 -0
  208. package/src/routes/supportChat.ts +62 -0
  209. package/src/routes/supportTicket.ts +114 -0
  210. package/src/routes/tag.ts +131 -0
  211. package/src/routes/task.ts +431 -0
  212. package/src/routes/taskRelation.ts +125 -0
  213. package/src/routes/token.ts +113 -0
  214. package/src/routes/user.ts +214 -0
  215. package/src/routes/version.ts +62 -0
  216. package/src/routes/webhook.ts +295 -0
  217. package/src/routes/workspace.ts +223 -0
  218. package/src/utils/uploadSessionManager.ts +407 -0
  219. package/src/utils/urlParams.ts +181 -0
  220. package/src/version.ts +22 -0
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Outbound webhook subscription management. Admin-gated server-side
3
+ * by `canManageWebhooks`. All operations are workspace-scoped — there
4
+ * is no app-owned surface here yet (Phase 3 / OAuth).
5
+ */
6
+ export default function createWebhookMethods(client) {
7
+ return {
8
+ /**
9
+ * Create a webhook subscription. The signing secret is in the
10
+ * response's `secret` field — store it immediately, it cannot be
11
+ * retrieved again.
12
+ *
13
+ * @requires `canManageWebhooks` on the workspace.
14
+ */
15
+ async createWebhook(workspaceId, data) {
16
+ if (!workspaceId)
17
+ throw new Error('workspaceId is required.');
18
+ return client._request({
19
+ method: 'POST',
20
+ endpoint: `/v1/workspaces/${workspaceId}/webhooks`,
21
+ body: data,
22
+ sendJWT: true,
23
+ });
24
+ },
25
+ /**
26
+ * List webhook subscriptions in a workspace. Secrets are never returned.
27
+ *
28
+ * @requires `canManageWebhooks` on the workspace.
29
+ */
30
+ async listWebhooks(workspaceId) {
31
+ if (!workspaceId)
32
+ throw new Error('workspaceId is required.');
33
+ return client._request({
34
+ method: 'GET',
35
+ endpoint: `/v1/workspaces/${workspaceId}/webhooks`,
36
+ sendJWT: true,
37
+ bypassCache: true,
38
+ });
39
+ },
40
+ /**
41
+ * Fetch a single webhook subscription by id.
42
+ *
43
+ * @requires `canManageWebhooks` on the workspace.
44
+ */
45
+ async getWebhook(workspaceId, webhookId) {
46
+ if (!workspaceId)
47
+ throw new Error('workspaceId is required.');
48
+ if (!webhookId)
49
+ throw new Error('webhookId is required.');
50
+ return client._request({
51
+ method: 'GET',
52
+ endpoint: `/v1/workspaces/${workspaceId}/webhooks/${webhookId}`,
53
+ sendJWT: true,
54
+ bypassCache: true,
55
+ });
56
+ },
57
+ /**
58
+ * Update a webhook subscription's url, event filter, or active state.
59
+ *
60
+ * @requires `canManageWebhooks` on the workspace.
61
+ */
62
+ async updateWebhook(workspaceId, webhookId, data) {
63
+ if (!workspaceId)
64
+ throw new Error('workspaceId is required.');
65
+ if (!webhookId)
66
+ throw new Error('webhookId is required.');
67
+ return client._request({
68
+ method: 'PATCH',
69
+ endpoint: `/v1/workspaces/${workspaceId}/webhooks/${webhookId}`,
70
+ body: data,
71
+ sendJWT: true,
72
+ });
73
+ },
74
+ /**
75
+ * Delete a webhook subscription. In-flight deliveries continue to
76
+ * the receiver until they exhaust retries; no new deliveries fire.
77
+ *
78
+ * @requires `canManageWebhooks` on the workspace.
79
+ */
80
+ async deleteWebhook(workspaceId, webhookId) {
81
+ if (!workspaceId)
82
+ throw new Error('workspaceId is required.');
83
+ if (!webhookId)
84
+ throw new Error('webhookId is required.');
85
+ return client._request({
86
+ method: 'DELETE',
87
+ endpoint: `/v1/workspaces/${workspaceId}/webhooks/${webhookId}`,
88
+ sendJWT: true,
89
+ });
90
+ },
91
+ /**
92
+ * Generate a new HMAC signing secret for a subscription and return
93
+ * it once. The old secret is invalidated immediately.
94
+ *
95
+ * @requires `canManageWebhooks` on the workspace.
96
+ */
97
+ async rotateWebhookSecret(workspaceId, webhookId) {
98
+ if (!workspaceId)
99
+ throw new Error('workspaceId is required.');
100
+ if (!webhookId)
101
+ throw new Error('webhookId is required.');
102
+ return client._request({
103
+ method: 'POST',
104
+ endpoint: `/v1/workspaces/${workspaceId}/webhooks/${webhookId}/rotate-secret`,
105
+ sendJWT: true,
106
+ });
107
+ },
108
+ /**
109
+ * Fire a synthetic `webhook.test` delivery to the subscription's
110
+ * URL. The receiver gets a small payload they can use to verify
111
+ * their HMAC + parsing setup. Returns immediately; check the
112
+ * delivery log for the outcome.
113
+ */
114
+ async testWebhook(workspaceId, webhookId) {
115
+ if (!workspaceId)
116
+ throw new Error('workspaceId is required.');
117
+ if (!webhookId)
118
+ throw new Error('webhookId is required.');
119
+ return client._request({
120
+ method: 'POST',
121
+ endpoint: `/v1/workspaces/${workspaceId}/webhooks/${webhookId}/test`,
122
+ sendJWT: true,
123
+ });
124
+ },
125
+ /**
126
+ * Paginated list of delivery attempts for a webhook subscription.
127
+ * Useful for diagnosing failures (HTTP status, response body snippet,
128
+ * retry timing).
129
+ *
130
+ * @requires `canManageWebhooks` on the workspace.
131
+ */
132
+ async listWebhookDeliveries(workspaceId, webhookId, params = {}) {
133
+ if (!workspaceId)
134
+ throw new Error('workspaceId is required.');
135
+ if (!webhookId)
136
+ throw new Error('webhookId is required.');
137
+ const search = new URLSearchParams();
138
+ if (params.limit !== undefined)
139
+ search.set('limit', String(params.limit));
140
+ if (params.cursor !== undefined)
141
+ search.set('cursor', params.cursor);
142
+ if (params.status !== undefined)
143
+ search.set('status', params.status);
144
+ const qs = search.toString();
145
+ return client._request({
146
+ method: 'GET',
147
+ endpoint: `/v1/workspaces/${workspaceId}/webhooks/${webhookId}/deliveries${qs ? `?${qs}` : ''}`,
148
+ sendJWT: true,
149
+ bypassCache: true,
150
+ });
151
+ },
152
+ /**
153
+ * Re-fire a specific past delivery attempt. Useful for confirming a
154
+ * receiver fix without waiting for the next real event.
155
+ *
156
+ * @requires `canManageWebhooks` on the workspace.
157
+ */
158
+ async replayWebhookDelivery(workspaceId, webhookId, attemptId) {
159
+ if (!workspaceId)
160
+ throw new Error('workspaceId is required.');
161
+ if (!webhookId)
162
+ throw new Error('webhookId is required.');
163
+ if (!attemptId)
164
+ throw new Error('attemptId is required.');
165
+ return client._request({
166
+ method: 'POST',
167
+ endpoint: `/v1/workspaces/${workspaceId}/webhooks/${webhookId}/deliveries/${attemptId}/replay`,
168
+ sendJWT: true,
169
+ });
170
+ },
171
+ };
172
+ }
173
+ //# sourceMappingURL=webhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/routes/webhook.ts"],"names":[],"mappings":"AAqHA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,MAAoB;IAC/D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,EACnB,SAAiB,EACjB,SAAiB;YAEjB,IAAI,CAAC,WAAW;gBAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAC9D,IAAI,CAAC,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAC1D,IAAI,CAAC,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAC1D,OAAO,MAAM,CAAC,QAAQ,CAA8B;gBAClD,MAAM,EAAE,MAAM;gBACd,QAAQ,EAAE,kBAAkB,WAAW,aAAa,SAAS,eAAe,SAAS,SAAS;gBAC9F,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,120 @@
1
+ import NuramaClient from '../NuramaClient.js';
2
+ export interface CreateWorkspaceData {
3
+ name: string;
4
+ description?: string;
5
+ }
6
+ export interface UpdateWorkspaceData {
7
+ name?: string;
8
+ description?: string;
9
+ updateSlug?: boolean;
10
+ }
11
+ export interface FileData {
12
+ name: string;
13
+ checksum: string;
14
+ sizeInMB: number;
15
+ }
16
+ export interface SortParams {
17
+ [key: string]: 1 | -1;
18
+ }
19
+ /**
20
+ * Defines workspace-related methods for the NuramaClient.
21
+ * @param {NuramaClient} client - The NuramaClient instance.
22
+ * @returns {object} An object containing the workspace methods.
23
+ */
24
+ export default function createWorkspaceMethods(client: NuramaClient): {
25
+ /**
26
+ * Creates a new workspace.
27
+ * Requires authentication.
28
+ * @param data - Workspace data.
29
+ * @returns {Promise<object>} The created workspace object.
30
+ */
31
+ createWorkspace(data: CreateWorkspaceData): Promise<any>;
32
+ /**
33
+ * Retrieves a specific workspace by its ID.
34
+ * Requires authentication.
35
+ * @param {string} workspaceId - The ID of the workspace to retrieve.
36
+ * @returns {Promise<object>} The workspace object.
37
+ */
38
+ getWorkspace(workspaceId: string): Promise<any>;
39
+ /**
40
+ * Lists all workspaces the authenticated user has access to.
41
+ * Requires authentication.
42
+ * @param {object} [sortParams] - Optional sorting. Keys are field names (`id`, `name`, `createdAt`, `updatedAt`);
43
+ * values are 1 for ascending or -1 for descending. Sent as `?sort[name]=1&sort[createdAt]=-1`.
44
+ * @returns {Promise<Array<object>>} Workspaces with the caller's `roles` and the workspace `capabilities`.
45
+ */
46
+ listWorkspaces(sortParams?: SortParams): Promise<any[]>;
47
+ /**
48
+ * Request signed URL data to upload a workspace logo.
49
+ * Caller then multipart-uploads the file using the returned `signedUrlData`
50
+ * and calls `client.asset.completeUpload(...)` to finalize.
51
+ *
52
+ * @param {string} fileData.checksum - The MD5 checksum.
53
+ * @param {number} fileData.sizeInMB - The file size in MB.
54
+ * @returns {Promise<object>} Response containing signed URL data and workspace info.
55
+ */
56
+ createLogo(workspaceId: string, fileData: FileData): Promise<any>;
57
+ /**
58
+ * Request signed URL data to replace the workspace logo. Same upload
59
+ * shape as `createLogo`; existing logo is replaced once `completeUpload`
60
+ * lands.
61
+ *
62
+ * @param {string} fileData.checksum - The MD5 checksum.
63
+ * @param {number} fileData.sizeInMB - The file size in MB.
64
+ * @returns {Promise<object>} Response containing signed URL data and workspace info.
65
+ */
66
+ updateLogo(workspaceId: string, fileData: FileData): Promise<any>;
67
+ /**
68
+ * Request signed URL data to upload a workspace icon (the small square
69
+ * shown in sidebars and tabs — distinct from the logo).
70
+ *
71
+ * @param {string} fileData.checksum - The MD5 checksum.
72
+ * @param {number} fileData.sizeInMB - The file size in MB.
73
+ * @returns {Promise<object>} Response containing signed URL data and workspace info.
74
+ */
75
+ createIcon(workspaceId: string, fileData: FileData): Promise<any>;
76
+ /**
77
+ * Request signed URL data to replace the workspace icon. Same upload
78
+ * shape as `createIcon`.
79
+ *
80
+ * @param {string} fileData.checksum - The MD5 checksum.
81
+ * @param {number} fileData.sizeInMB - The file size in MB.
82
+ * @returns {Promise<object>} Response containing signed URL data and workspace info.
83
+ */
84
+ updateIcon(workspaceId: string, fileData: FileData): Promise<any>;
85
+ /**
86
+ * List the projects inside a workspace that the calling user has
87
+ * access to.
88
+ *
89
+ * @param {string} workspaceId - The ID of the workspace.
90
+ * @returns {Promise<Array<object>>} An array of project objects.
91
+ */
92
+ listProjects(workspaceId: string): Promise<any[]>;
93
+ /**
94
+ * Update workspace metadata (name, description, etc.).
95
+ *
96
+ * @param {boolean} [updateData.updateSlug] - Whether to update the slug based on the new name.
97
+ * @returns {Promise<object>} The updated workspace object.
98
+ */
99
+ updateWorkspace(workspaceId: string, updateData: UpdateWorkspaceData): Promise<any>;
100
+ /**
101
+ * Soft-delete a workspace. All nested resources (projects, chats,
102
+ * assets) become inaccessible; bytes are reclaimed by the cleanup
103
+ * cron.
104
+ *
105
+ * @param {string} workspaceId - The ID of the workspace to delete.
106
+ * @returns {Promise<object>} Object confirming the status change.
107
+ */
108
+ deleteWorkspace(workspaceId: string): Promise<any>;
109
+ /**
110
+ * Toggle a single workspace boolean setting (e.g. an `enableX` feature
111
+ * flag).
112
+ *
113
+ * @param {string} workspaceId - The ID of the workspace.
114
+ * @param {string} settingName - The name of the setting.
115
+ * @param {boolean} value - The new value for the setting.
116
+ * @returns {Promise<object>} The updated workspace object with new settings.
117
+ */
118
+ updateSetting(workspaceId: string, settingName: string, value: boolean): Promise<any>;
119
+ };
120
+ //# sourceMappingURL=workspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/routes/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAG9C,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,MAAM,EAAE,YAAY;IAG/D;;;;;OAKG;0BACyB,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC;IAS9D;;;;;OAKG;8BAC6B,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IASrD;;;;;;OAMG;gCAC8B,UAAU,GAAQ,OAAO,CAAC,GAAG,EAAE,CAAC;IASjE;;;;;;;;OAQG;4BAC2B,MAAM,YAAY,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAUvE;;;;;;;;OAQG;4BAC2B,MAAM,YAAY,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAUvE;;;;;;;OAOG;4BAC2B,MAAM,YAAY,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAUvE;;;;;;;OAOG;4BAC2B,MAAM,YAAY,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAUvE;;;;;;OAMG;8BAC6B,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IASvD;;;;;OAKG;iCACgC,MAAM,cAAc,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC;IAUzF;;;;;;;OAOG;iCACgC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IASxD;;;;;;;;OAQG;+BAC8B,MAAM,eAAe,MAAM,SAAS,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;EAY9F"}
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Defines workspace-related methods for the NuramaClient.
3
+ * @param {NuramaClient} client - The NuramaClient instance.
4
+ * @returns {object} An object containing the workspace methods.
5
+ */
6
+ export default function createWorkspaceMethods(client) {
7
+ // Specify return type more accurately if possible, using WorkspaceMethods interface
8
+ return {
9
+ /**
10
+ * Creates a new workspace.
11
+ * Requires authentication.
12
+ * @param data - Workspace data.
13
+ * @returns {Promise<object>} The created workspace object.
14
+ */
15
+ async createWorkspace(data) {
16
+ return client._request({
17
+ endpoint: '/v1/workspaces',
18
+ method: 'POST',
19
+ body: data,
20
+ sendJWT: true,
21
+ });
22
+ },
23
+ /**
24
+ * Retrieves a specific workspace by its ID.
25
+ * Requires authentication.
26
+ * @param {string} workspaceId - The ID of the workspace to retrieve.
27
+ * @returns {Promise<object>} The workspace object.
28
+ */
29
+ async getWorkspace(workspaceId) {
30
+ if (!workspaceId)
31
+ throw new Error('workspaceId is required.');
32
+ return client._request({
33
+ endpoint: `/v1/workspaces/${workspaceId}`,
34
+ method: 'GET',
35
+ sendJWT: true,
36
+ });
37
+ },
38
+ /**
39
+ * Lists all workspaces the authenticated user has access to.
40
+ * Requires authentication.
41
+ * @param {object} [sortParams] - Optional sorting. Keys are field names (`id`, `name`, `createdAt`, `updatedAt`);
42
+ * values are 1 for ascending or -1 for descending. Sent as `?sort[name]=1&sort[createdAt]=-1`.
43
+ * @returns {Promise<Array<object>>} Workspaces with the caller's `roles` and the workspace `capabilities`.
44
+ */
45
+ async listWorkspaces(sortParams = {}) {
46
+ return client._request({
47
+ endpoint: '/v1/workspaces',
48
+ method: 'GET',
49
+ params: Object.keys(sortParams).length > 0 ? { sort: sortParams } : undefined,
50
+ sendJWT: true,
51
+ });
52
+ },
53
+ /**
54
+ * Request signed URL data to upload a workspace logo.
55
+ * Caller then multipart-uploads the file using the returned `signedUrlData`
56
+ * and calls `client.asset.completeUpload(...)` to finalize.
57
+ *
58
+ * @param {string} fileData.checksum - The MD5 checksum.
59
+ * @param {number} fileData.sizeInMB - The file size in MB.
60
+ * @returns {Promise<object>} Response containing signed URL data and workspace info.
61
+ */
62
+ async createLogo(workspaceId, fileData) {
63
+ if (!workspaceId)
64
+ throw new Error('workspaceId is required.');
65
+ return client._request({
66
+ endpoint: `/v1/workspaces/${workspaceId}/logo`,
67
+ method: 'POST',
68
+ body: fileData,
69
+ sendJWT: true,
70
+ });
71
+ },
72
+ /**
73
+ * Request signed URL data to replace the workspace logo. Same upload
74
+ * shape as `createLogo`; existing logo is replaced once `completeUpload`
75
+ * lands.
76
+ *
77
+ * @param {string} fileData.checksum - The MD5 checksum.
78
+ * @param {number} fileData.sizeInMB - The file size in MB.
79
+ * @returns {Promise<object>} Response containing signed URL data and workspace info.
80
+ */
81
+ async updateLogo(workspaceId, fileData) {
82
+ if (!workspaceId)
83
+ throw new Error('workspaceId is required.');
84
+ return client._request({
85
+ endpoint: `/v1/workspaces/${workspaceId}/logo`,
86
+ method: 'PUT',
87
+ body: fileData,
88
+ sendJWT: true,
89
+ });
90
+ },
91
+ /**
92
+ * Request signed URL data to upload a workspace icon (the small square
93
+ * shown in sidebars and tabs — distinct from the logo).
94
+ *
95
+ * @param {string} fileData.checksum - The MD5 checksum.
96
+ * @param {number} fileData.sizeInMB - The file size in MB.
97
+ * @returns {Promise<object>} Response containing signed URL data and workspace info.
98
+ */
99
+ async createIcon(workspaceId, fileData) {
100
+ if (!workspaceId)
101
+ throw new Error('workspaceId is required.');
102
+ return client._request({
103
+ endpoint: `/v1/workspaces/${workspaceId}/icon`,
104
+ method: 'POST',
105
+ body: fileData,
106
+ sendJWT: true,
107
+ });
108
+ },
109
+ /**
110
+ * Request signed URL data to replace the workspace icon. Same upload
111
+ * shape as `createIcon`.
112
+ *
113
+ * @param {string} fileData.checksum - The MD5 checksum.
114
+ * @param {number} fileData.sizeInMB - The file size in MB.
115
+ * @returns {Promise<object>} Response containing signed URL data and workspace info.
116
+ */
117
+ async updateIcon(workspaceId, fileData) {
118
+ if (!workspaceId)
119
+ throw new Error('workspaceId is required.');
120
+ return client._request({
121
+ endpoint: `/v1/workspaces/${workspaceId}/icon`,
122
+ method: 'PUT',
123
+ body: fileData,
124
+ sendJWT: true,
125
+ });
126
+ },
127
+ /**
128
+ * List the projects inside a workspace that the calling user has
129
+ * access to.
130
+ *
131
+ * @param {string} workspaceId - The ID of the workspace.
132
+ * @returns {Promise<Array<object>>} An array of project objects.
133
+ */
134
+ async listProjects(workspaceId) {
135
+ if (!workspaceId)
136
+ throw new Error('workspaceId is required.');
137
+ return client._request({
138
+ endpoint: `/v1/workspaces/${workspaceId}/projects`,
139
+ method: 'GET',
140
+ sendJWT: true,
141
+ });
142
+ },
143
+ /**
144
+ * Update workspace metadata (name, description, etc.).
145
+ *
146
+ * @param {boolean} [updateData.updateSlug] - Whether to update the slug based on the new name.
147
+ * @returns {Promise<object>} The updated workspace object.
148
+ */
149
+ async updateWorkspace(workspaceId, updateData) {
150
+ if (!workspaceId)
151
+ throw new Error('workspaceId is required.');
152
+ return client._request({
153
+ endpoint: `/v1/workspaces/${workspaceId}`,
154
+ method: 'PUT',
155
+ body: updateData,
156
+ sendJWT: true,
157
+ });
158
+ },
159
+ /**
160
+ * Soft-delete a workspace. All nested resources (projects, chats,
161
+ * assets) become inaccessible; bytes are reclaimed by the cleanup
162
+ * cron.
163
+ *
164
+ * @param {string} workspaceId - The ID of the workspace to delete.
165
+ * @returns {Promise<object>} Object confirming the status change.
166
+ */
167
+ async deleteWorkspace(workspaceId) {
168
+ if (!workspaceId)
169
+ throw new Error('workspaceId is required.');
170
+ return client._request({
171
+ endpoint: `/v1/workspaces/${workspaceId}`,
172
+ method: 'DELETE',
173
+ sendJWT: true,
174
+ });
175
+ },
176
+ /**
177
+ * Toggle a single workspace boolean setting (e.g. an `enableX` feature
178
+ * flag).
179
+ *
180
+ * @param {string} workspaceId - The ID of the workspace.
181
+ * @param {string} settingName - The name of the setting.
182
+ * @param {boolean} value - The new value for the setting.
183
+ * @returns {Promise<object>} The updated workspace object with new settings.
184
+ */
185
+ async updateSetting(workspaceId, settingName, value) {
186
+ if (!workspaceId)
187
+ throw new Error('workspaceId is required.');
188
+ if (!settingName)
189
+ throw new Error('settingName is required.');
190
+ return client._request({
191
+ endpoint: `/v1/workspaces/${workspaceId}/settings/${settingName}`,
192
+ method: 'PUT',
193
+ body: { value },
194
+ sendJWT: true,
195
+ });
196
+ },
197
+ };
198
+ }
199
+ //# sourceMappingURL=workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/routes/workspace.ts"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,MAAoB;IACjE,oFAAoF;IACpF,OAAO;QACL;;;;;WAKG;QACH,KAAK,CAAC,eAAe,CAAC,IAAyB;YAC7C,OAAO,MAAM,CAAC,QAAQ,CAAC;gBACrB,QAAQ,EAAE,gBAAgB;gBAC1B,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;;;WAKG;QACH,KAAK,CAAC,YAAY,CAAC,WAAmB;YACpC,IAAI,CAAC,WAAW;gBAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAC9D,OAAO,MAAM,CAAC,QAAQ,CAAC;gBACrB,QAAQ,EAAE,kBAAkB,WAAW,EAAE;gBACzC,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;;;;WAMG;QACH,KAAK,CAAC,cAAc,CAAC,aAAyB,EAAE;YAC9C,OAAO,MAAM,CAAC,QAAQ,CAAC;gBACrB,QAAQ,EAAE,gBAAgB;gBAC1B,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS;gBAC7E,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;;;;;;WAQG;QACH,KAAK,CAAC,UAAU,CAAC,WAAmB,EAAE,QAAkB;YACtD,IAAI,CAA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KAAK;gBACb,IAAI,EAAE,EAAE,KAAK,EAAE;gBACf,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KAEF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Upload Session Manager for Nurama SDK
3
+ *
4
+ * Provides upload progress persistence and cross-tab synchronization
5
+ * - Persists upload progress to localStorage with project isolation
6
+ * - Syncs upload state across multiple browser tabs
7
+ * - Automatic cleanup of completed/failed uploads
8
+ */
9
+ export interface UploadSessionData {
10
+ sessionId: string;
11
+ projectId: string;
12
+ uploadId: string;
13
+ key: string;
14
+ assetId?: string;
15
+ progress: number;
16
+ partNumber: number;
17
+ totalParts: number;
18
+ completedParts: number[];
19
+ fileName: string;
20
+ fileSize: number;
21
+ timestamp: number;
22
+ status: 'uploading' | 'completing' | 'completed' | 'failed' | 'cancelled';
23
+ error?: string;
24
+ }
25
+ export interface CrossTabMessage {
26
+ type: 'upload_progress_update' | 'upload_status_change' | 'upload_cleanup';
27
+ projectId: string;
28
+ sessionId: string;
29
+ data?: Partial<UploadSessionData>;
30
+ }
31
+ export declare class UploadSessionManager {
32
+ private static instance;
33
+ private messageListeners;
34
+ private readonly STORAGE_PREFIX;
35
+ private readonly MESSAGE_CHANNEL;
36
+ private broadcastChannel?;
37
+ constructor();
38
+ static getInstance(): UploadSessionManager;
39
+ /**
40
+ * Initialize cross-tab synchronization using BroadcastChannel
41
+ */
42
+ private initializeCrossTabSync;
43
+ /**
44
+ * Handle cross-tab messages
45
+ */
46
+ private handleCrossTabMessage;
47
+ /**
48
+ * Generate storage key for upload session
49
+ */
50
+ private getStorageKey;
51
+ /**
52
+ * Create a new upload session
53
+ */
54
+ createSession(projectId: string, sessionId: string, uploadData: {
55
+ uploadId: string;
56
+ key: string;
57
+ fileName: string;
58
+ fileSize: number;
59
+ totalParts: number;
60
+ assetId?: string;
61
+ }): UploadSessionData;
62
+ /**
63
+ * Update upload progress for a session
64
+ */
65
+ updateProgress(projectId: string, sessionId: string, progress: {
66
+ progress: number;
67
+ partNumber: number;
68
+ completedParts?: number[];
69
+ }): void;
70
+ /**
71
+ * Update upload status
72
+ */
73
+ updateStatus(projectId: string, sessionId: string, status: UploadSessionData['status'], error?: string): void;
74
+ /**
75
+ * Get upload session data
76
+ */
77
+ getSession(projectId: string, sessionId: string): UploadSessionData | null;
78
+ /**
79
+ * Get all upload sessions for a project
80
+ */
81
+ getProjectSessions(projectId: string): UploadSessionData[];
82
+ /**
83
+ * Get every upload session across ALL projects (scans the whole localStorage
84
+ * prefix, not a single project). Used by app-level guards that need a global
85
+ * "is anything uploading right now" answer without knowing the project id.
86
+ */
87
+ getAllSessions(): UploadSessionData[];
88
+ /**
89
+ * True when at least one upload is genuinely in flight anywhere in the app.
90
+ *
91
+ * "In flight" = status `uploading`/`completing` AND updated within `staleMs`.
92
+ * The freshness window matters: a tab that crashed mid-upload leaves an
93
+ * `uploading` row in localStorage forever (it never reaches a terminal
94
+ * status). Progress ticks bump `timestamp` on every part, so a real upload
95
+ * stays fresh; a dead one goes stale and stops counting — otherwise a stale
96
+ * row would block app refreshes/navigation indefinitely.
97
+ *
98
+ * @param staleMs How long since the last progress update still counts as
99
+ * active. Default 2 minutes — comfortably longer than a single part PUT on
100
+ * a slow connection, short enough that a crashed upload clears quickly.
101
+ */
102
+ hasActiveUploads(staleMs?: number): boolean;
103
+ /**
104
+ * Save session to localStorage
105
+ */
106
+ private saveSession;
107
+ /**
108
+ * Remove upload session
109
+ */
110
+ removeSession(projectId: string, sessionId: string): void;
111
+ /**
112
+ * Clean up old or completed sessions
113
+ */
114
+ cleanupSessions(projectId: string, olderThanMs?: number): void;
115
+ /**
116
+ * Register a listener for cross-tab messages
117
+ */
118
+ onMessage(listenerId: string, callback: (message: CrossTabMessage) => void): void;
119
+ /**
120
+ * Unregister a message listener
121
+ */
122
+ offMessage(listenerId: string): void;
123
+ /**
124
+ * Broadcast a message to other tabs
125
+ */
126
+ private broadcastMessage;
127
+ /**
128
+ * Cleanup resources
129
+ */
130
+ destroy(): void;
131
+ }
132
+ export declare const uploadSessionManager: UploadSessionManager;
133
+ //# sourceMappingURL=uploadSessionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploadSessionManager.d.ts","sourceRoot":"","sources":["../../src/utils/uploadSessionManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,EAAE,CAAC;IAGzB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;IAG1E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,wBAAwB,GAAG,sBAAsB,GAAG,gBAAgB,CAAC;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACnC;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAuB;IAC9C,OAAO,CAAC,gBAAgB,CAA8D;IACtF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA4B;IAC3D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAwB;IACxD,OAAO,CAAC,gBAAgB,CAAC,CAAmB;;WAM9B,WAAW,IAAI,oBAAoB;IAOj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