feat: expand Data Fabric entities service [DS-8360]#1616
feat: expand Data Fabric entities service [DS-8360]#1616avichalsri24 wants to merge 4 commits intomainfrom
Conversation
Add single-record operations (insert/get/update/delete), structured query with filters/sort/expansions/aggregates/joins/binnings, file attachments (upload/download/delete), entity schema management (create/delete/update metadata), and CSV bulk import — sync and async variants for each. Existing batch methods now accept expansion_level and fail_on_first; list_records exposes OData filter/orderby/select/ expand and returns total_count / has_next_page / next_cursor. Batch operations now recover per-record failures from HTTP 400 responses that carry successRecords/failureRecords lists, so callers can handle unknown record ids gracefully instead of catching exceptions. Client-side validation rejects bad entity / field names (regex, length, reserved names) and per-type constraints (range checks, type-vs-constraint compatibility) before any HTTP call. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR expands the Data Fabric EntitiesService surface area by adding missing Data Fabric entity operations (single-record CRUD, structured query, attachments, schema management, bulk import) and by exposing more backend parameters/metadata on existing batch and list endpoints.
Changes:
- Added new Data Fabric APIs to
EntitiesService: single-record CRUD, structured query (V1/V2 routing), attachments, entity schema create/update/delete, and CSV bulk import (sync + async). - Extended existing record list/batch operations to support additional backend parameters and richer pagination metadata (
EntityRecordsListResponse), plus improved batch error recovery for per-record failures on HTTP 400. - Added/updated entity/query/schema models and comprehensive tests for the new behaviors.
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/uipath/uv.lock | Bumps editable uipath-platform version reference. |
| packages/uipath-platform/uv.lock | Bumps uipath-platform version to 0.1.47. |
| packages/uipath-platform/pyproject.toml | Version bump to 0.1.47. |
| packages/uipath-platform/src/uipath/platform/entities/entities.py | Adds new response/query/schema models (batch failure shape, list response w/ metadata, structured query types). |
| packages/uipath-platform/src/uipath/platform/entities/_entities_service.py | Implements the new/extended EntitiesService methods and request/response helpers. |
| packages/uipath-platform/src/uipath/platform/entities/init.py | Exposes the newly added entities/query/schema symbols via package exports. |
| packages/uipath-platform/tests/services/test_entities_service.py | Adds test coverage for new methods, query routing, attachments, schema creation defaults, and validation/error recovery. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if isinstance(metadata, EntityMetadataUpdateOptions): | ||
| body = metadata.model_dump(by_alias=True, exclude_none=True) | ||
| else: | ||
| body = dict(metadata) | ||
| return RequestSpec( |
There was a problem hiding this comment.
dict inputs now route through EntityMetadataUpdateOptions.model_validate(...) then model_dump(by_alias=True, exclude_none=True), so display_name/is_rbac_enabled get serialized as displayName/isRbacEnabled on the wire. New test test_update_entity_metadata_normalizes_snake_case_dict_keys locks this in.
| "fields": [self._build_schema_field_payload(f) for f in fields], | ||
| "folderId": opts.folder_key or DATA_FABRIC_TENANT_FOLDER_ID, | ||
| "isRbacEnabled": bool(opts.is_rbac_enabled or False), | ||
| "isInsightsEnabled": bool(opts.is_analytics_enabled or False), |
There was a problem hiding this comment.
is_analytics_enabled → isInsightsEnabled — added a one-line comment at the payload site explaining the legacy wire-name divergence.
| def __getitem__(self, index: int) -> EntityRecord: | ||
| """Index records by position (delegates to ``self.items``).""" | ||
| return self.items[index] |
There was a problem hiding this comment.
added @overload for int and slice on EntityQueryRecordsResponse, so slicing returns List[EntityRecord] and indexing returns EntityRecord with proper type narrowing.
| ) -> EntityRecordsListResponse: | ||
| """Asynchronously list records from an entity with optional pagination and schema validation. | ||
|
|
||
| The schema parameter enables type-safe access to entity records by validating the |
There was a problem hiding this comment.
docstring now mirrors the sync version: Args list includes expansion_level, filter, orderby, select, expand; Returns describes EntityRecordsListResponse with pagination metadata; Examples include an OData filter/orderby/select/expand sample.
- update_entity_metadata: dict inputs are now validated through EntityMetadataUpdateOptions so snake_case keys are converted to the camelCase API field names the backend expects (instead of being sent through unchanged and silently no-op'ing the update). - create_entity: comment the user-facing is_analytics_enabled option maps to the legacy backend field name isInsightsEnabled. - EntityQueryRecordsResponse.__getitem__: add @overload for int and slice so type checkers reflect actual delegation behaviour. - list_records_async: docstring Args / Returns now match the sync variant (new OData params, EntityRecordsListResponse return type). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🚨 Heads up:
|
| FileContent = Union[bytes, bytearray, memoryview] | ||
| """Acceptable raw bytes types for attachment/CSV uploads.""" | ||
|
|
||
| _NAME_RE = re.compile(r"^[a-zA-Z]\w*$") |
There was a problem hiding this comment.
Is this consistent with backend?
| ) | ||
|
|
||
| return self.validate_entity_batch(response, schema) | ||
| async def _do() -> Response: |
| ), | ||
| ) | ||
|
|
||
| def _query_records_spec( |
There was a problem hiding this comment.
!!! You are swapping out the query_records_spec which is catering to FQS query endpoint from DataService. This breaks multiple APIs for agents. Right strategy to avoid this is:
- Isolate the changes for schema into EntitySchemaService
- Isolate the changes for data into EntityDataService.
- EntityService is a facade that doesnt change the external contract.
- Carefully understand the APIs for DS and FQS and then make these changes.
Summary
Adds the missing Data Fabric methods on
EntitiesServiceand exposes the full backend parameter set on existing batch methods.New methods (sync + async):
insert_record,get_record,update_record,delete_record— fire trigger events on each mutation.query_records— structured query withfilter_group,sort_options,selected_fields,expansions,expansion_level,aggregates,group_by,joins,binnings,start,limit. Routes to V2 endpoint whenbinningsis supplied.upload_attachment(bytes or path),download_attachment,delete_attachment.create_entity(with full SQL-type mapping and per-type constraint defaults),delete_entity,update_entity_metadata.import_recordsfor CSV bulk upload.Existing methods extended:
insert_records/update_records/delete_recordsacceptexpansion_levelandfail_on_first.list_recordsaccepts ODatafilter/orderby/select/expand/expansion_leveland returnsEntityRecordsListResponse(alistsubclass withtotal_count/has_next_page/next_cursor).Bug fixes:
successRecords/failureRecordslists; other non-2xx statuses propagate.EntityRecord, or any object with__dict__.Validation:
Client-side checks reject bad entity / field names (regex, length, reserved names) and per-field constraints (type compatibility, value ranges) before any HTTP call.
Backward compatibility:
Public method signatures only gained optional kwargs.
EntityRecord.idstays required.list_recordsreturn type subclasseslist, so iteration / indexing /len()/isinstance(records, list)continue to work.Test plan
pytest packages/uipath-platform/tests/services/test_entities_service.py— 111 passpytest packages/uipath-platform/tests/— 1157 passpytest packages/uipath/tests/— 1840 passruff check,ruff format --check,mypy src tests,lint_httpx_client.py— clean🤖 Generated with Claude Code