@bluecopa/core 0.1.72 → 0.1.74

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.
@@ -22,3 +22,4 @@ export * as clientIp from './clientIp';
22
22
  export * as emailEngine from './emailEngine';
23
23
  export * as tcn from './tcn';
24
24
  export * as webcron from './webcron';
25
+ export * as templates from './templates';
@@ -0,0 +1 @@
1
+ export * from './render';
@@ -0,0 +1,32 @@
1
+ export type TemplateEngine = "mustache" | "jinja";
2
+ export interface RenderTemplateRequest {
3
+ templateHtml?: string;
4
+ templateText?: string;
5
+ data: Record<string, unknown>;
6
+ /**
7
+ * Template engine. Defaults to `jinja` (Nunjucks).
8
+ * - `jinja` — supports `{% if %}`, `{% for %}`, filters, `{% set %}`.
9
+ * - `mustache` — legacy. Supports `{{var}}`, `{{{raw}}}`, `{{#each}}`.
10
+ * Filesystem features (`{% include %}` / `{% extends %}`) are blocked in both.
11
+ */
12
+ engine?: TemplateEngine;
13
+ }
14
+ export interface RenderTemplateWarning {
15
+ type?: "MISSING_KEY" | "INVALID_EACH_TARGET";
16
+ key?: string;
17
+ context?: string;
18
+ }
19
+ export interface RenderTemplateResponse {
20
+ renderedHtml?: string;
21
+ renderedText?: string;
22
+ warnings?: RenderTemplateWarning[];
23
+ }
24
+ /**
25
+ * Renders an email template by replacing {{variable}} placeholders with values from `data`.
26
+ * Supports {{#each items}} blocks for arrays.
27
+ *
28
+ * @param body - Template payload with optional html/text and required data map
29
+ * @returns Promise<RenderTemplateResponse> Rendered output and any warnings
30
+ * @throws { message, status } on failure
31
+ */
32
+ export declare const renderTemplate: (body: RenderTemplateRequest) => Promise<RenderTemplateResponse>;
package/dist/index.d.ts CHANGED
@@ -48,3 +48,4 @@ export type { TcnCallData } from './api/tcn/getCallData';
48
48
  export type { FilterOnSenderId, EmailMessage, PageChunkEmailMessage, } from './api/emailEngine/getMessageBySenderId';
49
49
  export type { Webhook, CreateWebhookRequest, UpdateWebhookRequest, Schedule, CreateScheduleRequest, UpdateScheduleRequest, Execution, ListExecutionsParams, Task, CreateTaskRequest, TaskProgressRequest, TaskSignalRequest, InspectionBin, CreateInspectionBinRequest, InspectionRequest, PaginationParams, WebcronHealth, } from './api/webcron/types';
50
50
  export type { TriggerWorkflowRequest, TriggerWorkflowResponse, } from './api/webcron/trigger';
51
+ export type { RenderTemplateRequest, RenderTemplateResponse, RenderTemplateWarning, TemplateEngine, } from './api/templates/render';
package/dist/index.es.js CHANGED
@@ -144,7 +144,7 @@ async function getAllUsers() {
144
144
  throw { message, status };
145
145
  }
146
146
  }
147
- const index$o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
147
+ const index$p = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
148
148
  __proto__: null,
149
149
  getAllUsers,
150
150
  getLoggedInUserDetails
@@ -224,7 +224,7 @@ async function getAllHttpTriggers() {
224
224
  throw { message, status };
225
225
  }
226
226
  }
227
- const index$n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
227
+ const index$o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
228
228
  __proto__: null,
229
229
  WorkflowStatus,
230
230
  getAllHttpTriggers,
@@ -330,7 +330,7 @@ async function fileDownload({
330
330
  throw { message, status };
331
331
  }
332
332
  }
333
- const index$m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
333
+ const index$n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
334
334
  __proto__: null,
335
335
  fileDownload,
336
336
  fileUpload,
@@ -406,7 +406,7 @@ const runDefinition = async (props) => {
406
406
  };
407
407
  }
408
408
  };
409
- const index$l = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
409
+ const index$m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
410
410
  __proto__: null,
411
411
  runDefinition,
412
412
  runPublishedDefinition,
@@ -444,7 +444,7 @@ const getWorksheetsByType = async (type) => {
444
444
  throw { message, status };
445
445
  }
446
446
  };
447
- const index$k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
447
+ const index$l = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
448
448
  __proto__: null,
449
449
  getWorksheets,
450
450
  getWorksheetsByType
@@ -9802,7 +9802,7 @@ const getUniqueDuplicateName = (name, collectionToCheckIn, suffix = "Copy", conc
9802
9802
  }
9803
9803
  return newName.trim();
9804
9804
  };
9805
- const index$j = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9805
+ const index$k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9806
9806
  __proto__: null,
9807
9807
  formatDate,
9808
9808
  generatePushID,
