import { IUiPath } from '../core/index'; /** * Simplified universal pagination cursor * Used to fetch next/previous pages */ interface PaginationCursor { /** Opaque string containing all information needed to fetch next page */ value: string; } /** * Discriminated union for pagination methods - ensures cursor and jumpToPage are mutually exclusive */ type PaginationMethodUnion = { cursor?: PaginationCursor; jumpToPage?: never; } | { cursor?: never; jumpToPage?: number; } | { cursor?: never; jumpToPage?: never; }; /** * Pagination options. Users cannot specify both cursor and jumpToPage. */ type PaginationOptions = { /** Size of the page to fetch (items per page) */ pageSize?: number; } & PaginationMethodUnion; /** * Paginated response containing items and navigation information */ interface PaginatedResponse { /** The items in the current page */ items: T[]; /** Total count of items across all pages (if available) */ totalCount?: number; /** Whether more pages are available */ hasNextPage: boolean; /** Cursor to fetch the next page (if available) */ nextCursor?: PaginationCursor; /** Cursor to fetch the previous page (if available) */ previousCursor?: PaginationCursor; /** Current page number (1-based, if available) */ currentPage?: number; /** Total number of pages (if available) */ totalPages?: number; /** Whether this pagination type supports jumping to arbitrary pages */ supportsPageJump: boolean; } /** * Response for non-paginated calls that includes both data and total count */ interface NonPaginatedResponse { items: T[]; totalCount?: number; } /** * Helper type for defining paginated method overloads * Creates a union type of all ways pagination can be triggered */ type HasPaginationOptions = (T & { pageSize: number; }) | (T & { cursor: PaginationCursor; }) | (T & { jumpToPage: number; }); /** * Pagination types supported by the SDK */ declare enum PaginationType { OFFSET = "offset", TOKEN = "token" } /** * Interface for service access methods needed by pagination helpers */ interface PaginationServiceAccess { get(path: string, options?: any): Promise<{ data: T; }>; post(path: string, body?: any, options?: any): Promise<{ data: T; }>; requestWithPagination(method: string, path: string, paginationOptions: PaginationOptions, options: RequestWithPaginationOptions): Promise>; } /** * Field names for extracting data from paginated responses. */ interface PaginationFieldNames { itemsField?: string; totalCountField?: string; continuationTokenField?: string; } /** * Options for the requestWithPagination method in BaseService. */ interface RequestWithPaginationOptions extends RequestSpec { pagination: PaginationFieldNames & { paginationType: PaginationType; paginationParams?: { pageSizeParam?: string; offsetParam?: string; tokenParam?: string; countParam?: string; convertToSkip?: boolean; zeroBased?: boolean; }; }; } /** * HTTP methods supported by the API client */ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS'; /** * Supported response types for API requests */ type ResponseType = 'json' | 'text' | 'blob' | 'arraybuffer' | 'stream'; /** * Query parameters type with support for arrays and nested objects */ type QueryParams = Record | null | undefined>; /** * Standard HTTP headers type */ type Headers = Record; /** * Options for request retries */ interface RetryOptions { /** Maximum number of retry attempts */ maxRetries?: number; /** Base delay between retries in milliseconds */ retryDelay?: number; /** Whether to use exponential backoff */ useExponentialBackoff?: boolean; /** Status codes that should trigger a retry */ retryableStatusCodes?: number[]; } /** * Options for request timeouts */ interface TimeoutOptions { /** Request timeout in milliseconds */ timeout?: number; /** Whether to abort the request on timeout */ abortOnTimeout?: boolean; } /** * Options for request body transformation */ interface BodyOptions { /** Whether to stringify the body */ stringify?: boolean; /** Content type override */ contentType?: string; } /** * Pagination metadata for API requests */ interface PaginationMetadata { /** Type of pagination used by the API endpoint */ paginationType: PaginationType; /** Response field containing items array (defaults to 'value') */ itemsField?: string; /** Response field containing total count (defaults to '@odata.count') */ totalCountField?: string; /** Response field containing continuation token (defaults to 'continuationToken') */ continuationTokenField?: string; } /** * Base interface for all API requests */ interface RequestSpec { /** HTTP method for the request */ method?: HttpMethod; /** URL endpoint for the request */ url?: string; /** Query parameters to be appended to the URL */ params?: QueryParams; /** HTTP headers to include with the request */ headers?: Headers; /** Raw body content (takes precedence over data) */ body?: unknown; /** Expected response type */ responseType?: ResponseType; /** Request timeout options */ timeoutOptions?: TimeoutOptions; /** Retry behavior options */ retryOptions?: RetryOptions; /** Body transformation options */ bodyOptions?: BodyOptions; /** AbortSignal for cancelling the request */ signal?: AbortSignal; /** Pagination metadata for the request */ pagination?: PaginationMetadata; } interface ApiResponse { data: T; } /** * Base class for all UiPath SDK services. * * Provides common functionality for authentication, configuration, and API communication. * All service classes extend this base to inherit dependency injection and HTTP client access. * * This class implements the dependency injection pattern where services receive a configured * UiPath instance. The ApiClient is created internally and handles all HTTP operations * including authentication token management. * * @remarks * Service classes should extend this base and call `super(uiPath)` in their constructor. * Protected HTTP methods (get, post, put, patch, delete) are available to all subclasses. * */ declare class BaseService { #private; /** * SDK configuration (read-only). Available to subclasses so they can * fall back to init-time defaults like `folderKey`. */ protected readonly config: { folderKey?: string; }; /** * Creates a base service instance with dependency injection. * * Extracts configuration, execution context, and token manager from the UiPath instance * to initialize an authenticated API client. The ApiClient handles all HTTP operations * and token management internally. * * @param instance - UiPath SDK instance providing authentication and configuration. * Services receive this via dependency injection in the modular pattern. * @param headers - Optional default headers to include in every request (e.g. `x-uipath-external-user-id` for * CAS external-app auth) * * @example * ```typescript * // Services automatically call this via super() * export class EntityService extends BaseService { * constructor(instance: IUiPath) { * super(instance); // Initializes the internal ApiClient * } * } * * // Usage in modular pattern * import { UiPath } from '@uipath/uipath-typescript/core'; * import { Entities } from '@uipath/uipath-typescript/entities'; * * const sdk = new UiPath(config); * await sdk.initialize(); * const entities = new Entities(sdk); * ``` */ constructor(instance: IUiPath, headers?: Record); /** * Gets a valid authentication token, refreshing if necessary. * Use this when you need to manually add Authorization headers (e.g., direct uploads). * * @returns Promise resolving to a valid access token string * @throws AuthenticationError if no token is available or refresh fails */ protected getValidAuthToken(): Promise; /** * Creates a service accessor for pagination helpers * This allows pagination helpers to access protected methods without making them public */ protected createPaginationServiceAccess(): PaginationServiceAccess; protected request(method: string, path: string, options?: RequestSpec): Promise>; protected requestWithSpec(spec: RequestSpec): Promise>; protected get(path: string, options?: RequestSpec): Promise>; protected post(path: string, data?: unknown, options?: RequestSpec): Promise>; protected put(path: string, data?: unknown, options?: RequestSpec): Promise>; protected patch(path: string, data?: unknown, options?: RequestSpec): Promise>; protected delete(path: string, options?: RequestSpec): Promise>; /** * Execute a request with cursor-based pagination */ protected requestWithPagination(method: string, path: string, paginationOptions: PaginationOptions, options: RequestWithPaginationOptions): Promise>; /** * Validates and prepares pagination parameters from options */ private validateAndPreparePaginationParams; /** * Prepares request parameters for pagination based on pagination type */ private preparePaginationRequestParams; /** * Creates a paginated response from API response */ private createPaginatedResponseFromResponse; /** * Determines if there are more pages based on pagination type and metadata */ private determineHasMorePages; } /** * Shared types for the Data Fabric domain — used by both Entities and ChoiceSets. * Lives here (not in either service's `*.types.ts`) to avoid cross-domain coupling * between sibling services. */ /** * Common shape for every folder-scoped Data Fabric operation. * Forwarded on the wire as the `X-UIPATH-FolderKey` header. */ interface EntityFolderScopedOptions { /** * Key identifying the folder the entity belongs to. Omit for tenant-level entities. * * @experimental Folder-scoped Data Fabric is in preview — the contract may change. */ folderKey?: string; } /** * Entity field data type names (SQL-level types returned by the API) */ declare enum EntityFieldDataType { UUID = "UUID", STRING = "STRING", INTEGER = "INTEGER", DATETIME = "DATETIME", DATETIME_WITH_TZ = "DATETIME_WITH_TZ", DECIMAL = "DECIMAL", FLOAT = "FLOAT", DOUBLE = "DOUBLE", DATE = "DATE", BOOLEAN = "BOOLEAN", BIG_INTEGER = "BIG_INTEGER", MULTILINE_TEXT = "MULTILINE_TEXT", /** * Large multi-line text (up to 128 KB). Unlike {@link MULTILINE_TEXT}, the full * value is lazy-loaded: list/query operations return a size marker * (e.g. `"HasValue=true Length=512"`) instead of the content; reading a single * record by ID returns the full value. */ MULTILINE_MAX = "MULTILINE_MAX", FILE = "FILE", CHOICE_SET_SINGLE = "CHOICE_SET_SINGLE", CHOICE_SET_MULTIPLE = "CHOICE_SET_MULTIPLE", AUTO_NUMBER = "AUTO_NUMBER", RELATIONSHIP = "RELATIONSHIP" } /** * Represents a single entity record */ interface EntityRecord { /** * Unique identifier for the record */ Id: string; /** * Additional dynamic fields for the entity */ [key: string]: any; } /** * Options for getting an entity by Id * @deprecated Use {@link EntityGetRecordByIdOptions} instead for better clarity on getting all records of an entity. This type will be removed in future versions. */ type EntityGetRecordsByIdOptions = { /** Level of entity expansion (default: 0) */ expansionLevel?: number; } & PaginationOptions & EntityFolderScopedOptions; /** * Options for getting all records of an entity */ type EntityGetAllRecordsOptions = EntityGetRecordsByIdOptions; /** * Options for getting a single entity record by entity ID and record ID */ interface EntityGetRecordByIdOptions extends EntityFolderScopedOptions { /** Level of entity expansion (default: 0) */ expansionLevel?: number; } /** * Common options for entity operations that modify multiple records */ interface EntityOperationOptions extends EntityFolderScopedOptions { /** Level of entity expansion (default: 0) */ expansionLevel?: number; /** Whether to fail on first error (default: false) */ failOnFirst?: boolean; } /** * Options for inserting a single record into an entity * @deprecated Use {@link EntityInsertRecordOptions} instead for better clarity on inserting a single record into an entity. This type will be removed in future versions. */ interface EntityInsertOptions extends EntityFolderScopedOptions { /** Level of entity expansion (default: 0) */ expansionLevel?: number; } /** * Options for inserting a single record into an entity */ interface EntityInsertRecordOptions extends EntityInsertOptions { } /** * Options for batch inserting data into an entity * @deprecated Use {@link EntityInsertRecordsOptions} instead for better clarity on inserting multiple records into an entity. This type will be removed in future versions. */ interface EntityBatchInsertOptions extends EntityOperationOptions { } /** * Options for inserting multiple records into an entity */ interface EntityInsertRecordsOptions extends EntityOperationOptions { } /** * Options for updating a single record in an entity */ interface EntityUpdateRecordOptions extends EntityGetRecordByIdOptions { } /** * Options for updating data in an entity * @deprecated Use {@link EntityUpdateRecordsOptions} instead for better clarity on updating records in an entity. This type will be removed in future versions. */ interface EntityUpdateOptions extends EntityOperationOptions { } /** * Options for updating data in an entity */ interface EntityUpdateRecordsOptions extends EntityOperationOptions { } /** * Options for deleting data from an entity * @deprecated Use {@link EntityDeleteRecordsOptions} instead for better clarity on deleting records from an entity. This type will be removed in future versions. */ interface EntityDeleteOptions extends EntityFolderScopedOptions { /** Whether to fail on first error (default: false) */ failOnFirst?: boolean; } /** * Options for deleting records in an entity */ interface EntityDeleteRecordsOptions extends EntityDeleteOptions { } interface EntityDeleteRecordByIdOptions extends EntityFolderScopedOptions { } interface EntityImportRecordsByIdOptions extends EntityFolderScopedOptions { } /** * Logical operator for combining query filter groups */ declare enum LogicalOperator { /** Combine conditions with AND — all conditions must match */ And = 0, /** Combine conditions with OR — any condition must match */ Or = 1 } /** * Comparison operators for entity query filters. * Not all operators are valid for all field types. */ declare enum QueryFilterOperator { Equals = "=", NotEquals = "!=", GreaterThan = ">", LessThan = "<", GreaterThanOrEqual = ">=", LessThanOrEqual = "<=", Contains = "contains", NotContains = "not contains", StartsWith = "startswith", EndsWith = "endswith", In = "in", NotIn = "not in" } /** * A single filter condition for querying entity records * * Values are always strings. For numeric or boolean fields, pass the string representation * (e.g., `"42"`, `"true"`). For `In` / `NotIn` operators, use {@link valueList} instead of `value`. */ interface EntityQueryFilter { /** Name of the field to filter on */ fieldName: string; /** Comparison operator */ operator: QueryFilterOperator; /** Value to compare against (always a string; omit when using `valueList`) */ value?: string; /** List of values for `in` / `not in` operators */ valueList?: string[]; } /** * A group of query filters combined with a logical operator */ interface EntityQueryFilterGroup { /** Logical operator applied between filters in `queryFilters` (default: AND) */ logicalOperator?: LogicalOperator; /** Logical operator applied between sibling filter groups (default: AND) */ continueLogicalOperator?: LogicalOperator; /** Array of filter conditions */ queryFilters?: EntityQueryFilter[]; /** Nested filter groups for complex boolean expressions */ filterGroups?: EntityQueryFilterGroup[]; } /** * Sort option for query results */ interface EntityQuerySortOption { /** Name of the field to sort by */ fieldName: string; /** Whether to sort in descending order (default: false) */ isDescending?: boolean; } /** * Aggregate functions supported by the Data Fabric query API. */ declare enum EntityAggregateFunction { Count = "COUNT", Sum = "SUM", Avg = "AVG", Min = "MIN", Max = "MAX" } /** * A single aggregate expression to apply during a query. * * Aggregate results are returned as fields on each item in the response, * keyed by `alias` when provided. */ interface EntityAggregate { /** Aggregate function to apply */ function: EntityAggregateFunction; /** Field to aggregate on. For `COUNT`, any non-null field works (typically `Id`). */ field: string; /** Optional alias for the aggregate result column. */ alias?: string; } /** * A single cross-entity JOIN clause for a structured query. * * A join pulls related records together by matching a field on the base (left) * entity (`joinFieldName`) to a field on a related (right) entity * (`relatedFieldName`). Pass one {@link EntityJoin} per related entity; supplying * several composes a multi-entity (multi-join) query. Up to 3 joins are * supported (the SDK throws a `ValidationError` for more), and all of them * must share the same {@link JoinType}. * * @example * ```typescript * import { EntityJoin, JoinType } from '@uipath/uipath-typescript/entities'; * * const join: EntityJoin = { * entityName: "Order", * joinType: JoinType.LeftJoin, * joinFieldName: "customerId", * relatedEntityName: "Customer", * relatedFieldName: "Id", * }; * ``` */ interface EntityJoin { /** Name of the base (left) entity that owns `joinFieldName`. Defaults to the queried entity; set it to anchor chained joins. */ entityName?: string; /** Join type to apply (default: {@link JoinType.LeftJoin}). */ joinType?: JoinType; /** Field on the base entity used as the join key. */ joinFieldName: string; /** Name of the related (right) entity to join in. */ relatedEntityName: string; /** Field on `relatedEntityName` matched against `joinFieldName`. */ relatedFieldName: string; } /** * Options for querying entity records with filters, sorting, aggregates, and pagination. * * Use `pageSize`, `cursor`, or `jumpToPage` for SDK-managed pagination. * The SDK computes and manages offset parameters automatically. */ type EntityQueryRecordsOptions = { /** Filter conditions to apply */ filterGroup?: EntityQueryFilterGroup; /** List of field names to include in results (returns all fields if omitted) */ selectedFields?: string[]; /** Sort options for the results */ sortOptions?: EntityQuerySortOption[]; /** Level of entity expansion for related fields (default: 0) */ expansionLevel?: number; /** Aggregate expressions (COUNT, SUM, AVG, MIN, MAX) to apply across the result set. */ aggregates?: EntityAggregate[]; /** Field names to group aggregate results by. */ groupBy?: string[]; /** * Cross-entity joins. Each entry joins one related entity into the query; * supply several for a multi-join query. A maximum of 3 joins is supported * (the SDK throws a `ValidationError` for more), and all joins must be of * the same {@link JoinType}. */ joins?: EntityJoin[]; } & PaginationOptions & EntityFolderScopedOptions; /** * Response from querying entity records */ interface EntityQueryRecordsResponse { /** Array of matching entity records */ items: EntityRecord[]; /** Total number of records matching the filter (before pagination) */ totalCount: number; } /** * Common field properties shared across field definition and update types */ interface EntityFieldBase { /** Human-readable display name shown in the UI (defaults to `name` if omitted) */ displayName?: string; /** Optional field description */ description?: string; /** Whether the field is required (default: false) */ isRequired?: boolean; /** Whether the field value must be unique across records (default: false) */ isUnique?: boolean; /** Whether role-based access control is enabled for this field (default: false) */ isRbacEnabled?: boolean; /** Whether the field value is encrypted at rest (default: false) */ isEncrypted?: boolean; /** Whether the field is hidden from the UI (default: false) */ isHiddenField?: boolean; /** Default value for the field */ defaultValue?: string; /** Maximum character length for STRING fields (default: 200, range: 1–4000) and MULTILINE_TEXT fields (default: 200, range: 1–10000). */ lengthLimit?: number; /** Maximum allowed value for numeric fields (INTEGER, BIG_INTEGER, FLOAT, DOUBLE, DECIMAL — default: 1,000,000,000,000; range: ±9,007,199,254,740,991) */ maxValue?: number; /** Minimum allowed value for numeric fields (INTEGER, BIG_INTEGER, FLOAT, DOUBLE, DECIMAL — default: -1,000,000,000,000; range: ±9,007,199,254,740,991) */ minValue?: number; /** Number of decimal places for DECIMAL, FLOAT, and DOUBLE fields (default: 2, range: 0–10) */ decimalPrecision?: number; } /** * User-facing field definition for creating or updating entity schemas */ interface EntityCreateFieldOptions extends EntityFieldBase { /** * Field name — must start with a letter and contain only * letters, numbers, and underscores (e.g., `"productName"`). */ fieldName: string; /** Field data type — one of the {@link EntityFieldDataType} values (default: STRING) */ type?: EntityFieldDataType; /** Choice set ID for choice-set fields */ choiceSetId?: string; /** UUID of the referenced entity (required when `type` is `RELATIONSHIP`; ignored for `FILE`). */ referenceEntityId?: string; /** UUID of the referenced field on the target entity (required when `type` is `RELATIONSHIP`; ignored for `FILE`). */ referenceFieldId?: string; /** * Folder key of the reference target when it lives outside the source's folder. Pass `'00000000-0000-0000-0000-000000000000'` for tenant-level system targets. * * @experimental Folder-scoped Data Fabric is in preview — the contract may change. */ referenceFolderKey?: string; } interface EntityGetAllOptions extends EntityFolderScopedOptions { /** * When `true`, returns tenant-level and folder-level entities together. * Omit (or `false`, the default) to return only tenant-level entities. * Ignored when `folderKey` is provided — `folderKey` is preferred over `includeFolderEntities` when both are set. * * @experimental Folder-scoped Data Fabric is in preview — the contract may change. */ includeFolderEntities?: boolean; } interface EntityGetByIdOptions extends EntityFolderScopedOptions { } interface EntityDeleteByIdOptions extends EntityFolderScopedOptions { } /** * Options for creating a new Data Fabric entity */ interface EntityCreateOptions extends EntityFolderScopedOptions { /** Human-readable display name shown in the UI (defaults to `name` if omitted) */ displayName?: string; /** Optional entity description */ description?: string; /** Whether role-based access control is enabled for this entity (default: false) */ isRbacEnabled?: boolean; /** Whether Analytics integration is enabled for this entity (default: false) */ isAnalyticsEnabled?: boolean; /** External field source definitions (default: empty) */ externalFields?: ExternalField[]; } /** * Identifies a field by its ID and supplies metadata updates to apply */ interface EntityFieldUpdateOptions extends EntityFieldBase { /** ID of the field to update */ id: string; } /** * Identifies a field to remove by its name */ interface EntityRemoveFieldOptions { /** Name of the field to remove */ fieldName: string; } /** * Options for updating an existing entity — schema and/or metadata in a single call. * * Schema changes (`addFields`, `removeFields`, `updateFields`) and metadata changes * (`displayName`, `description`, `isRbacEnabled`) can be combined; each is applied * only when the corresponding fields are provided. */ interface EntityUpdateByIdOptions extends EntityFolderScopedOptions { /** New fields to add */ addFields?: EntityCreateFieldOptions[]; /** Fields to remove, each identified by field name */ removeFields?: EntityRemoveFieldOptions[]; /** Fields to update, each identified by its field ID */ updateFields?: EntityFieldUpdateOptions[]; /** New display name for the entity */ displayName?: string; /** New description for the entity */ description?: string; /** Whether role-based access control is enabled for this entity */ isRbacEnabled?: boolean; } /** * Response from a bulk import operation */ interface EntityImportRecordsResponse { /** Total number of records in the import file */ totalRecords: number; /** Number of records successfully inserted */ insertedRecords: number; /** Link to download the error file (if any records failed) */ errorFileLink?: string | null; } /** * Supported file types for attachment upload */ type EntityFileType = Blob | File | Uint8Array; /** * Optional options for uploading an attachment to an entity record */ interface EntityUploadAttachmentOptions extends EntityFolderScopedOptions { /** Optional expansion level (default: 0) */ expansionLevel?: number; } /** * Optional options for downloading an attachment from an entity record */ interface EntityDownloadAttachmentOptions extends EntityFolderScopedOptions { } /** * Optional options for deleting an attachment from an entity record */ interface EntityDeleteAttachmentOptions extends EntityFolderScopedOptions { } /** * Response from uploading an attachment to an entity record */ type EntityUploadAttachmentResponse = Record; /** * Response from deleting an attachment from an entity record */ type EntityDeleteAttachmentResponse = Record; /** * Represents a failure record in an entity operation */ interface FailureRecord { /** Error message */ error?: string; /** Original record that failed */ record?: Record; } /** * Response from an entity operation that modifies multiple records */ interface EntityOperationResponse { /** Records that were successfully processed */ successRecords: Record[]; /** Records that failed processing */ failureRecords: FailureRecord[]; } /** * Response from inserting a single record into an entity. * Returns the inserted record with its generated record ID and other fields. */ interface EntityInsertResponse extends EntityRecord { } /** * Response from updating a single record in an entity. * Returns the updated record. */ interface EntityUpdateRecordResponse extends EntityRecord { } /** * Response from batch inserting data into an entity */ interface EntityBatchInsertResponse extends EntityOperationResponse { } /** * Response from updating data in an entity */ interface EntityUpdateResponse extends EntityOperationResponse { } /** * Response from deleting data from an entity */ interface EntityDeleteResponse extends EntityOperationResponse { } /** * Entity type enum */ declare enum EntityType { Entity = "Entity", ChoiceSet = "ChoiceSet", InternalEntity = "InternalEntity", SystemEntity = "SystemEntity" } /** * Field type metadata */ interface FieldDataType { name: EntityFieldDataType; lengthLimit?: number; maxValue?: number; minValue?: number; decimalPrecision?: number; } /** * Reference types for fields */ declare enum ReferenceType { ManyToOne = "ManyToOne" } /** * Field display types */ declare enum FieldDisplayType { Basic = "Basic", Relationship = "Relationship", File = "File", ChoiceSetSingle = "ChoiceSetSingle", ChoiceSetMultiple = "ChoiceSetMultiple", AutoNumber = "AutoNumber" } /** * Data direction type for external fields */ declare enum DataDirectionType { ReadOnly = "ReadOnly", ReadAndWrite = "ReadAndWrite" } /** * Join type applied when matching records across entities. * * Used by {@link EntityJoin} for cross-entity query joins and by * {@link SourceJoinCriteria} in entity metadata. */ declare enum JoinType { /** LEFT JOIN — all base-entity records, with related fields empty when unmatched. */ LeftJoin = "LeftJoin" } /** * Field reference with ID */ interface Field { id: string; definition?: FieldMetaData; } /** * SQL type metadata */ interface SqlType { /** Raw SQL type name (e.g., `"NVARCHAR"`, `"INT"`, `"UNIQUEIDENTIFIER"`) */ name: string; lengthLimit?: number; maxValue?: number; minValue?: number; decimalPrecision?: number; } /** * Detailed field definition */ interface FieldMetaData { id: string; name: string; isPrimaryKey: boolean; isForeignKey: boolean; isExternalField: boolean; isHiddenField: boolean; isUnique: boolean; isRequired: boolean; isSystemField: boolean; isAttachment: boolean; isEncrypted: boolean; isRbacEnabled: boolean; fieldDisplayType: FieldDisplayType; /** Transformed field data type — present after SDK transformation */ fieldDataType: FieldDataType; createdTime: string; createdBy: string; /** Raw SQL type from API — present on raw GET responses, used on write payloads */ sqlType?: SqlType; updatedTime?: string; updatedBy?: string; displayName?: string; description?: string; referenceName?: string; referenceEntity?: RawEntityGetResponse; referenceChoiceSet?: RawEntityGetResponse; referenceField?: Field; referenceType?: ReferenceType; choiceSetId?: string; defaultValue?: string; } /** * External object details */ interface ExternalObject { id: string; externalObjectName?: string; externalObjectDisplayName?: string; primaryKey?: string; externalConnectionId: string; entityId?: string; isPrimarySource: boolean; } /** * External connection details */ interface ExternalConnection { id: string; connectionId: string; elementInstanceId: number; folderKey: string; connectorKey?: string; connectorName?: string; connectionName?: string; } /** * External field mapping */ interface ExternalFieldMapping { id: string; externalFieldName?: string; externalFieldDisplayName?: string; externalObjectId: string; externalFieldType?: string; internalFieldId: string; directionType: DataDirectionType; } /** * External field */ interface ExternalField { fieldMetaData: FieldMetaData; externalFieldMappingDetail: ExternalFieldMapping; } /** * External source fields */ interface ExternalSourceFields { fields?: ExternalField[]; externalObjectDetail?: ExternalObject; externalConnectionDetail?: ExternalConnection; } /** * Source join criteria */ interface SourceJoinCriteria { id: string; entityId: string; joinFieldName?: string; joinType: JoinType; relatedSourceObjectId?: string; relatedSourceFieldName?: string; } /** * Entity metadata returned by getById */ interface RawEntityGetResponse { name: string; displayName: string; entityType: EntityType; description?: string; fields: FieldMetaData[]; folderId?: string; externalFields?: ExternalSourceFields[]; sourceJoinCriterias?: SourceJoinCriteria[]; recordCount?: number; storageSizeInMB?: number; usedStorageSizeInMB?: number; attachmentSizeInByte?: number; isRbacEnabled: boolean; isInsightsEnabled?: boolean; id: string; createdBy: string; createdTime: string; updatedTime?: string; updatedBy?: string; } /** * Service for managing UiPath Data Fabric Entities. * * Entities are collections of records that can be used to store and manage data in the Data Fabric. [UiPath Data Fabric Guide](https://docs.uipath.com/data-service/automation-cloud/latest/user-guide/introduction) * * ### Usage * * Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize) * * ```typescript * import { Entities } from '@uipath/uipath-typescript/entities'; * * const entities = new Entities(sdk); * const allEntities = await entities.getAll(); * ``` */ interface EntityServiceModel { /** * Gets entities in the tenant. * * Three call modes: * - `getAll()` — default. Returns only tenant-level entities. * - `getAll({ folderKey: "" })` — preferred for folder-scoped data. Returns only entities in that folder. * - `getAll({ includeFolderEntities: true })` — returns tenant-level **and** folder-level entities together. `folderKey` is preferred over `includeFolderEntities` when both are set. * * @param options - Optional {@link EntityGetAllOptions} (`folderKey` to list a single folder's entities — preferred when scoping to a folder; `includeFolderEntities: true` to list tenant + folder entities together) The `folderKey` property is **experimental**. * @returns Promise resolving to an array of entity metadata * {@link EntityGetResponse} * @example * ```typescript * // Tenant-only (default) * const tenantEntities = await entities.getAll(); * * // A single folder's entities (preferred when targeting a specific folder) * const folderEntities = await entities.getAll({ folderKey: "" }); * * // Tenant + folder entities together * const allEntities = await entities.getAll({ includeFolderEntities: true }); * * // Iterate through entities * tenantEntities.forEach(entity => { * console.log(`Entity: ${entity.displayName} (${entity.name})`); * console.log(`Type: ${entity.entityType}`); * }); * * // Find a specific entity by name * const customerEntity = tenantEntities.find(e => e.name === 'Customer'); * * // Use entity methods directly * if (customerEntity) { * const records = await customerEntity.getAllRecords(); * console.log(`Customer records: ${records.items.length}`); * * // Insert a single record * const insertResult = await customerEntity.insertRecord({ name: "John", age: 30 }); * * // Or batch insert multiple records * const batchResult = await customerEntity.insertRecords([ * { name: "Jane", age: 25 }, * { name: "Bob", age: 35 } * ]); * } * ``` */ getAll(options?: EntityGetAllOptions): Promise; /** * Gets entity metadata by entity ID with attached operation methods * * @param id - UUID of the entity * @param options - Optional {@link EntityGetByIdOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**. * @returns Promise resolving to entity metadata with operation methods * {@link EntityGetResponse} * @example * ```typescript * import { Entities, ChoiceSets } from '@uipath/uipath-typescript/entities'; * * const entities = new Entities(sdk); * const choicesets = new ChoiceSets(sdk); * * // Get entity metadata with methods * const entity = await entities.getById(""); * * // Folder-scoped: pass the entity's folder key * const folderEntity = await entities.getById("", { folderKey: "" }); * * // Call operations directly on the entity * const records = await entity.getAllRecords(); * * // If a field references a ChoiceSet, get the choiceSetId from records.fields * const choiceSetId = records.fields[0].referenceChoiceSet?.id; * if (choiceSetId) { * const choiceSetValues = await choicesets.getById(choiceSetId); * } * * // Insert a single record * const insertResult = await entity.insertRecord({ name: "John", age: 30 }); * * // Or batch insert multiple records * const batchResult = await entity.insertRecords([ * { name: "Jane", age: 25 }, * { name: "Bob", age: 35 } * ]); * ``` */ getById(id: string, options?: EntityGetByIdOptions): Promise; /** * Gets entity records by entity ID * * `MULTILINE_MAX` fields are returned as a size marker (e.g. `"HasValue=true Length=512"`) * instead of the full content — use {@link getRecordById} to retrieve the full value. * * @param entityId - UUID of the entity * @param options - Query options The `folderKey` property is **experimental**. * @returns Promise resolving to either an array of entity records NonPaginatedResponse or a PaginatedResponse when pagination options are used. * {@link EntityRecord} * @example * ```typescript * // Basic usage (non-paginated) * const records = await entities.getAllRecords(""); * * // With expansion level * const records = await entities.getAllRecords(, { * expansionLevel: 1 * }); * * // With pagination * const paginatedResponse = await entities.getAllRecords(, { * pageSize: 50, * expansionLevel: 1 * }); * * // Navigate to next page * const nextPage = await entities.getAllRecords(, { * cursor: paginatedResponse.nextCursor, * expansionLevel: 1 * }); * * // Folder-scoped entity: pass the entity's folder key * const records = await entities.getAllRecords("", { folderKey: "" }); * ``` */ getAllRecords(entityId: string, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * @deprecated Use {@link getAllRecords} instead. * @hidden */ getRecordsById(entityId: string, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * Gets a single entity record by entity ID and record ID * * Returns the full record, including the complete content of `MULTILINE_MAX` fields. * * @param entityId - UUID of the entity * @param recordId - UUID of the record * @param options - Query options The `folderKey` property is **experimental**. * @returns Promise resolving to a single entity record * {@link EntityRecord} * @example * ```typescript * // First, get records to obtain the record ID * const records = await entities.getAllRecords(""); * // Get the recordId for the record * const recordId = records.items[0].Id; * // Get the record * const record = await entities.getRecordById(, recordId); * * // With expansion level * const record = await entities.getRecordById(, recordId, { * expansionLevel: 1 * }); * * // Folder-scoped entity: pass the entity's folder key * const record = await entities.getRecordById(, recordId, { * folderKey: "" * }); * ``` */ getRecordById(entityId: string, recordId: string, options?: EntityGetRecordByIdOptions): Promise; /** * Inserts a single record into an entity by entity ID * * Note: Data Fabric supports trigger events only on individual inserts, not on inserting multiple records. * Use this method if you need trigger events to fire for the inserted record. * * @param id - UUID of the entity * @param data - Record to insert * @param options - Insert options The `folderKey` property is **experimental**. * @returns Promise resolving to the inserted record with generated record ID * {@link EntityInsertResponse} * @example * ```typescript * // Basic usage * const result = await entities.insertRecordById(, { name: "John", age: 30 }); * * // With options * const result = await entities.insertRecordById(, { name: "John", age: 30 }, { * expansionLevel: 1 * }); * * // Folder-scoped entity: pass the entity's folder key * await entities.insertRecordById(, { name: "John", age: 30 }, { * folderKey: "" * }); * ``` */ insertRecordById(id: string, data: Record, options?: EntityInsertRecordOptions): Promise; /** * @deprecated Use {@link insertRecordById} instead. * @hidden */ insertById(id: string, data: Record, options?: EntityInsertOptions): Promise; /** * Inserts one or more records into an entity by entity ID * * Note: Records inserted using insertRecordsById will not trigger Data Fabric trigger events. Use {@link insertRecordById} if you need * trigger events to fire for each inserted record. * * @param id - UUID of the entity * @param data - Array of records to insert * @param options - Insert options The `folderKey` property is **experimental**. * @returns Promise resolving to insert response * {@link EntityBatchInsertResponse} * @example * ```typescript * // Basic usage * const result = await entities.insertRecordsById(, [ * { name: "John", age: 30 }, * { name: "Jane", age: 25 } * ]); * * // With options * const result = await entities.insertRecordsById(, [ * { name: "John", age: 30 }, * { name: "Jane", age: 25 } * ], { * expansionLevel: 1, * failOnFirst: true * }); * * // Folder-scoped entity: pass the entity's folder key * await entities.insertRecordsById(, [ * { name: "John", age: 30 }, * { name: "Jane", age: 25 } * ], { folderKey: "" }); * ``` */ insertRecordsById(id: string, data: Record[], options?: EntityInsertRecordsOptions): Promise; /** * @deprecated Use {@link insertRecordsById} instead. * @hidden */ batchInsertById(id: string, data: Record[], options?: EntityBatchInsertOptions): Promise; /** * Updates a single record in an entity by entity ID * * Note: Data Fabric supports trigger events only on individual updates, not on updating multiple records. * Use this method if you need trigger events to fire for the updated record. * * @param entityId - UUID of the entity * @param recordId - UUID of the record to update * @param data - Key-value pairs of fields to update * @param options - Update options The `folderKey` property is **experimental**. * @returns Promise resolving to the updated record * {@link EntityUpdateRecordResponse} * @example * ```typescript * // Basic usage * const result = await entities.updateRecordById(, , { name: "John Updated", age: 31 }); * * // With options * const result = await entities.updateRecordById(, , { name: "John Updated", age: 31 }, { * expansionLevel: 1 * }); * * // Folder-scoped entity: pass the entity's folder key * await entities.updateRecordById(, , { name: "John Updated" }, { * folderKey: "" * }); * ``` */ updateRecordById(entityId: string, recordId: string, data: Record, options?: EntityUpdateRecordOptions): Promise; /** * Updates data in an entity by entity ID * * Note: Records updated using updateRecordsById will not trigger Data Fabric trigger events. Use {@link updateRecordById} if you need trigger events to fire for each updated record. * * @param id - UUID of the entity * @param data - Array of records to update. Each record MUST contain the record id. * @param options - Update options The `folderKey` property is **experimental**. * @returns Promise resolving to update response * {@link EntityUpdateResponse} * @example * ```typescript * // Basic usage * const result = await entities.updateRecordsById(, [ * { Id: "123", name: "John Updated", age: 31 }, * { Id: "456", name: "Jane Updated", age: 26 } * ]); * * // With options * const result = await entities.updateRecordsById(, [ * { Id: "123", name: "John Updated", age: 31 }, * { Id: "456", name: "Jane Updated", age: 26 } * ], { * expansionLevel: 1, * failOnFirst: true * }); * * // Folder-scoped entity: pass the entity's folder key * await entities.updateRecordsById(, [ * { Id: "123", name: "John Updated" } * ], { folderKey: "" }); * ``` */ updateRecordsById(id: string, data: EntityRecord[], options?: EntityUpdateRecordsOptions): Promise; /** * Deletes data from an entity by entity ID * * Note: Records deleted using deleteRecordsById will not trigger Data Fabric trigger events. Use {@link deleteRecordById} if you need trigger events to fire for the deleted record. * * @param id - UUID of the entity * @param recordIds - Array of record UUIDs to delete * @param options - Delete options The `folderKey` property is **experimental**. * @returns Promise resolving to delete response * {@link EntityDeleteResponse} * @example * ```typescript * // Basic usage * const result = await entities.deleteRecordsById(, [ * , * ]); * * // Folder-scoped entity: pass the entity's folder key * await entities.deleteRecordsById(, [ * , * ], { folderKey: "" }); * ``` */ deleteRecordsById(id: string, recordIds: string[], options?: EntityDeleteRecordsOptions): Promise; /** * Deletes a single record from an entity by entity ID and record ID * * Note: Data Fabric supports trigger events only on individual deletes, not on deleting multiple records. * Use this method if you need trigger events to fire for the deleted record. * * @param entityId - UUID of the entity * @param recordId - UUID of the record to delete * @param options - Optional {@link EntityDeleteRecordByIdOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**. * @returns Promise resolving to void on success * @example * ```typescript * import { Entities } from '@uipath/uipath-typescript/entities'; * * const entities = new Entities(sdk); * * await entities.deleteRecordById("", ""); * * // Folder-scoped: pass the entity's folder key * await entities.deleteRecordById("", "", { folderKey: "" }); * ``` */ deleteRecordById(entityId: string, recordId: string, options?: EntityDeleteRecordByIdOptions): Promise; /** * Queries entity records with filters, sorting, aggregates, and SDK-managed pagination * * `MULTILINE_MAX` fields are returned as a size marker (e.g. `"HasValue=true Length=512"`) * instead of the full content — use {@link getRecordById} to retrieve the full value. * * @param id - UUID of the entity * @param options - Query options including filterGroup, selectedFields, sortOptions, aggregates, groupBy, joins, and pagination The `folderKey` property is **experimental**. * @returns Promise resolving to {@link NonPaginatedResponse} without pagination options, * or {@link PaginatedResponse} when `pageSize`, `cursor`, or `jumpToPage` are provided * @example * ```typescript * import { Entities, LogicalOperator, QueryFilterOperator, EntityAggregateFunction, JoinType } from '@uipath/uipath-typescript/entities'; * * const entities = new Entities(sdk); * * // Non-paginated query with a filter * const result = await entities.queryRecordsById(, { * filterGroup: { * logicalOperator: LogicalOperator.And, * queryFilters: [{ fieldName: "status", operator: QueryFilterOperator.Equals, value: "active" }] * }, * sortOptions: [{ fieldName: "createdTime", isDescending: true }], * }); * console.log(`Found ${result.totalCount} records`); * * // With pagination * const page1 = await entities.queryRecordsById(, { pageSize: 25 }); * if (page1.hasNextPage) { * const page2 = await entities.queryRecordsById(, { cursor: page1.nextCursor }); * } * * // Aggregate: count of records per status * await entities.queryRecordsById(, { * selectedFields: ["status"], * groupBy: ["status"], * aggregates: [ * { function: EntityAggregateFunction.Count, field: "Id", alias: "total" }, * ], * }); * * // Folder-scoped entity: pass the entity's folder key * await entities.queryRecordsById(, { * filterGroup: { queryFilters: [{ fieldName: "status", operator: QueryFilterOperator.Equals, value: "active" }] }, * folderKey: "", * }); * * // Aggregate: total sum and average across all records (no grouping) * await entities.queryRecordsById(, { * aggregates: [ * { function: EntityAggregateFunction.Sum, field: "amount", alias: "totalAmount" }, * { function: EntityAggregateFunction.Avg, field: "amount", alias: "avgAmount" }, * ], * }); * * // Multi-join: pull fields from related entities into the query * await entities.queryRecordsById(, { * selectedFields: ["Id", "amount"], * joins: [ * { * entityName: "Order", * joinType: JoinType.LeftJoin, * joinFieldName: "customerId", * relatedEntityName: "Customer", * relatedFieldName: "Id", * }, * { * entityName: "Customer", * joinType: JoinType.LeftJoin, * joinFieldName: "regionId", * relatedEntityName: "Region", * relatedFieldName: "Id", * }, * ], * }); * ``` */ queryRecordsById(id: string, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * Imports records from a CSV file into an entity * * @param id - UUID of the entity * @param file - CSV file to import as a Blob or File or Uint8Array * @param options - Optional {@link EntityImportRecordsByIdOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**. * @returns Promise resolving to {@link EntityImportRecordsResponse} with record counts * @example * ```typescript * // Browser: upload from file input * const fileInput = document.getElementById('csv-input') as HTMLInputElement; * const result = await entities.importRecordsById(, fileInput.files[0]); * console.log(`Inserted ${result.insertedRecords} of ${result.totalRecords} records`); * * // Folder-scoped entity: pass the entity's folder key * await entities.importRecordsById(, fileInput.files[0], { folderKey: "" }); * ``` */ importRecordsById(id: string, file: EntityFileType, options?: EntityImportRecordsByIdOptions): Promise; /** * Downloads an attachment stored in a File-type field of an entity record. * * @param entityId - UUID of the entity * @param recordId - UUID of the record containing the attachment * @param fieldName - Name of the File-type field containing the attachment * @param options - Optional {@link EntityDownloadAttachmentOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**. * @returns Promise resolving to Blob containing the file content * @example * ```typescript * import { Entities } from '@uipath/uipath-typescript/entities'; * * const entities = new Entities(sdk); * * // First, get records to obtain the record ID * const records = await entities.getAllRecords(""); * // Get the recordId for the record that contains the attachment * const recordId = records.items[0].Id; * * // Get the entityId from getAll() * const allEntities = await entities.getAll(); * const entityId = allEntities[0].id; * * // Get the recordId from getAllRecords() * const records = await entities.getAllRecords(entityId); * const recordId = records[0].Id; * * // Download attachment using service method * const response = await entities.downloadAttachment(entityId, recordId, 'Documents'); * * // Or download using entity method (entityId is already known) * const entity = await entities.getById(entityId); * const blob = await entity.downloadAttachment(recordId, 'Documents'); * * // Browser: Display Image * const url = URL.createObjectURL(response); * document.getElementById('image').src = url; * // Call URL.revokeObjectURL(url) when done * * // Browser: Display PDF in iframe * const url = URL.createObjectURL(response); * document.getElementById('pdf-viewer').src = url; * // Call URL.revokeObjectURL(url) when done * * // Browser: Render PDF with PDF.js * const arrayBuffer = await response.arrayBuffer(); * const pdf = await pdfjsLib.getDocument({ data: arrayBuffer }).promise; * * // Node.js: Save to file * const buffer = Buffer.from(await response.arrayBuffer()); * fs.writeFileSync('attachment.pdf', buffer); * ``` */ downloadAttachment(entityId: string, recordId: string, fieldName: string, options?: EntityDownloadAttachmentOptions): Promise; /** * Uploads an attachment to a File-type field of an entity record. * * Uses multipart/form-data to upload the file content to the specified field. * * @param entityId - UUID of the entity * @param recordId - UUID of the record to upload the attachment to * @param fieldName - Name of the File-type field * @param file - File to upload (Blob, File, or Uint8Array) * @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. `expansionLevel`, `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**. * @returns Promise resolving to {@link EntityUploadAttachmentResponse} * @example * ```typescript * import { Entities } from '@uipath/uipath-typescript/entities'; * * const entities = new Entities(sdk); * * // Get the entityId from getAll() * const allEntities = await entities.getAll(); * const entityId = allEntities[0].id; * * // Get the recordId from getAllRecords() * const records = await entities.getAllRecords(entityId); * const recordId = records[0].Id; * * // Browser: Upload a file from an input element * const fileInput = document.getElementById('file-input') as HTMLInputElement; * const file = fileInput.files[0]; * const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file); * * // Folder-scoped entity: pass the entity's folder key * await entities.uploadAttachment(entityId, recordId, 'Documents', file, { folderKey: "" }); * * // Node.js: Upload a file from disk * const fileBuffer = fs.readFileSync('document.pdf'); * const blob = new Blob([fileBuffer], { type: 'application/pdf' }); * const response = await entities.uploadAttachment(entityId, recordId, 'Documents', blob); * ``` */ uploadAttachment(entityId: string, recordId: string, fieldName: string, file: EntityFileType, options?: EntityUploadAttachmentOptions): Promise; /** * Removes an attachment from a File-type field of an entity record. * * @param entityId - UUID of the entity * @param recordId - UUID of the record containing the attachment * @param fieldName - Name of the File-type field containing the attachment * @param options - Optional {@link EntityDeleteAttachmentOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**. * @returns Promise resolving to {@link EntityDeleteAttachmentResponse} * @example * ```typescript * import { Entities } from '@uipath/uipath-typescript/entities'; * * const entities = new Entities(sdk); * * // Get the entityId from getAll() * const allEntities = await entities.getAll(); * const entityId = allEntities[0].id; * * // Get the recordId from getAllRecords() * const records = await entities.getAllRecords(entityId); * const recordId = records[0].Id; * * // Delete attachment for a specific record and field * await entities.deleteAttachment(entityId, recordId, 'Documents'); * * // Or delete using entity method (entityId is already known) * const entity = await entities.getById(entityId); * await entity.deleteAttachment(recordId, 'Documents'); * ``` */ deleteAttachment(entityId: string, recordId: string, fieldName: string, options?: EntityDeleteAttachmentOptions): Promise; /** * Creates a new Data Fabric entity with the given schema * * @param name - Entity name — must start with a letter, letters/numbers/underscores only * (e.g., `"productCatalog"`). * @param fields - Array of field definitions * @param options - Optional entity-level settings ({@link EntityCreateOptions}) The `folderKey` property is **experimental**. * @returns Promise resolving to the ID of the created entity * @example * ```typescript * import { Entities } from '@uipath/uipath-typescript/entities'; * * const entities = new Entities(sdk); * * const id = await entities.create("product_catalog", [ * { fieldName: "product_name", type: EntityFieldDataType.STRING, isRequired: true, isUnique: true }, * { fieldName: "price", type: EntityFieldDataType.INTEGER, defaultValue: "0" }, * ], { displayName: "Product Catalog", description: "Our product catalog", isRbacEnabled: true }); * * // With advanced sqlType constraints (lengthLimit, decimalPrecision, maxValue, minValue) and defaultValue * const ordersId = await entities.create("orders", [ * { fieldName: "product_name", type: EntityFieldDataType.STRING, isRequired: true, isUnique: true, lengthLimit: 500 }, * { fieldName: "price", type: EntityFieldDataType.DECIMAL, decimalPrecision: 4, maxValue: 999999, minValue: 0 }, * { fieldName: "quantity", type: EntityFieldDataType.INTEGER, maxValue: 10000, minValue: 1, defaultValue: "0" }, * ]); * * // Cross-folder references — link a folder-scoped entity to entities and * // system choice sets that live in another folder or at the tenant level. * await entities.create("orderLine", [ * { * fieldName: "order", * type: EntityFieldDataType.RELATIONSHIP, * referenceEntityId: "", * referenceFieldId: "", * referenceFolderKey: "", // target lives in a different folder * }, * { * fieldName: "userType", * type: EntityFieldDataType.CHOICE_SET_SINGLE, * choiceSetId: "", // tenant-level system choice set * // referenceFolderKey omitted → SDK looks up the target at tenant scope * }, * ], { folderKey: "" }); * ``` * @internal */ create(name: string, fields: EntityCreateFieldOptions[], options?: EntityCreateOptions): Promise; /** * Deletes a Data Fabric entity and all its records * * @param id - UUID of the entity to delete * @param options - Optional {@link EntityDeleteByIdOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**. * @returns Promise resolving when the entity is deleted * @example * ```typescript * await entities.deleteById(); * * // Folder-scoped: pass the entity's folder key * await entities.deleteById(, { folderKey: "" }); * ``` * @internal */ deleteById(id: string, options?: EntityDeleteByIdOptions): Promise; /** * Updates an existing Data Fabric entity — schema and/or metadata. * * Pass any combination of schema fields (`addFields`, `removeFields`, `updateFields`) and * metadata fields (`displayName`, `description`, `isRbacEnabled`). Each group is applied * only when the corresponding fields are provided. * * @param id - UUID of the entity to update * @param options - Changes to apply ({@link EntityUpdateByIdOptions}) The `folderKey` property is **experimental**. * @returns Promise resolving when the update is complete * * @example * ```typescript * // Schema-only: add a field and remove another * await entities.updateById(, { * addFields: [{ fieldName: "notes", type: EntityFieldDataType.MULTILINE_TEXT }], * removeFields: [{ fieldName: "old_field" }], * }); * * // Metadata-only: rename the entity * await entities.updateById(, { * displayName: "My Updated Entity", * description: "Updated description", * }); * * // Combined: update a field and rename at the same time * await entities.updateById(, { * updateFields: [{ id: , displayName: "Unit Price", isRequired: true }], * displayName: "Price Catalog", * }); * * // Add a STRING/DECIMAL field with explicit advanced sqlType constraints and defaultValue * await entities.updateById(, { * addFields: [ * { fieldName: "summary", type: EntityFieldDataType.STRING, lengthLimit: 500, defaultValue: "summary" }, * { fieldName: "amount", type: EntityFieldDataType.DECIMAL, decimalPrecision: 4, maxValue: 999999, minValue: 0 }, * ], * updateFields: [ * { id: , lengthLimit: 1000 }, * ], * }); * * // Folder-scoped entity: add a field to an entity that lives in a non-tenant folder * await entities.updateById(, { * folderKey: "", * addFields: [{ fieldName: "notes", type: EntityFieldDataType.MULTILINE_TEXT }], * }); * ``` * @internal */ updateById(id: string, options?: EntityUpdateByIdOptions): Promise; } /** * Entity methods interface - defines operations that can be performed on an entity */ interface EntityMethods { /** * Insert a single record into this entity * * Note: Data Fabric supports trigger events only on individual inserts, not on inserting multiple records. * Use this method if you need trigger events to fire for the inserted record. * * @param data - Record to insert * @param options - Insert options * @returns Promise resolving to the inserted record with generated record ID */ insertRecord(data: Record, options?: EntityInsertRecordOptions): Promise; /** * Insert multiple records into this entity using insertRecords * * Note: Inserting multiple records do not trigger Data Fabric trigger events. Use {@link insertRecord} if you need * trigger events to fire for each inserted record. * * @param data - Array of records to insert * @param options - Insert options * @returns Promise resolving to batch insert response */ insertRecords(data: Record[], options?: EntityInsertRecordsOptions): Promise; /** * Update a single record in this entity * * Note: Data Fabric supports trigger events only on individual updates, not on updating multiple records. * Use this method if you need trigger events to fire for the updated record. * * @param recordId - UUID of the record to update * @param data - Key-value pairs of fields to update * @param options - Update options * @returns Promise resolving to the updated record */ updateRecord(recordId: string, data: Record, options?: EntityUpdateRecordOptions): Promise; /** * Update data in this entity * * Note: Records updated using updateRecords will not trigger Data Fabric trigger events. Use {@link updateRecord} if you need * trigger events to fire for each updated record. * * @param data - Array of records to update. Each record MUST contain the record Id, * otherwise the update will fail. * @param options - Update options * @returns Promise resolving to update response */ updateRecords(data: EntityRecord[], options?: EntityUpdateRecordsOptions): Promise; /** * Delete data from this entity * * Note: Records deleted using deleteRecords will not trigger Data Fabric trigger events. Use {@link deleteRecord} if you need trigger events to fire for the deleted record. * * @param recordIds - Array of record UUIDs to delete * @param options - Delete options * @returns Promise resolving to delete response */ deleteRecords(recordIds: string[], options?: EntityDeleteRecordsOptions): Promise; /** * Delete a single record from this entity * * Note: Data Fabric supports trigger events only on individual deletes, not on deleting multiple records. * Use this method if you need trigger events to fire for the deleted record. * * @param recordId - UUID of the record to delete * @param options - Optional {@link EntityDeleteRecordByIdOptions} (e.g. `folderKey` for folder-scoped entities) * @returns Promise resolving to void on success */ deleteRecord(recordId: string, options?: EntityDeleteRecordByIdOptions): Promise; /** * Get all records from this entity * * @param options - Query options The `folderKey` property is **experimental**. * @returns Promise resolving to query response */ getAllRecords(options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * Gets a single record from this entity by record ID * * @param recordId - UUID of the record * @param options - Query options including expansionLevel * @returns Promise resolving to the entity record */ getRecord(recordId: string, options?: EntityGetRecordByIdOptions): Promise; /** * Downloads an attachment stored in a File-type field of an entity record * * @param recordId - UUID of the record containing the attachment * @param fieldName - Name of the File-type field containing the attachment * @param options - Optional {@link EntityDownloadAttachmentOptions} (e.g. folderKey) The `folderKey` property is **experimental**. * @returns Promise resolving to Blob containing the file content */ downloadAttachment(recordId: string, fieldName: string, options?: EntityDownloadAttachmentOptions): Promise; /** * Uploads an attachment to a File-type field of an entity record * * @param recordId - UUID of the record to upload the attachment to * @param fieldName - Name of the File-type field * @param file - File to upload (Blob, File, or Uint8Array) * @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. expansionLevel, folderKey) The `folderKey` property is **experimental**. * @returns Promise resolving to {@link EntityUploadAttachmentResponse} */ uploadAttachment(recordId: string, fieldName: string, file: EntityFileType, options?: EntityUploadAttachmentOptions): Promise; /** * Deletes an attachment from a File-type field of an entity record * * @param recordId - UUID of the record containing the attachment * @param fieldName - Name of the File-type field containing the attachment * @param options - Optional {@link EntityDeleteAttachmentOptions} (e.g. folderKey) The `folderKey` property is **experimental**. * @returns Promise resolving to {@link EntityDeleteAttachmentResponse} */ deleteAttachment(recordId: string, fieldName: string, options?: EntityDeleteAttachmentOptions): Promise; /** * @deprecated Use {@link insertRecord} instead. * @hidden */ insert(data: Record, options?: EntityInsertOptions): Promise; /** * @deprecated Use {@link insertRecords} instead. * @hidden */ batchInsert(data: Record[], options?: EntityBatchInsertOptions): Promise; /** * Queries records in this entity with filters, sorting, aggregates, and SDK-managed pagination * * @param options - Query options including filterGroup, selectedFields, sortOptions, aggregates, groupBy, joins, and pagination * @returns Promise resolving to {@link NonPaginatedResponse} without pagination options, * or {@link PaginatedResponse} when `pageSize`, `cursor`, or `jumpToPage` are provided * @example * ```typescript * import { Entities, LogicalOperator, QueryFilterOperator, EntityAggregateFunction, JoinType } from '@uipath/uipath-typescript/entities'; * * const entities = new Entities(sdk); * * const entity = await entities.getById(); * const result = await entity.queryRecords({ * filterGroup: { * logicalOperator: LogicalOperator.And, * queryFilters: [{ fieldName: "status", operator: QueryFilterOperator.Equals, value: "active" }] * }, * sortOptions: [{ fieldName: "createdTime", isDescending: true }], * }); * console.log(`Found ${result.totalCount} records`); * * // Aggregate: count of records per status * await entity.queryRecords({ * selectedFields: ["status"], * groupBy: ["status"], * aggregates: [ * { function: EntityAggregateFunction.Count, field: "Id", alias: "total" }, * ], * }); * * // Aggregate: total sum and average across all records (no grouping) * await entity.queryRecords({ * aggregates: [ * { function: EntityAggregateFunction.Sum, field: "amount", alias: "totalAmount" }, * { function: EntityAggregateFunction.Avg, field: "amount", alias: "avgAmount" }, * ], * }); * * // Multi-join: pull fields from related entities into the query * await entity.queryRecords({ * selectedFields: ["Id", "amount"], * joins: [ * { * entityName: "Order", * joinType: JoinType.LeftJoin, * joinFieldName: "customerId", * relatedEntityName: "Customer", * relatedFieldName: "Id", * }, * { * entityName: "Customer", * joinType: JoinType.LeftJoin, * joinFieldName: "regionId", * relatedEntityName: "Region", * relatedFieldName: "Id", * }, * ], * }); * ``` */ queryRecords(options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * Imports records from a CSV file into this entity * * @param file - CSV file to import as a Blob, File, or Uint8Array * @param options - Optional {@link EntityImportRecordsByIdOptions} (e.g. `folderKey` for folder-scoped entities) * @returns Promise resolving to {@link EntityImportRecordsResponse} with record counts * @example * ```typescript * const entity = await entities.getById(); * const fileInput = document.getElementById('csv-input') as HTMLInputElement; * const result = await entity.importRecords(fileInput.files[0]); * console.log(`Inserted ${result.insertedRecords} of ${result.totalRecords} records`); * * // Folder-scoped entity: pass the entity's folder key * await entity.importRecords(fileInput.files[0], { folderKey: "" }); * ``` */ importRecords(file: EntityFileType, options?: EntityImportRecordsByIdOptions): Promise; /** * @deprecated Use {@link getAllRecords} instead. * @hidden */ getRecords(options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * Deletes this entity and all its records * * @param options - Optional {@link EntityDeleteByIdOptions} (e.g. `folderKey` for folder-scoped entities) * @returns Promise resolving when the entity is deleted * @example * ```typescript * const entity = await entities.getById(); * await entity.delete(); * * // Folder-scoped entity: pass the entity's folder key * await entity.delete({ folderKey: "" }); * ``` * @internal */ delete(options?: EntityDeleteByIdOptions): Promise; /** * Updates this entity — schema and/or metadata. * * @param options - Changes to apply ({@link EntityUpdateByIdOptions}) * @returns Promise resolving when the update is complete * @example * ```typescript * const entity = await entities.getById(); * await entity.update({ * displayName: "Updated Name", * addFields: [{ fieldName: "notes", type: EntityFieldDataType.MULTILINE_TEXT }], * }); * * // Add a STRING/DECIMAL field with explicit advanced sqlType constraints * await entity.update({ * addFields: [ * { fieldName: "summary", type: EntityFieldDataType.STRING, lengthLimit: 500, defaultValue: "string" }, * { fieldName: "amount", type: EntityFieldDataType.DECIMAL, decimalPrecision: 4, maxValue: 999999, minValue: 0 }, * ], * }); * ``` * @internal */ update(options?: EntityUpdateByIdOptions): Promise; } /** * Entity with methods combining metadata with operation methods */ type EntityGetResponse = RawEntityGetResponse & EntityMethods; /** * Creates an actionable entity by combining entity metadata with data and management methods * * @param entityMetadata - Entity metadata * @param service - The entity service instance * @returns Entity metadata with added methods */ declare function createEntityWithMethods(entityData: RawEntityGetResponse, service: EntityServiceModel): EntityGetResponse; /** * Service for interacting with the Data Fabric Entity API */ declare class EntityService extends BaseService implements EntityServiceModel { getById(id: string, options?: EntityGetByIdOptions): Promise; getAllRecords(entityId: string, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; getRecordById(entityId: string, recordId: string, options?: EntityGetRecordByIdOptions): Promise; insertRecordById(id: string, data: Record, options?: EntityInsertRecordOptions): Promise; insertRecordsById(id: string, data: Record[], options?: EntityInsertRecordsOptions): Promise; updateRecordById(entityId: string, recordId: string, data: Record, options?: EntityUpdateRecordOptions): Promise; updateRecordsById(id: string, data: EntityRecord[], options?: EntityUpdateRecordsOptions): Promise; deleteRecordsById(id: string, recordIds: string[], options?: EntityDeleteRecordsOptions): Promise; deleteRecordById(entityId: string, recordId: string, options?: EntityDeleteRecordByIdOptions): Promise; getAll(options?: EntityGetAllOptions): Promise; queryRecordsById(id: string, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; importRecordsById(id: string, file: EntityFileType, options?: EntityImportRecordsByIdOptions): Promise; downloadAttachment(entityId: string, recordId: string, fieldName: string, options?: EntityDownloadAttachmentOptions): Promise; uploadAttachment(entityId: string, recordId: string, fieldName: string, file: EntityFileType, options?: EntityUploadAttachmentOptions): Promise; deleteAttachment(entityId: string, recordId: string, fieldName: string, options?: EntityDeleteAttachmentOptions): Promise; getRecordsById(entityId: string, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; insertById(id: string, data: Record, options?: EntityInsertOptions): Promise; batchInsertById(id: string, data: Record[], options?: EntityBatchInsertOptions): Promise; create(name: string, fields: EntityCreateFieldOptions[], options?: EntityCreateOptions): Promise; deleteById(id: string, options?: EntityDeleteByIdOptions): Promise; updateById(id: string, options?: EntityUpdateByIdOptions): Promise; /** * Fetches the current entity schema, applies the field delta, then posts the full updated schema. * * @param entityId - UUID of the entity to update * @param options - Field changes to apply * @private */ private applySchemaUpdate; /** * Orchestrates all field mapping transformations * * @param metadata - Entity metadata to transform * @private */ private applyFieldMappings; /** * Maps SQL field types to friendly EntityFieldTypes * * @param metadata - Entity metadata with fields * @private */ private mapFieldTypes; /** * Resolves an {@link EntityFieldDataType} from a field's `fieldDisplayType` and * raw SQL type name. Prefers `fieldDisplayType` to disambiguate types that * share a SQL type (FILE, CHOICE_SET_*, AUTO_NUMBER, RELATIONSHIP); falls back * to the SQL-type-name mapping. Returns `undefined` if neither resolves. */ private tryResolveFieldDataType; /** * Transforms nested reference objects in field metadata */ private transformNestedReferences; /** * Maps external field names to consistent naming * * @param metadata - Entity metadata with externalFields * @private */ private mapExternalFields; private buildFieldsWithReferenceMeta; private buildReferenceMeta; /** Converts a user-facing EntityCreateFieldOptions to the raw API field payload */ private buildSchemaFieldPayload; /** * Derives the user-facing {@link EntityFieldDataType} for a field on the raw * API response. Throws if the field's `fieldDisplayType` and `sqlType.name` * are both unmappable. */ private resolveFieldDataType; /** * Validates that the user-supplied constraint properties on a field are * supported by the field's data type. Throws a `ValidationError` listing * any unsupported properties. */ private validateFieldConstraints; /** * Returns the sqlType constraint fields for a given field type. * * The API requires specific constraint properties to be set per SQL type; * without them the field is stored in an incomplete state, causing * "Field type cannot be changed" errors when the UI later tries to edit * advanced options. User-supplied values from `EntityCreateFieldOptions` * override the defaults where the type accepts overrides. */ private buildSqlTypeConstraints; } /** * ChoiceSet Get All Response * Only exposes essential fields to SDK users */ interface ChoiceSetGetAllResponse { /** UUID of the choice set */ id: string; /** Name identifier of the choice set */ name: string; /** Human-readable display name of the choice set*/ displayName: string; /** Description of the choice set */ description: string; /** Folder ID where the choice set is located */ folderId: string; /** User ID who created the choice set */ createdBy: string; /** User ID who last updated the choice set */ updatedBy: string; /** Creation timestamp */ createdTime: string; /** Last update timestamp */ updatedTime: string; } /** * Represents a single choice set value/record */ interface ChoiceSetGetResponse { /** Unique identifier for the choice set value */ id: string; /** Name of the choice set value */ name: string; /** Human-readable display name of the choice set value*/ displayName: string; /** Numeric identifier */ numberId: number; /** Creation timestamp */ createdTime: string; /** Last update timestamp */ updatedTime: string; /** User ID who created this value */ createdBy?: string; /** User ID who last updated this value */ updatedBy?: string; /** User ID of the record owner */ recordOwner?: string; } interface ChoiceSetGetAllOptions extends EntityFolderScopedOptions { /** * When `true`, also returns folder-level choice sets alongside tenant ones. * Omit (or `false`, the default) to return only tenant-level choice sets. * Ignored when `folderKey` is provided — `folderKey` is preferred over `includeFolderChoiceSets` when both are set. * * @experimental Folder-scoped Data Fabric is in preview — the contract may change. */ includeFolderChoiceSets?: boolean; } /** * Options for getting choice set values by choice set ID */ type ChoiceSetGetByIdOptions = PaginationOptions & EntityFolderScopedOptions; /** * Options for creating a new choice set */ interface ChoiceSetCreateOptions extends EntityFolderScopedOptions { /** Human-readable display name */ displayName?: string; /** Optional choice set description */ description?: string; } /** * Options for updating an existing choice set's metadata */ interface ChoiceSetUpdateOptions extends EntityFolderScopedOptions { /** New display name for the choice set */ displayName?: string; /** New description for the choice set */ description?: string; } interface ChoiceSetDeleteByIdOptions extends EntityFolderScopedOptions { } /** * Optional fields when inserting a single value into a choice set. * * The required `name` identifier is passed as a positional argument to * `insertValueById`. */ interface ChoiceSetValueInsertOptions extends EntityFolderScopedOptions { /** Human-readable display name */ displayName?: string; } interface ChoiceSetValueUpdateOptions extends EntityFolderScopedOptions { } interface ChoiceSetValueDeleteOptions extends EntityFolderScopedOptions { } /** * Response returned after inserting a choice-set value — the full value object. */ interface ChoiceSetValueInsertResponse extends ChoiceSetGetResponse { } /** * Response returned after updating a choice-set value — the full value object. */ interface ChoiceSetValueUpdateResponse extends ChoiceSetGetResponse { } /** * Service for managing UiPath Data Fabric Choice Sets * * Choice Sets are enumerated lists of values that can be used as field types in entities. They enable single-select or multi-select fields, such as expense types, categories, or status values. [UiPath Choice Sets Guide](https://docs.uipath.com/data-service/automation-cloud/latest/user-guide/choice-sets) * * ### Usage * * Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize) * * ```typescript * import { ChoiceSets } from '@uipath/uipath-typescript/entities'; * * const choicesets = new ChoiceSets(sdk); * const allChoiceSets = await choicesets.getAll(); * ``` */ interface ChoiceSetServiceModel { /** * Gets choice sets in the tenant. * * Three call modes: * - `getAll()` — default. Returns only tenant-level choice sets. * - `getAll({ folderKey: "" })` — preferred for folder-scoped data. Returns only choice sets in that folder. * - `getAll({ includeFolderChoiceSets: true })` — returns tenant-level **and** folder-level choice sets together. `folderKey` is preferred over `includeFolderChoiceSets` when both are set. * * @param options - Optional {@link ChoiceSetGetAllOptions} (`folderKey` to list a single folder's choice sets — preferred when scoping to a folder; `includeFolderChoiceSets: true` to list tenant + folder choice sets together) The `folderKey` property is **experimental**. * @returns Promise resolving to an array of choice set metadata * {@link ChoiceSetGetAllResponse} * @example * ```typescript * // Tenant-only (default) * const tenantChoiceSets = await choicesets.getAll(); * * // A single folder's choice sets (preferred when targeting a specific folder) * const folderChoiceSets = await choicesets.getAll({ folderKey: "" }); * * // Tenant + folder choice sets together * const allChoiceSets = await choicesets.getAll({ includeFolderChoiceSets: true }); * * // Find a specific choice set by name * const expenseTypes = tenantChoiceSets.find(cs => cs.name === 'ExpenseTypes'); * ``` */ getAll(options?: ChoiceSetGetAllOptions): Promise; /** * Gets choice set values by choice set ID with optional pagination * * The method returns either: * - A NonPaginatedResponse with items array (when no pagination parameters are provided) * - A PaginatedResponse with navigation cursors (when any pagination parameter is provided) * * @param choiceSetId - UUID of the choice set * @param options - Pagination options and optional `folderKey` (omit for tenant-level choice sets) The `folderKey` property is **experimental**. * @returns Promise resolving to choice set values or paginated result * {@link ChoiceSetGetResponse} * @example * ```typescript * // First, get the choice set ID using getAll() * const allChoiceSets = await choicesets.getAll(); * const expenseTypes = allChoiceSets.find(cs => cs.name === 'ExpenseTypes'); * const choiceSetId = expenseTypes.id; * * // Get all values (non-paginated) * const values = await choicesets.getById(choiceSetId); * * // Iterate through choice set values * for (const value of values.items) { * console.log(`Value: ${value.displayName}`); * } * * // First page with pagination * const page1 = await choicesets.getById(choiceSetId, { pageSize: 10 }); * * // Navigate using cursor * if (page1.hasNextPage) { * const page2 = await choicesets.getById(choiceSetId, { cursor: page1.nextCursor }); * } * * // Folder-scoped choice set * const folderValues = await choicesets.getById(choiceSetId, { folderKey: "" }); * ``` */ getById(choiceSetId: string, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * Creates a new Data Fabric choice set * * @param name - Choice set name. Must start with a * letter, may contain only letters, numbers, and underscores, length * 3–100 characters (e.g., `"expenseTypes"`). * @param options - Optional choice-set-level settings ({@link ChoiceSetCreateOptions}) The `folderKey` property is **experimental**. * @returns Promise resolving to the UUID of the created choice set * * @example * ```typescript * // Minimal create * const expenseTypesId = await choicesets.create("expense_types"); * * // With display name and description * const priorityLevelsId = await choicesets.create("priority_levels", { * displayName: "Priority Levels", * description: "Ticket priority categories", * }); * ``` * @internal */ create(name: string, options?: ChoiceSetCreateOptions): Promise; /** * Updates an existing choice set's metadata (display name and/or description). * * **At least one of `displayName` or `description` must be provided** — * the call throws `ValidationError` if both are omitted. * * @param choiceSetId - UUID of the choice set to update * @param options - Metadata fields to change ({@link ChoiceSetUpdateOptions}) The `folderKey` property is **experimental**. * @returns Promise resolving when the update is complete * * @example * ```typescript * // First, get the choice set ID using getAll() * const allChoiceSets = await choicesets.getAll(); * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types'); * * await choicesets.updateById(expenseTypes.id, { * displayName: "Expense Categories", * description: "Updated description", * }); * ``` * @internal */ updateById(choiceSetId: string, options: ChoiceSetUpdateOptions): Promise; /** * Deletes a Data Fabric choice set and all its values. * * @param choiceSetId - UUID of the choice set to delete * @param options - Optional {@link ChoiceSetDeleteByIdOptions} — pass `folderKey` for folder-scoped choice sets; omit for tenant-level The `folderKey` property is **experimental**. * @returns Promise resolving when the choice set is deleted * * @example * ```typescript * // First, get the choice set ID using getAll() * const allChoiceSets = await choicesets.getAll(); * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types'); * * await choicesets.deleteById(expenseTypes.id); * * // Folder-scoped choice set * await choicesets.deleteById(expenseTypes.id, { folderKey: "" }); * ``` * @internal */ deleteById(choiceSetId: string, options?: ChoiceSetDeleteByIdOptions): Promise; /** * Inserts a single value into a choice set. * * @param choiceSetId - UUID of the parent choice set * @param name - Identifier name of the new value (e.g., `"TRAVEL"`) * @param options - Optional fields ({@link ChoiceSetValueInsertOptions}) The `folderKey` property is **experimental**. * @returns Promise resolving to the inserted value ({@link ChoiceSetValueInsertResponse}) * * @example * ```typescript * // First, get the choice set ID using getAll() * const allChoiceSets = await choicesets.getAll(); * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types'); * * const inserted = await choicesets.insertValueById(expenseTypes.id, 'TRAVEL', { * displayName: 'Travel', * }); * console.log(inserted.id); * * // Folder-scoped choice set: folderKey is required on the wire * await choicesets.insertValueById(expenseTypes.id, 'TRAVEL', { * displayName: 'Travel', * folderKey: "", * }); * ``` * @internal */ insertValueById(choiceSetId: string, name: string, options?: ChoiceSetValueInsertOptions): Promise; /** * Updates an existing choice-set value's display name. * * Only `displayName` is mutable; the value's `name` (identifier) is fixed at * insert time and cannot be changed. * * @param choiceSetId - UUID of the parent choice set * @param valueId - UUID of the value to update * @param displayName - New human-readable display name for the value * @param options - Optional {@link ChoiceSetValueUpdateOptions} — pass `folderKey` for folder-scoped choice sets; omit for tenant-level. The `folderKey` property is **experimental**. * @returns Promise resolving to the updated value ({@link ChoiceSetValueUpdateResponse}) * * @example * ```typescript * // Get the choice set ID from getAll() and the value ID from getById() * const allChoiceSets = await choicesets.getAll(); * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types'); * const values = await choicesets.getById(expenseTypes.id); * const travel = values.items.find(v => v.name === 'TRAVEL'); * * await choicesets.updateValueById(expenseTypes.id, travel.id, 'Business Travel'); * * // Folder-scoped choice set: folderKey is required on the wire * await choicesets.updateValueById(expenseTypes.id, travel.id, 'Business Travel', { * folderKey: "", * }); * ``` * @internal */ updateValueById(choiceSetId: string, valueId: string, displayName: string, options?: ChoiceSetValueUpdateOptions): Promise; /** * Deletes one or more values from a choice set. * * @param choiceSetId - UUID of the parent choice set * @param valueIds - Array of value UUIDs to delete * @param options - Optional {@link ChoiceSetValueDeleteOptions} — pass `folderKey` for folder-scoped choice sets; omit for tenant-level The `folderKey` property is **experimental**. * @returns Promise resolving when the values are deleted * * @example * ```typescript * // Get the value IDs from getById() * const values = await choicesets.getById(''); * const idsToDelete = values.items.slice(0, 2).map(v => v.id); * * await choicesets.deleteValuesById('', idsToDelete); * * // Folder-scoped choice set * await choicesets.deleteValuesById('', idsToDelete, { folderKey: "" }); * ``` * @internal */ deleteValuesById(choiceSetId: string, valueIds: string[], options?: ChoiceSetValueDeleteOptions): Promise; } declare class ChoiceSetService extends BaseService implements ChoiceSetServiceModel { getAll(options?: ChoiceSetGetAllOptions): Promise; /** * Internal helper that performs the choice-set fetch. Kept separate from the * public `getAll()` so that internal callers (e.g. `resolveChoiceSetName`) * can reuse it without triggering double `@track` telemetry. */ private fetchAllChoiceSets; getById(choiceSetId: string, options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; create(name: string, options?: ChoiceSetCreateOptions): Promise; updateById(choiceSetId: string, options: ChoiceSetUpdateOptions): Promise; deleteById(choiceSetId: string, options?: ChoiceSetDeleteByIdOptions): Promise; insertValueById(choiceSetId: string, name: string, options?: ChoiceSetValueInsertOptions): Promise; updateValueById(choiceSetId: string, valueId: string, displayName: string, options?: ChoiceSetValueUpdateOptions): Promise; deleteValuesById(choiceSetId: string, valueIds: string[], options?: ChoiceSetValueDeleteOptions): Promise; private resolveChoiceSetName; } /** * @internal */ declare enum DataFabricRoleType { System = "System", UserDefined = "UserDefined" } /** * @internal */ interface DataFabricRole { id: string; name: string; type: DataFabricRoleType; directoryEntityCount?: number | null; folderId?: string; } /** * @internal */ interface DataFabricRoleGetAllOptions { /** * Include role statistics in the response. * * Defaults to true to match the Data Fabric UI and CLI role-list flow. */ stats?: boolean; /** * Optional folder key for folder-aware Role V2 requests. * * Forwarded on the wire as the `X-UIPATH-FolderKey` header. */ folderKey?: string; } /** * @internal */ interface DataFabricRoleServiceModel { /** * Lists Data Fabric access roles. * * Returns tenant Data Fabric roles such as Admin, Designer, DataWriter, and * DataReader. Role IDs from this method can be passed to * `DataFabricDirectoryService.assignRoles()`. * * @param options - Optional query options * @returns Promise resolving to an array of {@link DataFabricRole} * * @example * ```typescript * import { DataFabricRoleService } from '@uipath/uipath-typescript/entities'; * * const roles = new DataFabricRoleService(sdk); * const allRoles = await roles.getAll(); * const dataWriter = allRoles.find(role => role.name === 'DataWriter'); * ``` * * @example * ```typescript * const rolesWithoutStats = await roles.getAll({ stats: false }); * ``` * * @example * ```typescript * const folderRoles = await roles.getAll({ folderKey: '' }); * ``` * * @internal */ getAll(options?: DataFabricRoleGetAllOptions): Promise; } /** * @internal */ declare class DataFabricRoleService extends BaseService implements DataFabricRoleServiceModel { getAll(options?: DataFabricRoleGetAllOptions): Promise; } /** * @internal */ declare enum DataFabricDirectoryEntityType { /** Identity user, robot user, or directory robot principal. */ User = 0, /** Identity group principal. */ Group = 1, /** External application principal. */ Application = 2 } /** * @internal */ declare enum DataFabricDirectoryEntityTypeName { User = "User", Group = "Group", Application = "Application" } /** * @internal */ type DataFabricDirectoryEntityTypeInput = DataFabricDirectoryEntityType | DataFabricDirectoryEntityTypeName; /** * @internal */ interface DataFabricDirectoryRole { id: string; name: string; } /** * @internal */ interface DataFabricDirectoryEntry { externalId: string; name: string; email?: string | null; type: DataFabricDirectoryEntityTypeName; roles: DataFabricDirectoryRole[]; objectType?: string | null; isUIEnabled: boolean; } /** * @internal */ interface DataFabricDirectoryListOptions { skip?: number; top?: number; } /** * @internal */ interface DataFabricDirectoryGetAllOptions { pageSize?: number; } /** * @internal */ interface DataFabricDirectoryListResponse { totalCount: number; results: DataFabricDirectoryEntry[]; } /** * @internal */ interface DataFabricDirectoryAssignOptions { /** * Preserve the principal's current Data Fabric roles. * * Defaults to true because the Data Fabric role assignment endpoint replaces * the role set for each principal. */ preserveExisting?: boolean; /** * Enables Data Fabric UI access for the assigned principal. * * Defaults to true. */ uiEnabled?: boolean; } /** * @internal */ interface DataFabricDirectoryAssignmentResult { principalId: string; roleIds: string[]; } /** * @internal */ interface DataFabricDirectoryServiceModel { /** * Lists one page of Data Fabric directory principals and their current roles. * * Returns directory entries with external IDs, principal metadata, and * assigned Data Fabric roles. * * @param options - Optional offset paging options * @returns Promise resolving to {@link DataFabricDirectoryListResponse} * * @example * ```typescript * import { DataFabricDirectoryService } from '@uipath/uipath-typescript/entities'; * * const directory = new DataFabricDirectoryService(sdk); * const page = await directory.list({ skip: 0, top: 50 }); * const firstPrincipal = page.results[0]; * ``` * * @internal */ list(options?: DataFabricDirectoryListOptions): Promise; /** * Lists all Data Fabric directory principals and their current roles. * * Follows the Data Fabric directory top/skip pagination and returns * normalized entries. Entries without assigned roles include an empty * `roles` array. * * @param options - Optional page-size options * @returns Promise resolving to an array of {@link DataFabricDirectoryEntry} * * @example * ```typescript * import { DataFabricDirectoryService } from '@uipath/uipath-typescript/entities'; * * const directory = new DataFabricDirectoryService(sdk); * const principals = await directory.getAll({ pageSize: 100 }); * ``` * * @internal */ getAll(options?: DataFabricDirectoryGetAllOptions): Promise; /** * Assigns Data Fabric roles to one or more principals. * * The Data Fabric API replaces the role set for each principal, so this * method preserves existing roles by default and posts the union of current * and requested role IDs. * * Role IDs can be discovered with `DataFabricRoleService.getAll()`. Set * `preserveExisting: false` only when intentionally replacing a principal's * Data Fabric role set. * * @param principalIds - Principal external ID or IDs * @param principalType - Principal type * @param roleIds - Data Fabric role IDs to assign * @param options - Optional assignment behavior * @returns Promise resolving to an array of {@link DataFabricDirectoryAssignmentResult} * * @example * ```typescript * import { DataFabricDirectoryEntityTypeName, DataFabricDirectoryService, DataFabricRoleService } from '@uipath/uipath-typescript/entities'; * * const roles = new DataFabricRoleService(sdk); * const directory = new DataFabricDirectoryService(sdk); * * const dataWriter = (await roles.getAll()).find(role => role.name === 'DataWriter'); * if (!dataWriter) { * throw new Error('DataWriter role not found'); * } * * await directory.assignRoles('', DataFabricDirectoryEntityTypeName.Group, [dataWriter.id]); * ``` * * @example * ```typescript * await directory.assignRoles('', DataFabricDirectoryEntityTypeName.User, [''], { * preserveExisting: false, * }); * ``` * * @internal */ assignRoles(principalIds: string | string[], principalType: DataFabricDirectoryEntityTypeInput, roleIds: string[], options?: DataFabricDirectoryAssignOptions): Promise; /** * Revokes all direct Data Fabric roles from one or more principals. * * The Data Fabric API removes all role assignments for each supplied external * ID. Use this when a principal should no longer have direct Data Fabric * access. Inherited access through groups is not changed. * * @param principalIds - Principal external ID or IDs * @returns Promise resolving when the roles are revoked * * @example * ```typescript * import { DataFabricDirectoryService } from '@uipath/uipath-typescript/entities'; * * const directory = new DataFabricDirectoryService(sdk); * * await directory.revokeRoles(''); * ``` * * @example * ```typescript * await directory.revokeRoles([ * '', * '', * ]); * ``` * * @internal */ revokeRoles(principalIds: string | string[]): Promise; } /** * @internal */ declare class DataFabricDirectoryService extends BaseService implements DataFabricDirectoryServiceModel { private fetchAllEntries; list(options?: DataFabricDirectoryListOptions): Promise; getAll(options?: DataFabricDirectoryGetAllOptions): Promise; assignRoles(principalIds: string | string[], principalType: DataFabricDirectoryEntityTypeInput, roleIds: string[], options?: DataFabricDirectoryAssignOptions): Promise; revokeRoles(principalIds: string | string[]): Promise; } export { ChoiceSetService, ChoiceSetService as ChoiceSets, DataDirectionType, DataFabricDirectoryService, DataFabricRoleService, EntityService as Entities, EntityAggregateFunction, EntityFieldDataType, EntityService, EntityType, FieldDisplayType, JoinType, LogicalOperator, QueryFilterOperator, ReferenceType, createEntityWithMethods }; export type { ChoiceSetCreateOptions, ChoiceSetDeleteByIdOptions, ChoiceSetGetAllOptions, ChoiceSetGetAllResponse, ChoiceSetGetByIdOptions, ChoiceSetGetResponse, ChoiceSetServiceModel, ChoiceSetUpdateOptions, ChoiceSetValueDeleteOptions, ChoiceSetValueInsertOptions, ChoiceSetValueInsertResponse, ChoiceSetValueUpdateOptions, ChoiceSetValueUpdateResponse, EntityAggregate, EntityBatchInsertOptions, EntityBatchInsertResponse, EntityCreateFieldOptions, EntityCreateOptions, EntityDeleteAttachmentOptions, EntityDeleteAttachmentResponse, EntityDeleteByIdOptions, EntityDeleteOptions, EntityDeleteRecordByIdOptions, EntityDeleteRecordsOptions, EntityDeleteResponse, EntityDownloadAttachmentOptions, EntityFieldBase, EntityFieldUpdateOptions, EntityFileType, EntityFolderScopedOptions, EntityGetAllOptions, EntityGetAllRecordsOptions, EntityGetByIdOptions, EntityGetRecordByIdOptions, EntityGetRecordsByIdOptions, EntityGetResponse, EntityImportRecordsByIdOptions, EntityImportRecordsResponse, EntityInsertOptions, EntityInsertRecordOptions, EntityInsertRecordsOptions, EntityInsertResponse, EntityJoin, EntityMethods, EntityOperationOptions, EntityOperationResponse, EntityQueryFilter, EntityQueryFilterGroup, EntityQueryRecordsOptions, EntityQueryRecordsResponse, EntityQuerySortOption, EntityRecord, EntityRemoveFieldOptions, EntityServiceModel, EntityUpdateByIdOptions, EntityUpdateOptions, EntityUpdateRecordOptions, EntityUpdateRecordResponse, EntityUpdateRecordsOptions, EntityUpdateResponse, EntityUploadAttachmentOptions, EntityUploadAttachmentResponse, ExternalConnection, ExternalField, ExternalFieldMapping, ExternalObject, ExternalSourceFields, FailureRecord, Field, FieldDataType, FieldMetaData, RawEntityGetResponse, SourceJoinCriteria, SqlType };