import { Dictionary, Iterator } from "../Collections"; import type { Activity } from "./Activity"; import type { Component } from "./Component"; import type { DeploymentConfig } from "./DeploymentConfig"; import type { Form } from "./Form"; import type { Program } from "./Program"; import type { Reference } from "./Reference"; import type { Resource } from "./Resource"; import type { Step } from "./Step"; import type { Transition } from "./Transition"; import type { Iterable } from "../Collections"; /** Contains the results of the import operation. */ export interface ImportResults { [id: number]: Resource | undefined; [name: string]: Resource | undefined; start?: Step; } /** Delegates remapping of identifiers and names. */ interface NameIdMapper { (id: number, name: string): boolean | number | string | { id?: number; name?: string; }; } /** * Inspects and manipulates a Workflow program. * @product This is intended for internal use only within VertiGIS Studio products. */ export declare class ProgramInspector { /** The id of the editor created this ProgramInspector. */ readonly editorId: string | undefined; /** Indicates the program being built. */ program: Program; /** Indicates the starting step. */ start: Step | undefined; /** Indicates the components being built. */ protected components: ComponentList; /** Indicates the forms being built. */ protected forms: FormList; /** Any validation issues that have been hidden by the author in the designer. */ protected hiddenValidationIssues: Set; /** Indicates the map of incidents. */ protected incidents: IncidentList; /** Indicates the references being built. */ protected references: ReferenceList; /** Indicates the steps being built. */ protected steps: StepList; /** Indicates the transitions being built. */ protected transitions: TransitionList; /** * Creates a new instance of the `ProgramInspector` class. * @param editorId (optional) The id of the editor created this ProgramInspector. */ constructor(editorId?: string); /** Adds a new component. */ addComponent(): Component; /** Adds a new form. */ addForm(): Form; /** Adds a reference. */ addReference(): Reference; /** Adds a new step. */ addStep(): Step; /** Adds a new transition. */ addTransition(source: Step, target: Step): Transition | undefined; /** Iterates over all the assets. */ all(): Iterator; /** Iterates over the components. */ allComponents(): Iterator; /** Iterates over the forms. */ allForms(): Iterator
; /** Iterates over the references. */ allReferences(): Iterator; /** Iterates over the steps. */ allSteps(): Iterator; /** Iterates over the transitions. */ allTransitions(): Iterator; /** Forms a lookup cache of the components. */ cacheComponents(): Record; /** Forms a lookup cache of the forms. */ cacheForms(): Record; /** Forms a lookup cache of the references. */ cacheReference(): Record; /** Forms a lookup cache of the steps. */ cacheSteps(): Record; /** Forms a lookup cache of the transitions. */ cacheTransitions(): Record; /** Changes the branch of the given step or transition. */ changeBranch(transition: Transition, branch: boolean | number | string): boolean; /** Changes the parent of the given step or transition. */ changeParent(activity: Activity, parent: Component | undefined): boolean; /** Changes the source of the given transition. */ changeSource(transition: Transition, source: Step | undefined): boolean; /** Changes the starting step. */ changeStart(step: Step): boolean; /** Changes the target of the given transition. */ changeTarget(transition: Transition, target: Step | undefined): boolean; /** Checks to see if the given identifier exists. */ exists(resource: Resource | undefined): boolean; /** Exports the program. */ export(): Program; /** Retrieves the resource for the given identifier. */ find(id: number): Resource | undefined; /** Retrieves the component for the given identifier or name. */ findComponent(nameId: number | string): Component | undefined; /** Retrieves the form for the given identifier or name. */ findForm(nameId: number | string): Form | undefined; /** Retrieves the reference for the given identifier or name. */ findReference(nameId: number | string): Reference | undefined; /** Retrieves the reference for the given identifier or name. */ findStep(nameId: number | string): Step | undefined; /** Iterates over all the assets. */ findTransition(nameId: number | string): Transition | undefined; /** * Retrieves the default locale for the workflow. */ getDefaultLocale(): string; /** Returns deployment configuration details. */ getDeploymentConfig(): DeploymentConfig; /** * This method returns the ids of Validation Issues that have been hidden by the author in the designer. * @returns The ids of Validation Issues that have been hidden by the author in the designer. */ getHiddenValidationIssues(): Set; /** * Retrieves the string lookups for the given locale. * @param locale The locale of the strings to retrieve. Defaults to the invariant strings. */ getStrings(locale?: string): Record; /** * Imports a workflow program (must be pure JSON). * @param program The program as JSON or as a JSON-string. * @param compact Instructs the parsing to assume compact form. * @param mapper Indicates how identifiers and names should get preserved. */ import(program: Program | string, compact?: boolean, mapper?: NameIdMapper): ImportResults; /** Tests if the given resource is an activity. */ isActivity(resource: Resource): resource is Activity; /** Tests if the given resource is a component */ isComponent(resource: Resource | undefined): resource is Component; /** Tests if the given resource is a form. */ isForm(resource: Resource | undefined): resource is Form; /** Tests if the given resource is a member of the component. */ isParent(component: Component, resource: Resource): resource is Activity; /** Tests if the given resource is a reference. */ isReference(resource: Resource | undefined): resource is Reference; /** Tests if the given resource is the source for the given transition. */ isSource(transition: Transition, resource: Resource): resource is Step; /** Tests if the given resource is a step. */ isStep(resource: Resource | undefined): resource is Step; /** Tests if the given resource is the target for the given transition. */ isTarget(transition: Transition, resource: Resource): resource is Step; /** Tests if the given resource is a transition. */ isTransition(resource: Resource | undefined): resource is Transition; /** Yields a new identifier that is not currently in use. */ newId(nextId?: number): number; /** Attempts to align the underlying program with the actual state of the inspector. */ /** Use this to get a static view of the program (say for saving a project). */ realize(): void; /** Relates components to steps and transitions. */ relate(components: Iterable): Iterator; /** Relates steps to transitions. */ relate(steps: Iterable, branch?: string): Iterator; /** Relates transitions to steps. */ relate(transitions: Iterable): Iterator; /** Relates resources to resources. */ relate(member: Iterable): Iterator; release(): void; /** Removes the given resource. */ remove(resource: Resource, orphan?: boolean): boolean; /** Removes the given resources via an iterator. */ remove(resources: Resource[], orphan?: boolean): number; /** Removes the given resources via an iterator. */ remove(resources: Iterator, orphan?: boolean): number; /** Removes the given component. */ removeComponent(resource: Resource): boolean; /** Removes the given form. */ removeForm(resource: Resource): boolean; /** Removes the given reference. */ removeReference(resource: Resource): boolean; /** Removes the given step. */ removeStep(resource: Resource): boolean; /** Removes the given transition. */ removeTransition(resource: Resource): boolean; /** Renames the given resource. */ rename(resource: Resource, name: string): string | undefined; /** Renames the given componnent. */ renameComponent(resource: Resource, name: string): boolean; /** Renames the given form. */ renameForm(resource: Resource, name: string): boolean; /** Renames the given reference. */ renameReference(resource: Resource, name: string): boolean; /** Renames the given step. */ renameStep(resource: Resource, name: string): boolean; /** Renames the given transition. */ renameTransition(resource: Resource, name: string): boolean; /** Resets the entire state. */ reset(): void; resolveStart(start?: Step | number | string): Step | undefined; /** Renames the given component to another identifer. */ shift(resource: Resource, id: number): false | void; /** Renames the given component to another identifer. */ shiftComponent(resource: Resource, id: number): boolean; /** Shifts the given form to another identifier. */ shiftForm(resource: Resource, id: number): boolean; /** Shifts the given step to another identifier. */ shiftReference(resource: Resource, id: number): boolean; /** Shifts the given step to another identifier. */ shiftStep(resource: Resource, id: number): boolean; /** Renames the given transition to another identifier. */ shiftTransition(resource: Resource, id: number): boolean; toJSON(): Program; } interface Incident { master?: ResourceList>; resource?: TResource; token: string; } declare class IncidentList extends Dictionary> { nextId: number; findFor(resource: Resource | undefined): Incident | undefined; newId(): number; relate(resource: Resource, branch: string | undefined): Iterable; } declare abstract class ResourceList> extends Dictionary { incidents: IncidentList; protected cacheLookup: Record | undefined; constructor(incidents: IncidentList); add(): TIncident; all(): Iterator; cache(): Record; changeParent(this: StepList | TransitionList, incident: StepIncident | TransitionIncident, parent: ComponentIncident | undefined): void; findFor(resource: Resource | undefined): TIncident | undefined; findWith(nameId: number | string): T | undefined; relate(_incident: Incident, _branch: string | undefined): Iterable; removeFor(resource: Resource | undefined): boolean; /** * Renames the specified item, returning the old name. * @param incident The thing to be renamed. * @param name The new name. */ rename(incident: TIncident, name: string | undefined): string | undefined; renameFor(resource: Resource | undefined, name: string): boolean; shift(incident: TIncident, id: number): void; shiftFor(resource: Resource | undefined, id: number): boolean; test(incident: Incident | undefined): incident is TIncident; unlink(incident: Incident): number; abstract create(): T; abstract qualify(name: string): string; } interface ComponentIncident extends Incident { steps?: Dictionary; transitions?: Dictionary; } declare class ComponentList extends ResourceList { create(): Component; qualify(name: string): string; relate(incident: ComponentIncident): Iterable; unlink(incident: ComponentIncident): number; } declare class FormList extends ResourceList> { create(): Form; qualify(name: string): string; } declare class ReferenceList extends ResourceList> { create(): Reference; qualify(name: string): string; } interface StepIncident extends Incident { branches?: Record; master?: StepList; parent?: ComponentIncident; transitions?: Dictionary; } declare class StepList extends ResourceList { create(): Step; qualify(name: string): string; relate(incident: StepIncident, branch: string): Iterable; siblings(incident: ComponentIncident): Dictionary; unlink(incident: StepIncident): number; } interface TransitionIncident extends Incident { master?: TransitionList; parent?: ComponentIncident; source?: StepIncident; target?: StepIncident; } declare class TransitionList extends ResourceList { create(): Transition; qualify(name: string): string; relate(incident: TransitionIncident): Iterable; siblings(incident: ComponentIncident): Dictionary; unlink(incident: TransitionIncident): number; } export type LocaleParts = { language: string; script?: string; territory?: string; }; /** * Parses a locale code into its component parts. * If the locale is invalid, nothing is returned. */ export declare function parseLocale(locale: string | undefined): LocaleParts | undefined; /** Converts a locale code to its canonicalized form, e.g. "de-ch" becomes "de-CH", "ZH-HANS-CN" becomes "zh-Hans-CN"). */ export declare function canonicalizeLocale(locale: string | undefined): string | undefined; export {};