@bluecopa/core 0.1.22 → 0.1.24

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,23 @@
1
+ /**
2
+ * Delete one or more rows from an input table
3
+ * Row ID can be provided as a string (single ID) or array (multiple IDs)
4
+ *
5
+ * @param tableId - The ID of the input table
6
+ * @param rowId - Row ID(s) to delete (string for single, array for multiple)
7
+ * @param idField - Optional: Field name to use ('copa_id' or '_copa_id'), defaults to '_copa_id'
8
+ * @returns Promise<any> The delete response
9
+ * @throws Error if the request fails
10
+ *
11
+ * @example
12
+ * // Delete single row
13
+ * await deleteRow('table-123', 'row-123');
14
+ *
15
+ * @example
16
+ * // Delete multiple rows
17
+ * await deleteRow('table-123', ['row-123', 'row-456']);
18
+ *
19
+ * @example
20
+ * // Using copa_id field
21
+ * await deleteRow('table-123', 'row-123', 'copa_id');
22
+ */
23
+ export declare const deleteRow: (tableId: string, rowId: string | string[], idField?: "copa_id" | "_copa_id") => Promise<any>;
@@ -0,0 +1,38 @@
1
+ export interface GetRowsOptions {
2
+ limit?: number;
3
+ offset?: number;
4
+ order?: string;
5
+ order_by?: string;
6
+ [key: string]: any;
7
+ }
8
+ export interface GetRowsResponse {
9
+ data: any[];
10
+ count: number;
11
+ total_count: number;
12
+ }
13
+ /**
14
+ * Get rows from an input table with optional filtering and pagination
15
+ * Supports Supabase-style filtering via query parameters
16
+ *
17
+ * @param tableId - The ID of the input table
18
+ * @param options - Query options including filters, pagination, and sorting
19
+ * @returns Promise<GetRowsResponse> The rows data with count information
20
+ * @throws Error if the request fails
21
+ *
22
+ * @example
23
+ * // Get all rows
24
+ * await getRows('table-123');
25
+ *
26
+ * @example
27
+ * // Filter by equality
28
+ * await getRows('table-123', { status: 'active' });
29
+ *
30
+ * @example
31
+ * // Filter with operators
32
+ * await getRows('table-123', { price: 'gte.100', status: 'in.(active,pending)' });
33
+ *
34
+ * @example
35
+ * // Pagination
36
+ * await getRows('table-123', { limit: 10, offset: 0 });
37
+ */
38
+ export declare const getRows: (tableId: string, options?: GetRowsOptions) => Promise<GetRowsResponse>;
@@ -1,3 +1,7 @@
1
1
  export * from './getData';
2
2
  export * from './getTableById';
3
3
  export * from './getInputTables';
4
+ export * from './getRows';
5
+ export * from './insertRow';
6
+ export * from './updateRow';
7
+ export * from './deleteRow';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Insert a new row into an input table
3
+ *
4
+ * @param tableId - The ID of the input table
5
+ * @param rowData - The row data object (column names as keys)
6
+ * @returns Promise<any> The inserted row data
7
+ * @throws Error if the request fails
8
+ *
9
+ * @example
10
+ * await insertRow('table-123', {
11
+ * name: 'Item 1',
12
+ * status: 'active',
13
+ * price: 100
14
+ * });
15
+ */
16
+ export declare const insertRow: (tableId: string, rowData: Record<string, any>) => Promise<any>;
@@ -0,0 +1,24 @@
1
+ export interface UpdateRowOptions {
2
+ copa_id?: string;
3
+ _copa_id?: string;
4
+ [key: string]: any;
5
+ }
6
+ /**
7
+ * Update a row in an input table
8
+ * Row ID can be provided via copa_id/_copa_id in the updateData or as a separate parameter
9
+ *
10
+ * @param tableId - The ID of the input table
11
+ * @param updateData - The fields to update (may include copa_id or _copa_id)
12
+ * @param rowId - Optional: Row ID to update (alternative to including in updateData)
13
+ * @returns Promise<any> The updated row data
14
+ * @throws Error if the request fails
15
+ *
16
+ * @example
17
+ * // Using rowId parameter
18
+ * await updateRow('table-123', { status: 'completed' }, 'row-123');
19
+ *
20
+ * @example
21
+ * // Using copa_id in updateData
22
+ * await updateRow('table-123', { _copa_id: 'row-123', status: 'completed' });
23
+ */
24
+ export declare const updateRow: (tableId: string, updateData: UpdateRowOptions, rowId?: string) => Promise<any>;
@@ -0,0 +1,23 @@
1
+ export interface User {
2
+ id?: string;
3
+ email?: string;
4
+ firstName?: string;
5
+ lastName?: string;
6
+ externalId?: string;
7
+ active?: boolean;
8
+ organizationId?: string;
9
+ metadata?: Record<string, any>;
10
+ organizationExternalId?: string;
11
+ createdBy?: string;
12
+ createdDate?: string;
13
+ lastModifiedBy?: string;
14
+ lastModifiedDate?: string;
15
+ entityVersion?: number;
16
+ _links?: Record<string, any>;
17
+ }
18
+ /**
19
+ * Gets all users in the current workspace
20
+ * @returns Promise<User[]> The list of users
21
+ * @throws Error if the request fails
22
+ */
23
+ export declare function getAllUsers(): Promise<User[]>;
@@ -1 +1,2 @@
1
1
  export { getLoggedInUserDetails, type UserDetails } from './getLoggedInUserDetails';
