/*! * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { QueryType } from '../query'; import { ReadonlyTask, Task } from '../task'; import TaskClient from './client'; import { Listener } from './listener'; import { ArrayWithContinuation, CreateTaskOptions, IterateOptions, IterateSummaryOptions, ListenOptions, ListOptions, ListPageOptions, ListSummaryOptions, ListSummaryPageOptions, TaskHandler } from './types'; /** * Version of {@link TaskClient} that has all of its operations automatically * scoped to a single task type. * * @public */ export default class ScopedTaskClient { private _client; private _type; /** * @internal */ constructor(client: TaskClient, type: string); /** * Creates a task and saves it to the database. * * @param payload - Payload containing the data for the task * @param options - Options to configure the newly created task * * @public */ create(payload: T, options?: CreateTaskOptions): Promise>; /** * Retrieves the task of the given type with the provided id, if one exists. * If the task is not found, undefined is returned. * * @param id - The task's id * * @public */ get(id: string): Promise | undefined>; /** * Retrieves all tasks of the given type, paged using the provided list * options. * * @param options - Options controlling which tasks to retrieve * * @public */ list(options?: ListOptions): Promise[]>; /** * Retrieves a single page from the database for tasks of the given type, * optionally starting from the provided continuation token. * * @param options - Options controlling which tasks to retrieve * * @public */ listPaged(options?: ListPageOptions): Promise>>; /** * Retrieves a all tasks of the given type with the entire payload omitted * by default. This is primarily useful if you have tasks with a large * amount of data in the payload that you don't need to see in the listed * results and you want to save cost/memory. * * @remarks * * Results are paged, filtered and sorted using the provided options. You * may also specify certain properties of the payload you want to see in the * returned task through the options. * * @param options - Options controlling which tasks to retrieve * * @public */ listSummary(options?: ListSummaryOptions): Promise[]>; /** * Retrieves a single page of tasks of the given type with the entire payload * omitted by default, optionally starting from the provided continuation * token. This is primarily useful if you have tasks with a large amount of * data in the payload that you don't need to see in the listed results and * you want to save cost/memory. * * @remarks * * Results are paged, filtered and sorted using the provided options. You * may also specify certain properties of the payload you want to see in the * returned task through the options. * * @param type - Task type * @param options - Options controlling which tasks to retrieve * * @public */ listSummaryPaged(options?: ListSummaryPageOptions): Promise>>; /** * Returns an async iterator for iterating over all tasks of the given type, * optionally filtered/sorted using the provided options object. * * @remarks * * _NOTE: Asynchronous iterators are a new feature of Javascript and are * only available without a polyfill starting in Node.js 10. You can make * use of async iterators in prior versions of Node.js by using TypeScript * or Babel to downcompile the code for you: * https://node.green/#ES2018-features-Asynchronous-Iterators_ * * @param options - Options controlling which tasks to retrieve and the * order in which to receive them * * @public */ iterate(options?: IterateOptions): AsyncIterable>; /** * Returns an async iterator for iterating over all tasks of the given type * with the entire payload omitted by default. This is primarily useful if * you have tasks with a large amount of data in the payload that you don't * need to see in the listed results and you want to save cost/memory. * * @remarks * * Results are filtered and sorted using the provided options. You may also * specify certain properties of the payload you want to see in the returned * task through the options. * * _NOTE: Asynchronous iterators are a new feature of Javascript and are * only available without a polyfill starting in Node.js 10. You can make * use of async iterators in prior versions of Node.js by using TypeScript * or Babel to downcompile the code for you: * https://node.green/#ES2018-features-Asynchronous-Iterators_ * * @param options - Options controlling which tasks to retrieve and the * order in which to receive them * * @public */ iterateSummary(options?: IterateSummaryOptions): AsyncIterable>; /** * Compute the number of tasks of the given type that currently exist, * optionally filtered to a custom group of tasks within the type. * * @param filter - Query filter specifying which tasks within the provided * type to include */ count(filter?: QueryType.Bool): Promise; /** * Disables tasks of the scoped type, optionally filtered to a custom * group of tasks within the type. * * @param filter - Query filter specifying which tasks within the scoped * type to disable * * @public */ disable(filter?: QueryType.Bool): Promise; /** * Enables tasks of the scoped type, optionally filtered to a custom group * of tasks within the type. * * @param filter - Query filter specifying which tasks within the scoped * type to enable * * @public */ enable(filter?: QueryType.Bool): Promise; /** * Delete the task from the database. The operation is idempotent and will * succeed even if the task has already been deleted. * * @param id - The task's id * * @public */ deleteOne(id: string): Promise; /** * Deletes tasks of the scoped type, optionally filtered to a custom group * of tasks within the type. * * @param filter - Query filter specifying which tasks within the scoped * type to delete * * @public */ delete(filter?: QueryType.Bool): Promise; /** * Start listening for tasks of the scoped type. * * @param handler - Function to call with each task received for processing. * May be synchronous or asynchronous * @param options - Options for configuring the listener * * @public */ listen(handler: TaskHandler, options?: ListenOptions): Listener; } //# sourceMappingURL=scoped.d.ts.map