import { Statement, RelNodes, AttributeDefinition, PropertyDefinition } from '../language/generated/ast.js'; import { Path } from './util.js'; import { ActiveSessionInfo } from './auth/defs.js'; export declare class ModuleEntry { name: string; moduleName: string; constructor(name: string, moduleName: string); getFqName(): string; } export type AttributeSpec = { type: string; properties?: Map | undefined; }; export type RecordSchema = Map; export declare function newRecordSchema(): RecordSchema; type Meta = Map; export declare function newMeta(): Meta; export declare enum RecordType { RECORD = 0, ENTITY = 1, EVENT = 2, RELATIONSHIP = 3 } export declare class Record extends ModuleEntry { schema: RecordSchema; meta: Meta; type: RecordType; parentEntryName: string | undefined; constructor(name: string, moduleName: string, attributes?: AttributeDefinition[], parentEntryName?: string); addMeta(k: string, v: string): void; getMeta(k: string): string | undefined; addAttribute(n: string, attrSpec: AttributeSpec): Record; removeAttribute(n: string): Record; reorderAttributes(desiredOrder: string[]): void; addSystemAttribute(n: string, attrSpec: AttributeSpec): Record; findAttribute(predic: Function): AttributeEntry | undefined; hasRefTo(modName: string, entryName: string): boolean; getIdAttributeName(): string | undefined; toString(): string; getUserAttributes(): RecordSchema; getUserAttributeNames(): string[]; } export declare const PlaceholderRecordEntry: Record; export declare enum RbacPermissionFlag { CREATE = 0, READ = 1, UPDATE = 2, DELETE = 3 } type RbacExpression = { lhs: string; rhs: string; }; export declare class RbacSpecification { private static EmptyRoles; resource: string; roles: Set; permissions: Set; expression: RbacExpression | undefined; constructor(); setResource(s: string): RbacSpecification; hasResource(): boolean; setPermissions(perms: Array): RbacSpecification; hasPermissions(): boolean; hasCreatePermission(): boolean; hasReadPermission(): boolean; hasUpdatePermission(): boolean; hasDeletePermission(): boolean; setRoles(roles: Array): RbacSpecification; setExpression(lhs: string, rhs: string): RbacSpecification; } export declare class Entity extends Record { type: RecordType; rbac: RbacSpecification[] | undefined; setRbacSpecifications(rbac: RbacSpecification[]): Entity; } export declare class Event extends Record { type: RecordType; } declare enum RelType { CONTAINS = 0, BETWEEN = 1 } export type RelationshipNode = { path: Path; alias: string; origName: string; origAlias: string | undefined; }; export declare function newRelNodeEntry(nodeFqName: string, alias?: string): RelationshipNode; export declare class Relationship extends Record { type: RecordType; relType: RelType; node1: RelationshipNode; node2: RelationshipNode; properties: Map | undefined; constructor(name: string, typ: string, node1: RelationshipNode, node2: RelationshipNode, moduleName: string, attributes?: AttributeDefinition[], props?: Map); private updateSchemaWithNodeAttributes; joinNodesAttributeName(): string; setBetweenRef(inst: Instance, refPath: string, isQuery?: boolean): void; isContains(): boolean; isBetween(): boolean; parentNode(): RelationshipNode; childNode(): RelationshipNode; hasBooleanFlagSet(flag: string): boolean; isOneToOne(): boolean; isOneToMany(): boolean; isManyToMany(): boolean; isFirstNode(inst: Instance): boolean; getAliasFor(inst: Instance): string; getInverseAliasFor(inst: Instance): string; isFirstNodeName(fqName: string): boolean; getAliasForName(fqName: string): string; getInverseAliasForName(fqName: string): string; toString(): string; } export declare class Workflow extends ModuleEntry { statements: Statement[]; constructor(name: string, patterns: Statement[], moduleName: string); addStatement(stmtCode: string): Promise; setStatementAtHelper(statements: Statement[], newStmt: Statement | undefined, index: number[]): Workflow; setStatementAt(stmtCode: string, index: number | number[]): Promise; removeStatementAt(index: number | number[]): Workflow; private statementsToStringsHelper; statementsToStrings(): string[]; toString(): string; } export declare function isEmptyWorkflow(wf: Workflow): boolean; export declare class Module { name: string; entries: ModuleEntry[]; entriesByTypeCache: Map | null; constructor(name: string); addEntry(entry: ModuleEntry): ModuleEntry; private getEntryIndex; hasEntry(entryName: string): boolean; getEntry(entryName: string): ModuleEntry; getRecord(recordName: string): Record; removeEntry(entryName: string): boolean; private getEntriesOfType; getEntityEntries(): Entity[]; getEventEntries(): Event[]; getRecordEntries(): Record[]; getRelationshipEntries(): Relationship[]; private getRelationshipEntriesOfType; getBetweenRelationshipEntries(): Relationship[]; getContainsRelationshipEntries(): Relationship[]; getBetweenRelationshipEntriesThatNeedStore(): Relationship[]; getWorkflowForEvent(eventName: string): Workflow; isEntryOfType(t: RecordType, name: string): boolean; isEntity(name: string): boolean; isEvent(name: string): boolean; isRecord(name: string): boolean; isRelationship(name: string): boolean; getEntityNames(): string[]; getEventNames(): string[]; getRecordNames(): string[]; getRelationshipNames(): string[]; isContainsRelationship(entryName: string): boolean; isBetweenRelationship(entryName: string): boolean; toString(): string; } export declare function getActiveModuleName(): string; export declare function addModule(name: string): Module; export declare function removeModule(name: string): boolean; export declare function getModuleNames(): string[]; export declare function getUserModuleNames(): string[]; export declare function isModule(name: string): boolean; export declare function fetchModule(moduleName: string): Module; export declare function allModuleNames(): string[]; export declare function fetchModuleEntry(entryName: string, moduleName: string): ModuleEntry; export declare const builtInTypes: Set; export declare const propertyNames: Set; export declare function isBuiltInType(type: string): boolean; export declare function isValidType(type: string): boolean; export declare function defaultAttributes(schema: RecordSchema): Map; export declare function objectAttributes(schema: RecordSchema): Array | undefined; export declare function isIdAttribute(attrSpec: AttributeSpec): boolean; export declare function isUniqueAttribute(attrSpec: AttributeSpec): boolean; export declare function isIndexedAttribute(attrSpec: AttributeSpec): boolean; export declare function isOptionalAttribute(attrSpec: AttributeSpec): boolean; export declare function isArrayAttribute(attrSpec: AttributeSpec): boolean; export declare function isObjectAttribute(attrSpec: AttributeSpec): boolean; export declare function getOneOfValues(attrSpec: AttributeSpec): Set | undefined; export declare function getAttributeDefaultValue(attrSpec: AttributeSpec): any | undefined; export declare function getAttributeLength(attrSpec: AttributeSpec): number | undefined; export declare function getFkSpec(attrSpec: AttributeSpec): string | undefined; export declare function addEntity(name: string, moduleName?: string, attrs?: AttributeDefinition[], ext?: string): Entity; export declare function addEvent(name: string, moduleName?: string, attrs?: AttributeDefinition[], ext?: string): Event; export declare function addRecord(name: string, moduleName?: string, attrs?: AttributeDefinition[], ext?: string): Record; export declare function addRelationship(name: string, type: 'contains' | 'between', nodes: RelNodes | RelationshipNode[], moduleName?: string, attrs?: AttributeDefinition[] | undefined, props?: PropertyDefinition[] | undefined): Relationship; export declare function addBetweenRelationship(name: string, moduleName: string, nodes: RelationshipNode[]): Relationship; export declare function addContainsRelationship(name: string, moduleName: string, nodes: RelationshipNode[]): Relationship; export declare function addWorkflow(name: string, moduleName?: string, statements?: Statement[]): Workflow; export declare function getWorkflow(eventInstance: Instance): Workflow; export declare function getEntity(name: string, moduleName: string): Entity; export declare function getEvent(name: string, moduleName: string): Event; export declare function getRecord(name: string, moduleName: string): Record; export declare function getRelationship(name: string, moduleName: string): Relationship; export declare function getAllBetweenRelationships(): Relationship[]; export declare function getAllOneToOneRelationshipsForEntity(moduleName: string, entityName: string, allBetweenRels?: Relationship[]): Relationship[]; export declare function getAllOneToManyRelationshipsForEntity(moduleName: string, entityName: string, allBetweenRels?: Relationship[]): Relationship[]; export declare function getAllManyToOneRelationshipsForEntity(moduleName: string, entityName: string, allBetweenRels?: Relationship[]): Relationship[]; export declare function getAllManyToManyRelationshipsForEntity(moduleName: string, entityName: string, allBetweenRels?: Relationship[]): Relationship[]; export declare function getEntrySchema(name: string, moduleName: string): RecordSchema; export declare function removeEntity(name: string, moduleName?: string): boolean; export declare function removeRecord(name: string, moduleName?: string): boolean; export declare function removeRelationship(name: string, moduleName?: string): boolean; export declare function removeWorkflow(name: string, moduleName?: string): boolean; export declare function removeEvent(name: string, moduleName?: string): boolean; export type InstanceAttributes = Map; export declare function newInstanceAttributes(): InstanceAttributes; export declare class Instance { record: Record; name: string; moduleName: string; attributes: InstanceAttributes; queryAttributes: InstanceAttributes | undefined; queryAttributeValues: InstanceAttributes | undefined; relatedInstances: Map | undefined; private contextData; constructor(record: Record, moduleName: string, name: string, attributes: InstanceAttributes, queryAttributes?: InstanceAttributes, queryAttributeValues?: InstanceAttributes); static EmptyInstance(name: string, moduleName: string): Instance; static newWithAttributes(inst: Instance, newAttrs: InstanceAttributes): Instance; normalizeAttributes(attrs: InstanceAttributes): InstanceAttributes; lookup(k: string): any | undefined; asObject(): object; attributesAsObject(stringifyObjects?: boolean): object; queryAttributesAsObject(): object; queryAttributeValuesAsObject(): object; addQuery(attrName: string, op?: string, attrVal?: any): void; mergeAttributes(newAttrs: InstanceAttributes): Instance; attachRelatedInstances(relName: string, insts: Instance | Instance[]): void; detachAllRelatedInstance(): void; mergeRelatedInstances(): void; getRelatedInstances(relName: string): Instance[] | undefined; getAllUserAttributeNames(): string[]; getFqName(): string; addContextData(k: string, v: any): Instance; getContextData(k: string, notFoundValue?: any): any; setAuthContext(sesssionInfo: ActiveSessionInfo): Instance; getAuthContextUserId(): string; cast(): T; get(k: string): any; } export declare function objectAsInstanceAttributes(obj: object): InstanceAttributes; export type AttributeEntry = { name: string; spec: AttributeSpec; }; export declare function findIdAttribute(inst: Instance): AttributeEntry | undefined; export declare function makeInstance(moduleName: string, entryName: string, attributes: InstanceAttributes, queryAttributes?: InstanceAttributes, queryAttributeValues?: InstanceAttributes): Instance; export declare function isEventInstance(inst: Instance): boolean; export declare function isEntityInstance(inst: Instance): boolean; export declare function isRecordInstance(inst: Instance): boolean; export declare function getAllEventNames(): Map; export declare function isBetweenRelationship(relName: string, moduleName: string): boolean; export declare function isContainsRelationship(relName: string, moduleName: string): boolean; export type BetweenInstanceNodeValuesResult = { node1: any; node2: any; entry: Relationship; }; export declare function getBetweenInstanceNodeValues(inst: Instance): BetweenInstanceNodeValuesResult; export declare function isInstance(obj: any): boolean; export declare function isInstanceOfType(obj: any, fqName: string): boolean; export declare function assertInstance(obj: any): void; export declare function defineAgentEvent(moduleName: string, agentName: string): void; export declare function isAgentEvent(eventInst: Instance): boolean; export declare function eventAgentName(eventInst: Instance): string | undefined; export declare function instanceToObject(inst: Instance, obj: any): Type; export {}; //# sourceMappingURL=module.d.ts.map