webgme
Version:
Web-based Generic Modeling Environment
1,238 lines (1,148 loc) • 163 kB
TypeScript
// Type definitions for webgme
// Project: https://webgme.org
// Definitions by: Fred Eisele <https://github.com/phreed>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
// Based on examination of
// Example: https://github.com/typed-typings/env-node/blob/master/0.12/node.d.ts
// Source: https://raw.githubusercontent.com/phreed/typed-npm-webgme/master/webgme.d.ts
// Documentation: https://editor.webgme.org/docs/source/index.html
// https://github.com/webgme/webgme/tree/master/config
declare module "webgme" {
export class Standalone {
constructor(config: any);
start(fn: any): void;
stop(): void;
}
export interface GmeAuth {
unload(): Promise<void>,
connect(): Promise<void>,
listUsers(query?: object): Promise<GmeUser>,
getUser(userId: string, query?: object): Promise<GmeUser>;
addUser(userId: string, email: string, password: string, canCreate: boolean, options: any): Promise<GmeUser>;
updateUser(userId: string, userData: UserDataUpdate): Promise<GmeUser>;
deleteUser(userId: string, force?: boolean): Promise<void>;
reEnableUser(userId: string): Promise<GmeUser>;
listOrganizations(query?: object): Promise<GmeOrgData>;
getOrganization(orgId: string, query?: object): Promise<GmeOrgData>;
getAdminsInOrganization(origId: string): Promise<string[]>;
addOrganization(orgId: string, info: object): Promise<GmeOrgData>;
updateOrganizationInfo(orgId: string, info: object): Promise<GmeOrgData>;
addUserToOrganization(userId: string, orgId: string): Promise<void>;
addUserToOrganization(userId: string, orgId: string): Promise<void>;
setAdminForUserInOrganization(userId: string, orgId: string, makeAdmin: boolean): Promise<void>;
removeOrganizationByOrgId(origId: string, force?: boolean): Promise<void>;
reEnableOrganization(origId: string): Promise<GmeUser>;
}
export interface AccessLevel {
read: boolean;
write: boolean;
delete: boolean;
}
export interface UserData {
siteAdmin?: boolean;
displayName?: string;
data?: object;
settings?: object;
}
export interface UserDataCreate extends UserData {
aadId?: string;
overwrite?: boolean;
disabled?: boolean;
}
export interface UserDataUpdate extends UserData {
canCreate?: boolean;
email?: string;
resetHash?: string;
lastReset?: string;
password?: string;
}
export interface GmeUser extends UserData {
_id: string;
aadId?: string;
disabled: boolean;
email: string;
data: object;
settings: object;
orgs: string[];
projects: { [projectId: string]: AccessLevel }
}
export interface GmeOrgData {
_id: string;
info: object;
admins: string[];
users: string[];
projects: { [projectId: string]: AccessLevel }
}
export interface UserProject extends GmeClasses.ProjectInterface {
projectName: string;
projectId: string;
// Can be used to switch user
setUser(username: string): void;
}
export interface ProjectMetadata {
_id: string;
owner: string;
info: ProjectInfo;
branches: { [name: string]: string }; // name to commit hash
}
export interface ProjectInfo {
kind: string;
}
export interface OpenProjectParams {
username?: string;
projectId: string;
}
export interface SafeStorage {
openDatabase(): Promise<void>,
closeDatabase(): Promise<void>,
openProject(data: OpenProjectParams): Promise<UserProject>,
getProjects(data: any): Promise<ProjectMetadata[]>;
}
export function addToRequireJsPaths(gmeConfig: any): void;
export function standaloneServer(gmeConfig: any): void;
export function getGmeAuth(gmeConfig: any): Promise<GmeAuth>;
export function getStorage(logger: Global.GmeLogger, gmeConfig: any, gmeAtuh: any): SafeStorage;
/**
* Options passed to middleware initializers by the webgme server.
*
* `gmeAuth`, `safeStorage` and `workerManager` are not ready to use until the `start` function is called.
* (However inside an incoming request they are all ensured to have been initialized.)
*/
export type MiddlewareOptions = {
/** Passed by the webgme server. */
gmeConfig: GmeConfig.GmeConfig;
/** logger */
logger: Global.GmeLogger;
/** Ensures the user is authenticated. */
ensureAuthenticated: Function;
/** If authenticated retrieves the userId from the request. */
getUserId: (req: any) => string;
/** Authorization module. */
gmeAuth: GmeAuth;
/** Accesses the storage and emits events (PROJECT_CREATED, COMMIT..). */
safeStorage: SafeStorage;
/** Spawns and keeps track of "worker" sub-processes. */
workerManager: Object;
};
}
declare module "blob/BlobMetadata" {
export default class BlobMetadata implements Blobs.BlobMetadata {
constructor();
name: string;
size: number;
mime: string;
context: any;
contentType: string;
}
}
declare module "plugin/PluginConfig" {
export = GmeConfig.PluginConfig;
}
declare module "webgme/config/config.default" {
export = GmeConfig.config;
}
declare module "webgme/common" {
export = GmeCommon;
}
declare module "common/util/canon" {
export = GmeUtil.CANON;
}
declare module "common/util/assert" {
export = GmeUtil.ASSERT;
}
declare module "js/PanelBase/PanelBase" {
export = GmePanel.PanelBase;
}
declare module "js/PanelBase/PanelBaseWithHeader" {
export = GmePanel.PanelBaseWithHeader;
}
declare module "js/PanelManager/IActivePanel" {
export = GmePanel.IActivePanel;
}
declare module "js/NodePropertyNames" {
var names: Gme.NodePropertyNames;
export = names;
}
declare module "js/RegistryKeys" {
const keys: Gme.RegistryKeys;
export = keys;
}
declare module "js/Utils/GMEConcepts" {
export = Gme.Concepts;
}
declare module "js/Utils/PreferencesHelper" {
const helper: Gme.PreferenceHelper;
export = helper;
}
declare module "plugin/PluginBase" {
// const pb: GmePlugin.PluginBase;
export = GmePlugin.PluginBase;
}
declare namespace Gme {
interface NodePropertyNames {
Attributes: {
name: string;
};
}
interface RegistryKeys {
POSITION: string;
}
interface PreferenceHelper {
getPreferences(): PreferenceHelper;
}
export namespace Concepts {
function isConnection(node: Core.Node): boolean;
interface ConnectionStyle {
startArrow: string;
endArrow: string;
}
interface ComposeChain {
objId: string;
subCompId: undefined | string;
}
interface ConnectionCollectionPair {
sources: ComposeChain[];
destinations: ComposeChain[];
}
}
type Connection = any;
interface Project {
name: string;
/** should always be true */
read: boolean;
write: boolean;
delete: boolean;
branches: {
[key: string]: string;
}
}
type ProjectResult = Project[] | { [key: string]: Project };
interface Pos2D {
x: number;
y: number;
}
interface VisualizerControl {
}
interface ObjectDescriptor {
id: string;
name: string;
childrenIds: string[];
parentId: string;
isConnection: boolean;
childrenNum: number;
position: number;
source: string;
target: string;
pointers: GmeCommon.Dictionary<GmeCommon.Pointer>;
srcPos: Pos2D;
dstPos: Pos2D;
srcObjId: string;
dstObjId: string;
control?: VisualizerControl;
metaInfo?: GmeCommon.Dictionary<string>;
preferencesHelper?: Gme.PreferenceHelper;
srcSubCompId?: string;
dstSubCompId?: string;
reconnectable?: boolean;
editable?: boolean;
}
/**
* primary values are: 'load' 'update' 'unload'
*/
export type TerritoryEventType = "load" | "unload" | "update" | "complete" | "incomplete";
interface Event {
id?: string;
etype: TerritoryEventType;
eid: string;
}
/**
* The eventHandler is invoked whenever there are
* changes to the nodes matching any of the patterns.
* There are three cases when it is triggered:
* - updateTerritory was invoked by us.
* - Another client made changes to nodes within the territory.
* - We made changes to any of the nodes (via the setters).
*
* * ('load')
* The node is loaded and we have access to it.
* It was either just created or this is the initial updateTerritory we invoked.
* * ('update')
* There were changes to the node (some might not apply to your application).
* The node is still loaded and we have access to it.
* * ('unload')
* The node was removed from the model (we can no longer access it).
* We still get the path/id via events[i].eid
* * (else)
* "Technical events" not used.
*/
interface TerritoryEventHandler {
(event: Event[]): void;
}
interface ChildCreationParams {
parentId: string;
baseId: string;
}
interface TransactionResult {
hash: string;
/**
* may be: 'SYNCED' or 'FORKED'
*/
status: string;
}
interface AttributeSchema {
/** integer, float, asset, string */
type: string;
/** array of possible/allowed values */
enum: string[];
}
interface ChildType {
/**
* The id of the loaded new child type
*/
id: string;
/**
* the minimum necessary amount of this type of child
*/
min: number;
/**
* the maximum allowed children of this type
*/
max: number;
}
interface PointerMeta {
/**
* the maximum allowed targets for a pointer is 1.
* more than 1 requires a set.
*/
max: number;
items: { id: string }[];
}
type TerritoryId = Core.GUID;
/**
* A pattern is a filter for nodes to load/watch.
*
* The root-node (with path '') always exists in a
* project so it is the safest starting point.
* We specify the number of levels in the containment
* hierarchy to load.
* It can be set to any positive integer [0, Inf).
*/
interface TerritoryPattern {
children: number;
}
/**
* https://github.com/webgme/webgme/wiki/GME-Client-API
*
* https://github.com/webgme/webgme/blob/master/src/client/js/client.js
*/
class Client {
constructor();
/**
* Connecting to the webGME database.
*/
connectToDatabase(callback: GmeCommon.ResultCallback<Connection>): void;
/**
* asIndexed true to get an object indexed by project ids.
*/
getProjectsAndBranches(asIndexed: boolean, callback: GmeCommon.ResultCallback<ProjectResult>): void;
/**
* The client opens a project and a branch and
* from there we can start registering for node events.
*/
selectProject(projectId: string, branchName: string, callback: GmeCommon.ResultCallback<any>): void;
/**
* Add a user associated with the pattern and an event-handler.
* The eventHandler is invoked whenever there are changes
* to the nodes matching any of the patterns.
* There are three cases when it is triggered:
* - **updateTerritory** was invoked by us.
* - Another client made changes to nodes within the territory.
* - We made changes to any of the nodes (via the setters).
*
* Returns the user-id.
*/
addUI(pattern: any, eventHandler: TerritoryEventHandler, guid?: TerritoryId): string;
/**
* Initiate the initial load of nodes matching the patterns.
*/
updateTerritory(userId: string, patterns: GmeCommon.Dictionary<TerritoryPattern>): void;
/**
* When we are no longer interested in the the
* nodes for the userId so we remove the user.
* This will prevent further invocations of
* our eventHandler and it will be cleaned up.
*/
removeUI(userId: string): void;
/**
* Typically called from within the event-handler.
*/
getNode(nodeId: GmeCommon.NodeId): Core.Node;
/**
* Get an array of all the META nodes as nodeObjs.
* Since these may change it is a good idea to invoke
* this each time the territory of the root changes.
*/
getAllMetaNodes(): Core.Node[];
setAttributes(nodeId: GmeCommon.NodeId, name: string, newName: string, message: string): void;
createChild(params: ChildCreationParams, message: string): void;
delMoreNodes(nodeIds: GmeCommon.NodeId[], message: string): void;
/**
* Transactions
*/
startTransaction(message: string): void;
setRegistry(nodeId: GmeCommon.NodeId, attr: string, property: any, message: string): void;
completeTransaction(message: string, callback: GmeCommon.ResultCallback<TransactionResult>): void;
/**
* make a new pointer object.
* The source and target should already be loaded.
*/
makePointer(sourceNodeId: GmeCommon.NodeId, pointerName: string, targetNodeId: GmeCommon.NodeId, message: string): GmeCommon.Pointer;
/**
* assign a node to a set
* The source and target should already be loaded.
*/
addMember(sourceNodeId: GmeCommon.NodeId, targetNodeId: GmeCommon.NodeId, setName: string, message: string): GmeCommon.Pointer;
getAllMetaNodes(): Core.Node[];
setAttributeSchema(nodeId: string, name: string, schema: AttributeSchema): void;
updateValidChildrenItem(nodeId: GmeCommon.NodeId, type: ChildType): void
setPointerMeta(metaNodeId: GmeCommon.NodeId, newPointerName: string, meta: Gme.PointerMeta): void;
/**
* Creates a new core instance using the state of the client and loads the root node.
*/
getCoreInstance(
options: CoreInstanceOptions,
callback: (err: Error, result: CoreInstanceResult) => void | Promise<void>
): void;
}
class ClientNode {
_id: string;
constructor(id: string, logger: Global.GmeLogger, state: any, storeNode: Function);
constructor();
getNode(id: GmeCommon.NodeId, logger: Global.GmeLogger, state: any, storeNode: Function): ClientNode;
getParentId(): GmeCommon.NodeId;
getId(): GmeCommon.NodeId;
getRelid(): GmeCommon.RelId;
getGuid(): Core.GUID;
getChildrenIds(): GmeCommon.NodeId[];
getBaseId(): GmeCommon.NodeId;
isValidNewBase(basePath: GmeCommon.Path): boolean;
isValidNewParent(parentPath: GmeCommon.Path): boolean;
getInheritorIds(): GmeCommon.NodeId[];
getAttribute(name: GmeCommon.Name): GmeCommon.OutAttr;
getOwnAttribute(name: GmeCommon.Name): GmeCommon.OutAttr;
getEditableAttribute(name: GmeCommon.Name): GmeCommon.OutAttr;
getOwnEditableAttribute(name: GmeCommon.Name): GmeCommon.OutAttr;
getRegistry(name: GmeCommon.Name): GmeCommon.Registry;
getOwnRegistry(name: GmeCommon.Name): GmeCommon.Registry;
getEditableRegistry(name: GmeCommon.Name): GmeCommon.Registry;
getOwnEditableRegistry(name: GmeCommon.Name): GmeCommon.Registry;
getPointer(name: GmeCommon.Name): GmeCommon.Pointer;
getPointerId(name: GmeCommon.Name): GmeCommon.SetId;
getOwnPointer(name: GmeCommon.Name): GmeCommon.Pointer;
getOwnPointerId(name: GmeCommon.Name): GmeCommon.SetId;
getPointerNames(): GmeCommon.Name[];
getOwnPointerNames(): GmeCommon.Name[];
getAttributeNames(): GmeCommon.Name[];
getValidAttributeNames(): GmeCommon.Name[];
getOwnAttributeNames(): GmeCommon.Name[];
getOwnValidAttributeNames(): GmeCommon.Name[];
getAttributeMeta(name: GmeCommon.Name): GmeCommon.AttrMeta;
getRegistryNames(): GmeCommon.Name[];
getOwnRegistryNames(): GmeCommon.Name[];
/** Set */
getMemberIds(setId: GmeCommon.SetId): GmeCommon.Path[];
getSetNames(): GmeCommon.Name[];
getMemberAttributeNames(setId: GmeCommon.SetId, memberId: GmeCommon.MemberId): GmeCommon.Name[];
getMemberAttribute(setId: GmeCommon.SetId, memberId: GmeCommon.MemberId): GmeCommon.OutAttr;
getEditableMemberAttribute(setId: GmeCommon.SetId, memberId: GmeCommon.MemberId, name: GmeCommon.Name): GmeCommon.OutAttr;
getMemberRegistryNames(setId: GmeCommon.SetId, memberId: GmeCommon.MemberId): GmeCommon.Name[];
getMemberRegistry(setId: GmeCommon.SetId, memberId: GmeCommon.MemberId, name: GmeCommon.Name): GmeCommon.Registry;
getEditableMemberRegistry(setId: GmeCommon.SetId, memberId: GmeCommon.MemberId, name: GmeCommon.Name): GmeCommon.Registry;
/** META */
getValidChildrenTypes(): GmeCommon.NodeId[];
getValildAttributeNames(): GmeCommon.Name[];
isValidAttributeValueOf(name: GmeCommon.Name, value: any): boolean;
getValidPointerNames(): GmeCommon.Name[];
getValidSetNames(): GmeCommon.Name[];
getConstraintNames(): GmeCommon.Name[];
getOwnConstraintNames(): GmeCommon.Name[];
getConstraint(name: GmeCommon.Name): Core.Constraint;
toString(): string;
getCollectionPaths(name: GmeCommon.Name): GmeCommon.Path[];
getInstancePaths(): GmeCommon.Path[];
getJsonMeta(): GmeCommon.Metadata[];
isConnection(): boolean;
isAbstract(): boolean;
isLibraryRoot(): boolean;
isLibraryElement(): boolean;
getFullyQualifiedName(): GmeCommon.Name;
getNamespace(): GmeCommon.Name;
getLibraryGuid(): Core.GUID;
getCrosscutsInfo(): GmeCommon.CrosscutsInfo;
getValidChildrenTypesDetailed(aspect: GmeCommon.Aspect, noFilter: boolean): GmeCommon.Dictionary<any>;
getValidSetMemberTypesDetailed(setName: GmeCommon.Name): { [key: string]: any };
getMetaTypeId(): GmeCommon.NodeId | null;
getBaseTypeId(): GmeCommon.NodeId | null;
isMetaNode(): boolean;
isTypeOf(typePath: GmeCommon.Path): boolean;
isValidChildOf(parentPath: GmeCommon.Path): boolean;
getValidChildrenIds(): GmeCommon.NodeId[];
isValidTargetOf(sourcePath: GmeCommon.Path, name: GmeCommon.Name): boolean;
getValidAspectNames(): GmeCommon.Name[];
getOwnValidAspectNames(): GmeCommon.Name[];
getAspectMeta(): GmeCommon.Metadata;
/** MixIns */
getMixinPaths(): GmeCommon.Path[];
canSetAsMixin(mixinPath: GmeCommon.Path): boolean;
isReadOnly(): boolean;
}
interface CoreInstanceOptions {
commitHash: GmeCommon.MetadataHash;
logger: Global.GmeLogger;
}
interface CoreInstanceResult {
core: GmeClasses.Core;
commitHash: GmeCommon.MetadataHash;
rootNode: Core.Node;
project: GmeClasses.ProjectInterface;
}
}
declare const WebGMEGlobal: Global.WebGmeGlobal;
declare namespace GmeClasses {
export type ArtifactCallback = (err: Error, result: Artifact) => void;
export interface Artifact {
name: GmeCommon.Name;
blobClient: Blobs.BlobClient;
descriptor: Blobs.BlobMetadata;
constructor(name: GmeCommon.Name, blobClient: Blobs.BlobClient, descriptor: Blobs.BlobMetadata): void;
/** Adds content to the artifact as a file. */
addFile: {
(name: GmeCommon.Name, content: Blobs.ObjectBlob, callback: GmeCommon.ResultCallback<GmeCommon.MetadataHash>): void;
(name: GmeCommon.Name, content: Blobs.ObjectBlob): Promise<GmeCommon.MetadataHash>;
}
/** Adds files as soft-link. */
addFileAsSoftLink: {
(name: GmeCommon.Name, content: Blobs.ObjectBlob, callback: GmeCommon.ResultCallback<GmeCommon.MetadataHash>): void;
(name: GmeCommon.Name, content: Blobs.ObjectBlob): Promise<GmeCommon.MetadataHash>;
}
/** Adds multiple files. */
addFiles: {
(files: { [name: string]: Blobs.ObjectBlob }, callback: GmeCommon.ResultCallback<GmeCommon.MetadataHash[]>): void;
(files: { [name: string]: Blobs.ObjectBlob }): Promise<GmeCommon.MetadataHash[]> | Promise<string>;
}
/** Adds multiple files as soft-links. */
addFilesAsSoftLinks: {
(files: { [name: string]: Blobs.ObjectBlob }, callback: GmeCommon.ResultCallback<GmeCommon.MetadataHash[]>): void;
(files: { [name: string]: Blobs.ObjectBlob }): Promise<GmeCommon.MetadataHash[]>;
}
/** Adds a metadataHash to the artifact using the given file path. */
addMetadataHash: {
(name: GmeCommon.Name, metadataHash: GmeCommon.MetadataHash, size: number, callback: GmeCommon.ResultCallback<GmeCommon.MetadataHash>): void;
(name: GmeCommon.Name, metadataHash: GmeCommon.MetadataHash, size?: number): Promise<GmeCommon.MetadataHash>;
(objectHashes: { [name: string]: string }, callback: GmeCommon.ResultCallback<GmeCommon.MetadataHash>): void;
(objectHashes: { [name: string]: string }): Promise<GmeCommon.MetadataHash>;
}
/** Adds metadataHashes to the artifact using the given file paths. */
addMetadataHashes: {
(name: GmeCommon.Name, metadataHash: GmeCommon.MetadataHash, size: number, callback: GmeCommon.ResultCallback<GmeCommon.MetadataHash[]>): void;
(name: GmeCommon.Name, metadataHash: GmeCommon.MetadataHash, size?: number): Promise<GmeCommon.MetadataHash[]>;
(objectHashes: { [name: string]: string }, callback: GmeCommon.ResultCallback<GmeCommon.MetadataHash[]>): void;
(objectHashes: { [name: string]: string }): Promise<GmeCommon.MetadataHash[]>;
}
/** Adds a metadataHash to the artifact using the given file path. */
addObjectHash: {
(name: GmeCommon.Name, metadataHash: GmeCommon.MetadataHash, callback: GmeCommon.ResultCallback<GmeCommon.MetadataHash>): void;
(name: GmeCommon.Name, metadataHash: GmeCommon.MetadataHash): Promise<GmeCommon.MetadataHash>;
}
/** Adds metadataHashes to the artifact using the given file paths. */
addObjectHashes: {
(objectHashes: { [name: string]: string }, callback: GmeCommon.ResultCallback<GmeCommon.MetadataHash[]>): void;
(objectHashes: { [name: string]: string }): Promise<GmeCommon.MetadataHash[]>;
}
/** Saves this artifact and uploads the metadata to the server's storage. */
save: {
(callback: GmeCommon.ResultCallback<GmeCommon.MetadataHash>): void;
(message?: string): Promise<GmeCommon.MetadataHash>;
}
}
/**
commitHash - metadataHash of the commit.
status - storage.constants./SYNCED/FORKED/MERGED
*/
export interface Commit {
commitHash: GmeCommon.MetadataHash;
status: string;
branchName: string;
}
export interface Result {
success: boolean;
/** array of PluginMessages */
messages: string[];
/** array of hashes */
artifacts: GmeCommon.ArtifactHash[];
pluginName: string;
startTime: Date;
finishTime: Date;
error: Error;
projectId: any;
commits: any[];
/**
* Gets the success flag of this result object
*/
getSuccess(): boolean;
/**
* Sets the success flag of this result.
*/
setSuccess(value: boolean): void;
/**
* Returns with the plugin messages.
*/
getMessages(): GmeCommon.Message[];
/**
* Adds a new plugin message to the messages list.
*/
addMessage(pluginMessage: GmeCommon.Message): void;
/**
* Returns the plugin artifacts.
*/
getArtifacts(): Artifact[];
/**
* Adds a saved artifact to the result - linked via its metadataHash.
* Takes the metadataHash of saved artifact.
*/
addArtifact(metadataHash: GmeCommon.MetadataHash): void;
/**
* Adds a commit to the commit container.
*/
addCommit(commitData: Commit): void;
/**
* Gets the name of the plugin to which the result object belongs.
*/
getPluginName(): string;
//------------------------------------------
// Methods used by the plugin manager
//-----------------------------------------
/**
* Sets the name of the plugin to which the result object belongs to.
*/
setPluginName(pluginName: string): string;
/**
* Sets the name of the projectId the result was generated from.
*/
setProjectId(projectId: string): void;
/**
* Gets the ISO 8601 representation of the time when the plugin started its execution.
*/
getStartTime(): GmeCommon.ISO8601;
/**
* Sets the ISO 8601 representation of the time when the plugin started its execution.
*/
setStartTime(time: GmeCommon.ISO8601): void;
/**
* Gets the ISO 8601 representation of the time when the plugin finished its execution.
*/
getFinishTime(): GmeCommon.ISO8601;
/**
* Sets the ISO 8601 representation of the time when the plugin finished its execution.
*/
setFinishTime(time: GmeCommon.ISO8601): void;
/**
* Gets error if any error occured during execution.
* FIXME: should this return an Error object?
*/
getError(): GmeCommon.ErrorStr;
/**
* Sets the error string if any error occured during execution.
*/
setError(error: GmeCommon.ErrorStr | Error): void;
/**
* Serializes this object to a JSON representation.
*/
serialize(): { success: boolean, messages: GmeCommon.Message[], pluginName: string, finishTime: string };
}
export enum TraversalOrder { 'BFS', 'DFS' }
/**
* The details of a nodes creation.
*/
export interface NodeParameters {
/** the parent of the node to be created. */
parent?: Core.Node | null;
/** the base of the node to be created. */
base?: Core.Node | null;
/** the relative id of the node to be created
* (if reserved, the function returns the node behind the relative id) */
relid?: GmeCommon.RelId;
/** the GUID of the node to be created */
guid?: Core.GUID;
}
/**
* information about your library project.
*/
export interface LibraryInfo {
/** the projectId of your library. */
projectId: string;
/** the branch that your library follows in the origin project. */
branchName: string;
/** the version of your library. */
commitHash: string;
}
/**
* used by getValidChildrenMetaNodes
*/
export interface MetaNodeParameters {
/** the input parameters of the query. */
object: {
node: Core.Node,
children?: Core.Node[]
};
/**
* if true, the query filters out the
* abstract and connection-like nodes
* (the default value is false)
*/
sensitive?: boolean;
/**
* if true,
* the query tries to filter out even
* more nodes according to the multiplicity rules
* (the default value is false,
* the check is only meaningful if all the children were passed)
*/
multiplicity?: boolean;
/**
* if given,
* the query filters to contain only types
* that are visible in the given aspect.
*/
aspect?: string;
}
/**
* used by getValidSetMetaNodes
*/
export interface MetaSetParameters {
/** the input parameters of the query. */
object: {
/** the node in question. */
node: Core.Node;
/** the name of the set. */
name: GmeCommon.Name;
/** the members of the set of the node in question. */
members?: Core.Node[]
};
/**
* if true, the query filters out the
* abstract and connection-like nodes
* (the default value is false)
*/
sensitive?: boolean;
/**
* if true,
* the query tries to filter out even
* more nodes according to the multiplicity rules
* (the default value is false,
* the check is only meaningful if all the children were passed)
*/
multiplicity?: boolean;
}
export interface MetaRule {
type: string | number | boolean;
enum: string[];
}
export interface TraversalOptions {
excludeRoot?: boolean;
order?: TraversalOrder;
maxParallelLoad?: number;
stopOnError?: boolean;
}
/**
* The relationship between the core namespace
* and the core interface is not clearly expressed.
*
* https://editor.dev.webgme.org/docs/source/Core.html
*/
export interface Core {
/**
* It adds a project as library to your project by copying it over.
* The library will be a node with the given name directly
* under your project's ROOT.
* It becomes a read-only portion of your project.
* You will only be able to manipulate it with library functions,
* but cannot edit the individual nodes inside.
* However you will be able to instantiate or copy
* the nodes into other places of your project.
* Every node that was part of the META in the
* originating project becomes part of your project's meta.
*
* @param node any regular node in your project.
* @param name the name of the library you wish to use as a namespace in your project.
* @param libraryRootHash the hash of your library's root (must exist in the project's collection at the time of call).
* @param libraryInfo information about your project.
*/
addLibrary: {
(node: Core.Node, name: GmeCommon.Name, libraryRootHash: string,
libraryInfo: LibraryInfo, callback: GmeCommon.ResultCallback<void>): void;
(node: Core.Node, name: GmeCommon.Name, libraryRootHash: string,
libraryInfo: LibraryInfo): Promise<void>;
}
/**
* Adds a member to the given set.
* @param node the owner of the set.
* @param name the name of the set.
* @param member the new member of the set.
* @return If the set is not allowed to be modified,
* the function returns an error.
*/
addMember(node: Core.Node, name: GmeCommon.Name, member: Core.Node): undefined | Error;
/**
* Adds a mixin to the mixin set of the node.
* @param node the node in question.
* @param the path of the mixin node.
* @return If the node is not allowed to be modified, the function returns an error.
*/
addMixin(node: Core.Node, mixinPath: GmeCommon.Path): undefined | Error;
/**
* When our attempt to merge two patches ended in some conflict,
* then we can modify that result highlighting that in case of every conflict,
* which side we prefer (mine vs. theirs).
* If we give that object as an input to this function,
* it will finish the merge resolving the conflict according
* our settings and present a final patch.
* @param conflict the object that represents our
* settings for every conflict and the so-far-merged patch.
* @return The function results in a tree structured patch
* object that contains the changes that cover both
* parties modifications
* (and the conflicts are resolved according the input settings).
*/
applyResolution(conflict: {}): {};
/**
* Apply changes to the current project.
* @param root
* @param patch
* @return only reports errors.
*/
applyTreeDiff: {
(root: Core.Node, patch: any, callback: GmeCommon.ResultCallback<object>): void;
(root: Core.Node, patch: any): Promise<object>;
}
/**
* Checks if the given path can be added as a mixin to the given node.
* @param node the node in question.
* @param mixinPath the path of the mixin node.
* @return Returns if the mixin could be added, or the reason why it is not.
*/
canSetAsMixin(node: Core.Node, mixinPath: GmeCommon.Path): boolean | string;
/**
* Removes all META rules that were specifically defined for the node
* (so the function do not touches inherited rules).
* @param node the node in question.
* @return If the node is not allowed to be modified, the function returns an error.
*/
clearMetaRules(node: Core.Node): undefined | Error;
/**
* Removes all mixins for a given node.
* @param node the node in question.
* @return If the node is not allowed to be modified, the function returns an error.
*/
clearMixins(node: Core.Node): undefined | Error;
/**
* Copies the given node into parent.
* @param node the node to be copied.
* @param parent the target parent where the copy will be placed.
* @return The function returns the copied node or an error if the copy is not allowed.
*/
copyNode(node: Core.Node, parent: Core.Node): Core.Node | Error;
/**
* Copies the given nodes into parent.
* @param nodes the nodes to be copied.
* @param parent the target parent where the copies will be placed.
* @return The function returns an array of the copied nodes or an error
* if any of the nodes are not allowed to be copied to the given parent.
*/
copyNodes(nodes: Core.Node[], parent: Core.Node): Core.Node[] | Error;
/**
* Creates a node according to the given parameters.
* @param parameters the details of the creation.
* @return The function returns the created node or null if no node was
* created or an error if the creation with the given parameters are not allowed.
*/
createNode(parameters: NodeParameters): Core.Node | Error;
/**
* Creates a set for the node.
* @param node the node that will own the set.
* @param name the name of the set.
* @return If the node is not allowed to be modified, the function returns an error.
*/
createSet(node: Core.Node, name: GmeCommon.Name): undefined | Error;
/**
* Removes the given aspect rule of the node.
* @param node the node whose aspect rule will be deleted.
* @param name the name of the aspect rule.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delAspectMeta(node: Core.Node, name: GmeCommon.Name): undefined | Error;
/**
* Removes a valid type from the given aspect of the node.
* @param node the node in question.
* @param name the name of the aspect rule.
* @param targetPath the absolute path of the valid type of the aspect.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delAspectMetaTarget(node: Core.Node, name: GmeCommon.Name, targetPath: GmeCommon.Path): undefined | Error;
/**
* Removes the given attributes from the given node.
* @param node the node in question.
* @param name the name of the attribute.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delAttribute(node: Core.Node, name: GmeCommon.Name): undefined | Error;
/**
* Removes an attribute definition from the META rules of the node.
* @param name the node in question.
* @param name the name of the attribute.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delAttributeMeta(node: Core.Node, name: GmeCommon.Name): undefined | Error;
/**
* Removes the given child rule from the node.
* @param the node in question.
* @param childPath the absolute path of the child which rule is to be removed from the node.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delChildMeta(node: Core.Node, childPath: GmeCommon.Path): undefined | Error;
/**
* Removes a constraint from the node.
* @param node the node in question.
* @param name the name of the constraint.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delConstraint(node: Core.Node, name: GmeCommon.Name): undefined | Error;
/**
* Removes a node from the containment hierarchy.
* It also removes all contained nodes.
* @param node the node in question.
* @return If the operation is not allowed it returns an error.
*/
deleteNode(node: Core.Node): undefined | Error;
/**
* Removes the pointer from the node.
* @param node the node in question.
* @param name the name of the pointer.
* @return If the node is not allowed to be modified, the function returns an error.
*/
deletePointer(node: Core.Node, name: GmeCommon.Name): undefined | Error;
/**
* Removes a set from the node.
* @param node the node in question.
* @param name the name of the set.
* @return If the node is not allowed to be modified, the function returns an error.
*/
deleteSet(node: Core.Node, name: GmeCommon.Name): undefined | Error;
/**
* Removes a member from the set. The functions doesn't remove the node itself.
* @param node the node in question.
* @param name the name of the set.
* @param path the path to the member to be removed.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delMember(node: Core.Node, name: GmeCommon.Name, path: GmeCommon.Path): undefined | Error;
/**
* Removes an attribute which represented a property of the given set membership.
* @param node the node in question.
* @param setName the name of the set.
* @param memberPath the path to the member to be removed.
* @param attrName the name of the attribute.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delMemberAttribute(node: Core.Node, setName: GmeCommon.Name, memberPath: GmeCommon.Path, attrName: GmeCommon.Name): undefined | Error;
/**
* Removes a registry entry which represented a property of the given set membership.
* @param node the node in question.
* @param setName the name of the set.
* @param memberPath the path to the member to be removed.
* @param regName the name of the registry entry.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delMemberRegistry(node: Core.Node, setName: GmeCommon.Name, memberPath: GmeCommon.Path, regName: GmeCommon.Name): undefined | Error;
/**
* Removes a mixin from the mixin set of the node.
* @param node the node in question.
* @param mixinPath the path of the mixin node.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delMixin(node: Core.Node, mixinPath: GmeCommon.Path): undefined | Error;
/**
* Removes the complete META rule regarding the given pointer/set of the node.
* @param node the node in question.
* @param name the name of the pointer/set.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delPointerMeta(node: Core.Node, name: GmeCommon.Name): undefined | Error;
/**
* Removes a possible target type from the pointer/set of the node.
* @param node the node in question.
* @param name the name of the pointer/set.
* @param targetPath the absolute path of the possible target type.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delPointerMetaTarget(node: Core.Node, name: GmeCommon.Name, targetPath: string): undefined | Error;
/**
* Removes the given registry entry from the given node.
* @param node the node in question.
* @param name the name of the registry entry.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delRegistry(node: Core.Node, name: GmeCommon.Name): undefined | Error;
/**
* Removes the attribute entry for the set at the node.
* @param node the node in question.
* @param setName the name of the set.
* @param attrName the name of the attribute entry.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delSetAttribute(node: Core.Node, setName: GmeCommon.Name, attrName: GmeCommon.Name): undefined | Error;
/**
* Removes the registry entry for the set at the node.
* @param node the node in question.
* @param setName the name of the set.
* @param regName the name of the registry entry.
* @return If the node is not allowed to be modified, the function returns an error.
*/
delSetRegistry(node: Core.Node, setName: GmeCommon.Name, regName: GmeCommon.Name): undefined | Error;
/**
* Generates a differential tree among the two states
* of the project that contains the necessary changes
* that can modify the source to be identical to the target.
*
* @param sourceRoot the root node of the source state.
* @param targetRoot the root node of the target state.
* @return the result is in form of a json object.
*/
generateTreeDiff: {
(sourceRoot: Core.Node, targetRoot: Core.Node, callback: GmeCommon.ResultCallback<object>): void;
(sourceRoot: Core.Node, targetRoot: Core.Node): Promise<object>;
}
/**
* Returns all META nodes.
* @param node any node of the containment hierarchy.
* @return the function returns a dictionary.
* The keys of the dictionary are the absolute
* paths of the META nodes of the project.
* Every value of the dictionary is a module:Core~Node.
*/
getAllMetaNodes(node: Core.Node): GmeCommon.Dictionary<Core.Node>;
/**
* Returns the list of valid children types of the given aspect.
* @param node the node in question
* @param name the name of the aspect.
* @return the function returns a list of absolute paths
* of nodes that are valid children of the node and fits
* to the META rules defined for the aspect.
* Any children, visible under the given aspect of
* the node must be an instance of at least one node
* represented by the absolute paths.
*/
getAspectMeta(node: Core.Node, name: GmeCommon.Name): GmeCommon.Path[];
/**
* Retrieves the value of the given attribute of the given node.
* @param node - the node in question.
* @param name - the name of the attribute.
*
* @return The function returns the value of the attribute of the node.
* The retrieved attribute should not be modified as is - it should be copied first!
* The value can be an object or any primitive type.
* If the return value is undefined; the node does not have such attribute defined.
* If the node is undefined the returned value is null.
*/
getAttribute(node: Core.Node | null, name: GmeCommon.Name): GmeCommon.OutAttr;
/**
* Returns the definition object of an attribute from the META rules of the node.
* @param node the node in question.
* @param name the name of the attribute.
* @return The function returns the definition object, where type is always defined.
*/
getAttributeMeta(node: Core.Node, name: GmeCommon.Name): GmeCommon.DefObject;
/**
* Get the defined attribute names for the node.
* @param node the node in question.
* @return The function returns an array of the names of the attributes of the node.
*/
getAttributeNames(node: Core.Node): GmeCommon.Name[];
/**
* Get the base node
* @param node the node in question.
* @return the base of the given node or null if there is no such node.
*/
getBase(node: Core.Node): Core.Node | null;
/**
* Get the base node at the top of the inheritance chain.
* @param node the node in question.
* @return the root of the inheritance chain (usually the FCO).
*/
getBaseRoot(node: Core.Node): Core.Node;
/**
* Get the most specific meta node;
* the closest META node of the node in question.
* @param node the node in question.
* @return the first node (including itself) among the
* inheritance chain that is a META node.
* It returns null if it does not find such node
* (ideally the only node with this result is the ROOT).
*/
getBaseType(node: Core.Node | null): Core.Node | null;
/**
* Returns the meta-node of the node in question, that is the first base node that is part of the meta. (Aliased getBaseType).
* @param node the node in question.
* @return the base of the given node or null if there is no such node.
*/
getMetaType(node: Core.Node | null): Core.Node | null;
/**
* Get the most specific meta nodes;
* Searches for the closest META node of the
* node in question and the direct mixins of that node.
* @param node the node in question.
* @return the closest Meta node that is a base of the
* given node plus it returns all the mixin nodes
* associated with the base in a path-node dictionary.
*/
getBaseTypes(node: Core.Node): GmeCommon.Dictionary<Core.Node> | null;
/**
* Retrieves the child of the input node at the given relative id.
* It is not an asynchronous load and it automatically creates
* the child under the given relative id if no child was there
* beforehand.
* @param node the node in question.
* @param relativeId the relative id of the child in question.
* @return an empty node if it was created as a result
* of the function or return the already existing
* and loaded node if it found.
*/
getChild(node: Core.Node, relativeId: string): Core.Node;
/**
* Collects the data hash values of the children of the node.
* @param node the node in question.
* @return a dictionary of module:Core~ObjectHash that stored in
* pair with the relative id of the corresponding child of the node.
*/
getChildrenHashes(node: Core.Node): GmeCommon.Dictionary<GmeCommon.MetadataHash>;
/**
* Return a JSON representation of the META rules
* regarding the valid children of the given node.
* @param node the node in question.
* @return a detailed JSON structure that represents the
* META rules regarding the possible children of the node.
*/
getChildrenMeta(node: Core.Node): Core.RelationRule;
/**
* Collects the paths of all the children of the given node.
* @param node the node in question.
* @return an array of the absolute paths of the children.
*/
getChildrenPaths(parent: Core.Node): GmeCommon.Path[];
/**
* Collects the relative ids of all the children of the given node.
* @param parent the container node in question.
* @return an array of the relative ids.
*/
getChildrenRelids(parent: Core.Node): GmeCommon