@bluecopa/core 0.1.8 → 0.1.10

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.
@@ -0,0 +1,16 @@
1
+ export interface CheckSubscriptionStatusResponse {
2
+ success: boolean;
3
+ data: {
4
+ isSubscribed: boolean;
5
+ subscriptionDetails?: any;
6
+ };
7
+ message?: string;
8
+ }
9
+ /**
10
+ * Checks if a user is subscribed to a thread
11
+ * @param userId - The ID of the user
12
+ * @param threadId - The ID of the thread
13
+ * @returns Promise<CheckSubscriptionStatusResponse> The subscription status
14
+ * @throws Error if the request fails
15
+ */
16
+ export declare function checkSubscriptionStatus(userId: string, threadId: string): Promise<CheckSubscriptionStatusResponse>;
@@ -0,0 +1,16 @@
1
+ import { ChatThread } from '../../../../models/src/lib/gen/Api';
2
+ export interface CreateThreadRequest {
3
+ data: ChatThread;
4
+ }
5
+ export interface CreateThreadResponse {
6
+ success: boolean;
7
+ data: ChatThread;
8
+ message?: string;
9
+ }
10
+ /**
11
+ * Creates a new comment thread
12
+ * @param request - The thread creation request containing ChatThread data
13
+ * @returns Promise<CreateThreadResponse> The created thread details
14
+ * @throws Error if the request fails
15
+ */
16
+ export declare function createThread(request: CreateThreadRequest): Promise<CreateThreadResponse>;
@@ -0,0 +1,12 @@
1
+ export interface DeleteCommentResponse {
2
+ success: boolean;
3
+ data?: any;
4
+ message?: string;
5
+ }
6
+ /**
7
+ * Deletes a comment
8
+ * @param commentId - The ID of the comment to delete
9
+ * @returns Promise<DeleteCommentResponse> The deletion result
10
+ * @throws Error if the request fails
11
+ */
12
+ export declare function deleteComment(commentId: string): Promise<DeleteCommentResponse>;
@@ -0,0 +1,13 @@
1
+ import { ChatComment } from '../../../../models/src/lib/gen/Api';
2
+ export interface GetCommentsByThreadIdResponse {
3
+ success: boolean;
4
+ data: ChatComment[];
5
+ message?: string;
6
+ }
7
+ /**
8
+ * Gets all comments for a specific thread
9
+ * @param threadId - The ID of the thread to get comments for
10
+ * @returns Promise<GetCommentsByThreadIdResponse> The comments for the thread
11
+ * @throws Error if the request fails
12
+ */
13
+ export declare function getCommentsByThreadId(threadId: string): Promise<GetCommentsByThreadIdResponse>;
@@ -0,0 +1,8 @@
1
+ export { createThread, type CreateThreadRequest, type CreateThreadResponse } from './createThread';
2
+ export { getCommentsByThreadId, type GetCommentsByThreadIdResponse } from './getCommentsByThreadId';
3
+ export { postComment, type PostCommentRequest, type PostCommentResponse } from './postComment';
4
+ export { updateComment, type UpdateCommentRequest, type UpdateCommentResponse } from './updateComment';
5
+ export { deleteComment, type DeleteCommentResponse } from './deleteComment';
6
+ export { subscribeUser, type SubscribeUserRequest, type SubscribeUserResponse } from './subscribeUser';
7
+ export { unsubscribeUser, type UnsubscribeUserRequest, type UnsubscribeUserResponse } from './unsubscribeUser';
8
+ export { checkSubscriptionStatus, type CheckSubscriptionStatusResponse } from './checkSubscriptionStatus';
@@ -0,0 +1,16 @@
1
+ import { ChatComment } from '../../../../models/src/lib/gen/Api';
2
+ export interface PostCommentRequest {
3
+ data: ChatComment;
4
+ }
5
+ export interface PostCommentResponse {
6
+ success: boolean;
7
+ data: ChatComment;
8
+ message?: string;
9
+ }
10
+ /**
11
+ * Adds a new comment to an existing thread
12
+ * @param request - The comment creation request containing ChatComment data
13
+ * @returns Promise<PostCommentResponse> The created comment details
14
+ * @throws Error if the request fails
15
+ */
16
+ export declare function postComment(request: PostCommentRequest): Promise<PostCommentResponse>;
@@ -0,0 +1,18 @@
1
+ export interface SubscribeUserRequest {
2
+ params: {
3
+ userId: string;
4
+ threadId: string;
5
+ };
6
+ }
7
+ export interface SubscribeUserResponse {
8
+ success: boolean;
9
+ data?: any;
10
+ message?: string;
11
+ }
12
+ /**
13
+ * Subscribes a user to a thread
14
+ * @param request - The subscription request containing userId and threadId
15
+ * @returns Promise<SubscribeUserResponse> The subscription result
16
+ * @throws Error if the request fails
17
+ */
18
+ export declare function subscribeUser(request: SubscribeUserRequest): Promise<SubscribeUserResponse>;
@@ -0,0 +1,18 @@
1
+ export interface UnsubscribeUserRequest {
2
+ params: {
3
+ userId: string;
4
+ threadId: string;
5
+ };
6
+ }
7
+ export interface UnsubscribeUserResponse {
8
+ success: boolean;
9
+ data?: any;
10
+ message?: string;
11
+ }
12
+ /**
13
+ * Unsubscribes a user from a thread
14
+ * @param request - The unsubscription request containing userId and threadId
15
+ * @returns Promise<UnsubscribeUserResponse> The unsubscription result
16
+ * @throws Error if the request fails
17
+ */
18
+ export declare function unsubscribeUser(request: UnsubscribeUserRequest): Promise<UnsubscribeUserResponse>;
@@ -0,0 +1,17 @@
1
+ import { ChatComment } from '../../../../models/src/lib/gen/Api';
2
+ export interface UpdateCommentRequest {
3
+ data: ChatComment;
4
+ commentId: string;
5
+ }
6
+ export interface UpdateCommentResponse {
7
+ success: boolean;
8
+ data: ChatComment;
9
+ message?: string;
10
+ }
11
+ /**
12
+ * Updates an existing comment
13
+ * @param request - The comment update request containing ChatComment data and commentId
14
+ * @returns Promise<UpdateCommentResponse> The updated comment details
15
+ * @throws Error if the request fails
16
+ */
17
+ export declare function updateComment(request: UpdateCommentRequest): Promise<UpdateCommentResponse>;
@@ -4,6 +4,7 @@ export * as workflow from './workflow';
4
4
  export * as files from './file';
