@bluecopa/core 0.1.96 → 0.1.97

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.
@@ -17,6 +17,8 @@ export interface CreateReconV2Request {
17
17
  rightDataset?: ReconV2DatasetRef;
18
18
  /** Optional initial workflow config (leftDef, rightDef, matchGroups, sources, ...) */
19
19
  config?: Partial<ReconV2Workflow>;
20
+ /** Optional custom fields — spread into the workflow's customFields */
21
+ customFields?: Record<string, any>;
20
22
  }
21
23
  /**
22
24
  * Creates a recon v2 (SMART_RECONCILIATION) workflow along with its backing
@@ -29,7 +31,8 @@ export interface CreateReconV2Request {
29
31
  * @param params.leftDataset - Optional: Left dataset { id, name, dateColumn? }
30
32
  * @param params.rightDataset - Optional: Right dataset { id, name, dateColumn? }
31
33
  * @param params.config - Optional: Initial workflow config to merge in
34
+ * @param params.customFields - Optional: custom fields spread into the workflow's customFields
32
35
  * @returns Promise<ReconV2Workflow> The created workflow
33
36
  * @throws Error if the request fails
34
37
  */
35
- export declare function createReconV2({ name, type, leftDataset, rightDataset, config, }: CreateReconV2Request): Promise<ReconV2Workflow>;
38
+ export declare function createReconV2({ name, type, leftDataset, rightDataset, config, customFields, }: CreateReconV2Request): Promise<ReconV2Workflow>;
@@ -0,0 +1,9 @@
1
+ import { ReconV2TemplateCatalog } from '../../../../models/src/lib/types/reconV2TemplateTypes';
2
+ /**
3
+ * Fetches the predefined recon v2 domain/exception templates used while
4
+ * configuring a workflow. The response is deserialised through the shared
5
+ * parser so callers always receive the typed catalog (keyed by domainId).
6
+ * @returns Promise<ReconV2TemplateCatalog> The template catalog
7
+ * @throws Error if the request fails
8
+ */
9
+ export declare function getReconV2Templates(): Promise<ReconV2TemplateCatalog>;
@@ -0,0 +1,14 @@
1
+ import { ReconV2Workflow } from './createReconV2';
2
+ export interface GetReconV2WorkflowRequest {
3
+ /** Workflow id (or its backing workbook id — the BFF resolves both) */
4
+ id: string;
5
+ }
6
+ /**
7
+ * Gets the detail/config of a single recon v2 workflow by id.
8
+ * Accepts a workflow id or its backing workbook id (resolved server-side).
9
+ * @param params - The request parameters
10
+ * @param params.id - Required: the workflow (or workbook) id
11
+ * @returns Promise<ReconV2Workflow> The workflow
12
+ * @throws Error if the request fails
13
+ */
14
+ export declare function getReconV2Workflow({ id, }: GetReconV2WorkflowRequest): Promise<ReconV2Workflow>;
@@ -3,6 +3,7 @@ export * from './updateReconV2';
3
3
  export * from './deleteReconV2';
4
4
  export * from './runReconV2';
5
5
  export * from './getAllReconV2Workflows';
6
+ export * from './getReconV2Workflow';
6
7
  export * from './getReconV2Runs';
7
8
  export * from './getReconV2RunResult';
8
9
  export * from './getReconV2SmartResult';
@@ -10,3 +11,4 @@ export * from './profileReconV2';
10
11
  export * from './cleanReconV2';
11
12
  export * from './getReconV2Diff';
12
13
  export * from './getReconV2Explanation';
14
+ export * from './getReconV2Templates';
@@ -6,6 +6,8 @@ export interface UpdateReconV2Request {
6
6
  leftDataset?: ReconV2DatasetRef;
7
7
  /** Optional: rewire the secondary (right) sheet to this dataset */
8
8
  rightDataset?: ReconV2DatasetRef;
9
+ /** Optional custom fields — merged (spread) into the workflow's customFields */
10
+ customFields?: Record<string, any>;
9
11
  }
10
12
  /**
11
13
  * Updates (saves) a recon v2 workflow config.
@@ -20,7 +22,8 @@ export interface UpdateReconV2Request {
20
22
  * @param params.reconWorkflow - Required: The workflow object with id
21
23
  * @param params.leftDataset - Optional: Left dataset { id, name, dateColumn? }
22
24
  * @param params.rightDataset - Optional: Right dataset { id, name, dateColumn? }
25
+ * @param params.customFields - Optional: custom fields merged into the workflow's customFields
23
26
  * @returns Promise<ReconV2Workflow> The updated workflow
24
27
  * @throws Error if the request fails
25
28
  */
26
- export declare function updateReconV2({ reconWorkflow, leftDataset, rightDataset, }: UpdateReconV2Request): Promise<ReconV2Workflow>;
29
+ export declare function updateReconV2({ reconWorkflow, leftDataset, rightDataset, customFields, }: UpdateReconV2Request): Promise<ReconV2Workflow>;
package/dist/index.d.ts CHANGED
@@ -14,7 +14,10 @@ export type { ReconV2Workflow, ReconV2DatasetRef, CreateReconV2Request, } from '
14
14
  export type { UpdateReconV2Request } from './api/reconV2/updateReconV2';
