@bluecopa/core 0.1.33 → 0.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -57,13 +57,13 @@ The package uses a singleton-based configuration system to manage API settings.
57
57
  Import and set the config:
58
58
 
59
59
  ```typescript
60
- import { copaSetConfig, copaApi } from '@bluecopa/core';
60
+ import { copaSetConfig, copaApi } from "@bluecopa/core";
61
61
 
62
62
  copaSetConfig({
63
- apiBaseUrl: 'https://develop.bluecopa.com', // Base URL for API endpoints
64
- accessToken: 'your-access-token', // Authentication token
65
- workspaceId: 'your-workspace-id', // Current workspace identifier
66
- userId: 'your-user-id' // User identifier for WebSocket connections
63
+ apiBaseUrl: "https://develop.bluecopa.com", // Base URL for API endpoints
64
+ accessToken: "your-access-token", // Authentication token
65
+ workspaceId: "your-workspace-id", // Current workspace identifier
66
+ userId: "your-user-id", // User identifier for WebSocket connections
67
67
  });
68
68
  ```
69
69
 
@@ -72,22 +72,22 @@ copaSetConfig({
72
72
  To automatically set the userId from the logged-in user:
73
73
 
74
74
  ```typescript
75
- import { copaSetConfig, copaApi } from '@bluecopa/core';
75
+ import { copaSetConfig, copaApi } from "@bluecopa/core";
76
76
 
77
77
  // First configure basic settings
78
78
  copaSetConfig({
79
- apiBaseUrl: 'https://develop.bluecopa.com',
80
- accessToken: 'your-access-token',
81
- workspaceId: 'your-workspace-id'
79
+ apiBaseUrl: "https://develop.bluecopa.com",
80
+ accessToken: "your-access-token",
81
+ workspaceId: "your-workspace-id",
82
82
  });
83
83
 
84
84
  // Get user details and set userId
85
85
  try {
86
86
  const userDetails = await copaApi.user.getLoggedInUserDetails();
87
87
  copaSetConfig({ userId: userDetails.id });
88
- console.log('User ID set:', userDetails.id);
88
+ console.log("User ID set:", userDetails.id);
89
89
  } catch (error) {
90
- console.error('Failed to get user details:', error);
90
+ console.error("Failed to get user details:", error);
91
91
  }
92
92
  ```
93
93
 
@@ -183,12 +183,15 @@ The core package provides WebSocket utilities for real-time communication using
183
183
  Access WebSocket functionality through the utilities:
184
184
 
185
185
  ```typescript
186
- import { copaUtils } from '@bluecopa/core';
186
+ import { copaUtils } from "@bluecopa/core";
187
187
 
188
188
  // Create a WebSocket connection
189
- const websocket = copaUtils.websocketUtils.WebsocketContextFactory.create('centrifugo', {
190
- connectionUrl: 'wss://your-centrifugo-url'
191
- });
189
+ const websocket = copaUtils.websocketUtils.WebsocketContextFactory.create(
190
+ "centrifugo",
191
+ {
192
+ connectionUrl: "wss://your-centrifugo-url",
193
+ },
194
+ );
192
195
  ```
193
196
 
194
197
  ### WebSocket Provider Interface
@@ -204,29 +207,32 @@ The `IWebsocketProvider` interface provides the following methods:
204
207
  ### WebSocket Usage Example
205
208
 
206
209
  ```typescript
207
- import { copaSetConfig, copaApi, copaUtils } from '@bluecopa/core';
210
+ import { copaSetConfig, copaApi, copaUtils } from "@bluecopa/core";
208
211
 
209
212
  // Configure with userId for WebSocket connections
210
213
  copaSetConfig({
211
- apiBaseUrl: 'https://develop.bluecopa.com',
212
- accessToken: 'your-access-token',
213
- workspaceId: 'your-workspace-id',
214
- userId: 'your-user-id'
214
+ apiBaseUrl: "https://develop.bluecopa.com",
215
+ accessToken: "your-access-token",
216
+ workspaceId: "your-workspace-id",
217
+ userId: "your-user-id",
215
218
  });
216
219
 
217
220
  // Create WebSocket connection
218
- const websocket = copaUtils.websocketUtils.WebsocketContextFactory.create('centrifugo', {
219
- connectionUrl: 'wss://centrifugo.your-domain.com/connection/websocket'
220
- });
221
+ const websocket = copaUtils.websocketUtils.WebsocketContextFactory.create(
222
+ "centrifugo",
223
+ {
224
+ connectionUrl: "wss://centrifugo.your-domain.com/connection/websocket",
225
+ },
226
+ );
221
227
 
222
228
  // Subscribe to user-specific events
223
- websocket.bind('notifications', 'new_message', (data) => {
224
- console.log('New notification:', data);
229
+ websocket.bind("notifications", "new_message", (data) => {
230
+ console.log("New notification:", data);
225
231
  });
226
232
 
227
233
  // Subscribe to global events
228
- websocket.bindGlobal('system_updates', (data) => {
229
- console.log('System update:', data);
234
+ websocket.bindGlobal("system_updates", (data) => {
235
+ console.log("System update:", data);
230
236
  });
231
237
 
232
238
  // Clean up when done
@@ -248,32 +254,35 @@ The WebSocket connection automatically uses the configured `accessToken` and `us
248
254
  Complete example showing configuration, user details retrieval, and WebSocket setup.
249
255
 
250
256
  ```typescript
251
- import { copaSetConfig, copaApi, copaUtils } from '@bluecopa/core';
257
+ import { copaSetConfig, copaApi, copaUtils } from "@bluecopa/core";
252
258
 
253
259
  // Initial configuration
254
260
  copaSetConfig({
255
- apiBaseUrl: 'https://develop.bluecopa.com',
256
- accessToken: 'your-access-token',
257
- workspaceId: 'your-workspace-id'
261
+ apiBaseUrl: "https://develop.bluecopa.com",
262
+ accessToken: "your-access-token",
263
+ workspaceId: "your-workspace-id",
258
264
  });
259
265
 
260
266
  // Get user details and set userId
261
267
  try {
262
268
  const userDetails = await copaApi.user.getLoggedInUserDetails();
263
269
  copaSetConfig({ userId: userDetails.id });
264
- console.log('User configured:', userDetails.name, userDetails.id);
270
+ console.log("User configured:", userDetails.name, userDetails.id);
265
271
  } catch (error: any) {
266
- console.error('Failed to get user details:', error.message, error.status);
272
+ console.error("Failed to get user details:", error.message, error.status);
267
273
  }
268
274
 
269
275
  // Set up WebSocket connection
270
- const websocket = copaUtils.websocketUtils.WebsocketContextFactory.create('centrifugo', {
271
- connectionUrl: 'wss://centrifugo.develop.bluecopa.com/connection/websocket'
272
- });
276
+ const websocket = copaUtils.websocketUtils.WebsocketContextFactory.create(
277
+ "centrifugo",
278
+ {
279
+ connectionUrl: "wss://centrifugo.develop.bluecopa.com/connection/websocket",
280
+ },
281
+ );
273
282
 
274
283
  // Subscribe to notifications
275
- websocket.bind('notifications', 'new_message', (data) => {
276
- console.log('New notification received:', data);
284
+ websocket.bind("notifications", "new_message", (data) => {
285
+ console.log("New notification received:", data);
277
286
  });
278
287
  ```
279
288
 
@@ -282,14 +291,14 @@ websocket.bind('notifications', 'new_message', (data) => {
282
291
  Fetches all input tables from the API.
283
292
 
284
293
  ```typescript
285
- import { copaApi } from '@bluecopa/core';
294
+ import { copaApi } from "@bluecopa/core";
286
295
 
287
296
  // Configure first
288
- copaSetConfig({
289
- apiBaseUrl: 'https://api.example.com',
290
- accessToken: 'token',
291
- workspaceId: 'ws1',
292
- userId: 'user123'
297
+ copaSetConfig({
298
+ apiBaseUrl: "https://api.example.com",
299
+ accessToken: "token",
300
+ workspaceId: "ws1",
301
+ userId: "user123",
293
302
  });
294
303
 
295
304
  // Use API
@@ -302,11 +311,13 @@ const { getWorkbooksByType } = copaApi.workbook;
302
311
  Retrieves workbooks filtered by a specific type.
303
312
 
304
313
  ```typescript
305
- import { copaApi } from '@bluecopa/core';
314
+ import { copaApi } from "@bluecopa/core";
306
315
  import type { Worksheet } from "$models/gen/Api";
307
316
 
308
317
  try {
309
- const workbooks = await copaApi.workbook.getWorkbooksByType('dashboard' as Worksheet["type"]);
318
+ const workbooks = await copaApi.workbook.getWorkbooksByType(
319
+ "dashboard" as Worksheet["type"],
320
+ );
310
321
  console.log(workbooks); // Array of Worksheet
311
322
  } catch (error: any) {
312
323
  console.error(error.message, error.status);
@@ -2,7 +2,7 @@ export interface GetAuditLogsRequest {
2
2
  entityType?: string;
3
3
  entitySubType?: string;
4
4
  entityId?: string;
5
- source?: 'UI' | 'BACKEND';
5
+ source?: "UI" | "BACKEND";
6
6
  userId?: string;
7
7
  limit: number;
8
8
  startDate?: string;
@@ -1,8 +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';
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
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';
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,9 @@
1
+ export interface ClientIpResponse {
2
+ ip: string;
3
+ }
4
+ /**
5
+ * Fetches the client's IP address from the server
6
+ * @returns Promise<ClientIpResponse> The client's IP address
7
+ * @throws Error if the request fails or user is not authenticated
8
+ */
9
+ export declare function getClientIp(): Promise<ClientIpResponse>;
@@ -0,0 +1 @@
1
+ export { getClientIp, type ClientIpResponse } from './getClientIp';
@@ -0,0 +1,29 @@
1
+ import { EmailConversation } from './getAllConversations';
2
+ export interface CreateConversationRequest {
3
+ toEmail: string;
4
+ subject: string;
5
+ bodyText: string;
6
+ bodyHtml?: string;
7
+ accountId: string;
8
+ senderId: string;
9
+ attachments?: {
10
+ filename: string;
11
+ content: string;
12
+ /** snake_case to match backend API contract */
13
+ content_type: string;
14
+ }[];
15
+ }
16
+ /**
17
+ * Creates a new email conversation
18
+ * @param params - The conversation data
19
+ * @param params.toEmail - Required: Recipient email address
20
+ * @param params.subject - Required: Email subject
21
+ * @param params.bodyText - Required: Plain text body
22
+ * @param params.bodyHtml - Optional: HTML body
23
+ * @param params.accountId - Required: Account ID
24
+ * @param params.senderId - Required: Sender email address
25
+ * @param params.attachments - Optional: Array of attachments
26
+ * @returns Promise<EmailConversation> The created conversation
27
+ * @throws Error if the request fails
28
+ */
29
+ export declare function createConversation(params: CreateConversationRequest): Promise<EmailConversation>;
@@ -0,0 +1,23 @@
1
+ export interface EmailConversation {
2
+ id?: string;
3
+ toEmail: string;
4
+ senderId: string;
5
+ subject: string;
6
+ bodyText?: string;
7
+ bodyHtml?: string;
8
+ status: "AWAITING_RESPONSE" | "RESPONSE_RECEIVED" | "IN_PROGRESS" | "RESOLVED" | "ESCALATED" | "CLOSED";
9
+ threadId?: string;
10
+ lastMessageAt?: string;
11
+ accountId: string;
12
+ createdBy?: string;
13
+ createdDate?: string;
14
+ lastModifiedBy?: string;
15
+ lastModifiedDate?: string;
16
+ workspaceId?: string;
17
+ }
18
+ /**
19
+ * Gets all email conversations
20
+ * @returns Promise<EmailConversation[]> List of all conversations
21
+ * @throws Error if the request fails
22
+ */
23
+ export declare function getAllConversations(): Promise<EmailConversation[]>;
@@ -0,0 +1,12 @@
1
+ import { EmailConversation } from './getAllConversations';
2
+ export interface GetConversationRequest {
3
+ conversationId: string;
4
+ }
5
+ /**
6
+ * Gets a single email conversation by ID
7
+ * @param params - The request parameters
8
+ * @param params.conversationId - Required: The conversation ID
9
+ * @returns Promise<EmailConversation> The conversation details
10
+ * @throws Error if the request fails
11
+ */
12
+ export declare function getConversation(params: GetConversationRequest): Promise<EmailConversation>;
@@ -0,0 +1,4 @@
1
+ export * from './getAllConversations';
2
+ export * from './getConversation';
3
+ export * from './createConversation';
4
+ export * from './replyToConversation';
@@ -0,0 +1,26 @@
1
+ export interface ReplyToConversationRequest {
2
+ conversationId: string;
3
+ accountId: string;
4
+ senderId: string;
5
+ bodyText: string;
6
+ bodyHtml?: string;
7
+ attachments?: {
8
+ filename: string;
9
+ content: string;
10
+ /** snake_case to match backend API contract */
11
+ content_type: string;
12
+ }[];
13
+ }
14
+ /**
15
+ * Replies to an existing email conversation
16
+ * @param params - The reply parameters
17
+ * @param params.conversationId - Required: The conversation ID to reply to
18
+ * @param params.accountId - Required: Account ID
19
+ * @param params.senderId - Required: Sender email address
20
+ * @param params.bodyText - Required: Plain text body of the reply
21
+ * @param params.bodyHtml - Optional: HTML body of the reply
22
+ * @param params.attachments - Optional: Array of attachments
23
+ * @returns Promise<any> The reply response
24
+ * @throws Error if the request fails
25
+ */
26
+ export declare function replyToConversation(params: ReplyToConversationRequest): Promise<any>;
@@ -1,7 +1,7 @@
1
1
  export interface GetFileUrlRequest {
2
2
  key: string;
3
3
  contentType: string;
4
- method: 'GET' | 'PUT' | 'POST';
4
+ method: "GET" | "PUT" | "POST";
5
5
  }
6
6
  export interface GetFileUrlResponse {
7
7
  url: string;
@@ -17,3 +17,6 @@ export * as audit from './audit';
17
17
  export * as templatedPipeline from './templatedPipeline';
18
18
  export * as process from './process';
19
19
  export * as inboxItems from './inboxItems';
20
+ export * as permissions from './permissions';
21
+ export * as clientIp from './clientIp';
22
+ export * as emailEngine from './emailEngine';
@@ -0,0 +1,21 @@
1
+ export type GetPermissionsParams = {
2
+ objectId: string;
3
+ objectType: string;
4
+ user: string;
5
+ userType: "User" | "Team";
6
+ relations: string[];
7
+ };
8
+ export type PermissionsResponse = Record<string, boolean>;
9
+ /**
10
+ * Fetches permissions for a user on a given object (e.g. workbook/page).
11
+ * Used by external apps to gate UI or logic by Owner/Editor/Viewer/ReadOnly.
12
+ * All parameters are required; no defaults.
13
+ *
14
+ * @param params.objectId - Workbook/page ID
15
+ * @param params.objectType - e.g. 'Portal', 'Workbook', 'ExternalAppPage'
16
+ * @param params.user - User ID
17
+ * @param params.userType - 'User' | 'Team'
18
+ * @param params.relations - e.g. ['Owner', 'Editor', 'Viewer', 'ReadOnly']
19
+ * @returns Record of role to boolean (e.g. { Owner: false, Editor: true, Viewer: true })
20
+ */
21
+ export declare function getPermissions(params: GetPermissionsParams): Promise<PermissionsResponse>;
@@ -0,0 +1 @@
1
+ export * from './getPermissions';
@@ -1,2 +1,2 @@
1
- export { getLoggedInUserDetails, type UserDetails } from './getLoggedInUserDetails';
1
+ export { getLoggedInUserDetails, type UserDetails, } from './getLoggedInUserDetails';
2
2
  export { getAllUsers, type User } from './getAllUsers';
package/dist/index.d.ts CHANGED
@@ -1,25 +1,31 @@
1
- export { setConfig as copaSetConfig, getConfig as copaGetConfig } from './config';
1
+ export { setConfig as copaSetConfig, getConfig as copaGetConfig, } from './config';
2
2
  export * as copaApi from './api';
3
3
  export * as copaUtils from './utils';
4
4
  export { default as copaTailwindConfig } from './tailwind/bluecopa.config';
5
- export type { GetAuditLogsRequest, AuditLogResponse } from './api/audit/getAuditLogs';
6
- export type { AuditRecord, CreateAuditLogRequest } from './api/audit/createAuditLog';
7
- export type { TemplatedPipelineWorkflow, GetAllTemplatedPipelinesResponse } from './api/templatedPipeline/getAllTemplatedPipelines';
5
+ export type { GetAuditLogsRequest, AuditLogResponse, } from './api/audit/getAuditLogs';
6
+ export type { AuditRecord, CreateAuditLogRequest, } from './api/audit/createAuditLog';
7
+ export type { TemplatedPipelineWorkflow, GetAllTemplatedPipelinesResponse, } from './api/templatedPipeline/getAllTemplatedPipelines';
8
8
  export type { ReconWorkflow } from './api/recon/getAllReconWorkflows';
9
9
  export type { RunReconRequest, RunReconResponse } from './api/recon/runRecon';
10
10
  export type { GetFormByIdRequest, Form } from './api/form/getFormById';
11
- export type { CreateOrUpdateFormRequest, CreateOrUpdateFormResponse } from './api/form/createOrUpdateForm';
11
+ export type { CreateOrUpdateFormRequest } from './api/form/createOrUpdateForm';
12
12
  export type { GetFormSchemaRequest } from './api/form/getFormSchema';
13
13
  export type { GetFormDataRequest } from './api/form/getFormData';
14
- export type { MarkTaskDoneRequest, MarkTaskDoneResponse, ProcessTask, CompleteTaskRequest } from './api/process/markTaskDone';
15
- export type { ReassignTaskRequest, ReassignTaskResponse } from './api/process/reassignTask';
16
- export type { FileUploadRequest, FileUploadResponse } from './api/file/fileUpload';
14
+ export type { MarkTaskDoneRequest, MarkTaskDoneResponse, ProcessTask, CompleteTaskRequest, } from './api/process/markTaskDone';
15
+ export type { ReassignTaskRequest, ReassignTaskResponse, } from './api/process/reassignTask';
16
+ export type { FileUploadRequest, FileUploadResponse, } from './api/file/fileUpload';
17
17
  export type { FileDownloadRequest } from './api/file/fileDownload';
18
- export type { GetFileUrlRequest, GetFileUrlResponse } from './api/file/getFileUrlByFileId';
18
+ export type { GetFileUrlRequest, GetFileUrlResponse, } from './api/file/getFileUrlByFileId';
19
19
  export type { User } from './api/user/getAllUsers';
20
20
  export type { HttpTrigger } from './api/workflow/getAllHttpTriggers';
21
21
  export type { GetRowsOptions, GetRowsResponse } from './api/inputTable/getRows';
22
22
  export type { UpdateRowOptions } from './api/inputTable/updateRow';
23
- export type { GetAllInboxItemsRequest, InboxItem } from './api/inboxItems/getAllInboxItems';
23
+ export type { GetAllInboxItemsRequest, InboxItem, } from './api/inboxItems/getAllInboxItems';
24
24
  export type { MarkItemAsReadRequest } from './api/inboxItems/markItemAsRead';
25
25
  export type { MarkItemAsUnreadRequest } from './api/inboxItems/markItemAsUnread';
26
+ export type { PermissionsResponse, GetPermissionsParams, } from './api/permissions/getPermissions';
27
+ export type { ClientIpResponse } from './api/clientIp/getClientIp';
28
+ export type { EmailConversation, } from './api/emailEngine/getAllConversations';
29
+ export type { GetConversationRequest, } from './api/emailEngine/getConversation';
30
+ export type { CreateConversationRequest, } from './api/emailEngine/createConversation';
31
+ export type { ReplyToConversationRequest, } from './api/emailEngine/replyToConversation';