5
5
  export * as definition from './definition';
6
6
  export * as metric from './metric';
7
+ export * as chat from './chat';
7
8
  export * as dataset from './dataset';
8
9
  export * as inputTable from './inputTable';
9
10
  export * as workbook from './workbook';
package/dist/index.es.js CHANGED
@@ -99,7 +99,7 @@ async function getLoggedInUserDetails() {
99
99
  throw { message, status };
100
100
  }
101
101
  }
102
- const index$a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
102
+ const index$b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
103
103
  __proto__: null,
104
104
  getLoggedInUserDetails
105
105
  }, Symbol.toStringTag, { value: "Module" }));
@@ -158,7 +158,7 @@ const getWorkflowInstanceStatusById = async (request) => {
158
158
  throw { message, status };
159
159
  }
160
160
  };
161
- const index$9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
161
+ const index$a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
162
162
  __proto__: null,
163
163
  WorkflowStatus,
164
164
  getWorkflowInstanceStatusById,
@@ -183,7 +183,7 @@ async function getFileUrlByFileId({
183
183
  throw { message, status };
184
184
  }
185
185
  }
186
- const index$8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
186
+ const index$9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
187
187
  __proto__: null,
188
188
  getFileUrlByFileId
189
189
  }, Symbol.toStringTag, { value: "Module" }));
@@ -236,7 +236,7 @@ const runDefinition = async (props) => {
236
236
  { cancelToken: source == null ? void 0 : source.token }
237
237
  );
238
238
  };
239
- const index$7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
239
+ const index$8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
240
240
  __proto__: null,
241
241
  runDefinition,
242
242
  runPublishedDefinition,
@@ -274,7 +274,7 @@ const getWorksheetsByType = async (type) => {
274
274
  throw { message, status };
275
275
  }
276
276
  };
277
- const index$6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
277
+ const index$7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
278
278
  __proto__: null,
279
279
  getWorksheets,
280
280
  getWorksheetsByType
