@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,49 @@
1
+ // --- Method Definitions ---
2
+ /**
3
+ * Defines storage-related methods for the NuramaClient.
4
+ * @param {NuramaClient} client - The NuramaClient instance.
5
+ * @returns {object} An object containing the storage-related methods.
6
+ */
7
+ export default function createStorageMethods(client) {
8
+ return {
9
+ /**
10
+ * Retrieves storage usage chart data for a specific resource.
11
+ * Requires authentication and permission.
12
+ * @param {ResourceType} resourceType - The type of the resource.
13
+ * @param {string} resourceId - The ID of the resource.
14
+ * @param {GetStorageChartParams} [params] - Optional query parameters for date range and aggregation.
15
+ * @returns {Promise<ChartDataResponse>} An array of chart data entries.
16
+ */
17
+ async getStorageChart(resourceType, resourceId, params) {
18
+ if (!resourceType)
19
+ throw new Error('resourceType is required.');
20
+ if (!resourceId)
21
+ throw new Error('resourceId is required.');
22
+ return client._request({
23
+ method: 'GET',
24
+ endpoint: `/v1/storage/chart/${resourceType}/${resourceId}`,
25
+ params,
26
+ sendJWT: true,
27
+ });
28
+ },
29
+ /**
30
+ * Retrieves the latest storage record for a specific resource.
31
+ * Requires authentication and permission.
32
+ * @param {ResourceType} resourceType - The type of the resource.
33
+ * @param {string} resourceId - The ID of the resource.
34
+ * @returns {Promise<StorageRecord>} The latest storage record for the resource.
35
+ */
36
+ async getStorageRecord(resourceType, resourceId) {
37
+ if (!resourceType)
38
+ throw new Error('resourceType is required.');
39
+ if (!resourceId)
40
+ throw new Error('resourceId is required.');
41
+ return client._request({
42
+ method: 'GET',
43
+ endpoint: `/v1/storage/${resourceType}/${resourceId}`,
44
+ sendJWT: true,
45
+ });
46
+ },
47
+ };
48
+ }
49
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/routes/storage.ts"],"names":[],"mappings":"AA2BA,6BAA6B;AAE7B;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,MAAoB;IAC/D,OAAO;QACL;;;;;;;eAOO;QACP,KAAK,CAAC,eAAe,CACnB,YAA0B,EAC1B,UAAkB,EAClB,MAA8B;YAE9B,IAAI,CAAC,YAAY;gBAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAChE,IAAI,CAAC,UAAU;gBAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;YAC5D,OAAO,MAAM,CAAC,QAAQ,CAAoB;gBACxC,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,qBAAqB,YAAY,IAAI,UAAU,EAAE;gBAC3D,MAAM;gBACN,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;;;;eAMO;QACP,KAAK,CAAC,gBAAgB,CACpB,YAA0B,EAC1B,UAAkB;YAElB,IAAI,CAAC,YAAY;gBAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAChE,IAAI,CAAC,UAAU;gBAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;YAC5D,OAAO,MAAM,CAAC,QAAQ,CAAgB;gBACpC,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,eAAe,YAAY,IAAI,UAAU,EAAE;gBACrD,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,184 @@
1
+ import NuramaClient from '../NuramaClient.js';
2
+ import { type Subscription } from '@nurama/types';
3
+ export interface SortParams {
4
+ sort?: Record<string, 1 | -1>;
5
+ }
6
+ export type SubscriptionStatus = 'active' | 'pending' | 'canceled' | 'expired' | 'pastDue' | 'paused' | 'paymentFailed' | 'unpaid';
7
+ /**
8
+ * Soft warnings returned by a plan swap / dry-run. STRUCTURED (not localized
9
+ * strings) so the multi-lingual FE renders the copy from these values.
10
+ */
11
+ export type PlanChangeWarning = {
12
+ type: 'capabilityRemoved';
13
+ capability: string;
14
+ } | {
15
+ type: 'seatMigration';
16
+ currentSeats: number;
17
+ unitPrice: number | null;
18
+ total: number | null;
19
+ currency: string;
20
+ period: 'month' | 'year';
21
+ };
22
+ export interface GetSubscriptionsParams extends SortParams {
23
+ status?: SubscriptionStatus;
24
+ limit?: number;
25
+ page?: number;
26
+ }
27
+ export interface CreateWorkspaceOrderParams {
28
+ productId: string;
29
+ quantity: number;
30
+ /**
31
+ * Customer-chosen purchase amount in the subscription's currency MINOR
32
+ * unit (pence for GBP, cents for USD, yen for JPY, etc.). Required for
33
+ * variable-amount products (currently only the AI add-on, `productType:
34
+ * 'enableAi'`). Server enforces a per-currency minimum.
35
+ */
36
+ amountInMinor?: number;
37
+ }
38
+ export interface GetSubscriptionOrdersParams {
39
+ limit?: number;
40
+ page?: number;
41
+ sortBy?: string;
42
+ }
43
+ export interface ResourceLimits {
44
+ totalStorageInBytes: number;
45
+ totalSeats: number;
46
+ totalCredits: number;
47
+ }
48
+ export interface SeatUsage {
49
+ totalSeats: number;
50
+ usedSeats: number;
51
+ availableSeats: number;
52
+ }
53
+ export interface RoleSeatUsage {
54
+ /** Distinct users occupying this seat type across the workspace + projects. */
55
+ used: number;
56
+ /** Plan cap for this seat type, or `null` when the plan is unlimited for it. */
57
+ limit: number | null;
58
+ }
59
+ export interface RoleUsage {
60
+ creators: RoleSeatUsage;
61
+ reviewers: RoleSeatUsage;
62
+ }
63
+ export interface StorageUsage {
64
+ totalStorageInBytes: number;
65
+ usedStorageInBytes: number;
66
+ availableStorageInBytes: number;
67
+ }
68
+ /**
69
+ * Defines subscription-related methods for the NuramaClient.
70
+ * @param {NuramaClient} client - The NuramaClient instance.
71
+ * @returns {object} An object containing the subscription-related methods.
72
+ */
73
+ export default function createSubscriptionMethods(client: NuramaClient): {
74
+ /**
75
+ * Retrieves the active subscription for a specific workspace.
76
+ * Requires authentication and permission.
77
+ * @param {string} workspaceId - The ID of the workspace.
78
+ * @returns {Promise<Subscription>} The workspace subscription object.
79
+ */
80
+ getWorkspaceSubscription(workspaceId: string): Promise<Subscription>;
81
+ /**
82
+ * Cancels the subscription for a specific workspace.
83
+ * Requires authentication and permission.
84
+ * @param {string} workspaceId - The ID of the workspace.
85
+ * @returns {Promise<any>} The cancellation response.
86
+ */
87
+ cancelWorkspaceSubscription(workspaceId: string): Promise<any>;
88
+ /**
89
+ * Reverse a scheduled (period-end) cancellation, keeping the workspace's
90
+ * subscription on its normal renewal cycle. Only valid while the
91
+ * subscription is still active with a pending cancellation; a fully
92
+ * lapsed subscription can't be resumed (the owner must re-subscribe).
93
+ * Requires authentication and permission.
94
+ * @param {string} workspaceId - The ID of the workspace.
95
+ * @returns {Promise<any>} The resume response.
96
+ */
97
+ resumeWorkspaceSubscription(workspaceId: string): Promise<any>;
98
+ /**
99
+ * Swap the workspace's active basePlan line for a different basePlan product.
100
+ * Same code path both upgrades and downgrades; the API's pre-flight
101
+ * capacity check is what distinguishes a permitted change from a refused
102
+ * one. Pass `dryRun: true` to get the pre-flight verdict without mutating.
103
+ *
104
+ * On over-allocation the API returns 400 `planCapacityInsufficient` with
105
+ * `errorData.violations: [{ resource, current, newLimit }]`, surfaced via
106
+ * the SDK's normal error path.
107
+ *
108
+ * On success, returns the updated subscription plus a `warnings[]` array
109
+ * of feature-gate capabilities the destination plan does NOT include (the
110
+ * FE renders these as a confirmation notice).
111
+ */
112
+ swapWorkspacePlan(workspaceId: string, params: {
113
+ newProductId: string;
114
+ currency: string;
115
+ billingPeriod: "month" | "year";
116
+ dryRun?: boolean;
117
+ }): Promise<{
118
+ subscription: Subscription | null;
119
+ warnings: PlanChangeWarning[];
120
+ }>;
121
+ /**
122
+ * Retrieves subscription orders for a specific workspace.
123
+ * Requires authentication and permission.
124
+ * @param {string} workspaceId - The ID of the workspace.
125
+ * @param {GetSubscriptionOrdersParams} [params] - Optional query parameters.
126
+ * @returns {Promise<any[]>} An array of subscription order objects.
127
+ */
128
+ getWorkspaceOrders(workspaceId: string, params?: GetSubscriptionOrdersParams): Promise<any[]>;
129
+ /**
130
+ * Creates a subscription order for a specific workspace.
131
+ * Requires authentication and permission.
132
+ * @param {string} workspaceId - The ID of the workspace.
133
+ * @param {CreateWorkspaceOrderParams} orderData - The order data.
134
+ * @returns {Promise<any>} The created order response.
135
+ */
136
+ createWorkspaceOrder(workspaceId: string, orderData: CreateWorkspaceOrderParams): Promise<any>;
137
+ /**
138
+ * Retrieves all subscriptions owned by the currently authenticated user.
139
+ * Requires authentication.
140
+ * @param {GetSubscriptionsParams} [params] - Optional query parameters for status and sorting.
141
+ * @returns {Promise<Subscription[]>} An array of subscription objects.
142
+ */
143
+ getUserSubscriptions(params?: GetSubscriptionsParams): Promise<Subscription[]>;
144
+ /**
145
+ * Retrieves the resource limits (e.g., storage, seats) for a specific resource (typically workspace).
146
+ * Requires authentication.
147
+ * @param {string} resourceId - The ID of the resource (e.g., workspaceId).
148
+ * @returns {Promise<ResourceLimits>} An object containing the resource limits.
149
+ */
150
+ getResourceLimits(resourceId: string): Promise<ResourceLimits>;
151
+ /**
152
+ * Retrieves the seat usage for a specific resource (typically workspace).
153
+ * Requires authentication.
154
+ * @param {string} resourceId - The ID of the resource (e.g., workspaceId).
155
+ * @returns {Promise<SeatUsage>} An object containing seat usage details.
156
+ */
157
+ getSeatUsage(resourceId: string): Promise<SeatUsage>;
158
+ /**
159
+ * Retrieves per-role (creator / reviewer) seat usage and caps for a
160
+ * workspace. `limit` is `null` when the plan is unlimited for that
161
+ * seat type. Requires authentication.
162
+ * @param {string} resourceId - The workspace ID.
163
+ * @returns {Promise<RoleUsage>} Creator- and reviewer-side seat usage.
164
+ */
165
+ getRoleUsage(resourceId: string): Promise<RoleUsage>;
166
+ /**
167
+ * Retrieves the storage usage for a specific resource (typically workspace).
168
+ * Requires authentication.
169
+ * @param {string} resourceId - The ID of the resource (e.g., workspaceId).
170
+ * @returns {Promise<StorageUsage>} An object containing storage usage details.
171
+ */
172
+ getStorageUsage(resourceId: string): Promise<StorageUsage>;
173
+ /**
174
+ * Retrieves the workspace usage summary (billable seats and storage used).
175
+ * Requires authentication and subscription management permission.
176
+ * @param {string} workspaceId - The ID of the workspace.
177
+ * @returns {Promise<{billableSeatCount: number; storageUsedInBytes: number}>} Usage summary.
178
+ */
179
+ getWorkspaceUsageSummary(workspaceId: string): Promise<{
180
+ billableSeatCount: number;
181
+ storageUsedInBytes: number;
182
+ }>;
183
+ };
184
+ //# sourceMappingURL=subscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/routes/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,MAAM,WAAW,UAAU;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACjC;AAED,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,eAAe,GAAG,QAAQ,CAAC;AAEnI;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACjD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B,CAAC;AAGN,MAAM,WAAW,sBAAuB,SAAQ,UAAU;IACtD,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf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AAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,OAAO,GAAG,MAAM,CAAC;QAChC,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;QAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAA;KAAE,CAAC;IAajF;;;;;;WAMO;oCAC+B,MAAM,WAAW,2BAA2B,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAUnG;;;;;;WAMO;sCACiC,MAAM,aAAa,0BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC;IAapG;;;;;WAKO;kCAC6B,sBAAsB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IASpF;;;;;WAKO;kCAC6B,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAWpE;;;;;WAKO;6BACwB,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAS1D;;;;;;WAMO;6BACwB,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAS1D;;;;;WAKO;gCAC2B,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAShE;;;;;WAKO;0CACqC,MAAM,GAAG,OAAO,CAAC;QAC3D,iBAAiB,EAAE,MAAM,CAAC;QAC1B,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;EASL"}
@@ -0,0 +1,219 @@
1
+ // --- Method Definitions ---
2
+ /**
3
+ * Defines subscription-related methods for the NuramaClient.
4
+ * @param {NuramaClient} client - The NuramaClient instance.
5
+ * @returns {object} An object containing the subscription-related methods.
6
+ */
7
+ export default function createSubscriptionMethods(client) {
8
+ return {
9
+ /**
10
+ * Retrieves the active subscription for a specific workspace.
11
+ * Requires authentication and permission.
12
+ * @param {string} workspaceId - The ID of the workspace.
13
+ * @returns {Promise<Subscription>} The workspace subscription object.
14
+ */
15
+ async getWorkspaceSubscription(workspaceId) {
16
+ if (!workspaceId)
17
+ throw new Error('workspaceId is required.');
18
+ return client._request({
19
+ method: 'GET',
20
+ endpoint: `/v1/subscriptions/workspace/${workspaceId}`,
21
+ sendJWT: true,
22
+ });
23
+ },
24
+ /**
25
+ * Cancels the subscription for a specific workspace.
26
+ * Requires authentication and permission.
27
+ * @param {string} workspaceId - The ID of the workspace.
28
+ * @returns {Promise<any>} The cancellation response.
29
+ */
30
+ async cancelWorkspaceSubscription(workspaceId) {
31
+ if (!workspaceId)
32
+ throw new Error('workspaceId is required.');
33
+ return client._request({
34
+ method: 'DELETE',
35
+ endpoint: `/v1/subscriptions/workspace/${workspaceId}`,
36
+ sendJWT: true,
37
+ });
38
+ },
39
+ /**
40
+ * Reverse a scheduled (period-end) cancellation, keeping the workspace's
41
+ * subscription on its normal renewal cycle. Only valid while the
42
+ * subscription is still active with a pending cancellation; a fully
43
+ * lapsed subscription can't be resumed (the owner must re-subscribe).
44
+ * Requires authentication and permission.
45
+ * @param {string} workspaceId - The ID of the workspace.
46
+ * @returns {Promise<any>} The resume response.
47
+ */
48
+ async resumeWorkspaceSubscription(workspaceId) {
49
+ if (!workspaceId)
50
+ throw new Error('workspaceId is required.');
51
+ return client._request({
52
+ method: 'POST',
53
+ endpoint: `/v1/subscriptions/workspace/${workspaceId}/resume`,
54
+ sendJWT: true,
55
+ });
56
+ },
57
+ /**
58
+ * Swap the workspace's active basePlan line for a different basePlan product.
59
+ * Same code path both upgrades and downgrades; the API's pre-flight
60
+ * capacity check is what distinguishes a permitted change from a refused
61
+ * one. Pass `dryRun: true` to get the pre-flight verdict without mutating.
62
+ *
63
+ * On over-allocation the API returns 400 `planCapacityInsufficient` with
64
+ * `errorData.violations: [{ resource, current, newLimit }]`, surfaced via
65
+ * the SDK's normal error path.
66
+ *
67
+ * On success, returns the updated subscription plus a `warnings[]` array
68
+ * of feature-gate capabilities the destination plan does NOT include (the
69
+ * FE renders these as a confirmation notice).
70
+ */
71
+ async swapWorkspacePlan(workspaceId, params) {
72
+ if (!workspaceId)
73
+ throw new Error('workspaceId is required.');
74
+ if (!params.newProductId)
75
+ throw new Error('newProductId is required.');
76
+ if (!params.currency)
77
+ throw new Error('currency is required.');
78
+ if (!params.billingPeriod)
79
+ throw new Error('billingPeriod is required.');
80
+ return client._request({
81
+ method: 'PUT',
82
+ endpoint: `/v1/subscriptions/workspace/${workspaceId}/plan`,
83
+ body: params,
84
+ sendJWT: true,
85
+ });
86
+ },
87
+ /**
88
+ * Retrieves subscription orders for a specific workspace.
89
+ * Requires authentication and permission.
90
+ * @param {string} workspaceId - The ID of the workspace.
91
+ * @param {GetSubscriptionOrdersParams} [params] - Optional query parameters.
92
+ * @returns {Promise<any[]>} An array of subscription order objects.
93
+ */
94
+ async getWorkspaceOrders(workspaceId, params) {
95
+ if (!workspaceId)
96
+ throw new Error('workspaceId is required.');
97
+ return client._request({
98
+ method: 'GET',
99
+ endpoint: `/v1/subscriptions/workspace/${workspaceId}/orders`,
100
+ params,
101
+ sendJWT: true,
102
+ });
103
+ },
104
+ /**
105
+ * Creates a subscription order for a specific workspace.
106
+ * Requires authentication and permission.
107
+ * @param {string} workspaceId - The ID of the workspace.
108
+ * @param {CreateWorkspaceOrderParams} orderData - The order data.
109
+ * @returns {Promise<any>} The created order response.
110
+ */
111
+ async createWorkspaceOrder(workspaceId, orderData) {
112
+ if (!workspaceId)
113
+ throw new Error('workspaceId is required.');
114
+ if (!orderData.productId)
115
+ throw new Error('productId is required.');
116
+ if (typeof orderData.quantity !== 'number')
117
+ throw new Error('quantity is required and must be a number.');
118
+ return client._request({
119
+ method: 'POST',
120
+ endpoint: `/v1/subscriptions/workspace/${workspaceId}/order`,
121
+ body: orderData,
122
+ sendJWT: true,
123
+ });
124
+ },
125
+ /**
126
+ * Retrieves all subscriptions owned by the currently authenticated user.
127
+ * Requires authentication.
128
+ * @param {GetSubscriptionsParams} [params] - Optional query parameters for status and sorting.
129
+ * @returns {Promise<Subscription[]>} An array of subscription objects.
130
+ */
131
+ async getUserSubscriptions(params) {
132
+ return client._request({
133
+ method: 'GET',
134
+ endpoint: '/v1/subscriptions/',
135
+ params,
136
+ sendJWT: true,
137
+ });
138
+ },
139
+ /**
140
+ * Retrieves the resource limits (e.g., storage, seats) for a specific resource (typically workspace).
141
+ * Requires authentication.
142
+ * @param {string} resourceId - The ID of the resource (e.g., workspaceId).
143
+ * @returns {Promise<ResourceLimits>} An object containing the resource limits.
144
+ */
145
+ async getResourceLimits(resourceId) {
146
+ if (!resourceId)
147
+ throw new Error('resourceId is required.');
148
+ // Note: Backend route uses /limits/:resourceId, validation uses resourceId
149
+ // Endpoint in test file is not hit for limits directly, assuming workspace ID based on context
150
+ return client._request({
151
+ method: 'GET',
152
+ endpoint: `/v1/subscriptions/limits/${resourceId}`, // Assuming resourceId here is workspaceId
153
+ sendJWT: true,
154
+ });
155
+ },
156
+ /**
157
+ * Retrieves the seat usage for a specific resource (typically workspace).
158
+ * Requires authentication.
159
+ * @param {string} resourceId - The ID of the resource (e.g., workspaceId).
160
+ * @returns {Promise<SeatUsage>} An object containing seat usage details.
161
+ */
162
+ async getSeatUsage(resourceId) {
163
+ if (!resourceId)
164
+ throw new Error('resourceId is required.');
165
+ return client._request({
166
+ method: 'GET',
167
+ endpoint: `/v1/subscriptions/usage/seats/${resourceId}`, // Assuming resourceId here is workspaceId
168
+ sendJWT: true,
169
+ });
170
+ },
171
+ /**
172
+ * Retrieves per-role (creator / reviewer) seat usage and caps for a
173
+ * workspace. `limit` is `null` when the plan is unlimited for that
174
+ * seat type. Requires authentication.
175
+ * @param {string} resourceId - The workspace ID.
176
+ * @returns {Promise<RoleUsage>} Creator- and reviewer-side seat usage.
177
+ */
178
+ async getRoleUsage(resourceId) {
179
+ if (!resourceId)
180
+ throw new Error('resourceId is required.');
181
+ return client._request({
182
+ method: 'GET',
183
+ endpoint: `/v1/subscriptions/usage/roles/${resourceId}`,
184
+ sendJWT: true,
185
+ });
186
+ },
187
+ /**
188
+ * Retrieves the storage usage for a specific resource (typically workspace).
189
+ * Requires authentication.
190
+ * @param {string} resourceId - The ID of the resource (e.g., workspaceId).
191
+ * @returns {Promise<StorageUsage>} An object containing storage usage details.
192
+ */
193
+ async getStorageUsage(resourceId) {
194
+ if (!resourceId)
195
+ throw new Error('resourceId is required.');
196
+ return client._request({
197
+ method: 'GET',
198
+ endpoint: `/v1/subscriptions/usage/storage/${resourceId}`, // Assuming resourceId here is workspaceId
199
+ sendJWT: true,
200
+ });
201
+ },
202
+ /**
203
+ * Retrieves the workspace usage summary (billable seats and storage used).
204
+ * Requires authentication and subscription management permission.
205
+ * @param {string} workspaceId - The ID of the workspace.
206
+ * @returns {Promise<{billableSeatCount: number; storageUsedInBytes: number}>} Usage summary.
207
+ */
208
+ async getWorkspaceUsageSummary(workspaceId) {
209
+ if (!workspaceId)
210
+ throw new Error('workspaceId is required.');
211
+ return client._request({
212
+ method: 'GET',
213
+ endpoint: `/v1/subscriptions/workspace/${workspaceId}/usage-summary`,
214
+ sendJWT: true,
215
+ });
216
+ },
217
+ };
218
+ }
219
+ //# sourceMappingURL=subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/routes/subscription.ts"],"names":[],"mappings":"AAoFA,6BAA6B;AAE7B;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,MAAoB;IACpE,OAAO;QACL;;;;;eAKO;QACP,KAAK,CAAC,wBAAwB,CAAC,WAAmB;YAChD,IAAI,CAAC,WAAW;gBAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAC9D,OAAO,MAAM,CAAC,QAAQ,CAAe;gBACnC,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,+BAA+B,WAAW,EAAE;gBACtD,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;;;eAKO;QACP,KAAK,CAAC,2BAA2B,CAAC,WAAmB;YACnD,IAAI,CAAC,WAAW;gBAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CA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 import type { SupportChatGetTopicResponse, SupportChatCreateAttachmentRequest, SupportChatCreateAttachmentResponse } from '@nurama/types';
3
+ /**
4
+ * Nurama Support chat — one topic per user on the `/news` page.
5
+ *
6
+ * The surface is intentionally tiny: one endpoint that lazily creates
7
+ * the user's support topic on first call and returns the existing row
8
+ * on every subsequent call. There is no list / archive / delete — each
9
+ * user has exactly one support conversation that persists across visits.
10
+ *
11
+ * Messages flow through the regular chat endpoints on
12
+ * `nuramaClient.chat`:
13
+ *
14
+ * - send: `nuramaClient.chat.createMessage(topic.chatId, { content })`
15
+ * - list: `nuramaClient.chat.getMessages(topic.chatId, …)`
16
+ *
17
+ * Backend gates: `auth → requireGlobalSupportChatEnabled → supportChatLimiter`.
18
+ * Unmetered (no credit deduction) — abuse is bounded by the per-user
19
+ * per-day rate limiter, not a credit balance check.
20
+ */
21
+ export default function createSupportChatMethods(client: NuramaClient): {
22
+ /**
23
+ * Get-or-create the caller's Support topic. Idempotent: re-calling
24
+ * returns the same row, so this is safe to invoke on every page mount.
25
+ */
26
+ getTopic(): Promise<SupportChatGetTopicResponse>;
27
+ /**
28
+ * Mint a Scratch upload bundle for one image attachment. The bytes
29
+ * land in a Scratch row with a 72-hour TTL and are read by the
30
+ * orchestrator's vision pass on the next user message — never
31
+ * promoted to a permanent Asset.
32
+ *
33
+ * Same upload protocol as every other multipart upload on the
34
+ * platform: call this, multipart-upload the bytes to `urls`, then
35
+ * call `nuramaClient.scratch.completeUpload(scratchId, { uploadId, parts })`.
36
+ * Send the message with `attachments: [{ scratchId, name }]`.
37
+ */
38
+ createAttachment(data: SupportChatCreateAttachmentRequest): Promise<SupportChatCreateAttachmentResponse>;
39
+ };
40
+ //# sourceMappingURL=supportChat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supportChat.d.ts","sourceRoot":"","sources":["../../src/routes/supportChat.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EACV,2BAA2B,EAC3B,kCAAkC,EAClC,mCAAmC,EACpC,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,MAAM,EAAE,YAAY;IAEjE;;;OAGG;gBACe,OAAO,CAAC,2BAA2B,CAAC;IAQtD;;;;;;;;;;OAUG;2BAEK,kCAAkC,GACvC,OAAO,CAAC,mCAAmC,CAAC;EASlD"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Nurama Support chat — one topic per user on the `/news` page.
3
+ *
4
+ * The surface is intentionally tiny: one endpoint that lazily creates
5
+ * the user's support topic on first call and returns the existing row
6
+ * on every subsequent call. There is no list / archive / delete — each
7
+ * user has exactly one support conversation that persists across visits.
8
+ *
9
+ * Messages flow through the regular chat endpoints on
10
+ * `nuramaClient.chat`:
11
+ *
12
+ * - send: `nuramaClient.chat.createMessage(topic.chatId, { content })`
13
+ * - list: `nuramaClient.chat.getMessages(topic.chatId, …)`
14
+ *
15
+ * Backend gates: `auth → requireGlobalSupportChatEnabled → supportChatLimiter`.
16
+ * Unmetered (no credit deduction) — abuse is bounded by the per-user
17
+ * per-day rate limiter, not a credit balance check.
18
+ */
19
+ export default function createSupportChatMethods(client) {
20
+ return {
21
+ /**
22
+ * Get-or-create the caller's Support topic. Idempotent: re-calling
23
+ * returns the same row, so this is safe to invoke on every page mount.
24
+ */
25
+ async getTopic() {
26
+ return client._request({
27
+ endpoint: '/v1/ai/support-chat/topic',
28
+ method: 'GET',
29
+ sendJWT: true,
30
+ });
31
+ },
32
+ /**
33
+ * Mint a Scratch upload bundle for one image attachment. The bytes
34
+ * land in a Scratch row with a 72-hour TTL and are read by the
35
+ * orchestrator's vision pass on the next user message — never
36
+ * promoted to a permanent Asset.
37
+ *
38
+ * Same upload protocol as every other multipart upload on the
39
+ * platform: call this, multipart-upload the bytes to `urls`, then
40
+ * call `nuramaClient.scratch.completeUpload(scratchId, { uploadId, parts })`.
41
+ * Send the message with `attachments: [{ scratchId, name }]`.
42
+ */
43
+ async createAttachment(data) {
44
+ return client._request({
45
+ endpoint: '/v1/ai/support-chat/attachments',
46
+ method: 'POST',
47
+ body: data,
48
+ sendJWT: true,
49
+ });
50
+ },
51
+ };
52
+ }
53
+ //# sourceMappingURL=supportChat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supportChat.js","sourceRoot":"","sources":["../../src/routes/supportChat.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,MAAoB;IACnE,OAAO;QACL;;;WAGG;QACH,KAAK,CAAC,QAAQ;YACZ,OAAO,MAAM,CAAC,QAAQ,CAAC;gBACrB,QAAQ,EAAE,2BAA2B;gBACrC,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QAED;;;;;;;;;;WAUG;QACH,KAAK,CAAC,gBAAgB,CACpB,IAAwC;YAExC,OAAO,MAAM,CAAC,QAAQ,CAAC;gBACrB,QAAQ,EAAE,iCAAiC;gBAC3C,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,89 @@
1
+ import NuramaClient from '../NuramaClient.js';
2
+ export type SupportTicketScope = 'user' | 'workspace' | 'project';
3
+ export type SupportTicketStatus = 'open' | 'pending' | 'resolved' | 'closed';
4
+ export interface CreateSupportTicketRequest {
5
+ scopeType: SupportTicketScope;
6
+ /** Required for workspace/project scope; ignored for user scope. */
7
+ scopeId?: string;
8
+ subject: string;
9
+ body: string;
10
+ /** Browser/app/device snapshot collected at submit time. */
11
+ deviceInfo?: Record<string, unknown>;
12
+ /**
13
+ * `true` when the ticket was drafted by Nu via the
14
+ * `create_support_ticket` chat tool and submitted by the user from
15
+ * the pre-populated SupportTicketCreateModal. Stamped onto the
16
+ * `SupportTicket` row for ops analytics; the FE sets this when the
17
+ * modal was opened by an AI-draft CTA.
18
+ */
19
+ aiGenerated?: boolean;
20
+ }
21
+ export interface SupportTicket {
22
+ id: string;
23
+ ticketNumber: number;
24
+ subject: string;
25
+ scopeType: SupportTicketScope;
26
+ scopeId: string | null;
27
+ creatorId: string;
28
+ status: SupportTicketStatus;
29
+ priority: string;
30
+ chatId: string;
31
+ deviceInfo: Record<string, unknown>;
32
+ /** True for tickets drafted by Nu's `create_support_ticket` tool. */
33
+ aiGenerated: boolean;
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ }
37
+ export interface SupportTicketListParams {
38
+ status?: SupportTicketStatus;
39
+ page?: number;
40
+ limit?: number;
41
+ }
42
+ export interface SupportTicketListResponse {
43
+ results: SupportTicket[];
44
+ page: number;
45
+ limit: number;
46
+ totalPages: number;
47
+ totalResults: number;
48
+ }
49
+ /** A logo asset (thumbnail-ready) attached to a scope for avatar rendering. */
50
+ export type SupportTicketScopeLogo = {
51
+ files?: unknown[];
52
+ [key: string]: unknown;
53
+ } | null;
54
+ export interface SupportTicketScopeOptions {
55
+ workspaces: {
56
+ id: string;
57
+ name: string;
58
+ slug: string;
59
+ color?: string | null;
60
+ logo?: SupportTicketScopeLogo;
61
+ }[];
62
+ projects: {
63
+ id: string;
64
+ name: string;
65
+ slug: string | null;
66
+ workspaceId: string;
67
+ color?: string | null;
68
+ logo?: SupportTicketScopeLogo;
69
+ }[];
70
+ }
71
+ /**
72
+ * Support tickets. A ticket carries the metadata + a backing Chat thread; the
73
+ * conversation itself is sent/read through the regular chat endpoints:
74
+ *
75
+ * - send: `nuramaClient.chat.createMessage(ticket.chatId, …)`
76
+ * - read: `nuramaClient.chat.getMessages(ticket.chatId, …)`
77
+ *
78
+ * Nurama customer service replies (as the support persona) from the admin site.
79
+ */
80
+ export default function createSupportTicketMethods(client: NuramaClient): {
81
+ /** Create a ticket. The opening message body becomes the first thread entry. */
82
+ createSupportTicket(data: CreateSupportTicketRequest): Promise<SupportTicket>;
83
+ /** List the caller's own tickets + (for resource admins) tickets in their scope. */
84
+ listSupportTickets(params?: SupportTicketListParams): Promise<SupportTicketListResponse>;
85
+ getSupportTicket(ticketId: string): Promise<SupportTicket>;
86
+ /** Workspaces/projects the caller may scope a new ticket to. */
87
+ getSupportTicketScopeOptions(): Promise<SupportTicketScopeOptions>;
88
+ };
89
+ //# sourceMappingURL=supportTicket.d.ts.map