@sketch-hq/sketch-assistant-utils
Version:
Utility functions and types for Sketch Assistants.
30 lines • 1.53 kB
TypeScript
import { AssistantDefinition, AssistantEnv, Maybe, RuleDefinition } from '@sketch-hq/sketch-assistant-types';
/**
* Prepare an assistant package. That is, un-roll its exported value into a flat list of assistant
* functions, invoke and await them to obtain a flat list of concrete assistant definitions which is
* then merged to form a final/single assistant definition.
*
* Assistant preparation is performed at runtime by an assistant runner.
*
* @param source The assistant package to prepare
* @param context The env within which the assistant package is being prepared
*/
declare const prepare: (pkg: unknown, env: AssistantEnv) => Promise<AssistantDefinition>;
/**
* Merge assistant definitions together to form a single assistant definition, with a syntax similar
* to Object.assign(). Assistants are merged from the right-most argument to the left into
* preceeding arguments, according to the following algorithm:
*
* 1. Rule configuration objects are merged together, with values from right-most assistants
* overriding those from the next assistant to the left
* 2. Assistant rule function arrays are concatenated
*
* @param sources Assistant definitions to merge
*/
declare const assign: (...sources: AssistantDefinition[]) => AssistantDefinition;
/**
* Lookup a rule definition by rule name.
*/
declare const getRuleDefinition: (assistant: AssistantDefinition, ruleName: string) => Maybe<RuleDefinition>;
export { prepare, assign, getRuleDefinition };
//# sourceMappingURL=index.d.ts.map