@@ -4830,15 +4830,24 @@ class CentrifugoWebsocket {
4830
4830
  if (!this.accessToken) {
4831
4831
  throw new Error("Unable to connect to websocket, missing info");
4832
4832
  }
4833
- if (!this.connectionUrl) {
4834
- throw new Error("Unable to connect to websocket, missing url");
4835
- }
4836
4833
  if (!this.centrifuge) {
4837
- this.centrifuge = new Centrifuge(this.connectionUrl, {
4838
- token: this.accessToken
4839
- });
4834
+ const token = atob(this.accessToken);
4835
+ this.centrifuge = new Centrifuge(
4836
+ [
4837
+ {
4838
+ transport: "websocket",
4839
+ endpoint: this.connectionUrl
4840
+ }
4841
+ ],
4842
+ {
4843
+ token
4844
+ }
4845
+ );
4840
4846
  this.centrifuge.on("connecting", () => {
4841
- console.log("Connecting to centrifuge", this.connectionUrl);
4847
+ console.log(
4848
+ "Connecting to centrifuge",
4849
+ this.connectionUrl
4850
+ );
4842
4851
  });
4843
4852
  this.centrifuge.on("error", (err) => {
4844
4853
  console.error("Error connecting to centrifuge", err);
@@ -4922,7 +4931,7 @@ const websocketProviderFactory = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ O
4922
4931
  __proto__: null,
4923
4932
  WebsocketContextFactory
4924
4933
  }, Symbol.toStringTag, { value: "Module" }));
4925
- const index$5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4934
+ const index$6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4926
4935
  __proto__: null,
4927
4936
  formatDate,
4928
4937
  getMetricDefinition,
@@ -5109,10 +5118,168 @@ const getData$2 = async (metricSheetId, options) => {
5109
5118
  resultData = _.flatten(resultData);
5110
5119
  return { data: resultData };
5111
5120
  };
5112
- const index$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5121
+ const index$5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5113
5122
  __proto__: null,
5114
5123
  getData: getData$2
5115
5124
  }, Symbol.toStringTag, { value: "Module" }));
