Skip to content

Commit 1072ca7

Browse files
committed
fix: address data fabric access review comments
1 parent d5f4cad commit 1072ca7

11 files changed

Lines changed: 18 additions & 179 deletions

File tree

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ import { Cases, CaseInstances } from '@uipath/uipath-typescript/cases';
282282
import { Tasks, TaskType } from '@uipath/uipath-typescript/tasks';
283283
import { Processes } from '@uipath/uipath-typescript/processes';
284284
import { Buckets } from '@uipath/uipath-typescript/buckets';
285-
import { ChoiceSets, DataFabricDirectory, DataFabricRoles, Entities } from '@uipath/uipath-typescript/entities';
285+
import { ChoiceSets, Entities } from '@uipath/uipath-typescript/entities';
286286

287287
// Initialize SDK
288288
const sdk = new UiPath({ /* config */ });
@@ -297,8 +297,6 @@ const processes = new Processes(sdk);
297297
const buckets = new Buckets(sdk);
298298
const entities = new Entities(sdk);
299299
const choiceSets = new ChoiceSets(sdk);
300-
const dataFabricRoles = new DataFabricRoles(sdk);
301-
const dataFabricDirectory = new DataFabricDirectory(sdk);
302300

303301
// Maestro - Get processes and their instances
304302
const allProcesses = await maestroProcesses.getAll();

src/services/data-fabric/directory.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
} from '../../models/data-fabric/directory.types';
1515
import {
1616
DataFabricDirectoryAssignPayload,
17-
RawDataFabricDirectoryEntry,
1817
DataFabricDirectoryRevokePayload,
1918
RawDataFabricDirectoryListResponse,
2019
} from '../../models/data-fabric/directory.internal-types';
@@ -186,7 +185,7 @@ export class DataFabricDirectoryService extends BaseService implements DataFabri
186185
async list(options: DataFabricDirectoryListOptions = {}): Promise<DataFabricDirectoryListResponse> {
187186
const params = createParams({
188187
skip: options.skip,
189-
top: options.top ?? DEFAULT_DIRECTORY_PAGE_SIZE,
188+
top: clampDirectoryPageSize(options.top),
190189
});
191190
const response = await this.get<RawDataFabricDirectoryListResponse>(
192191
DATA_FABRIC_ENDPOINTS.DIRECTORY.GET_ALL,

src/utils/constants/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const CHOICESET_VALUES_PAGINATION = {
5656
TOTAL_COUNT_FIELD: 'totalRecordCount'
5757
};
5858

59+
/**
5960
* Bucket pagination constants for token-based pagination
6061
*/
6162
export const BUCKET_PAGINATION = {

src/utils/pagination/helpers.ts

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { createHeaders } from '../http/headers';
1111
import { FOLDER_ID } from '../constants/headers';
1212
import { ODATA_PREFIX, HTTP_METHODS } from '../constants/common';
1313
import { addPrefixToKeys } from '../transform';
14-
import { DEFAULT_ITEMS_FIELD, DEFAULT_PAGE_SIZE, DEFAULT_TOTAL_COUNT_FIELD } from './constants';
14+
import { DEFAULT_ITEMS_FIELD, DEFAULT_TOTAL_COUNT_FIELD } from './constants';
1515
import { filterUndefined, resolveNestedField } from '../object';
1616
import { decodeBase64 } from '../encoding/base64';
1717

@@ -364,41 +364,4 @@ export class PaginationHelpers {
364364
}
365365
}) as any;
366366
}
367-
368-
/**
369-
* Fetches every page for offset/token paginated APIs and returns a flat item array.
370-
*
371-
* Use this when a service must preserve an array-returning `getAll()` surface
372-
* but the backend endpoint only exposes paginated responses.
373-
*
374-
* @param config - Configuration for the paginated operation
375-
* @param options - Request options including pageSize and non-pagination filters
376-
* @returns Promise resolving to all transformed items
377-
*/
378-
static async getAllPages<TOptions extends Record<string, unknown>, TRaw, TTransformed = TRaw>(
379-
config: GetAllConfig<TRaw, TTransformed>,
380-
options: TOptions & { pageSize?: number } = {} as TOptions & { pageSize?: number }
381-
): Promise<TTransformed[]> {
382-
const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE;
383-
const items: TTransformed[] = [];
384-
let cursor: PaginationCursor | undefined;
385-
let hasNextPage = true;
386-
387-
while (hasNextPage) {
388-
const pageOptions = cursor
389-
? { ...options, pageSize, cursor }
390-
: { ...options, pageSize };
391-
const page = await PaginationHelpers.getAll<
392-
TOptions & { pageSize: number; cursor?: PaginationCursor },
393-
TRaw,
394-
TTransformed
395-
>(config, pageOptions) as PaginatedResponse<TTransformed>;
396-
397-
items.push(...page.items);
398-
hasNextPage = page.hasNextPage;
399-
cursor = page.nextCursor;
400-
}
401-
402-
return items;
403-
}
404367
}