15
15
  export type { DeleteReconV2Request, DeleteReconV2Response, } from './api/reconV2/deleteReconV2';
16
16
  export type { ReconV2MatchConfig, RunReconV2Request, RunReconV2Response, } from './api/reconV2/runReconV2';
17
+ export type { GetReconV2WorkflowRequest } from './api/reconV2/getReconV2Workflow';
17
18
  export type { GetReconV2RunsRequest, ReconV2Run, } from './api/reconV2/getReconV2Runs';
19
+ export type { ReconV2TemplateCatalog, ReconV2DomainTemplate, ReconV2TemplateDomain, ReconV2TemplateItem, ReconV2TemplateTypeMapping, ReconV2TemplateFlags, ReconV2TemplateActionOverride, ReconV2SignalRule, ReconV2SignalRuleType, ReconV2TemplateOperator, ReconV2TemplateExceptionType, ReconV2TemplateMappingMode, } from '../../models/src/lib/types/reconV2TemplateTypes';
20
+ export { parseReconV2Templates } from '../../models/src/lib/common/reconV2TemplateParser';
18
21
  export type { GetReconV2RunResultRequest, ReconV2RunResult, } from './api/reconV2/getReconV2RunResult';
19
22
  export type { GetReconV2SmartResultRequest, ReconV2SmartResult, } from './api/reconV2/getReconV2SmartResult';
20
23
  export type { ReconV2ProfileRequest, ReconV2ProfileResult, } from './api/reconV2/profileReconV2';