5125
+ async function createThread(request) {
5126
+ var _a, _b, _c;
5127
+ try {
5128
+ const response = await apiClient.post("/chat/create-thread", request);
5129
+ if (!response.data) {
5130
+ throw { message: "Failed to create thread", status: 500 };
5131
+ }
5132
+ return {
5133
+ success: true,
5134
+ data: response.data
5135
+ };
5136
+ } catch (error) {
5137
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while creating thread";
5138
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
5139
+ throw { message, status };
5140
+ }
5141
+ }
5142
+ async function getCommentsByThreadId(threadId) {
5143
+ var _a, _b, _c;
5144
+ try {
5145
+ if (!threadId) {
5146
+ throw { message: "Thread ID is required", status: 400 };
5147
+ }
5148
+ const response = await apiClient.get(`/chat/get-comments-by-thread-id?threadId=${threadId}`);
5149
+ if (!response.data) {
5150
+ throw { message: "Failed to fetch comments", status: 500 };
5151
+ }
5152
+ return {
5153
+ success: true,
5154
+ data: response.data
5155
+ };
5156
+ } catch (error) {
5157
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while fetching comments";
5158
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
5159
+ throw { message, status };
5160
+ }
5161
+ }
5162
+ async function postComment(request) {
5163
+ var _a, _b, _c;
5164
+ try {
5165
+ const response = await apiClient.post("/chat/post-comment", request);
5166
+ if (!response.data) {
5167
+ throw { message: "Failed to post comment", status: 500 };
5168
+ }
5169
+ return {
5170
+ success: true,
5171
+ data: response.data
5172
+ };
5173
+ } catch (error) {
5174
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while posting comment";
5175
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
5176
+ throw { message, status };
5177
+ }
5178
+ }
5179
+ async function updateComment(request) {
5180
+ var _a, _b, _c;
5181
+ try {
5182
+ if (!request.commentId) {
5183
+ throw { message: "Comment ID is required", status: 400 };
5184
+ }
5185
+ const response = await apiClient.put("/chat/update-comment", request);
5186
+ if (!response.data) {
5187
+ throw { message: "Failed to update comment", status: 500 };
5188
+ }
5189
+ return {
5190
+ success: true,
5191
+ data: response.data
5192
+ };
5193
+ } catch (error) {
5194
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while updating comment";
5195
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
5196
+ throw { message, status };
5197
+ }
5198
+ }
5199
+ async function deleteComment(commentId) {
5200
+ var _a, _b, _c;
5201
+ try {
5202
+ if (!commentId) {
5203
+ throw { message: "Comment ID is required", status: 400 };
5204
+ }
5205
+ const response = await apiClient.delete(`/chat/delete-comment?commentId=${commentId}`);
5206
+ return {
5207
+ success: true,
5208
+ data: response.data
5209
+ };
5210
+ } catch (error) {
5211
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while deleting comment";
5212
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
5213
+ throw { message, status };
5214
+ }
5215
+ }
5216
+ async function subscribeUser(request) {
5217
+ var _a, _b, _c;
5218
+ try {
5219
+ if (!request.params.userId || !request.params.threadId) {
5220
+ throw { message: "User ID and Thread ID are required", status: 400 };
5221
+ }
5222
+ const response = await apiClient.post("/chat/subscribe-user", request);
5223
+ return {
5224
+ success: true,
5225
+ data: response.data
5226
+ };
5227
+ } catch (error) {
5228
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while subscribing user";
5229
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
5230
+ throw { message, status };
5231
+ }
5232
+ }
5233
+ async function unsubscribeUser(request) {
5234
+ var _a, _b, _c;
5235
+ try {
5236
+ if (!request.params.userId || !request.params.threadId) {
5237
+ throw { message: "User ID and Thread ID are required", status: 400 };
5238
+ }
5239
+ const response = await apiClient.post("/chat/unsubscribe-user", request);
5240
+ return {
5241
+ success: true,
5242
+ data: response.data
5243
+ };
5244
+ } catch (error) {
5245
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while unsubscribing user";
5246
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
5247
+ throw { message, status };
5248
+ }
5249
+ }
5250
+ async function checkSubscriptionStatus(userId, threadId) {
5251
+ var _a, _b, _c;
5252
+ try {
5253
+ if (!userId || !threadId) {
5254
+ throw { message: "User ID and Thread ID are required", status: 400 };
5255
+ }
5256
+ const response = await apiClient.get(
5257
+ `/chat/check-user-subscription-status?userId=${userId}&threadId=${threadId}`
5258
+ );
5259
+ if (!response.data) {
5260
+ throw { message: "Failed to check subscription status", status: 500 };
5261
+ }
5262
+ return {
5263
+ success: true,
5264
+ data: response.data
5265
+ };
5266
+ } catch (error) {
5267
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while checking subscription status";
5268
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
5269
+ throw { message, status };
5270
+ }
5271
+ }
5272
+ const index$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5273
+ __proto__: null,
5274
+ checkSubscriptionStatus,
5275
+ createThread,
5276
+ deleteComment,
5277
+ getCommentsByThreadId,
5278
+ postComment,
5279
+ subscribeUser,
5280
+ unsubscribeUser,
5281
+ updateComment
5282
+ }, Symbol.toStringTag, { value: "Module" }));
5116
5283
  class DefinitionBuilder {
5117
5284
  constructor(def) {
5118
5285
  __publicField(this, "definition");
@@ -5523,15 +5690,16 @@ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
5523
5690
  const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5524
5691
  __proto__: null,
5525
5692
  apiClient,
5693
+ chat: index$4,
5526
5694
  dataset: index$3,
5527
- definition: index$7,
5528
- files: index$8,
5695
+ definition: index$8,
5696
+ files: index$9,
5529
5697
  inputTable: index$2,
5530
- metric: index$4,
5531
- user: index$a,
5698
+ metric: index$5,
5699
+ user: index$b,
5532
5700
  workbook: index$1,
5533
- workflow: index$9,
5534
- worksheet: index$6
5701
+ workflow: index$a,
5702
+ worksheet: index$7
5535
5703
  }, Symbol.toStringTag, { value: "Module" }));
5536
5704
  const bluecopaTailwindConfig = {
5537
5705
  darkMode: "class",
@@ -5695,6 +5863,6 @@ export {
5695
5863
  getConfig as copaGetConfig,
5696
5864
  setConfig as copaSetConfig,
5697
5865
  bluecopaTailwindConfig as copaTailwindConfig,
5698
- index$5 as copaUtils
5866
+ index$6 as copaUtils
5699
5867
  };
5700
5868
  //# sourceMappingURL=index.es.js.map