@appsemble/node-utils
Version:
NodeJS utilities used by Appsemble internally.
34 lines (33 loc) • 1.57 kB
TypeScript
import { type ResourceDefinition } from '@appsemble/lang-sdk';
import { type App } from '@appsemble/types';
import { type Context } from 'koa';
import { type Options, type OrderItem, type WhereOptions } from '../types.js';
/**
* The `selectedGroupId` value representing the app-wide (ungrouped) scope, as
* opposed to a concrete group id.
*/
export declare const appWideGroupId = -1;
/**
* Collapse a `selectedGroupId` selection to a single group for operations that
* are inherently scoped to one group (create, update, reorder).
*
* @param selectedGroupId The selected group ids from the query parameters.
* @returns The first concrete group id, or null for the app-wide scope.
*/
export declare function getSingleGroupId(selectedGroupId?: number[]): number | null;
/**
* Build a resource `GroupId` filter for operations that may span multiple
* groups (query, delete).
*
* The app-wide scope (`appWideGroupId`, or an empty selection) matches
* resources without a group; concrete ids match resources in those groups.
*
* @param selectedGroupId The selected group ids from the query parameters.
* @returns A value for a resource `GroupId` where clause.
*/
export declare function getGroupIdWhere(selectedGroupId?: number[]): WhereOptions[string];
export declare function generateResourceQuery(ctx: Context, { parseQuery }: Options, resourceDefinition?: ResourceDefinition): {
order: OrderItem[];
where: WhereOptions;
};
export declare function deleteResourcesRecursively(type: string, app: App, options: Options, context: Context): Promise<void>;