tests/.env.integration.example

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,6 @@ INTEGRATION_TEST_FOLDER_ID=
3737
# Requires DataFabric.Data.Read and DataFabric.Data.Write on the configured token/app.
3838
DATA_FABRIC_ACCESS_INTEGRATION=false
3939

40-
# Enable Agent Feedback integration tests.
41-
# Requires feedback API access on the configured token/app.
42-
AGENT_FEEDBACK_INTEGRATION=false
43-
44-
# Enable Observability Traces integration tests.
45-
# Requires traces API access and a pre-existing trace ID.
46-
TRACES_INTEGRATION=false
47-
TRACES_TEST_TRACE_ID=
48-
4940
# Folder key (GUID) matching INTEGRATION_TEST_FOLDER_ID
5041
# Used by getByName integration tests for assets/processes
5142
INTEGRATION_TEST_FOLDER_KEY=

tests/integration/README.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,11 @@ tests/integration/
9898
INTEGRATION_TEST_SKIP_CLEANUP=false
9999
INTEGRATION_TEST_FOLDER_ID=
100100
DATA_FABRIC_ACCESS_INTEGRATION=false
101-
AGENT_FEEDBACK_INTEGRATION=false
102-
TRACES_INTEGRATION=false
103101
104102
# Optional: Pre-existing Test Data
105103
MAESTRO_TEST_PROCESS_KEY=
106104
ORCHESTRATOR_TEST_PROCESS_KEY=
107105
DATA_FABRIC_TEST_ENTITY_ID=
108-
TRACES_TEST_TRACE_ID=
109106
```
110107

111108
### 4. Install Dependencies
@@ -166,24 +163,6 @@ prepared for access-management validation:
166163
DATA_FABRIC_ACCESS_INTEGRATION=true npm run test:integration -- tests/integration/shared/data-fabric/access.integration.test.ts
167164
```
168165

169-
### Run Optional Agent Feedback Tests
170-
171-
Agent Feedback integration tests are opt-in because they require feedback API
172-
authorization on the configured external app/PAT:
173-
174-
```bash
175-
AGENT_FEEDBACK_INTEGRATION=true npm run test:integration -- tests/integration/shared/agents/feedback.integration.test.ts
176-
```
177-
178-
### Run Optional Observability Traces Tests
179-
180-
Observability Traces integration tests are opt-in because they require traces API
181-
authorization and a pre-existing trace ID:
182-
183-
```bash
184-
TRACES_INTEGRATION=true TRACES_TEST_TRACE_ID=<trace-id> npm run test:integration -- tests/integration/shared/observability/traces.integration.test.ts
185-
```
186-
187166
### Watch Mode
188167

