@uipath/data-fabric-tool 1.1.0 → 1.195.0

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.
@@ -3,6 +3,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
3
3
 
4
4
  vi.mock("../utils/sdk-client", () => ({
5
5
  createDataFabricClient: vi.fn(),
6
+ connectOrFail: vi.fn(),
6
7
  }));
7
8
 
8
9
  vi.mock("@uipath/common", async (importOriginal) => {
@@ -22,7 +23,7 @@ vi.mock("../utils/input", () => ({
22
23
 
23
24
  import { OutputFormatter } from "@uipath/common";
24
25
  import { readJsonInput } from "../utils/input";
25
- import { createDataFabricClient } from "../utils/sdk-client";
26
+ import { connectOrFail } from "../utils/sdk-client";
26
27
  import { registerEntitiesCommand } from "./entities";
27
28
 
28
29
  function buildProgram(): Command {
@@ -43,7 +44,7 @@ function mockSdk(overrides: Record<string, unknown> = {}) {
43
44
  ...overrides,
44
45
  },
45
46
  };
46
- vi.mocked(createDataFabricClient).mockResolvedValue(sdk as never);
47
+ vi.mocked(connectOrFail).mockResolvedValue(sdk as never);
47
48
  return sdk;
48
49
  }
49
50
 
@@ -74,9 +75,9 @@ describe("entities list", () => {
74
75
  ).toBeFalsy();
75
76
  });
76
77
 
77
- it("should list entities successfully", async () => {
78
+ it("should list entities successfully (raw SDK shape)", async () => {
78
79
  const sdk = mockSdk();
79
- vi.mocked(sdk.entities.getAll).mockResolvedValue([
80
+ const rawEntities = [
80
81
  {
81
82
  id: "uuid-1",
82
83
  name: "invoice",
@@ -86,7 +87,8 @@ describe("entities list", () => {
86
87
  fields: [{ name: "amount" }, { name: "date" }],
87
88
  externalFields: [],
88
89
  },
89
- ]);
90
+ ];
91
+ vi.mocked(sdk.entities.getAll).mockResolvedValue(rawEntities);
90
92
 
91
93
  const program = buildProgram();
92
94
  await program.parseAsync(["node", "test", "entities", "list"]);
@@ -95,53 +97,12 @@ describe("entities list", () => {
95
97
  expect.objectContaining({
96
98
  Result: "Success",
97
99
  Code: "EntityList",
98
- Data: expect.arrayContaining([
99
- expect.objectContaining({
100
- Name: "invoice",
101
- ID: "uuid-1",
102
- FieldCount: 2,
103
- Source: "Native",
104
- }),
105
- ]),
106
- }),
107
- );
108
- });
109
-
110
- it("should label federated entity with connector name", async () => {
111
- const sdk = mockSdk();
112
- vi.mocked(sdk.entities.getAll).mockResolvedValue([
113
- {
114
- id: "uuid-2",
115
- name: "contacts",
116
- displayName: "Contacts",
117
- entityType: "Federated",
118
- description: "",
119
- fields: [],
120
- externalFields: [
121
- {
122
- externalConnectionDetail: {
123
- connectorName: "Salesforce",
124
- },
125
- },
126
- ],
127
- },
128
- ]);
129
-
130
- const program = buildProgram();
131
- await program.parseAsync(["node", "test", "entities", "list"]);
132
-
133
- expect(OutputFormatter.success).toHaveBeenCalledWith(
134
- expect.objectContaining({
135
- Data: expect.arrayContaining([
136
- expect.objectContaining({
137
- Source: "Federated (Salesforce)",
138
- }),
139
- ]),
100
+ Data: rawEntities,
140
101
  }),
141
102
  );
142
103
  });
143
104
 
144
- it("should filter out federated entities with --native-only", async () => {
105
+ it("should filter out federated entities with --native-only (raw shape)", async () => {
145
106
  const sdk = mockSdk();
146
107
  vi.mocked(sdk.entities.getAll).mockResolvedValue([
147
108
  {
@@ -168,10 +129,10 @@ describe("entities list", () => {
168
129
  ]);
169
130
 
170
131
  const call = vi.mocked(OutputFormatter.success).mock.calls[0][0] as {
171
- Data: { ID: string }[];
132
+ Data: { id: string }[];
172
133
  };
173
134
  expect(call.Data).toHaveLength(1);
174
- expect(call.Data[0].ID).toBe("uuid-1");
135
+ expect(call.Data[0].id).toBe("uuid-1");
175
136
  });
176
137
 
177
138
  it("should return empty list when no entities exist", async () => {
@@ -189,21 +150,15 @@ describe("entities list", () => {
189
150
  );
190
151
  });
191
152
 
192
- it("should error when SDK connection fails", async () => {
193
- vi.mocked(createDataFabricClient).mockRejectedValue(
194
- new Error("Not logged in"),
195
- );
153
+ it("should bail when SDK connection fails", async () => {
154
+ const sdk = mockSdk();
155
+ vi.mocked(connectOrFail).mockResolvedValue(undefined);
196
156
 
197
157
  const program = buildProgram();
198
158
  await program.parseAsync(["node", "test", "entities", "list"]);
199
159
 
200
- expect(OutputFormatter.error).toHaveBeenCalledWith(
201
- expect.objectContaining({
202
- Result: "Failure",
203
- Message: "Error connecting to Data Fabric",
204
- }),
205
- );
206
- expect(process.exitCode).toBe(1);
160
+ expect(sdk.entities.getAll).not.toHaveBeenCalled();
161
+ expect(OutputFormatter.success).not.toHaveBeenCalled();
207
162
  });
208
163
 
209
164
  it("should error when list API fails", async () => {
@@ -231,23 +186,33 @@ describe("entities get", () => {
231
186
  process.exitCode = undefined;
232
187
  });
233
188
 
234
- it("should return entity schema with fields", async () => {
189
+ it("should return entity schema as the raw SDK response", async () => {
235
190
  const sdk = mockSdk();
236
- vi.mocked(sdk.entities.getById).mockResolvedValue({
191
+ const rawEntity = {
237
192
  id: "uuid-1",
238
193
  name: "invoice",
239
194
  displayName: "Invoice",
240
195
  entityType: "Local",
241
196
  description: "Invoice entity",
197
+ isRbacEnabled: false,
242
198
  fields: [
243
199
  {
244
200
  id: "field-uuid-1",
245
201
  name: "amount",
246
202
  displayName: "Amount",
247
203
  fieldDataType: { name: "DECIMAL" },
204
+ sqlType: {
205
+ name: "DECIMAL",
206
+ decimalPrecision: 2,
207
+ },
248
208
  isRequired: true,
249
209
  isPrimaryKey: false,
250
210
  isSystemField: false,
211
+ // SDK-internal fields are no longer projected away
212
+ isForeignKey: false,
213
+ referenceName: "fk_Amount_ab00841b",
214
+ createdTime: "2026-01-01T00:00:00Z",
215
+ createdBy: "u1",
251
216
  },
252
217
  {
253
218
  id: "field-uuid-2",
@@ -259,7 +224,8 @@ describe("entities get", () => {
259
224
  isSystemField: false,
260
225
  },
261
226
  ],
262
- });
227
+ };
228
+ vi.mocked(sdk.entities.getById).mockResolvedValue(rawEntity);
263
229
 
264
230
  const program = buildProgram();
265
231
  await program.parseAsync(["node", "test", "entities", "get", "uuid-1"]);
@@ -268,55 +234,20 @@ describe("entities get", () => {
268
234
  expect.objectContaining({
269
235
  Result: "Success",
270
236
  Code: "EntitySchema",
271
- Data: expect.objectContaining({
272
- ID: "uuid-1",
273
- Name: "invoice",
274
- Fields: expect.arrayContaining([
275
- expect.objectContaining({
276
- ID: "field-uuid-1",
277
- Name: "amount",
278
- Type: "DECIMAL",
279
- Required: true,
280
- }),
281
- ]),
282
- }),
237
+ Data: rawEntity,
283
238
  }),
284
239
  );
285
240
  });
286
241
 
287
- it("should use name as DisplayName when displayName is missing", async () => {
242
+ it("should bail when SDK connection fails", async () => {
288
243
  const sdk = mockSdk();
289
- vi.mocked(sdk.entities.getById).mockResolvedValue({
290
- id: "uuid-1",
291
- name: "invoice",
292
- fields: [],
293
- });
244
+ vi.mocked(connectOrFail).mockResolvedValue(undefined);
294
245
 
295
246
  const program = buildProgram();
296
247
  await program.parseAsync(["node", "test", "entities", "get", "uuid-1"]);
297
248
 
298
- expect(OutputFormatter.success).toHaveBeenCalledWith(
299
- expect.objectContaining({
300
- Data: expect.objectContaining({ DisplayName: "invoice" }),
301
- }),
302
- );
303
- });
304
-
305
- it("should error when SDK connection fails", async () => {
306
- vi.mocked(createDataFabricClient).mockRejectedValue(
307
- new Error("Not logged in"),
308
- );
309
-
310
- const program = buildProgram();
311
- await program.parseAsync(["node", "test", "entities", "get", "uuid-1"]);
312
-
313
- expect(OutputFormatter.error).toHaveBeenCalledWith(
314
- expect.objectContaining({
315
- Result: "Failure",
316
- Message: "Error connecting to Data Fabric",
317
- }),
318
- );
319
- expect(process.exitCode).toBe(1);
249
+ expect(sdk.entities.getById).not.toHaveBeenCalled();
250
+ expect(OutputFormatter.success).not.toHaveBeenCalled();
320
251
  });
321
252
 
322
253
  it("should error when entity is not found (SDK throws)", async () => {
@@ -546,15 +477,15 @@ describe("entities create", () => {
546
477
  );
547
478
  });
548
479
 
549
- it("should create entity with a RELATIONSHIP field carrying referenceEntityName and referenceFieldName", async () => {
480
+ it("should create entity with a RELATIONSHIP field carrying referenceEntityId and referenceFieldId", async () => {
550
481
  const sdk = mockSdk();
551
482
  vi.mocked(sdk.entities.create).mockResolvedValue("entity-rel");
552
483
  const fields = [
553
484
  {
554
485
  fieldName: "rel1",
555
486
  type: "RELATIONSHIP",
556
- referenceEntityName: "CodeEvalTestEntity",
557
- referenceFieldName: "Email",
487
+ referenceEntityId: "a1b2c3d4-0000-0000-0000-000000000010",
488
+ referenceFieldId: "f1000000-0000-0000-0000-000000000100",
558
489
  },
559
490
  ];
560
491
  vi.mocked(readJsonInput).mockResolvedValue({ fields });
@@ -576,8 +507,8 @@ describe("entities create", () => {
576
507
  expect.objectContaining({
577
508
  fieldName: "rel1",
578
509
  type: "RELATIONSHIP",
579
- referenceEntityName: "CodeEvalTestEntity",
580
- referenceFieldName: "Email",
510
+ referenceEntityId: "a1b2c3d4-0000-0000-0000-000000000010",
511
+ referenceFieldId: "f1000000-0000-0000-0000-000000000100",
581
512
  }),
582
513
  ]),
583
514
  undefined,
@@ -710,13 +641,12 @@ describe("entities create", () => {
710
641
  expect(process.exitCode).toBe(1);
711
642
  });
712
643
 
713
- it("should error when SDK connection fails on create", async () => {
644
+ it("should bail when SDK connection fails on create", async () => {
645
+ const sdk = mockSdk();
714
646
  vi.mocked(readJsonInput).mockResolvedValue({
715
647
  fields: [{ fieldName: "title", type: "STRING" }],
716
648
  });
717
- vi.mocked(createDataFabricClient).mockRejectedValue(
718
- new Error("Not logged in"),
719
- );
649
+ vi.mocked(connectOrFail).mockResolvedValue(undefined);
720
650
 
721
651
  const program = buildProgram();
722
652
  await program.parseAsync([
@@ -729,13 +659,8 @@ describe("entities create", () => {
729
659
  '{"fields":[{"fieldName":"title","type":"STRING"}]}',
730
660
  ]);
731
661
 
732
- expect(OutputFormatter.error).toHaveBeenCalledWith(
733
- expect.objectContaining({
734
- Result: "Failure",
735
- Message: "Error connecting to Data Fabric",
736
- }),
737
- );
738
- expect(process.exitCode).toBe(1);
662
+ expect(sdk.entities.create).not.toHaveBeenCalled();
663
+ expect(OutputFormatter.success).not.toHaveBeenCalled();
739
664
  });
740
665
 
741
666
  it("should error when create API fails", async () => {
@@ -806,14 +731,14 @@ describe("entities update", () => {
806
731
  );
807
732
  });
808
733
 
809
- it("should update entity by adding a RELATIONSHIP field with referenceFieldName=Email", async () => {
734
+ it("should update entity by adding a RELATIONSHIP field with referenceEntityId and referenceFieldId", async () => {
810
735
  const sdk = mockSdk();
811
736
  const addFields = [
812
737
  {
813
738
  fieldName: "rel1",
814
739
  type: "RELATIONSHIP",
815
- referenceEntityName: "CodeEvalTestEntity",
816
- referenceFieldName: "Email",
740
+ referenceEntityId: "a1b2c3d4-0000-0000-0000-000000000010",
741
+ referenceFieldId: "f1000000-0000-0000-0000-000000000100",
817
742
  },
818
743
  ];
819
744
  vi.mocked(readJsonInput).mockResolvedValue({ addFields });
@@ -1751,13 +1676,12 @@ describe("entities update", () => {
1751
1676
  expect(process.exitCode).toBe(1);
1752
1677
  });
1753
1678
 
1754
- it("should error when SDK connection fails on update", async () => {
1679
+ it("should bail when SDK connection fails on update", async () => {
1680
+ const sdk = mockSdk();
1755
1681
  vi.mocked(readJsonInput).mockResolvedValue({
1756
1682
  displayName: "New Name",
1757
1683
  });
1758
- vi.mocked(createDataFabricClient).mockRejectedValue(
1759
- new Error("Not logged in"),
1760
- );
1684
+ vi.mocked(connectOrFail).mockResolvedValue(undefined);
1761
1685
 
1762
1686
  const program = buildProgram();
1763
1687
  await program.parseAsync([
@@ -1770,13 +1694,8 @@ describe("entities update", () => {
1770
1694
  '{"displayName":"New Name"}',
1771
1695
  ]);
1772
1696
 
1773
- expect(OutputFormatter.error).toHaveBeenCalledWith(
1774
- expect.objectContaining({
1775
- Result: "Failure",
1776
- Message: "Error connecting to Data Fabric",
1777
- }),
1778
- );
1779
- expect(process.exitCode).toBe(1);
1697
+ expect(sdk.entities.updateById).not.toHaveBeenCalled();
1698
+ expect(OutputFormatter.success).not.toHaveBeenCalled();
1780
1699
  });
1781
1700
 
1782
1701
  it("should error when updateById API fails", async () => {
@@ -1917,10 +1836,9 @@ describe("entities delete", () => {
1917
1836
  expect(process.exitCode).toBe(1);
1918
1837
  });
1919
1838
 
1920
- it("should error when SDK connection fails", async () => {
1921
- vi.mocked(createDataFabricClient).mockRejectedValue(
1922
- new Error("Not logged in"),
1923
- );
1839
+ it("should bail when SDK connection fails", async () => {
1840
+ const sdk = mockSdk();
1841
+ vi.mocked(connectOrFail).mockResolvedValue(undefined);
1924
1842
 
1925
1843
  const program = buildProgram();
1926
1844
  await program.parseAsync([
@@ -1934,13 +1852,8 @@ describe("entities delete", () => {
1934
1852
  "cleanup",
1935
1853
  ]);
1936
1854
 
1937
- expect(OutputFormatter.error).toHaveBeenCalledWith(
1938
- expect.objectContaining({
1939
- Result: "Failure",
1940
- Message: "Error connecting to Data Fabric",
1941
- }),
1942
- );
1943
- expect(process.exitCode).toBe(1);
1855
+ expect(sdk.entities.deleteById).not.toHaveBeenCalled();
1856
+ expect(OutputFormatter.success).not.toHaveBeenCalled();
1944
1857
  });
1945
1858
 
1946
1859
  it("should error when delete API fails", async () => {