@@ -9973,7 +9973,7 @@ const getData$3 = async (metricSheetId, options) => {
9973
9973
  resultData = _.flatten(resultData);
9974
9974
  return { data: resultData };
9975
9975
  };
9976
- const index$i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9976
+ const index$j = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9977
9977
  __proto__: null,
9978
9978
  getData: getData$3
9979
9979
  }, Symbol.toStringTag, { value: "Module" }));
@@ -10128,7 +10128,7 @@ async function checkSubscriptionStatus(userId, threadId) {
10128
10128
  throw { message, status };
10129
10129
  }
10130
10130
  }
10131
- const index$h = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10131
+ const index$i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10132
10132
  __proto__: null,
10133
10133
  checkSubscriptionStatus,
10134
10134
  createThread,
@@ -10333,7 +10333,7 @@ const getAllDatasets = async () => {
10333
10333
  throw { message, status };
10334
10334
  }
10335
10335
  };
10336
- const index$g = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10336
+ const index$h = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10337
10337
  __proto__: null,
10338
10338
  getAllDatasets,
10339
10339
  getData: getData$2,
@@ -10652,7 +10652,7 @@ const deleteRow = async (tableId, rowId, idField = "_copa_id") => {
10652
10652
  throw { message, status };
10653
10653
  }
10654
10654
  };
10655
- const index$f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10655
+ const index$g = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10656
10656
  __proto__: null,
10657
10657
  deleteRow,
10658
10658
  getData: getData$1,
@@ -10746,7 +10746,7 @@ async function publishWorkbook({
10746
10746
  throw { message, status };
10747
10747
  }
10748
10748
  }
10749
- const index$e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10749
+ const index$f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10750
10750
  __proto__: null,
10751
10751
  getPublishedWorkbookById,
10752
10752
  getWorkbookDetails,
@@ -11014,7 +11014,7 @@ const getRunResultById = async (runId) => {
11014
11014
  throw { message, status };
11015
11015
  }
11016
11016
  };
11017
- const index$d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11017
+ const index$e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11018
11018
  __proto__: null,
11019
11019
  createNewRun,
11020
11020
  getData,
@@ -11044,7 +11044,7 @@ async function getTaskDetails({
11044
11044
  throw { message, status };
11045
11045
  }
11046
11046
  }
11047
- const index$c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11047
+ const index$d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11048
11048
  __proto__: null,
11049
11049
  getTaskDetails
11050
11050
  }, Symbol.toStringTag, { value: "Module" }));
@@ -11090,7 +11090,7 @@ async function getAllReconWorkflows() {
11090
11090
  throw { message, status };
11091
11091
  }
11092
11092
  }
11093
- const index$b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11093
+ const index$c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11094
11094
  __proto__: null,
11095
11095
  getAllReconWorkflows,
11096
11096
  runRecon
@@ -11191,7 +11191,7 @@ async function createOrUpdateForm({
11191
11191
  throw { message, status: status2 };
11192
11192
  }
11193
11193
  }
11194
- const index$a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11194
+ const index$b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11195
11195
  __proto__: null,
11196
11196
  createOrUpdateForm,
11197
11197
  getFormById,
@@ -11232,7 +11232,7 @@ async function createAuditLog(params) {
11232
11232
  throw { message, status };
11233
11233
  }
11234
11234
  }
11235
- const index$9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11235
+ const index$a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11236
11236
  __proto__: null,
11237
11237
  createAuditLog,
11238
11238
  getAuditLogs
@@ -11251,7 +11251,7 @@ async function getAllTemplatedPipelines() {
11251
11251
  throw { message, status };
11252
11252
  }
11253
11253
  }
11254
- const index$8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11254
+ const index$9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11255
11255
  __proto__: null,
11256
11256
  getAllTemplatedPipelines
11257
11257
  }, Symbol.toStringTag, { value: "Module" }));
@@ -11376,7 +11376,7 @@ async function deleteProcessTrigger(id) {
11376
11376
  throw { message, status };
11377
11377
  }
11378
11378
  }
11379
- const index$7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11379
+ const index$8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11380
11380
  __proto__: null,
11381
11381
  deleteProcessTrigger,
11382
11382
  getTriggersBySheet,
@@ -11474,7 +11474,7 @@ async function createInboxItemPerUser(data) {
11474
11474
  throw { message, status };
11475
11475
  }
11476
11476
  }
11477
- const index$6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11477
+ const index$7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11478
11478
  __proto__: null,
11479
11479
  createInboxItemPerUser,
11480
11480
  getAllInboxItems,
@@ -11502,7 +11502,7 @@ async function getPermissions(params) {
11502
11502
  throw { message, status };
11503
11503
  }
11504
11504
  }
11505
- const index$5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11505
+ const index$6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11506
11506
  __proto__: null,
11507
11507
  getPermissions
11508
11508
  }, Symbol.toStringTag, { value: "Module" }));
