@gmetrixr/rjson
Version:
(R)ecursive Json
53 lines (52 loc) • 3.1 kB
TypeScript
import { RecordFactory } from "../R/RecordFactory";
import { ClipboardR, RecordNode } from "../R/RecordNode";
import { RT } from "../R/RecordTypes";
export declare class SceneFactory extends RecordFactory<RT.scene> {
constructor(json: RecordNode<RT.scene>);
/** Overriding add rule: Sub record ids should be made unique after duplications - this helps keeping all ids in the tree unique */
addRecord<N extends RT>(this: SceneFactory, record: RecordNode<N>, position?: number): RecordNode<N> | undefined;
/**
* adds record into the group if groupElementId is present
* else adds record to the scene
*/
addDeepRecord<N extends RT>(this: SceneFactory, { record, position, groupElementId }: {
record: RecordNode<N>;
position?: number;
groupElementId?: number;
}): RecordNode<N> | undefined;
/** Overriding duplicate rule: Sub record ids should be made unique after duplications - this helps keeping all ids in the tree unique */
duplicateRecord<N extends RT>(this: SceneFactory, type: N, id: number): RecordNode<N> | undefined;
/**
* Overriding duplicate rule: Sub record ids should be made unique after duplications - this helps keeping all ids in the tree unique
*/
duplicateDeepRecord<N extends RT>(type: N, id: number): RecordNode<N> | undefined;
/** Overriding delete element: Deleting an element/variable (any CogObject) should also delete its rules */
deleteRecord<N extends RT>(this: SceneFactory, type: N, id: number): RecordNode<N> | undefined;
/** Overriding delete deep element: Deleting an element/variable (any CogObject) should also delete its rules */
deleteDeepRecord<N extends RT>(this: SceneFactory, type: N, id: number): RecordNode<N> | undefined;
/**
* Deleting an element/variable (any CogObject) should also delete its rules
*/
deleteRulesForCoId(this: SceneFactory, id: number): void;
/**
* Makes sure all event ids and action ids don't clash with any of the event/actions ids in the current scene
* This is useful when a rule is duplicated - we need to change the event_id's and action_id's of
* all the WhenEvents and ThenActions inside the rule to unique ones.
*/
dedupeWeTaIds(this: SceneFactory, rule: RecordNode<RT.rule>): void;
/**
* Makes sure that all elements in a single scene have unique ids. This function ensures that whenever a group is duplicated (at any depth),
* new ids are generated for all it's children
* @param group
*/
dedupeGroupElements(this: SceneFactory, group: RecordNode<RT.element>): void;
/**
* ISSUE : We were facing issue when we copy element from root to group, id for that element was duplicated and that was causing an issue. Below id fix for that
* this function will add record with new element id to prevent duplicate issue.
*/
pasteFromClipboardObject(this: SceneFactory, { obj, position, groupElementId }: {
obj: ClipboardR;
position?: number;
groupElementId?: number;
}): (RecordNode<RT> | undefined)[];
}