189168
```bash
@@ -267,9 +246,6 @@ Tests skip gracefully when:
267246
| `INTEGRATION_TEST_SKIP_CLEANUP` | Skip cleanup after tests (useful for debugging) | `false` |
268247
| `INTEGRATION_TEST_FOLDER_ID` | Default folder ID for tests | (uses default folder) |
269248
| `DATA_FABRIC_ACCESS_INTEGRATION` | Enable opt-in Data Fabric role and directory access tests | `false` |
270-
| `AGENT_FEEDBACK_INTEGRATION` | Enable opt-in Agent Feedback tests requiring feedback API access | `false` |
271-
| `TRACES_INTEGRATION` | Enable opt-in Observability Traces tests requiring traces API access | `false` |
272-
| `TRACES_TEST_TRACE_ID` | Pre-existing trace ID for Observability Traces tests | (required when `TRACES_INTEGRATION=true`) |
273249
| `MAESTRO_TEST_PROCESS_KEY` | Pre-existing Maestro process for read-only tests | (optional) |
274250
| `ORCHESTRATOR_TEST_PROCESS_KEY` | Pre-existing Orchestrator process for start tests | (optional) |
275251
| `DATA_FABRIC_TEST_ENTITY_ID` | Pre-existing Data Fabric entity for record tests | (optional) |

tests/integration/shared/agents/feedback.integration.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,12 @@ import { registerResource } from '../../utils/cleanup';
66
import { generateRandomString } from '../../utils/helpers';
77

88
const modes: InitMode[] = ['v1'];
9-
const hasAgentFeedbackIntegration = process.env.AGENT_FEEDBACK_INTEGRATION === 'true';
109

1110
describe.each(modes)('Agent Feedback - Integration Tests [%s]', (mode) => {
1211
setupUnifiedTests(mode);
1312

1413
let feedback: Feedback;
1514

16-
beforeAll(() => {
17-
if (!hasAgentFeedbackIntegration) {
18-
throw new Error(
19-
'AGENT_FEEDBACK_INTEGRATION must be set to run Agent Feedback integration tests ' +
20-
'(requires feedback API access on the configured external app/PAT)'
21-
);
22-
}
23-
});
24-
2515
beforeEach(() => {
2616
feedback = getServices().feedback!;
2717
});

tests/integration/shared/observability/traces.integration.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
} from '../../../../src/models/observability/traces/traces.types';
88

99
const modes: InitMode[] = ['v1'];
10-
const hasTracesIntegration = process.env.TRACES_INTEGRATION === 'true';
1110

1211
describe.each(modes)('Traces - Integration Tests [%s]', (mode) => {
1312
setupUnifiedTests(mode);
@@ -17,13 +16,6 @@ describe.each(modes)('Traces - Integration Tests [%s]', (mode) => {
1716
let existingSpanId!: string;
1817

1918
beforeAll(async () => {
20-
if (!hasTracesIntegration) {
21-
throw new Error(
22-
'TRACES_INTEGRATION must be set to run Traces integration tests ' +
23-
'(requires traces API access and a pre-existing trace ID)'
24-
);
25-
}
26-
2719
if (!process.env.TRACES_TEST_TRACE_ID) {
2820
throw new Error('TRACES_TEST_TRACE_ID env var required for Traces integration tests');
2921
}

tests/unit/services/data-fabric/directory.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ describe('DataFabricDirectoryService Unit Tests', () => {
9393
});
9494
});
9595

96+
it('should clamp top to the maximum directory page size', async () => {
97+
mockApiClient.get.mockResolvedValue({ totalCount: 0, results: [] });
98+
99+
await directoryService.list({ top: 500 });
100+
101+
expect(mockApiClient.get).toHaveBeenCalledWith(
102+
DATA_FABRIC_ENDPOINTS.DIRECTORY.GET_ALL,
103+
{ params: { top: 100 } }
104+
);
105+
});
106+
96107
it('should reject invalid directory response formats', async () => {
97108
mockApiClient.get.mockResolvedValue({ value: [] });
98109

tests/unit/utils/pagination/helpers.test.ts

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// ===== IMPORTS =====
22
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
33
import { PaginationHelpers } from '../../../../src/utils/pagination/helpers';
4-
import { PaginationType } from '../../../../src/utils/pagination/internal-types';
5-
import type { GetAllConfig, PaginationServiceAccess } from '../../../../src/utils/pagination/internal-types';
4+
import { PaginationServiceAccess, PaginationType } from '../../../../src/utils/pagination/internal-types';
65
import { PaginationCursor, PaginationOptions } from '../../../../src/utils/pagination/types';
76
import { encodeBase64 } from '../../../../src/utils/encoding/base64';
87
import { TEST_CONSTANTS, PAGINATION_TEST_CONSTANTS } from '../../../utils/constants';
@@ -23,9 +22,6 @@ import {
2322
import { DEFAULT_TOTAL_COUNT_FIELD, DEFAULT_ITEMS_FIELD } from '../../../../src/utils/pagination/constants';
2423
import { FOLDER_ID } from '../../../../src/utils/constants/headers';
2524

26-
type MockRawItem = ReturnType<typeof createMockRawItem>;
27-
type MockTransformedItem = ReturnType<typeof createMockTransformedItem>;
28-
2925
// ===== TEST SUITE =====
3026
describe('PaginationHelpers Unit Tests', () => {
3127
afterEach(() => {
@@ -936,73 +932,4 @@ describe('PaginationHelpers Unit Tests', () => {
936932
});
937933
});
938934
});
939-
940-
describe('getAllPages', () => {
941-
let mockServiceAccess: PaginationServiceAccess;
942-
let mockConfig: GetAllConfig<MockRawItem, MockTransformedItem>;
943-
944-
beforeEach(() => {
945-
mockServiceAccess = createMockPaginationServiceAccess();
946-
mockConfig = {
947-
serviceAccess: mockServiceAccess,
948-
getEndpoint: () => PAGINATION_TEST_CONSTANTS.ENDPOINT_API_ITEMS,
949-
transformFn: mockTransformFunction,
950-
pagination: {
951-
paginationType: PaginationType.OFFSET,
952-
itemsField: DEFAULT_ITEMS_FIELD,
953-
totalCountField: DEFAULT_TOTAL_COUNT_FIELD
954-
}
955-
};
956-
});
957-
958-
it('should follow cursors and return a flattened item array', async () => {
959-
const nextCursor = createMockPaginationCursor();
960-
const firstRawItem = createMockRawItem(PAGINATION_TEST_CONSTANTS.ITEM_ID_1, PAGINATION_TEST_CONSTANTS.ITEM_NAME_1);
961-
const secondRawItem = createMockRawItem(PAGINATION_TEST_CONSTANTS.ITEM_ID_2, PAGINATION_TEST_CONSTANTS.ITEM_NAME_2);
962-
const firstTransformedItem = createMockTransformedItem(PAGINATION_TEST_CONSTANTS.ITEM_ID_1, PAGINATION_TEST_CONSTANTS.ITEM_NAME_1);
963-
const secondTransformedItem = createMockTransformedItem(PAGINATION_TEST_CONSTANTS.ITEM_ID_2, PAGINATION_TEST_CONSTANTS.ITEM_NAME_2);
964-
965-
vi.mocked(mockServiceAccess.requestWithPagination)
966-
.mockResolvedValueOnce(createMockPaginatedResponse([firstRawItem], {
967-
hasNextPage: true,
968-
nextCursor
969-
}))
970-
.mockResolvedValueOnce(createMockPaginatedResponse([secondRawItem], {
971-
hasNextPage: false
972-
}));
973-
974-
const result = await PaginationHelpers.getAllPages<
975-
{ pageSize?: number },
976-
MockRawItem,
977-
MockTransformedItem
978-
>(mockConfig, {
979-
pageSize: PAGINATION_TEST_CONSTANTS.PAGE_SIZE
980-
});
981-
982-
expect(result).toEqual([firstTransformedItem, secondTransformedItem]);
983-
expect(mockServiceAccess.requestWithPagination).toHaveBeenNthCalledWith(
984-
1,
985-
'GET',
986-
PAGINATION_TEST_CONSTANTS.ENDPOINT_API_ITEMS,
987-
{ pageSize: PAGINATION_TEST_CONSTANTS.PAGE_SIZE },
988-
expect.any(Object)
989-
);
990-
expect(mockServiceAccess.requestWithPagination).toHaveBeenNthCalledWith(
991-
2,
992-
'GET',
993-
PAGINATION_TEST_CONSTANTS.ENDPOINT_API_ITEMS,
994-
{ pageSize: PAGINATION_TEST_CONSTANTS.PAGE_SIZE, cursor: nextCursor },
995-
expect.any(Object)
996-
);
997-
});
998-
999-
it('should propagate errors from the underlying paginated call', async () => {
1000-
vi.mocked(mockServiceAccess.requestWithPagination)
1001-
.mockRejectedValue(new Error(TEST_CONSTANTS.ERROR_MESSAGE));
1002-
1003-
await expect(PaginationHelpers.getAllPages(mockConfig, {
1004-
pageSize: PAGINATION_TEST_CONSTANTS.PAGE_SIZE
1005-
})).rejects.toThrow(TEST_CONSTANTS.ERROR_MESSAGE);
1006-
});
1007-
});
1008935
});

0 commit comments

Comments
 (0)