2
+ export { getAllUsers, type User } from './getAllUsers';
@@ -0,0 +1,21 @@
1
+ export interface HttpTrigger {
2
+ id?: string;
3
+ name?: string;
4
+ description?: string;
5
+ url?: string;
6
+ active?: boolean;
7
+ metadata?: Record<string, any>;
8
+ schema?: Record<string, any>;
9
+ createdBy?: string;
10
+ createdDate?: string;
11
+ lastModifiedBy?: string;
12
+ lastModifiedDate?: string;
13
+ entityVersion?: number;
14
+ _links?: Record<string, any>;
15
+ }
16
+ /**
17
+ * Gets all HTTP triggers (webhooks) in the current workspace
18
+ * @returns Promise<HttpTrigger[]> The list of HTTP triggers
19
+ * @throws Error if the request fails
20
+ */
21
+ export declare function getAllHttpTriggers(): Promise<HttpTrigger[]>;
@@ -1,3 +1,4 @@
1
1
  export * from './triggerHttpWorkflowById';
2
2
  export * from './triggerWorkflowById';
3
3
  export * from './getWorkflowInstanceStatusById';
4
+ export * from './getAllHttpTriggers';
package/dist/index.d.ts CHANGED
@@ -16,3 +16,7 @@ export type { ReassignTaskRequest, ReassignTaskResponse } from './api/process/re
16
16
  export type { FileUploadRequest, FileUploadResponse } from './api/file/fileUpload';
17
17
  export type { FileDownloadRequest } from './api/file/fileDownload';
18
18
  export type { GetFileUrlRequest, GetFileUrlResponse } from './api/file/getFileUrlByFileId';
19
+ export type { User } from './api/user/getAllUsers';
20
+ export type { HttpTrigger } from './api/workflow/getAllHttpTriggers';
21
+ export type { GetRowsOptions, GetRowsResponse } from './api/inputTable/getRows';
22
+ export type { UpdateRowOptions } from './api/inputTable/updateRow';
package/dist/index.es.js CHANGED
@@ -100,8 +100,23 @@ async function getLoggedInUserDetails() {
100
100
  throw { message, status };
101
101
  }
102
102
  }
103
+ async function getAllUsers() {
104
+ var _a, _b, _c;
105
+ try {
106
+ const response = await apiClient.get("/user/get-all");
107
+ if (!response.data) {
108
+ throw { message: "Failed to fetch users", status: 500 };
109
+ }
110
+ return response.data;
111
+ } catch (error) {
112
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while fetching users";
113
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
114
+ throw { message, status };
115
+ }
116
+ }
103
117
  const index$i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
104
118
  __proto__: null,
119
+ getAllUsers,
105
120
  getLoggedInUserDetails
106
121
  }, Symbol.toStringTag, { value: "Module" }));
107
122
  async function triggerHttpWorkflowById({
@@ -159,9 +174,24 @@ const getWorkflowInstanceStatusById = async (request) => {
159
174
  throw { message, status };
160
175
  }
161
176
  };
177
+ async function getAllHttpTriggers() {
178
+ var _a, _b, _c;
179
+ try {
180
+ const response = await apiClient.get("/http-trigger/get-all");
181
+ if (!response.data) {
182
+ throw { message: "Failed to fetch HTTP triggers", status: 500 };
183
+ }
184
+ return response.data;
185
+ } catch (error) {
186
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while fetching HTTP triggers";
187
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
188
+ throw { message, status };
189
+ }
190
+ }
162
191
  const index$h = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
163
192
  __proto__: null,
164
193
  WorkflowStatus,
194
+ getAllHttpTriggers,
165
195
  getWorkflowInstanceStatusById,
166
196
  triggerHttpWorkflowById,
167
197
  triggerWorkflowById
@@ -6196,11 +6226,147 @@ const getInputTables = async () => {
6196
6226
  throw { message, status };
6197
6227
  }
6198
6228
  };
