-
Notifications
You must be signed in to change notification settings - Fork 13
feat(queues): add queue item operations [PLT-104203] #643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shivendra6720
wants to merge
3
commits into
main
Choose a base branch
from
feat/sdk-plt-104203
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,17 @@ | ||
| import { QueueGetAllOptions, QueueGetByIdOptions, QueueGetResponse } from './queues.types'; | ||
| import { | ||
| QueueGetAllOptions, | ||
| QueueGetByIdOptions, | ||
| RawQueueGetResponse, | ||
| QueueGetAllItemsOptions, | ||
| QueueInsertItemOptions, | ||
| QueueItem, | ||
| QueueItemValue | ||
| } from './queues.types'; | ||
| import { PaginatedResponse, NonPaginatedResponse, HasPaginationOptions } from '../../utils/pagination'; | ||
|
|
||
| /** Combined response type for queue data with bound methods. */ | ||
| export type QueueGetResponse = RawQueueGetResponse & QueueMethods; | ||
|
|
||
| /** | ||
| * Service for managing UiPath Queues | ||
| * | ||
|
|
@@ -20,11 +31,9 @@ import { PaginatedResponse, NonPaginatedResponse, HasPaginationOptions } from '. | |
| export interface QueueServiceModel { | ||
| /** | ||
| * Gets all queues across folders with optional filtering and folder scoping | ||
| * | ||
| * @signature getAll(options?) → Promise<QueueGetResponse[]> | ||
| * | ||
| * @param options Query options including optional folderId and pagination options | ||
| * @returns Promise resolving to either an array of queues NonPaginatedResponse<QueueGetResponse> or a PaginatedResponse<QueueGetResponse> when pagination options are used. | ||
| * {@link QueueGetResponse} | ||
| * @returns Promise resolving to either a {@link QueueGetResponse} array (`NonPaginatedResponse`) or a `PaginatedResponse<QueueGetResponse>` when pagination options are used. Each queue has methods attached for operating on its items. | ||
| * @example | ||
| * ```typescript | ||
| * // Standard array return | ||
|
|
@@ -63,15 +72,171 @@ export interface QueueServiceModel { | |
|
|
||
| /** | ||
| * Gets a single queue by ID | ||
| * | ||
| * | ||
| * @param id - Queue ID | ||
| * @param folderId - Required folder ID | ||
| * @returns Promise resolving to a queue definition | ||
| * @returns Promise resolving to a {@link QueueGetResponse} — the queue definition with methods attached for operating on its items | ||
| * @example | ||
| * ```typescript | ||
| * // Get queue by ID | ||
| * const queue = await queues.getById(<queueId>, <folderId>); | ||
| * | ||
| * // Operate on the queue directly via the attached methods | ||
| * const items = await queue.getAllItems(); | ||
| * const item = await queue.insertItem({ | ||
| * invoiceId: 'INV-1001', | ||
| * amount: 1520 | ||
| * }); | ||
| * ``` | ||
| */ | ||
| getById(id: number, folderId: number, options?: QueueGetByIdOptions): Promise<QueueGetResponse>; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the items of a queue with optional filtering and pagination | ||
| * | ||
| * Returns the queue's work items including their status, business payload | ||
| * (`specificData`), output, timing fields, and failure details. | ||
| * | ||
| * @param queueId - Queue ID | ||
| * @param folderId - Required folder ID | ||
| * @param options Query options including filtering and pagination options | ||
| * @returns Promise resolving to either a {@link QueueItem} array (`NonPaginatedResponse`) or a `PaginatedResponse<QueueItem>` when pagination options are used. | ||
| * @example | ||
| * ```typescript | ||
| * const items = await queues.getAllItems(<queueId>, <folderId>); | ||
| * | ||
| * // Failed items only, newest first | ||
| * const failed = await queues.getAllItems(<queueId>, <folderId>, { | ||
| * filter: "status eq 'Failed'", | ||
| * orderby: 'createdTime desc', | ||
| * pageSize: 25 | ||
| * }); | ||
| * ``` | ||
| * @example | ||
| * ```typescript | ||
| * // Or operate on a queue returned by getById/getAll | ||
| * const queue = await queues.getById(<queueId>, <folderId>); | ||
| * const items = await queue.getAllItems(); | ||
| * ``` | ||
| */ | ||
| getAllItems<T extends QueueGetAllItemsOptions = QueueGetAllItemsOptions>( | ||
| queueId: number, | ||
| folderId: number, | ||
| options?: T | ||
| ): Promise< | ||
| T extends HasPaginationOptions<T> | ||
| ? PaginatedResponse<QueueItem> | ||
| : NonPaginatedResponse<QueueItem> | ||
| >; | ||
|
|
||
| /** | ||
| * Inserts a new item into a queue by queue name | ||
| * | ||
| * Returns the created queue item including its id, status, and the stored | ||
| * payload. The payload keys are user-defined and are stored and returned | ||
| * exactly as provided. | ||
| * | ||
| * The payload must be flat — values are simple scalars (see | ||
| * {@link QueueItemValue}); nested objects and arrays are rejected. | ||
| * | ||
| * @param queueName - Name of the queue to insert into | ||
| * @param folderId - Required folder ID | ||
| * @param specificData - The item's business payload (stored as the queue item's specific content) | ||
| * @param options Optional item metadata (priority, reference, defer/due dates) | ||
| * @returns Promise resolving to the created {@link QueueItem} | ||
| * @example | ||
| * ```typescript | ||
| * import { QueuePriority } from '@uipath/uipath-typescript/queues'; | ||
| * | ||
| * // Minimal insert | ||
| * const item = await queues.insertItemByName('<queueName>', <folderId>, { | ||
| * invoiceId: 'INV-1001', | ||
| * amount: 1520 | ||
| * }); | ||
| * | ||
| * // With metadata | ||
| * const rushItem = await queues.insertItemByName('<queueName>', <folderId>, { | ||
| * invoiceId: 'INV-1002' | ||
| * }, { | ||
| * priority: QueuePriority.High, | ||
| * reference: 'INV-1002', | ||
| * dueDate: new Date('2026-08-15') | ||
| * }); | ||
| * ``` | ||
| */ | ||
| insertItemByName( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @deepeshrai-tech please help refresh my memory. For CRUD naming conventions, we decided to drop the |
||
| queueName: string, | ||
| folderId: number, | ||
| specificData: Record<string, QueueItemValue>, | ||
| options?: QueueInsertItemOptions | ||
| ): Promise<QueueItem>; | ||
| } | ||
|
|
||
| /** | ||
| * Queue methods interface - operations bound to a queue returned by | ||
| * getAll/getById. The queue's own id, name, and folder are filled in | ||
| * automatically. | ||
| */ | ||
| export interface QueueMethods { | ||
| /** | ||
| * Gets this queue's items with optional filtering and pagination. | ||
| * | ||
| * @param options Query options including filtering and pagination options | ||
| * @returns Promise resolving to the queue's {@link QueueItem} entries | ||
| */ | ||
| getAllItems<T extends QueueGetAllItemsOptions = QueueGetAllItemsOptions>(options?: T): Promise< | ||
| T extends HasPaginationOptions<T> | ||
| ? PaginatedResponse<QueueItem> | ||
| : NonPaginatedResponse<QueueItem> | ||
| >; | ||
|
|
||
| /** | ||
| * Inserts a new item into this queue. | ||
| * | ||
| * The payload must be flat — nested objects and arrays are rejected. | ||
| * | ||
| * @param specificData - The item's business payload (keys are stored exactly as provided) | ||
| * @param options Optional item metadata (priority, reference, defer/due dates) | ||
| * @returns Promise resolving to the created {@link QueueItem} | ||
| */ | ||
| insertItem( | ||
| specificData: Record<string, QueueItemValue>, | ||
| options?: QueueInsertItemOptions | ||
| ): Promise<QueueItem>; | ||
| } | ||
|
|
||
| /** | ||
| * Creates queue methods bound to a specific queue's data | ||
| * @param queueData - The queue data | ||
| * @param service - The queue service instance | ||
| * @returns Object containing queue methods | ||
| */ | ||
| function createQueueMethods(queueData: RawQueueGetResponse, service: QueueServiceModel): QueueMethods { | ||
| return { | ||
| async getAllItems<T extends QueueGetAllItemsOptions = QueueGetAllItemsOptions>(options?: T): Promise< | ||
| T extends HasPaginationOptions<T> | ||
| ? PaginatedResponse<QueueItem> | ||
| : NonPaginatedResponse<QueueItem> | ||
| > { | ||
| if (queueData.id === undefined) throw new Error('Queue ID is undefined'); | ||
| if (queueData.folderId === undefined) throw new Error('Folder ID is undefined'); | ||
| return service.getAllItems(queueData.id, queueData.folderId, options); | ||
| }, | ||
|
|
||
| async insertItem(specificData: Record<string, QueueItemValue>, options?: QueueInsertItemOptions): Promise<QueueItem> { | ||
| if (!queueData.name) throw new Error('Queue name is undefined'); | ||
| if (queueData.folderId === undefined) throw new Error('Folder ID is undefined'); | ||
| return service.insertItemByName(queueData.name, queueData.folderId, specificData, options); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a queue object with methods attached | ||
| * @param queueData - The queue data | ||
| * @param service - The queue service instance | ||
| * @returns Queue data with bound methods | ||
| */ | ||
| export function createQueueWithMethods(queueData: RawQueueGetResponse, service: QueueServiceModel): QueueGetResponse { | ||
| return Object.assign({}, queueData, createQueueMethods(queueData, service)); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a insertItem example as well?