@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) => {
@@ -23,7 +24,7 @@ vi.mock("@uipath/filesystem", () => ({
23
24
  }));
24
25
 
25
26
  import { OutputFormatter } from "@uipath/common";
26
- import { createDataFabricClient } from "../utils/sdk-client";
27
+ import { connectOrFail } from "../utils/sdk-client";
27
28
  import { registerRecordsCommand } from "./records";
28
29
 
29
30
  function buildProgram(): Command {
@@ -66,7 +67,7 @@ function mockSdk(overrides: Record<string, unknown> = {}) {
66
67
  ...overrides,
67
68
  },
68
69
  };
69
- vi.mocked(createDataFabricClient).mockResolvedValue(sdk as never);
70
+ vi.mocked(connectOrFail).mockResolvedValue(sdk as never);
70
71
  return sdk;
71
72
  }
72
73
 
@@ -83,13 +84,14 @@ describe("records list", () => {
83
84
  expect(cmd?.commands.map((c) => c.name())).toContain("list");
84
85
  });
85
86
 
86
- it("should list records successfully", async () => {
87
+ it("should list records successfully (raw SDK shape)", async () => {
87
88
  const sdk = mockSdk();
88
- vi.mocked(sdk.entities.getAllRecords).mockResolvedValue({
89
+ const rawResult = {
89
90
  items: [{ Id: "rec-1", name: "test" }],
90
91
  totalCount: 1,
91
92
  hasNextPage: false,
92
- });
93
+ };
94
+ vi.mocked(sdk.entities.getAllRecords).mockResolvedValue(rawResult);
93
95
 
94
96
  const program = buildProgram();
95
97
  await program.parseAsync([
@@ -107,22 +109,20 @@ describe("records list", () => {
107
109
  expect.objectContaining({
108
110
  Result: "Success",
109
111
  Code: "RecordList",
110
- Data: expect.objectContaining({
111
- TotalCount: 1,
112
- HasNextPage: false,
113
- }),
112
+ Data: rawResult,
114
113
  }),
115
114
  );
116
115
  });
117
116
 
118
- it("should pass cursor to SDK and include NextCursor in output", async () => {
117
+ it("should pass cursor to SDK and return the raw paginated response", async () => {
119
118
  const sdk = mockSdk();
120
- vi.mocked(sdk.entities.getAllRecords).mockResolvedValue({
119
+ const rawResult = {
121
120
  items: [{ Id: "rec-2" }],
122
121
  totalCount: 100,
123
122
  hasNextPage: true,
124
- nextCursor: "cursor-abc",
125
- });
123
+ nextCursor: { value: "cursor-abc" },
124
+ };
125
+ vi.mocked(sdk.entities.getAllRecords).mockResolvedValue(rawResult);
126
126
 
127
127
  const program = buildProgram();
128
128
  await program.parseAsync([
@@ -141,16 +141,15 @@ describe("records list", () => {
141
141
  });
142
142
  expect(OutputFormatter.success).toHaveBeenCalledWith(
143
143
  expect.objectContaining({
144
- Data: expect.objectContaining({
145
- HasNextPage: true,
146
- NextCursor: "cursor-abc",
147
- }),
144
+ Data: rawResult,
148
145
  }),
149
146
  );
150
147
  });
151
148
 
152
- it("should return empty list when no records exist", async () => {
153
- mockSdk();
149
+ it("should return empty list when no records exist (raw SDK shape)", async () => {
150
+ const sdk = mockSdk();
151
+ const rawResult = { items: [], totalCount: 0 };
152
+ vi.mocked(sdk.entities.getAllRecords).mockResolvedValue(rawResult);
154
153
 
155
154
  const program = buildProgram();
156
155
  await program.parseAsync([
@@ -165,7 +164,7 @@ describe("records list", () => {
165
164
  expect.objectContaining({
166
165
  Result: "Success",
167
166
  Code: "RecordList",
168
- Data: expect.objectContaining({ TotalCount: 0, Records: [] }),
167
+ Data: rawResult,
169
168
  }),
170
169
  );
171
170
  expect(process.exitCode).not.toBe(1);
@@ -361,10 +360,9 @@ describe("records list client error", () => {
361
360
  process.exitCode = undefined;
362
361
  });
363
362
 
364
- it("should error when SDK connection fails on list", async () => {
365
- vi.mocked(createDataFabricClient).mockRejectedValue(
366
- new Error("Not logged in"),
367
- );
363
+ it("should bail when SDK connection fails on list", async () => {
364
+ const sdk = mockSdk();
365
+ vi.mocked(connectOrFail).mockResolvedValue(undefined);
368
366
  const program = buildProgram();
369
367
  await program.parseAsync([
370
368
  "node",
@@ -373,20 +371,14 @@ describe("records list client error", () => {
373
371
  "list",
374
372
  "entity-id",
375
373
  ]);
376
- expect(OutputFormatter.error).toHaveBeenCalledWith(
377
- expect.objectContaining({
378
- Result: "Failure",
379
- Message: "Error connecting to Data Fabric",
380
- }),
381
- );
382
- expect(process.exitCode).toBe(1);
374
+ expect(sdk.entities.getAllRecords).not.toHaveBeenCalled();
375
+ expect(OutputFormatter.success).not.toHaveBeenCalled();
383
376
  });
384
377
 
385
- it("should handle list result without items/totalCount (uses defaults)", async () => {
378
+ it("should pass through the raw list result verbatim", async () => {
379
+ const rawResult = { items: [], hasNextPage: false };
386
380
  const sdk = mockSdk({
387
- getAllRecords: vi
388
- .fn()
389
- .mockResolvedValue({ items: [], hasNextPage: false }),
381
+ getAllRecords: vi.fn().mockResolvedValue(rawResult),
390
382
  });
391
383
  const program = buildProgram();
392
384
  await program.parseAsync([
@@ -399,11 +391,7 @@ describe("records list client error", () => {
399
391
  expect(sdk.entities.getAllRecords).toHaveBeenCalled();
400
392
  expect(OutputFormatter.success).toHaveBeenCalledWith(
401
393
  expect.objectContaining({
402
- Data: expect.objectContaining({
403
- TotalCount: 0,
404
- Records: [],
405
- HasNextPage: false,
406
- }),
394
+ Data: rawResult,
407
395
  }),
408
396
  );
409
397
  });
@@ -496,10 +484,9 @@ describe("records get client error", () => {
496
484
  process.exitCode = undefined;
497
485
  });
498
486
 
499
- it("should error when SDK connection fails on get", async () => {
500
- vi.mocked(createDataFabricClient).mockRejectedValue(
501
- new Error("Not logged in"),
502
- );
487
+ it("should bail when SDK connection fails on get", async () => {
488
+ const sdk = mockSdk();
489
+ vi.mocked(connectOrFail).mockResolvedValue(undefined);
503
490
  const program = buildProgram();
504
491
  await program.parseAsync([
505
492
  "node",
@@ -509,13 +496,8 @@ describe("records get client error", () => {
509
496
  "entity-id",
510
497
  "rec-1",
511
498
  ]);
512
- expect(OutputFormatter.error).toHaveBeenCalledWith(
513
- expect.objectContaining({
514
- Result: "Failure",
515
- Message: "Error connecting to Data Fabric",
516
- }),
517
- );
518
- expect(process.exitCode).toBe(1);
499
+ expect(sdk.entities.getRecordById).not.toHaveBeenCalled();
500
+ expect(OutputFormatter.success).not.toHaveBeenCalled();
519
501
  });
520
502
  });
521
503
 
@@ -630,10 +612,9 @@ describe("records insert", () => {
630
612
  expect(process.exitCode).toBe(1);
631
613
  });
632
614
 
633
- it("should error when SDK connection fails on insert", async () => {
634
- vi.mocked(createDataFabricClient).mockRejectedValue(
635
- new Error("Not logged in"),
636
- );
615
+ it("should bail when SDK connection fails on insert", async () => {
616
+ const sdk = mockSdk();
617
+ vi.mocked(connectOrFail).mockResolvedValue(undefined);
637
618
  const program = buildProgram();
638
619
  await program.parseAsync([
639
620
  "node",
@@ -644,13 +625,8 @@ describe("records insert", () => {
644
625
  "--body",
645
626
  '{"amount":100}',
646
627
  ]);
647
- expect(OutputFormatter.error).toHaveBeenCalledWith(
648
- expect.objectContaining({
649
- Result: "Failure",
650
- Message: "Error connecting to Data Fabric",
651
- }),
652
- );
653
- expect(process.exitCode).toBe(1);
628
+ expect(sdk.entities.insertRecordById).not.toHaveBeenCalled();
629
+ expect(OutputFormatter.success).not.toHaveBeenCalled();
654
630
  });
655
631
 
656
632
  it("should handle batch insert result without successRecords/failureRecords", async () => {
@@ -977,10 +953,9 @@ describe("records update client/batch errors", () => {
977
953
  process.exitCode = undefined;
978
954
  });
979
955
 
980
- it("should error when SDK connection fails on update", async () => {
981
- vi.mocked(createDataFabricClient).mockRejectedValue(
982
- new Error("Not logged in"),
983
- );
956
+ it("should bail when SDK connection fails on update", async () => {
957
+ const sdk = mockSdk();
958
+ vi.mocked(connectOrFail).mockResolvedValue(undefined);
984
959
  const program = buildProgram();
985
960
  await program.parseAsync([
986
961
  "node",
@@ -991,13 +966,8 @@ describe("records update client/batch errors", () => {
991
966
  "--body",
992
967
  '{"Id":"rec-1"}',
993
968
  ]);
994
- expect(OutputFormatter.error).toHaveBeenCalledWith(
995
- expect.objectContaining({
996
- Result: "Failure",
997
- Message: "Error connecting to Data Fabric",
998
- }),
999
- );
1000
- expect(process.exitCode).toBe(1);
969
+ expect(sdk.entities.updateRecordById).not.toHaveBeenCalled();
970
+ expect(OutputFormatter.success).not.toHaveBeenCalled();
1001
971
  });
1002
972
 
1003
973
  it("should handle batch update result without successRecords/failureRecords", async () => {
@@ -1193,10 +1163,9 @@ describe("records delete client error", () => {
1193
1163
  process.exitCode = undefined;
1194
1164
  });
1195
1165
 
1196
- it("should error when SDK connection fails on delete", async () => {
1197
- vi.mocked(createDataFabricClient).mockRejectedValue(
1198
- new Error("Not logged in"),
1199
- );
1166
+ it("should bail when SDK connection fails on delete", async () => {
1167
+ const sdk = mockSdk();
1168
+ vi.mocked(connectOrFail).mockResolvedValue(undefined);
1200
1169
  const program = buildProgram();
1201
1170
  await program.parseAsync([
1202
1171
  "node",
@@ -1206,13 +1175,8 @@ describe("records delete client error", () => {
1206
1175
  "entity-id",
1207
1176
  "rec-1",
1208
1177
  ]);
1209
- expect(OutputFormatter.error).toHaveBeenCalledWith(
1210
- expect.objectContaining({
1211
- Result: "Failure",
1212
- Message: "Error connecting to Data Fabric",
1213
- }),
1214
- );
1215
- expect(process.exitCode).toBe(1);
1178
+ expect(sdk.entities.deleteRecordsById).not.toHaveBeenCalled();
1179
+ expect(OutputFormatter.success).not.toHaveBeenCalled();
1216
1180
  });
1217
1181
  });
1218
1182
 
@@ -1305,13 +1269,14 @@ describe("records query", () => {
1305
1269
  process.exitCode = undefined;
1306
1270
  });
1307
1271
 
1308
- it("should query records without filters (no --body)", async () => {
1272
+ it("should query records without filters (no --body) and return raw shape", async () => {
1309
1273
  const sdk = mockSdk();
1310
- vi.mocked(sdk.entities.queryRecordsById).mockResolvedValue({
1274
+ const rawResult = {
1311
1275
  items: [{ Id: "rec-1", title: "test" }],
1312
1276
  totalCount: 1,
1313
1277
  hasNextPage: false,
1314
- });
1278
+ };
1279
+ vi.mocked(sdk.entities.queryRecordsById).mockResolvedValue(rawResult);
1315
1280
 
1316
1281
  const program = buildProgram();
1317
1282
  await program.parseAsync([
@@ -1330,10 +1295,7 @@ describe("records query", () => {
1330
1295
  expect.objectContaining({
1331
1296
  Result: "Success",
1332
1297
  Code: "RecordQuery",
1333
- Data: expect.objectContaining({
1334
- TotalCount: 1,
1335
- HasNextPage: false,
1336
- }),
1298
+ Data: rawResult,
1337
1299
  }),
1338
1300
  );
1339
1301
  });
@@ -1421,7 +1383,7 @@ describe("records query", () => {
1421
1383
  expect.objectContaining({
1422
1384
  Result: "Success",
1423
1385
  Code: "RecordQuery",
1424
- Data: expect.objectContaining({ TotalCount: 2 }),
1386
+ Data: expect.objectContaining({ totalCount: 2 }),
1425
1387
  }),
1426
1388
  );
1427
1389
  });
@@ -1470,8 +1432,8 @@ describe("records query", () => {
1470
1432
  Result: "Success",
1471
1433
  Code: "RecordQuery",
1472
1434
  Data: expect.objectContaining({
1473
- TotalCount: 2,
1474
- Records: [
1435
+ totalCount: 2,
1436
+ items: [
1475
1437
  { status: "Open", total: 12 },
1476
1438
  { status: "Closed", total: 5 },
1477
1439
  ],
@@ -1527,12 +1489,13 @@ describe("records query", () => {
1527
1489
 
1528
1490
  it("should pass custom --limit and --cursor to queryRecordsById", async () => {
1529
1491
  const sdk = mockSdk();
1530
- vi.mocked(sdk.entities.queryRecordsById).mockResolvedValue({
1492
+ const rawResult = {
1531
1493
  items: [{ Id: "rec-3" }],
1532
1494
  totalCount: 100,
1533
1495
  hasNextPage: true,
1534
- nextCursor: "next-cursor-xyz",
1535
- });
1496
+ nextCursor: { value: "next-cursor-xyz" },
1497
+ };
1498
+ vi.mocked(sdk.entities.queryRecordsById).mockResolvedValue(rawResult);
1536
1499
 
1537
1500
  const program = buildProgram();
1538
1501
  await program.parseAsync([
@@ -1556,10 +1519,7 @@ describe("records query", () => {
1556
1519
  );
1557
1520
  expect(OutputFormatter.success).toHaveBeenCalledWith(
1558
1521
  expect.objectContaining({
1559
- Data: expect.objectContaining({
1560
- HasNextPage: true,
1561
- NextCursor: "next-cursor-xyz",
1562
- }),
1522
+ Data: rawResult,
1563
1523
  }),
1564
1524
  );
1565
1525
  });
@@ -1627,10 +1587,9 @@ describe("records query", () => {
1627
1587
  expect(process.exitCode).toBe(1);
1628
1588
  });
1629
1589
 
1630
- it("should error when SDK connection fails on query", async () => {
1631
- vi.mocked(createDataFabricClient).mockRejectedValue(
1632
- new Error("Not logged in"),
1633
- );
1590
+ it("should bail when SDK connection fails on query", async () => {
1591
+ const sdk = mockSdk();
1592
+ vi.mocked(connectOrFail).mockResolvedValue(undefined);
1634
1593
  const program = buildProgram();
1635
1594
  await program.parseAsync([
1636
1595
  "node",
@@ -1639,13 +1598,8 @@ describe("records query", () => {
1639
1598
  "query",
1640
1599
  "entity-id",
1641
1600
  ]);
1642
- expect(OutputFormatter.error).toHaveBeenCalledWith(
1643
- expect.objectContaining({
1644
- Result: "Failure",
1645
- Message: "Error connecting to Data Fabric",
1646
- }),
1647
- );
1648
- expect(process.exitCode).toBe(1);
1601
+ expect(sdk.entities.queryRecordsById).not.toHaveBeenCalled();
1602
+ expect(OutputFormatter.success).not.toHaveBeenCalled();
1649
1603
  });
1650
1604
 
1651
1605
  it("should error when query API fails", async () => {
@@ -1877,10 +1831,9 @@ describe("records import", () => {
1877
1831
  expect(process.exitCode).toBe(1);
1878
1832
  });
1879
1833
 
1880
- it("should error when SDK connection fails on import", async () => {
1881
- vi.mocked(createDataFabricClient).mockRejectedValue(
1882
- new Error("Not logged in"),
1883
- );
1834
+ it("should bail when SDK connection fails on import", async () => {
1835
+ const sdk = mockSdk();
1836
+ vi.mocked(connectOrFail).mockResolvedValue(undefined);
1884
1837
 
1885
1838
  const { getFileSystem } = await import("@uipath/filesystem");
1886
1839
  vi.mocked(getFileSystem).mockReturnValue({
@@ -1900,13 +1853,8 @@ describe("records import", () => {
1900
1853
  "data.csv",
1901
1854
  ]);
1902
1855
 
1903
- expect(OutputFormatter.error).toHaveBeenCalledWith(
1904
- expect.objectContaining({
1905
- Result: "Failure",
1906
- Message: "Error connecting to Data Fabric",
1907
- }),
1908
- );
1909
- expect(process.exitCode).toBe(1);
1856
+ expect(sdk.entities.importRecordsById).not.toHaveBeenCalled();
1857
+ expect(OutputFormatter.success).not.toHaveBeenCalled();
1910
1858
  });
1911
1859
  });
1912
1860
 
@@ -1940,14 +1888,14 @@ describe("records query — pagination", () => {
1940
1888
  const call = vi.mocked(OutputFormatter.success).mock
1941
1889
  .calls[0][0] as unknown as {
1942
1890
  Data: {
1943
- TotalCount: number;
1944
- Records: unknown[];
1945
- HasNextPage: boolean;
1891
+ totalCount: number;
1892
+ items: unknown[];
1893
+ hasNextPage: boolean;
1946
1894
  };
1947
1895
  };
1948
- expect(call.Data.TotalCount).toBe(3);
1949
- expect(call.Data.Records).toHaveLength(3);
1950
- expect(call.Data.HasNextPage).toBe(false);
1896
+ expect(call.Data.totalCount).toBe(3);
1897
+ expect(call.Data.items).toHaveLength(3);
1898
+ expect(call.Data.hasNextPage).toBe(false);
1951
1899
  });
1952
1900
 
1953
1901
  it("should return first page with cursor when paginated", async () => {
@@ -1956,7 +1904,7 @@ describe("records query — pagination", () => {
1956
1904
  items: [{ Id: "r1" }, { Id: "r2" }],
1957
1905
  totalCount: 5,
1958
1906
  hasNextPage: true,
1959
- nextCursor: "cursor-page2",
1907
+ nextCursor: { value: "cursor-page2" },
1960
1908
  });
1961
1909
 
1962
1910
  const program = buildProgram();
@@ -1977,16 +1925,16 @@ describe("records query — pagination", () => {
1977
1925
  const call = vi.mocked(OutputFormatter.success).mock
1978
1926
  .calls[0][0] as unknown as {
1979
1927
  Data: {
1980
- TotalCount: number;
1981
- Records: unknown[];
1982
- HasNextPage: boolean;
1983
- NextCursor: string;
1928
+ totalCount: number;
1929
+ items: unknown[];
1930
+ hasNextPage: boolean;
1931
+ nextCursor: { value: string };
1984
1932
  };
1985
1933
  };
1986
- expect(call.Data.TotalCount).toBe(5);
1987
- expect(call.Data.Records).toHaveLength(2);
1988
- expect(call.Data.HasNextPage).toBe(true);
1989
- expect(call.Data.NextCursor).toBe("cursor-page2");
1934
+ expect(call.Data.totalCount).toBe(5);
1935
+ expect(call.Data.items).toHaveLength(2);
1936
+ expect(call.Data.hasNextPage).toBe(true);
1937
+ expect(call.Data.nextCursor).toEqual({ value: "cursor-page2" });
1990
1938
  });
1991
1939
 
1992
1940
  it("should pass cursor to second page request", async () => {
@@ -1995,7 +1943,7 @@ describe("records query — pagination", () => {
1995
1943
  items: [{ Id: "r3" }, { Id: "r4" }],
1996
1944
  totalCount: 5,
1997
1945
  hasNextPage: true,
1998
- nextCursor: "cursor-page3",
1946
+ nextCursor: { value: "cursor-page3" },
1999
1947
  });
2000
1948
 
2001
1949
  const program = buildProgram();
@@ -2021,8 +1969,8 @@ describe("records query — pagination", () => {
2021
1969
  expect(OutputFormatter.success).toHaveBeenCalledWith(
2022
1970
  expect.objectContaining({
2023
1971
  Data: expect.objectContaining({
2024
- HasNextPage: true,
2025
- NextCursor: "cursor-page3",
1972
+ hasNextPage: true,
1973
+ nextCursor: { value: "cursor-page3" },
2026
1974
  }),
2027
1975
  }),
2028
1976
  );
@@ -2034,7 +1982,7 @@ describe("records query — pagination", () => {
2034
1982
  items: [{ Id: "r1", status: "active" }],
2035
1983
  totalCount: 10,
2036
1984
  hasNextPage: true,
2037
- nextCursor: "cur-next",
1985
+ nextCursor: { value: "cur-next" },
2038
1986
  });
2039
1987
 
2040
1988
  const body = JSON.stringify({
@@ -2074,67 +2022,14 @@ describe("records query — pagination", () => {
2074
2022
  expect(OutputFormatter.success).toHaveBeenCalledWith(
2075
2023
  expect.objectContaining({
2076
2024
  Data: expect.objectContaining({
2077
- TotalCount: 10,
2078
- HasNextPage: true,
2079
- NextCursor: "cur-next",
2025
+ totalCount: 10,
2026
+ hasNextPage: true,
2027
+ nextCursor: { value: "cur-next" },
2080
2028
  }),
2081
2029
  }),
2082
2030
  );
2083
2031
  });
2084
2032
 
2085
- it("should omit NextCursor when hasNextPage is false", async () => {
2086
- const sdk = mockSdk();
2087
- vi.mocked(sdk.entities.queryRecordsById).mockResolvedValue({
2088
- items: [{ Id: "r1" }],
2089
- totalCount: 1,
2090
- hasNextPage: false,
2091
- });
2092
-
2093
- const program = buildProgram();
2094
- await program.parseAsync([
2095
- "node",
2096
- "test",
2097
- "records",
2098
- "query",
2099
- "entity-id",
2100
- ]);
2101
-
2102
- const call = vi.mocked(OutputFormatter.success).mock.calls[0][0] as {
2103
- Data: Record<string, unknown>;
2104
- };
2105
- expect(call.Data).not.toHaveProperty("NextCursor");
2106
- });
2107
-
2108
- it("should normalise cursor object {value} returned by SDK to a plain string", async () => {
2109
- const sdk = mockSdk();
2110
- // SDK may return PaginationCursor = { value: string } instead of a raw string
2111
- vi.mocked(sdk.entities.queryRecordsById).mockResolvedValue({
2112
- items: [{ Id: "r1" }, { Id: "r2" }],
2113
- totalCount: 4,
2114
- hasNextPage: true,
2115
- nextCursor: { value: "cursor-as-object" } as unknown as string,
2116
- });
2117
-
2118
- const program = buildProgram();
2119
- await program.parseAsync([
2120
- "node",
2121
- "test",
2122
- "records",
2123
- "query",
2124
- "entity-id",
2125
- "--limit",
2126
- "2",
2127
- ]);
2128
-
2129
- const call = vi.mocked(OutputFormatter.success).mock
2130
- .calls[0][0] as unknown as {
2131
- Data: { NextCursor: unknown };
2132
- };
2133
- // Must be a plain string, not the object
2134
- expect(typeof call.Data.NextCursor).toBe("string");
2135
- expect(call.Data.NextCursor).toBe("cursor-as-object");
2136
- });
2137
-
2138
2033
  it("should use default limit 50 when --cursor is given without --limit", async () => {
2139
2034
  const sdk = mockSdk();
2140
2035
  vi.mocked(sdk.entities.queryRecordsById).mockResolvedValue({
@@ -2240,14 +2135,14 @@ describe("records query — pagination", () => {
2240
2135
  expect(process.exitCode).toBe(1);
2241
2136
  });
2242
2137
 
2243
- it("should handle last page correctly no NextCursor even if SDK emits undefined", async () => {
2138
+ it("should pass cursor through on the last page and return the raw result", async () => {
2244
2139
  const sdk = mockSdk();
2245
- vi.mocked(sdk.entities.queryRecordsById).mockResolvedValue({
2140
+ const rawResult = {
2246
2141
  items: [{ Id: "r5" }],
2247
2142
  totalCount: 5,
2248
2143
  hasNextPage: false,
2249
- nextCursor: undefined,
2250
- });
2144
+ };
2145
+ vi.mocked(sdk.entities.queryRecordsById).mockResolvedValue(rawResult);
2251
2146
 
2252
2147
  const program = buildProgram();
2253
2148
  await program.parseAsync([
@@ -2269,11 +2164,11 @@ describe("records query — pagination", () => {
2269
2164
  cursor: { value: "cursor-page2" },
2270
2165
  }),
2271
2166
  );
2272
- const call = vi.mocked(OutputFormatter.success).mock.calls[0][0] as {
2273
- Data: Record<string, unknown>;
2274
- };
2275
- expect(call.Data.HasNextPage).toBe(false);
2276
- expect(call.Data).not.toHaveProperty("NextCursor");
2167
+ expect(OutputFormatter.success).toHaveBeenCalledWith(
2168
+ expect.objectContaining({
2169
+ Data: rawResult,
2170
+ }),
2171
+ );
2277
2172
  });
2278
2173
  });
2279
2174