@convo-lang/convo-lang
Version:
The language of AI
53 lines (52 loc) • 2.77 kB
TypeScript
import { ResultTypeVoid } from "../result-type.js";
import { ConvoDbCommand, ConvoDbDriver, ConvoDbDriverFunction, ConvoNodeCondition, ConvoNodeQuery } from "./convo-db-types.js";
/**
* Normalizes a convo node path.
*
* Normalization rules:
* - leading and trailing whitespace is trimmed
* - the path must be absolute and start with `/`
* - duplicate slashes are collapsed to a single slash
* - trailing slashes are removed except for the root path `/`
* - `.` and `..` path segments are not allowed
* - empty strings are invalid
*
* Wildcard rules:
* - `none` no `*` characters are allowed
* - `end` validates query path globs and is retained for backwards compatibility
* - `any` validates query path globs
* - `*` matches zero or more characters within a single path segment
* - `**` matches zero or more complete path segments and must be its own path segment
* - `*` and `**` are the only supported wildcard tokens
*
* Returns the normalized path or `undefined` if the path is invalid.
*/
export declare const normalizeConvoNodePath: (path: string | null | undefined, wildcard: "none" | "end" | "any") => string | undefined;
export declare const validateConvoNodeCondition: (condition: ConvoNodeCondition) => string | undefined;
export declare const validateConvoNodeQuery: (query: ConvoNodeQuery<any>) => string | undefined;
/**
* Calls a ConvoDbDriver function and ensures the specified function is an allowed function to be called
*/
export declare const callConvoDbDriverCmdAsync: <FN extends ConvoDbDriverFunction>(driver: ConvoDbDriver, fn: FN, args: Parameters<ConvoDbDriver[FN]>) => ReturnType<ConvoDbDriver[FN]>;
/**
* Sets the `permissionFrom` and `permissionRequired` based on `identityPath` and the action being
* taken by the step. The `permissionFrom` of the query will be updated if it is defined but does
* not match the `identityPath`
*/
export declare const applyIdentityToConvoDbQuery: (identityPath: string, query: ConvoNodeQuery<any>) => ConvoNodeQuery;
/**
* Sets the permissionFrom of the given object to `identityPath` If the given `permissionObject`
*/
export declare const applyIdentityToPermission: <T extends {
permissionFrom?: string;
}>(identityPath: string, permissionObject: T) => T;
/**
* Applies the identityPath to all properties of all commands. Changes to the commands are made in-place,
* mutating the commands.
*/
export declare const applyIdentityToConvoDbCommands: (identityPath: string, cmds: ConvoDbCommand[]) => ResultTypeVoid;
/**
* Applies the identityPath to all properties of the command. Changes to the command are made in-place,
* mutating the command.
*/
export declare const applyIdentityToConvoDbCommand: (identityPath: string, cmd: ConvoDbCommand<any>) => ResultTypeVoid;