@@ -11520,7 +11520,7 @@ async function getClientIp() {
11520
11520
  throw { message, status };
11521
11521
  }
11522
11522
  }
11523
- const index$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11523
+ const index$5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11524
11524
  __proto__: null,
11525
11525
  getClientIp
11526
11526
  }, Symbol.toStringTag, { value: "Module" }));
@@ -11655,7 +11655,7 @@ async function getMessageBySenderId(params) {
11655
11655
  throw { message, status };
11656
11656
  }
11657
11657
  }
11658
- const index$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11658
+ const index$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11659
11659
  __proto__: null,
11660
11660
  createConversation,
11661
11661
  getAllConversations,
@@ -11920,7 +11920,7 @@ async function agentGetCallFromHold(token, sessionSid, holdType = "SIMPLE") {
11920
11920
  throw { message, status };
11921
11921
  }
11922
11922
  }
11923
- const index$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11923
+ const index$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11924
11924
  __proto__: null,
11925
11925
  agentDisconnect,
11926
11926
  agentGetCallFromHold,
@@ -12299,7 +12299,7 @@ async function triggerWorkflowById(id, data) {
12299
12299
  throw { message, status };
12300
12300
  }
12301
12301
  }
12302
- const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
12302
+ const index$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
12303
12303
  __proto__: null,
12304
12304
  cancelTask,
12305
12305
  clearBinRequests,
@@ -12334,32 +12334,60 @@ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
12334
12334
  updateSchedule,
12335
12335
  updateWebhook
12336
12336
  }, Symbol.toStringTag, { value: "Module" }));
12337
+ const renderTemplate = async (body) => {
12338
+ var _a, _b, _c;
12339
+ try {
12340
+ if (!body || !body.data) {
12341
+ throw { message: "Template data is required", status: 400 };
12342
+ }
12343
+ if (!body.templateHtml && !body.templateText) {
12344
+ throw {
12345
+ message: "At least one of templateHtml or templateText is required",
12346
+ status: 400
12347
+ };
12348
+ }
12349
+ const response = await apiClient.post("/templates/render", body);
12350
+ if (!response.data) {
12351
+ throw { message: "Failed to render template", status: 500 };
12352
+ }
12353
+ return response.data;
12354
+ } catch (error) {
12355
+ const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while rendering template";
12356
+ const status = ((_c = error.response) == null ? void 0 : _c.status) || error.status || 500;
12357
+ throw { message, status };
12358
+ }
12359
+ };
12360
+ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
12361
+ __proto__: null,
12362
+ renderTemplate
12363
+ }, Symbol.toStringTag, { value: "Module" }));
12337
12364
  const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
12338
12365
  __proto__: null,
12339
12366
  apiClient,
12340
- audit: index$9,
12341
- chat: index$h,
12342
- clientIp: index$4,
12343
- dataset: index$g,
12344
- definition: index$l,
12345
- emailEngine: index$3,
12346
- files: index$m,
12347
- form: index$a,
12348
- inboxItems: index$6,
12349
- inputTable: index$f,
12350
- metric: index$i,
12351
- permissions: index$5,
12352
- process: index$7,
12353
- recon: index$b,
12354
- statement: index$d,
12355
- task: index$c,
12356
- tcn: index$2,
12357
- templatedPipeline: index$8,
12358
- user: index$o,
12359
- webcron: index$1,
12360
- workbook: index$e,
12361
- workflow: index$n,
12362
- worksheet: index$k
12367
+ audit: index$a,
12368
+ chat: index$i,
12369
+ clientIp: index$5,
12370
+ dataset: index$h,
12371
+ definition: index$m,
12372
+ emailEngine: index$4,
12373
+ files: index$n,
12374
+ form: index$b,
12375
+ inboxItems: index$7,
12376
+ inputTable: index$g,
12377
+ metric: index$j,
12378
+ permissions: index$6,
12379
+ process: index$8,
12380
+ recon: index$c,
12381
+ statement: index$e,
12382
+ task: index$d,
12383
+ tcn: index$3,
12384
+ templatedPipeline: index$9,
12385
+ templates: index$1,
12386
+ user: index$p,
12387
+ webcron: index$2,
12388
+ workbook: index$f,
12389
+ workflow: index$o,
12390
+ worksheet: index$l
12363
12391
  }, Symbol.toStringTag, { value: "Module" }));
12364
12392
  var InputTableColumnType = /* @__PURE__ */ ((InputTableColumnType2) => {
12365
12393
  InputTableColumnType2["UUID"] = "uuid";
@@ -14436,6 +14464,6 @@ export {
14436
14464
  copaInputTableDb,
14437
14465
  setConfig as copaSetConfig,
14438
14466
  bluecopaTailwindConfig as copaTailwindConfig,
14439
- index$j as copaUtils
14467
+ index$k as copaUtils
14440
14468
  };
14441
14469
  //# sourceMappingURL=index.es.js.map