package/dist/index.es.js CHANGED
@@ -11351,7 +11351,8 @@ async function createReconV2({
11351
11351
  type,
11352
11352
  leftDataset,
11353
11353
  rightDataset,
11354
- config
11354
+ config,
11355
+ customFields
11355
11356
  }) {
11356
11357
  try {
11357
11358
  if (!name) {
@@ -11362,7 +11363,8 @@ async function createReconV2({
11362
11363
  type,
11363
11364
  leftDataset,
11364
11365
  rightDataset,
11365
- config
11366
+ config,
11367
+ customFields
11366
11368
  });
11367
11369
  if (!response.data) {
11368
11370
  throw { message: "Failed to create recon v2 workflow", status: 500 };
@@ -11377,7 +11379,8 @@ async function createReconV2({
11377
11379
  async function updateReconV2({
11378
11380
  reconWorkflow,
11379
11381
  leftDataset,
11380
- rightDataset
11382
+ rightDataset,
11383
+ customFields
11381
11384
  }) {
11382
11385
  try {
11383
11386
  if (!reconWorkflow?.id) {
@@ -11386,7 +11389,8 @@ async function updateReconV2({
11386
11389
  const response = await apiClient.put("/recon-v2/update", {
11387
11390
  reconWorkflow,
11388
11391
  leftDataset,
11389
- rightDataset
11392
+ rightDataset,
11393
+ customFields
11390
11394
  });
11391
11395
  if (!response.data) {
11392
11396
  throw { message: "Failed to update recon v2 workflow", status: 500 };
@@ -11459,6 +11463,27 @@ async function getAllReconV2Workflows() {
11459
11463
  throw { message, status };
11460
11464
  }
11461
11465
  }
11466
+ async function getReconV2Workflow({
11467
+ id
11468
+ }) {
11469
+ try {
11470
+ const trimmedId = id?.trim();
11471
+ if (!trimmedId) {
11472
+ throw { message: "Workflow id is required", status: 400 };
11473
+ }
11474
+ const response = await apiClient.get(
11475
+ `/recon-v2/get/${encodeURIComponent(trimmedId)}`
11476
+ );
11477
+ if (!response.data) {
11478
+ throw { message: "Failed to fetch recon v2 workflow", status: 500 };
11479
+ }
11480
+ return response.data;
11481
+ } catch (error) {
11482
+ const message = error.response?.data?.message || error.message || "An unexpected error occurred while fetching recon v2 workflow";
11483
+ const status = error.response?.status || 500;
11484
+ throw { message, status };
11485
+ }
11486
+ }
11462
11487
  async function getReconV2Runs({
11463
11488
  workflowId
11464
11489
  }) {
@@ -11663,6 +11688,94 @@ async function getReconV2Explanation({
11663
11688
  throw { message, status };
11664
11689
  }
11665
11690
  }
11691
+ const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
11692
+ const asString = (v, fallback = "") => typeof v === "string" ? v : fallback;
11693
+ const asBool = (v, fallback = false) => typeof v === "boolean" ? v : fallback;
11694
+ const asStringOrNull = (v) => typeof v === "string" ? v : null;
11695
+ function parseSignalRule(raw) {
11696
+ if (!isObject(raw)) return null;
11697
+ const value = typeof raw.value === "string" || typeof raw.value === "number" ? raw.value : null;
11698
+ return {
11699
+ ruleType: asString(raw.ruleType),
11700
+ col: asStringOrNull(raw.col),
11701
+ operator: asStringOrNull(raw.operator),
11702
+ value,
11703
+ isNot: asBool(raw.isNot),
11704
+ isCaseSensitive: asBool(raw.isCaseSensitive, true),
11705
+ rules: Array.isArray(raw.rules) ? raw.rules.map(parseSignalRule).filter((r) => r !== null) : null,
11706
+ ignoreIfColNotExists: asBool(raw.ignoreIfColNotExists)
11707
+ };
11708
+ }
11709
+ function parseFlags(raw) {
11710
+ if (!isObject(raw)) return null;
11711
+ const flags = {};
11712
+ for (const [k, v] of Object.entries(raw)) {
11713
+ if (typeof v === "boolean") flags[k] = v;
11714
+ }
11715
+ return flags;
11716
+ }
11717
+ function parseTypeMapping(raw) {
11718
+ if (!isObject(raw)) return null;
11719
+ return {
11720
+ exceptionType: asString(raw.exceptionType),
11721
+ agingGate: asStringOrNull(raw.agingGate),
11722
+ flags: parseFlags(raw.flags)
11723
+ };
11724
+ }
11725
+ function parseItem(raw) {
11726
+ if (!isObject(raw)) return null;
11727
+ return {
11728
+ name: asString(raw.name),
11729
+ description: asString(raw.description),
11730
+ typeMappings: Array.isArray(raw.typeMappings) ? raw.typeMappings.map(parseTypeMapping).filter((m) => m !== null) : [],
11731
+ mappingMode: asString(raw.mappingMode, "single"),
11732
+ signals: parseSignalRule(raw.signals),
11733
+ actionOverride: isObject(raw.actionOverride) ? raw.actionOverride : null,
11734
+ agingNote: asStringOrNull(raw.agingNote)
11735
+ };
11736
+ }
11737
+ function parseDomain(raw) {
11738
+ if (!isObject(raw)) return null;
11739
+ return {
11740
+ domainId: asString(raw.domainId),
11741
+ domainName: asString(raw.domainName),
11742
+ leftLabel: asString(raw.leftLabel),
11743
+ rightLabel: asString(raw.rightLabel),
11744
+ items: Array.isArray(raw.items) ? raw.items.map(parseItem).filter((i) => i !== null) : []
11745
+ };
11746
+ }
11747
+ function parseDomainTemplate(raw) {
11748
+ if (!isObject(raw)) return null;
11749
+ const domain = parseDomain(raw.domain);
11750
+ if (!domain) return null;
11751
+ return {
11752
+ domain,
11753
+ signalColumns: isObject(raw.signalColumns) ? raw.signalColumns : null,
11754
+ thresholds: isObject(raw.thresholds) ? raw.thresholds : null
11755
+ };
11756
+ }
11757
+ function parseReconV2Templates(raw) {
11758
+ if (!isObject(raw)) return {};
11759
+ const catalog = {};
11760
+ for (const [domainId, entry] of Object.entries(raw)) {
11761
+ const parsed = parseDomainTemplate(entry);
11762
+ if (parsed) catalog[domainId] = parsed;
11763
+ }
11764
+ return catalog;
11765
+ }
11766
+ async function getReconV2Templates() {
11767
+ try {
11768
+ const response = await apiClient.get("/recon-v2/templates");
11769
+ if (!response.data) {
11770
+ throw { message: "Failed to fetch recon v2 templates", status: 500 };
11771
+ }
11772
+ return parseReconV2Templates(response.data);
11773
+ } catch (error) {
11774
+ const message = error.response?.data?.message || error.message || "An unexpected error occurred while fetching recon v2 templates";
11775
+ const status = error.response?.status || 500;
11776
+ throw { message, status };
11777
+ }
11778
+ }
11666
11779
  const index$c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11667
11780
  __proto__: null,
11668
11781
  createReconV2,
@@ -11675,6 +11788,8 @@ const index$c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
11675
11788
  getReconV2RunResult,
11676
11789
  getReconV2Runs,
11677
11790
  getReconV2SmartResult,
11791
+ getReconV2Templates,
11792
+ getReconV2Workflow,
11678
11793
  runReconV2,
11679
11794
  startReconV2Clean,
11680
11795
  startReconV2Profile,
@@ -15119,6 +15234,7 @@ export {
15119
15234
  copaInputTableDb,
15120
15235
  setConfig as copaSetConfig,
15121
15236
  bluecopaTailwindConfig as copaTailwindConfig,
15122
- index$l as copaUtils
15237
+ index$l as copaUtils,
15238
+ parseReconV2Templates
15123
15239
  };
15124
15240
  //# sourceMappingURL=index.es.js.map