6229
+ const getRows = async (tableId, options) => {
6230
+ var _a, _b, _c;
6231
+ try {
6232
+ if (!tableId) {
6233
+ throw { message: "Table ID is required", status: 400 };
6234
+ }
6235
+ const params = {};
6236
+ if (options) {
6237
+ Object.keys(options).forEach((key) => {
6238
+ if (options[key] !== void 0 && options[key] !== null) {
6239
+ params[key] = options[key];
6240
+ }
6241
+ });
6242
+ }
6243
+ const response = await apiClient.get(
6244
+ `/api/v1/input-table/${tableId}/rows`,
6245
+ { params }
6246
+ );
6247
+ if (!response.data) {
6248
+ throw { message: "Failed to fetch rows", status: 500 };
6249
+ }
6250
+ return response.data;
6251
+ } catch (error) {
6252
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while fetching rows";
6253
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
6254
+ throw { message, status };
6255
+ }
6256
+ };
6257
+ const insertRow = async (tableId, rowData) => {
6258
+ var _a, _b, _c;
6259
+ try {
6260
+ if (!tableId) {
6261
+ throw { message: "Table ID is required", status: 400 };
6262
+ }
6263
+ if (!rowData || typeof rowData !== "object" || Array.isArray(rowData)) {
6264
+ throw { message: "Row data must be an object", status: 400 };
6265
+ }
6266
+ const response = await apiClient.post(
6267
+ `/api/v1/input-table/${tableId}/rows`,
6268
+ rowData
6269
+ );
6270
+ if (!response.data) {
6271
+ throw { message: "Failed to insert row", status: 500 };
6272
+ }
6273
+ return response.data;
6274
+ } catch (error) {
6275
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while inserting row";
6276
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
6277
+ throw { message, status };
6278
+ }
6279
+ };
6280
+ const updateRow = async (tableId, updateData, rowId) => {
6281
+ var _a, _b, _c;
6282
+ try {
6283
+ if (!tableId) {
6284
+ throw { message: "Table ID is required", status: 400 };
6285
+ }
6286
+ if (!updateData || typeof updateData !== "object" || Array.isArray(updateData)) {
6287
+ throw { message: "Update data must be an object", status: 400 };
6288
+ }
6289
+ const body = { ...updateData };
6290
+ const params = {};
6291
+ if (rowId) {
6292
+ params._copa_id = rowId;
6293
+ delete body.copa_id;
6294
+ delete body._copa_id;
6295
+ }
6296
+ const fieldsToUpdate = Object.keys(body).filter(
6297
+ (key) => key !== "copa_id" && key !== "_copa_id"
6298
+ );
6299
+ if (fieldsToUpdate.length === 0 && !rowId) {
6300
+ throw {
6301
+ message: "At least one field to update must be provided",
6302
+ status: 400
6303
+ };
6304
+ }
6305
+ const response = await apiClient.patch(
6306
+ `/api/v1/input-table/${tableId}/rows`,
6307
+ body,
6308
+ { params }
6309
+ );
6310
+ if (!response.data) {
6311
+ throw { message: "Failed to update row", status: 500 };
6312
+ }
6313
+ return response.data;
6314
+ } catch (error) {
6315
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while updating row";
6316
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
6317
+ throw { message, status };
6318
+ }
6319
+ };
6320
+ const deleteRow = async (tableId, rowId, idField = "_copa_id") => {
6321
+ var _a, _b, _c;
6322
+ try {
6323
+ if (!tableId) {
6324
+ throw { message: "Table ID is required", status: 400 };
6325
+ }
6326
+ if (!rowId) {
6327
+ throw { message: "Row ID is required", status: 400 };
6328
+ }
6329
+ const isMultiple = Array.isArray(rowId);
6330
+ const params = {};
6331
+ let body;
6332
+ if (isMultiple && rowId.length === 0) {
6333
+ throw { message: "At least one row ID must be provided", status: 400 };
6334
+ }
6335
+ if (isMultiple) {
6336
+ body = { [idField]: rowId };
6337
+ } else {
6338
+ params[idField] = rowId;
6339
+ }
6340
+ const config = {
6341
+ url: `/api/v1/input-table/${tableId}/rows`,
6342
+ method: "delete"
6343
+ };
6344
+ if (Object.keys(params).length > 0) {
6345
+ config.params = params;
6346
+ }
6347
+ if (body) {
6348
+ config.data = body;
6349
+ }
6350
+ const response = await apiClient.request(config);
6351
+ if (!response.data) {
6352
+ throw { message: "Failed to delete row(s)", status: 500 };
6353
+ }
6354
+ return response.data;
6355
+ } catch (error) {
6356
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while deleting row(s)";
6357
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
6358
+ throw { message, status };
6359
+ }
6360
+ };
6199
6361
  const index$9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6200
6362
  __proto__: null,
6363
+ deleteRow,
6201
6364
  getData: getData$1,
6202
6365
  getInputTables,
6203
- getTableById
6366
+ getRows,
6367
+ getTableById,
6368
+ insertRow,
6369
+ updateRow
6204
6370
  }, Symbol.toStringTag, { value: "Module" }));
6205
6371
  const getWorkbooksByType = async (type) => {
6206
6372
  var _a, _b, _c;