@bluecopa/core 0.1.76 → 0.1.78

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
@@ -11,12 +11,27 @@ The core package provides essential API utilities and functions for data managem
11
11
  - [Requirements](#requirements)
12
12
  - [Configuration](#configuration)
13
13
  - [API Reference](#api-reference)
14
+ - [Audit Module](#audit-module)
15
+ - [Chat Module](#chat-module)
16
+ - [ClientIp Module](#clientip-module)
14
17
  - [Dataset Module](#dataset-module)
15
18
  - [Definition Module](#definition-module)
19
+ - [EmailEngine Module](#emailengine-module)
16
20
  - [File Module](#file-module)
21
+ - [Form Module](#form-module)
22
+ - [InboxItems Module](#inboxitems-module)
17
23
  - [InputTable Module](#inputtable-module)
18
24
  - [Metric Module](#metric-module)
25
+ - [Permissions Module](#permissions-module)
26
+ - [Process Module](#process-module)
27
+ - [Recon Module](#recon-module)
28
+ - [Statement Module](#statement-module)
29
+ - [Task Module](#task-module)
30
+ - [TemplatedPipeline Module](#templatedpipeline-module)
31
+ - [Templates Module](#templates-module)
32
+ - [Tcn Module](#tcn-module)
19
33
  - [User Module](#user-module)
34
+ - [Webcron Module](#webcron-module)
20
35
  - [Workbook Module](#workbook-module)
21
36
  - [Workflow Module](#workflow-module)
22
37
  - [Worksheet Module](#worksheet-module)
@@ -120,13 +135,39 @@ export interface Config {
120
135
 
121
136
  All API functions are asynchronous and use the shared `apiClient` for HTTP requests. They handle errors by throwing objects with `message` and `status`. Access via `copaApi.moduleName.functionName()`.
122
137
 
138
+ ### Audit Module
139
+
140
+ - `copaApi.audit.createAuditLog()`: Records an audit log entry
141
+ - `copaApi.audit.getAuditLogs()`: Retrieves audit log entries
142
+
143
+ See: [`audit/createAuditLog.ts`](src/api/audit/createAuditLog.ts), [`audit/getAuditLogs.ts`](src/api/audit/getAuditLogs.ts)
144
+
145
+ ### Chat Module
146
+
147
+ - `copaApi.chat.checkSubscriptionStatus()`: Checks whether the user is subscribed to chat updates
148
+ - `copaApi.chat.createThread()`: Creates a new chat thread
149
+ - `copaApi.chat.getCommentsByThreadId()`: Lists comments in a thread
150
+ - `copaApi.chat.postComment()`: Posts a comment to a thread
151
+ - `copaApi.chat.updateComment()`: Updates an existing comment
152
+ - `copaApi.chat.deleteComment()`: Deletes a comment
153
+ - `copaApi.chat.subscribeUser()`: Subscribes a user to chat updates
154
+ - `copaApi.chat.unsubscribeUser()`: Unsubscribes a user from chat updates
155
+
156
+ See: [`chat/`](src/api/chat:1)
157
+
158
+ ### ClientIp Module
159
+
160
+ - `copaApi.clientIp.getClientIp()`: Returns the caller's client IP
161
+
162
+ See: [`clientIp/getClientIp.ts`](src/api/clientIp/getClientIp.ts)
163
+
123
164
  ### Dataset Module
124
165
 
125
166
  - `copaApi.dataset.getData()`: Retrieves specific dataset data by ID or parameters
126
167
  - `copaApi.dataset.getDatasets()`: Fetches a list of datasets
127
168
  - `copaApi.dataset.getSampleData()`: Gets sample data for datasets
128
169
 
129
- See: [`dataset/getData.ts`](src/api/dataset/getData.ts:1), [`dataset/getSampleData.ts`](src/api/dataset/getSampleData.ts:1), [`dataset/getDatasets.ts`](src/api/dataset/getDatasets.ts:1)
170
+ See: [`dataset/getData.ts`](src/api/dataset/getData.ts), [`dataset/getSampleData.ts`](src/api/dataset/getSampleData.ts), [`dataset/getDatasets.ts`](src/api/dataset/getDatasets.ts)
130
171
 
131
172
  ### Definition Module
132
173
 
@@ -134,55 +175,193 @@ See: [`dataset/getData.ts`](src/api/dataset/getData.ts:1), [`dataset/getSampleDa
134
175
  - `copaApi.definition.runPublishedDefinition()`: Runs a published definition
135
176
  - `copaApi.definition.runSampleDefinition()`: Executes a sample definition for testing
136
177
 
137
- See: [`definition/runPublishedDefinition.ts`](src/api/definition/runPublishedDefinition.ts:1), [`definition/runSampleDefinition.ts`](src/api/definition/runSampleDefinition.ts:1), [`definition/runDefinition.ts`](src/api/definition/runDefinition.ts:1)
178
+ See: [`definition/runPublishedDefinition.ts`](src/api/definition/runPublishedDefinition.ts), [`definition/runSampleDefinition.ts`](src/api/definition/runSampleDefinition.ts), [`definition/runDefinition.ts`](src/api/definition/runDefinition.ts)
179
+
180
+ ### EmailEngine Module
181
+
182
+ - `copaApi.emailEngine.getAllConversations()`: Lists email conversations (paginated)
183
+ - `copaApi.emailEngine.getConversation()`: Fetches a single conversation
184
+ - `copaApi.emailEngine.createConversation()`: Creates a new conversation
185
+ - `copaApi.emailEngine.replyToConversation()`: Sends a reply on a conversation
186
+ - `copaApi.emailEngine.getMessageBySenderId()`: Retrieves messages filtered by sender id
187
+
188
+ See: [`emailEngine/`](src/api/emailEngine:1)
138
189
 
139
190
  ### File Module
140
191
 
141
192
  - `copaApi.files.getFileUrlByFileId(fileId: string)`: Generates a URL for a file by its ID
193
+ - `copaApi.files.fileUpload({ data, contentType, method, uploadType })`: Uploads data and returns a file id/path
194
+ - `copaApi.files.fileDownload({ fileId })`: Downloads a file by id
195
+ - `copaApi.files.getFileByFolderIdAndName({ folderId, name })`: Fetches a filebox file by its parent folder and name
196
+
197
+ See: [`file/getFileUrlByFileId.ts`](src/api/file/getFileUrlByFileId.ts), [`file/fileUpload.ts`](src/api/file/fileUpload.ts), [`file/fileDownload.ts`](src/api/file/fileDownload.ts), [`file/getFileByFolderIdAndName.ts`](src/api/file/getFileByFolderIdAndName.ts)
142
198
 
143
- See: [`file/getFileUrlByFileId.ts`](src/api/file/getFileUrlByFileId.ts:1)
199
+ ### Form Module
200
+
201
+ - `copaApi.form.getFormById()`: Fetches a form by id
202
+ - `copaApi.form.getFormSchema()`: Retrieves a form's schema
203
+ - `copaApi.form.getFormData()`: Retrieves submitted form data
204
+ - `copaApi.form.createOrUpdateForm()`: Creates or updates a form definition
205
+
206
+ See: [`form/`](src/api/form:1)
207
+
208
+ ### InboxItems Module
209
+
210
+ - `copaApi.inboxItems.getAllInboxItems()`: Lists inbox items
211
+ - `copaApi.inboxItems.createInboxItemPerUser()`: Creates an inbox item for a specific user
212
+ - `copaApi.inboxItems.markItemAsRead()`: Marks an inbox item as read
213
+ - `copaApi.inboxItems.markItemAsUnread()`: Marks an inbox item as unread
214
+
215
+ See: [`inboxItems/`](src/api/inboxItems:1)
144
216
 
145
217
  ### InputTable Module
146
218
 
147
219
  - `copaApi.inputTable.getData()`: Retrieves data from an input table
148
220
  - `copaApi.inputTable.getInputTables()`: Fetches all input tables
149
221
  - `copaApi.inputTable.getTableById(id: string)`: Gets a specific input table by ID
222
+ - `copaApi.inputTable.getRows(options)`: Reads rows from an input table view (filters, paging, sorting)
223
+ - `copaApi.inputTable.insertRow(options)`: Inserts a new row
224
+ - `copaApi.inputTable.updateRow(options)`: Updates an existing row
225
+ - `copaApi.inputTable.deleteRow(options)`: Deletes a row
150
226
 
151
- See: [`inputTable/getData.ts`](src/api/inputTable/getData.ts:1), [`inputTable/getInputTables.ts`](src/api/inputTable/getInputTables.ts:1), [`inputTable/getTableById.ts`](src/api/inputTable/getTableById.ts:1)
227
+ See: [`inputTable/getData.ts`](src/api/inputTable/getData.ts), [`inputTable/getInputTables.ts`](src/api/inputTable/getInputTables.ts), [`inputTable/getTableById.ts`](src/api/inputTable/getTableById.ts), [`inputTable/getRows.ts`](src/api/inputTable/getRows.ts), [`inputTable/insertRow.ts`](src/api/inputTable/insertRow.ts), [`inputTable/updateRow.ts`](src/api/inputTable/updateRow.ts), [`inputTable/deleteRow.ts`](src/api/inputTable/deleteRow.ts)
152
228
 
153
229
  ### Metric Module
154
230
 
155
231
  - `copaApi.metric.getData()`: Fetches metric data
156
232
 
157
- See: [`metric/getData.ts`](src/api/metric/getData.ts:1)
233
+ See: [`metric/getData.ts`](src/api/metric/getData.ts)
234
+
235
+ ### Permissions Module
236
+
237
+ - `copaApi.permissions.getPermissions()`: Retrieves permissions for the current user / context
238
+
239
+ See: [`permissions/getPermissions.ts`](src/api/permissions/getPermissions.ts)
240
+
241
+ ### Process Module
242
+
243
+ - `copaApi.process.markTaskDone()`: Marks a process task as done
244
+ - `copaApi.process.reassignTask()`: Reassigns a process task to a different user
245
+ - `copaApi.process.getTriggersBySheet()`: Lists triggers associated with a sheet
246
+ - `copaApi.process.registerProcessTrigger()`: Registers a new process trigger
247
+ - `copaApi.process.deleteProcessTrigger()`: Deletes a process trigger
248
+
249
+ See: [`process/`](src/api/process:1)
250
+
251
+ ### Recon Module
252
+
253
+ - `copaApi.recon.runRecon()`: Triggers a recon workflow run
254
+ - `copaApi.recon.getAllReconWorkflows()`: Lists all recon workflows
255
+
256
+ See: [`recon/runRecon.ts`](src/api/recon/runRecon.ts), [`recon/getAllReconWorkflows.ts`](src/api/recon/getAllReconWorkflows.ts)
257
+
258
+ ### Statement Module
259
+
260
+ - `copaApi.statement.getData()`: Retrieves statement data
261
+ - `copaApi.statement.getViewsBySheetId()`: Lists statement views for a sheet
262
+ - `copaApi.statement.getViewById()`: Fetches a single statement view
263
+ - `copaApi.statement.getRunsByViewId()`: Lists runs for a given view
264
+ - `copaApi.statement.createNewRun()`: Creates a new statement run
265
+ - `copaApi.statement.getRunResultById()`: Fetches the result of a given run
266
+
267
+ See: [`statement/`](src/api/statement:1)
268
+
269
+ ### Task Module
270
+
271
+ - `copaApi.task.getTaskDetails()`: Fetches detailed information about a task
272
+
273
+ See: [`task/getTaskDetails.ts`](src/api/task/getTaskDetails.ts)
274
+
275
+ ### TemplatedPipeline Module
276
+
277
+ - `copaApi.templatedPipeline.getAllTemplatedPipelines()`: Lists all templated pipelines
278
+
279
+ See: [`templatedPipeline/getAllTemplatedPipelines.ts`](src/api/templatedPipeline/getAllTemplatedPipelines.ts)
280
+
281
+ ### Templates Module
282
+
283
+ - `copaApi.templates.renderTemplate()`: Renders a template with provided variables
284
+
285
+ See: [`templates/render.ts`](src/api/templates/render.ts)
286
+
287
+ ### Tcn Module
288
+
289
+ - `copaApi.tcn.getAuthUrl()`: Returns the TCN OAuth authorization URL
290
+ - `copaApi.tcn.exchangeCode()`: Exchanges an OAuth code for TCN tokens
291
+ - `copaApi.tcn.refreshToken()`: Refreshes a TCN access token
292
+ - `copaApi.tcn.getCurrentAgent()`: Fetches the currently signed-in TCN agent
293
+ - `copaApi.tcn.getAgentSkills()`: Lists skills available to the agent
294
+ - `copaApi.tcn.createSession()`: Creates a new TCN agent session
295
+ - `copaApi.tcn.keepAlive()`: Pings the TCN session to keep it alive
296
+ - `copaApi.tcn.agentGetStatus()`: Returns the current agent status
297
+ - `copaApi.tcn.agentSetReady()`: Marks the agent as ready
298
+ - `copaApi.tcn.agentPause()`: Pauses the agent
299
+ - `copaApi.tcn.agentDisconnect()`: Disconnects the agent
300
+ - `copaApi.tcn.agentGetConnectedParty()`: Returns the currently connected party for the agent
301
+ - `copaApi.tcn.agentPutCallOnHold()`: Puts the agent's current call on hold
302
+ - `copaApi.tcn.agentGetCallFromHold()`: Resumes the agent's held call
303
+ - `copaApi.tcn.getHuntGroupAgentSettings()`: Fetches hunt-group settings for the agent
304
+ - `copaApi.tcn.getCallData()`: Retrieves data for an active call
305
+ - `copaApi.tcn.dialManualPrepare()`: Prepares a manual dial
306
+ - `copaApi.tcn.manualDialStart()`: Starts a prepared manual dial
307
+ - `copaApi.tcn.processManualDial()`: Processes the result of a manual dial
308
+
309
+ See: [`tcn/`](src/api/tcn:1)
158
310
 
159
311
  ### User Module
160
312
 
161
313
  - `copaApi.user.getLoggedInUserDetails()`: Retrieves details of the currently logged-in user
314
+ - `copaApi.user.getAllUsers()`: Lists all users in the workspace
315
+
316
+ See: [`user/getLoggedInUserDetails.ts`](src/api/user/getLoggedInUserDetails.ts), [`user/getAllUsers.ts`](src/api/user/getAllUsers.ts)
317
+
318
+ ### Webcron Module
319
+
320
+ Webhook CRUD + execution helpers:
321
+ - `copaApi.webcron.listWebhooks()`, `getWebhook()`, `createWebhook()`, `updateWebhook()`, `deleteWebhook()`, `testWebhook()`, `getWebhookExecutions()`, `getWebhookSchedules()`, `createWebhookSchedule()`
322
+
323
+ Schedule controls:
324
+ - `copaApi.webcron.getSchedule()`, `updateSchedule()`, `deleteSchedule()`, `pauseSchedule()`, `resumeSchedule()`, `triggerSchedule()`
325
+
326
+ Execution history:
327
+ - `copaApi.webcron.listExecutions()`, `getExecution()`, `retryExecution()`
328
+
329
+ Task lifecycle:
330
+ - `copaApi.webcron.listTasks()`, `createTask()`, `getTask()`, `cancelTask()`, `retryTask()`, `progressTask()`, `signalTask()`
331
+
332
+ Inspection bins:
333
+ - `copaApi.webcron.listBins()`, `createBin()`, `getBin()`, `deleteBin()`, `getBinRequests()`, `clearBinRequests()`
334
+
335
+ Workflow trigger:
336
+ - `copaApi.webcron.triggerWorkflowById()`
162
337
 
163
- See: [`user/getLoggedInUserDetails.ts`](src/api/user/getLoggedInUserDetails.ts:1)
338
+ See: [`webcron/`](src/api/webcron:1)
164
339
 
165
340
  ### Workbook Module
166
341
 
167
342
  - `copaApi.workbook.getPublishedWorkbookById(id: string)`: Fetches a published workbook by ID
168
343
  - `copaApi.workbook.getWorkbooksByType(type: string)`: Retrieves workbooks filtered by type
344
+ - `copaApi.workbook.getWorkbookDetails()`: Retrieves workbook metadata/details
345
+ - `copaApi.workbook.saveWorkbook()`: Saves a workbook draft
346
+ - `copaApi.workbook.publishWorkbook()`: Publishes a workbook
169
347
 
170
- See: [`workbook/getPublishedWorkbookById.ts`](src/api/workbook/getPublishedWorkbookById.ts:1), [`workbook/getWorkbooksByType.ts`](src/api/workbook/getWorkbooksByType.ts:1)
348
+ See: [`workbook/getPublishedWorkbookById.ts`](src/api/workbook/getPublishedWorkbookById.ts), [`workbook/getWorkbooksByType.ts`](src/api/workbook/getWorkbooksByType.ts), [`workbook/getWorkbookDetails.ts`](src/api/workbook/getWorkbookDetails.ts), [`workbook/saveWorkbook.ts`](src/api/workbook/saveWorkbook.ts), [`workbook/publishWorkbook.ts`](src/api/workbook/publishWorkbook.ts)
171
349
 
172
350
  ### Workflow Module
173
351
 
174
352
  - `copaApi.workflow.getWorkflowInstanceStatusById(id: string)`: Checks the status of a workflow instance
175
353
  - `copaApi.workflow.triggerHttpWorkflowById(id: string)`: Triggers an HTTP-based workflow
176
354
  - `copaApi.workflow.triggerWorkflowById(id: string)`: Triggers a workflow by ID
355
+ - `copaApi.workflow.getAllHttpTriggers()`: Lists all HTTP triggers
177
356
 
178
- See: [`workflow/triggerHttpWorkflowById.ts`](src/api/workflow/triggerHttpWorkflowById.ts:1), [`workflow/triggerWorkflowById.ts`](src/api/workflow/triggerWorkflowById.ts:1), [`workflow/getWorkflowInstanceStatusById.ts`](src/api/workflow/getWorkflowInstanceStatusById.ts:1)
357
+ See: [`workflow/triggerHttpWorkflowById.ts`](src/api/workflow/triggerHttpWorkflowById.ts), [`workflow/triggerWorkflowById.ts`](src/api/workflow/triggerWorkflowById.ts), [`workflow/getWorkflowInstanceStatusById.ts`](src/api/workflow/getWorkflowInstanceStatusById.ts), [`workflow/getAllHttpTriggers.ts`](src/api/workflow/getAllHttpTriggers.ts)
179
358
 
180
359
  ### Worksheet Module
181
360
 
182
361
  - `copaApi.worksheet.getWorksheets()`: Fetches all worksheets
183
362
  - `copaApi.worksheet.getWorksheetsByType(type: string)`: Retrieves worksheets by type
184
363
 
185
- See: [`worksheet/getWorksheets.ts`](src/api/worksheet/getWorksheets.ts:1), [`worksheet/getWorksheetsByType.ts`](src/api/worksheet/getWorksheetsByType.ts:1)
364
+ See: [`worksheet/getWorksheets.ts`](src/api/worksheet/getWorksheets.ts), [`worksheet/getWorksheetsByType.ts`](src/api/worksheet/getWorksheetsByType.ts)
186
365
 
187
366
  ## InputTableDB — Reactive Database Client
188
367
 
@@ -0,0 +1,31 @@
1
+ export interface GetFileByFolderIdAndNameRequest {
2
+ folderId: string;
3
+ name: string;
4
+ }
5
+ export type FileboxFileType = "CSV" | "XLSX" | "ZIP" | "RAW" | "JSON" | "PDF" | "TXT" | "SWT1" | "MSG" | "OUT" | "PNG" | "JPG" | "JPEG" | "MT940" | "XLS" | "XLSB" | "GZ" | "DOCX";
6
+ export interface FileboxFile {
7
+ name: string;
8
+ type: FileboxFileType;
9
+ parentId: string;
10
+ status: "DRAFT" | "PUBLISHED";
11
+ blobFileId: string;
12
+ copaUploadDate?: string;
13
+ solutionId?: string;
14
+ solutionBranch?: string;
15
+ createdBy?: string;
16
+ createdDate?: string;
17
+ lastModifiedBy?: string;
18
+ lastModifiedDate?: string;
19
+ id?: string;
20
+ workspaceId?: string;
21
+ entityVersion?: number;
22
+ }
23
+ /**
24
+ * Gets a filebox file by its parent folder and name.
25
+ *
26
+ * @param params.folderId - The parent folder id
27
+ * @param params.name - The exact file name to look up
28
+ * @returns Promise<FileboxFile> The matching filebox file metadata
29
+ * @throws { message: string; status: number } if the request fails
30
+ */
31
+ export declare function getFileByFolderIdAndName({ folderId, name, }: GetFileByFolderIdAndNameRequest): Promise<FileboxFile>;
@@ -1,3 +1,4 @@
1
1
  export * from './getFileUrlByFileId';
2
2
  export * from './fileUpload';
3
3
  export * from './fileDownload';
4
+ export * from './getFileByFolderIdAndName';
package/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ export type { DeleteProcessTriggerResponse, } from './api/process/deleteProcessT
21
21
  export type { FileUploadRequest, FileUploadResponse, } from './api/file/fileUpload';
22
22
  export type { FileDownloadRequest } from './api/file/fileDownload';
23
23
  export type { GetFileUrlRequest, GetFileUrlResponse, } from './api/file/getFileUrlByFileId';
24
+ export type { GetFileByFolderIdAndNameRequest, FileboxFile, FileboxFileType, } from './api/file/getFileByFolderIdAndName';
24
25
  export type { User } from './api/user/getAllUsers';
25
26
  export type { HttpTrigger } from './api/workflow/getAllHttpTriggers';
26
27
  export type { GetRowsOptions, GetRowsResponse } from './api/inputTable/getRows';
package/dist/index.es.js CHANGED
@@ -330,10 +330,37 @@ async function fileDownload({
330
330
  throw { message, status };
331
331
  }
332
332
  }
333
+ async function getFileByFolderIdAndName({
334
+ folderId,
335
+ name
336
+ }) {
337
+ var _a, _b, _c, _d;
338
+ const normalizedFolderId = folderId == null ? void 0 : folderId.trim();
339
+ const normalizedName = name == null ? void 0 : name.trim();
340
+ if (!normalizedFolderId || !normalizedName) {
341
+ throw { message: "folderId and name are required", status: 400 };
342
+ }
343
+ try {
344
+ const response = await apiClient.get(
345
+ `/filebox/${encodeURIComponent(normalizedFolderId)}`,
346
+ { params: { fileName: normalizedName } }
347
+ );
348
+ if (!response.data) {
349
+ throw { message: "Failed to get filebox file", status: 500 };
350
+ }
351
+ return response.data;
352
+ } catch (error) {
353
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while getting filebox file";
354
+ const status = ((_c = error.response) == null ? void 0 : _c.status) ?? error.status ?? 500;
355
+ const data = ((_d = error.response) == null ? void 0 : _d.data) ?? error.data;
356
+ throw data !== void 0 ? { message, status, data } : { message, status };
357
+ }
358
+ }
333
359
  const index$n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
334
360
  __proto__: null,
335
361
  fileDownload,
336
362
  fileUpload,
363
+ getFileByFolderIdAndName,
337
364
  getFileUrlByFileId
338
365
  }, Symbol.toStringTag, { value: "Module" }));
339
366
  const runPublishedDefinition = async (props) => {
@@ -9975,32 +10002,6 @@ function applyWorkbookBindings(fileRead, bindings) {
9975
10002
  }
9976
10003
  return remapped;
9977
10004
  }
9978
- function applyReconBindings(fileRead, bindings) {
9979
- if (!fileRead || !Array.isArray(fileRead.imports)) return fileRead;
9980
- return {
9981
- ...fileRead,
9982
- imports: fileRead.imports.map((imp) => {
9983
- if (!(imp == null ? void 0 : imp.loc)) return imp;
9984
- const resolved = resolveBinding(imp.loc, bindings);
9985
- return resolved ? { ...imp, loc: resolved } : imp;
9986
- })
9987
- };
9988
- }
9989
- function applyDefinitionBindings(fileRead, bindings, definitionType) {
9990
- if (!fileRead || !bindings || !Object.keys(bindings).length) return fileRead;
9991
- switch (definitionType) {
9992
- case "PIPELINE":
9993
- return applyPipelineBindings(fileRead, bindings);
9994
- case "SCHEDULE":
9995
- return applyScheduleBindings(fileRead, bindings);
9996
- case "WORKBOOK":
9997
- return applyWorkbookBindings(fileRead, bindings);
9998
- case "RECON":
9999
- return applyReconBindings(fileRead, bindings);
10000
- default:
10001
- return fileRead;
10002
- }
10003
- }
10004
10005
  function applyTargetedBindings(fileRead, bindings) {
10005
10006
  if (!fileRead || !bindings || !Object.keys(bindings).length) return fileRead;
10006
10007
  let result = { ...fileRead };
@@ -10026,13 +10027,9 @@ async function fetchSolutionBindings() {
10026
10027
  }
10027
10028
  function applyBindings(fileRead, bindings, definitionType) {
10028
10029
  if (!fileRead || !Object.keys(bindings).length) return fileRead;
10029
- return definitionType ? applyDefinitionBindings(
10030
- fileRead,
10031
- bindings,
10032
- definitionType
10033
- ) : applyTargetedBindings(fileRead, bindings);
10030
+ return applyTargetedBindings(fileRead, bindings);
10034
10031
  }
10035
- const hydrateWorksheet = async (sheet) => {
10032
+ const hydrateWorksheet = async (sheet, prefetchedBindings) => {
10036
10033
  try {
10037
10034
  if (!sheet) return sheet;
10038
10035
  const isHydrated = sheet.definitionModel && sheet.customModel;
@@ -10054,43 +10051,56 @@ const hydrateWorksheet = async (sheet) => {
10054
10051
  "application/json"
10055
10052
  );
10056
10053
  }
10057
- if (!definitionModel || !definitionModel[sheetId]) {
10058
- return sheet;
10059
- }
10060
- const bindings = await fetchSolutionBindings();
10061
- sheet.definitionModel = applyBindings(
10062
- definitionModel[sheetId],
10063
- bindings
10064
- );
10065
- sheet.customModel = applyBindings(
10066
- customModel[sheetId],
10054
+ const bindings = prefetchedBindings ?? await fetchSolutionBindings();
10055
+ const reboundDefinitionModel = applyBindings(
10056
+ definitionModel,
10067
10057
  bindings
10068
10058
  );
10059
+ const reboundCustomModel = applyBindings(customModel, bindings);
10060
+ if (!reboundDefinitionModel || !reboundDefinitionModel[sheetId] || !(reboundCustomModel == null ? void 0 : reboundCustomModel[sheetId])) {
10061
+ return sheet;
10062
+ }
10063
+ sheet.definitionModel = reboundDefinitionModel[sheetId];
10064
+ sheet.customModel = reboundCustomModel[sheetId];
10069
10065
  return sheet;
10070
10066
  } catch (error) {
10071
10067
  console.error("Error hydrating portal page:", error);
10072
10068
  throw error;
10073
10069
  }
10074
10070
  };
10071
+ const resolveBoundId = (rawId, bindings) => {
10072
+ const value = bindings[rawId];
10073
+ if (typeof value === "string") return value;
10074
+ if (value && typeof value === "object" && "id" in value) {
10075
+ const id = value.id;
10076
+ if (typeof id === "string") return id;
10077
+ }
10078
+ return rawId;
10079
+ };
10075
10080
  const getData$3 = async (metricSheetId, options) => {
10076
- var _a, _b, _c, _d, _e, _f;
10077
- const worksheets = await getWorksheets([metricSheetId]);
10081
+ var _a, _b, _c, _d, _e, _f, _g;
10082
+ const bindings = await fetchSolutionBindings();
10083
+ const resolvedMetricSheetId = resolveBoundId(metricSheetId, bindings);
10084
+ const worksheets = await getWorksheets([resolvedMetricSheetId]);
10078
10085
  if (_.isEmpty(worksheets)) return {};
10079
10086
  const selectedWorksheet = worksheets[0];
10080
- const hydratedSheet = await hydrateWorksheet(selectedWorksheet);
10087
+ const hydratedSheet = await hydrateWorksheet(selectedWorksheet, bindings);
10081
10088
  if (!hydratedSheet) return {};
10082
10089
  const selectedMetricsParentIds = getSelectedMetricsParentIds([
10083
10090
  { sheet: selectedWorksheet }
10084
10091
  ]);
10085
- const parentWorksheets = await getWorksheets(selectedMetricsParentIds);
10086
- const parentSheet = _.find(
10087
- parentWorksheets,
10088
- (ps) => ps.id === (hydratedSheet == null ? void 0 : hydratedSheet.customFields.parentTableId)
10092
+ const resolvedParentIds = selectedMetricsParentIds.map(
10093
+ (id) => resolveBoundId(id, bindings)
10089
10094
  );
10095
+ const rawParentTableId = (_a = hydratedSheet == null ? void 0 : hydratedSheet.customFields) == null ? void 0 : _a.parentTableId;
10096
+ const resolvedParentTableId = typeof rawParentTableId === "string" ? resolveBoundId(rawParentTableId, bindings) : void 0;
10097
+ const parentFetchIds = resolvedParentTableId ? Array.from(/* @__PURE__ */ new Set([...resolvedParentIds, resolvedParentTableId])) : resolvedParentIds;
10098
+ const parentWorksheets = await getWorksheets(parentFetchIds);
10099
+ const parentSheet = resolvedParentTableId ? _.find(parentWorksheets, (ps) => ps.id === resolvedParentTableId) : void 0;
10090
10100
  let definitionModel;
10091
10101
  let customModel;
10092
10102
  if (parentSheet) {
10093
- const hydratedParentSheet = await hydrateWorksheet(parentSheet);
10103
+ const hydratedParentSheet = await hydrateWorksheet(parentSheet, bindings);
10094
10104
  if (hydratedParentSheet == null ? void 0 : hydratedParentSheet.definitionModel) {
10095
10105
  const {
10096
10106
  definitionModel: parentDefinitionModel,
@@ -10112,7 +10122,7 @@ const getData$3 = async (metricSheetId, options) => {
10112
10122
  const dModel = definitionModel;
10113
10123
  const gridColumnState = cModel == null ? void 0 : cModel.gridColumnState;
10114
10124
  const { variable, parentTableVariable, inputs } = cModel;
10115
- const aliases = (_a = dModel == null ? void 0 : dModel.aliases) == null ? void 0 : _a[parentTableVariable];
10125
+ const aliases = (_b = dModel == null ? void 0 : dModel.aliases) == null ? void 0 : _b[parentTableVariable];
10116
10126
  let timeBin = "";
10117
10127
  if (options == null ? void 0 : options.isKPI) {
10118
10128
  timeBin = (options == null ? void 0 : options.plotAsTrend) ? !_.isEmpty(cModel == null ? void 0 : cModel.timeBin) ? cModel == null ? void 0 : cModel.timeBin : "per_month" : "";
@@ -10135,13 +10145,13 @@ const getData$3 = async (metricSheetId, options) => {
10135
10145
  datasetName: (cModel == null ? void 0 : cModel.datasetName) ?? "",
10136
10146
  columnSettings: columnSettings ?? [],
10137
10147
  filterColumnsBy: (cModel == null ? void 0 : cModel.filterColumnsBy) ?? {},
10138
- filterModel: ((_c = (_b = hydratedSheet == null ? void 0 : hydratedSheet.customModel) == null ? void 0 : _b.gridColumnState) == null ? void 0 : _c.filterModel) ?? {},
10148
+ filterModel: ((_d = (_c = hydratedSheet == null ? void 0 : hydratedSheet.customModel) == null ? void 0 : _c.gridColumnState) == null ? void 0 : _d.filterModel) ?? {},
10139
10149
  valueCols: valueCols ?? [],
10140
10150
  rowGroupCols: (gridColumnState == null ? void 0 : gridColumnState.rowGroupCols) ?? [],
10141
10151
  pivotCols: (gridColumnState == null ? void 0 : gridColumnState.pivotCols) ?? [],
10142
10152
  dateColumn: cModel == null ? void 0 : cModel.dateColumn,
10143
10153
  timeBin,
10144
- dateRange: (_d = cModel == null ? void 0 : cModel.inputs) == null ? void 0 : _d.date_range,
10154
+ dateRange: (_e = cModel == null ? void 0 : cModel.inputs) == null ? void 0 : _e.date_range,
10145
10155
  aliases,
10146
10156
  lastModifiedDate: hydratedSheet == null ? void 0 : hydratedSheet.lastModifiedDate,
10147
10157
  hierarchy: cModel == null ? void 0 : cModel.hierarchy,
@@ -10159,8 +10169,8 @@ const getData$3 = async (metricSheetId, options) => {
10159
10169
  lastModifiedDate: hydratedSheet.lastModifiedDate,
10160
10170
  promotedFiltersStoreValue: {},
10161
10171
  promotedFilters: [],
10162
- dateRangeModel: ((_e = hydratedSheet == null ? void 0 : hydratedSheet.customModel) == null ? void 0 : _e.dateRangeModel) ?? defaultDashboardDateRangeModel,
10163
- currencyModel: ((_f = hydratedSheet == null ? void 0 : hydratedSheet.customModel) == null ? void 0 : _f.currencyModel) ?? defaultCurrencyModel,
10172
+ dateRangeModel: ((_f = hydratedSheet == null ? void 0 : hydratedSheet.customModel) == null ? void 0 : _f.dateRangeModel) ?? defaultDashboardDateRangeModel,
10173
+ currencyModel: ((_g = hydratedSheet == null ? void 0 : hydratedSheet.customModel) == null ? void 0 : _g.currencyModel) ?? defaultCurrencyModel,
10164
10174
  commonFilters: []
10165
10175
  });
10166
10176
  let resultData = [];