Skip to content

Instantly share code, notes, and snippets.

@mjpitz
Created June 27, 2018 03:51
Show Gist options
  • Save mjpitz/435b26e9e26bd5ed1248225d8cde916b to your computer and use it in GitHub Desktop.
Save mjpitz/435b26e9e26bd5ed1248225d8cde916b to your computer and use it in GitHub Desktop.
Typescript definition for apache tinkerpop's gremlin-javascript library. Makes for easy use with Typescript language.
declare module "gremlin" {
export namespace driver {
import TraversalStrategy = process.TraversalStrategy;
import Traversal = process.Traversal;
import Bytecode = process.Bytecode;
import GraphSONReader = structure.io.GraphSONReader;
import GraphSONWriter = structure.io.GraphSONWriter;
export class RemoteConnection {
constructor(url: string);
submit(bytecode: Bytecode): Promise<void>;
}
export class RemoteStrategy extends TraversalStrategy {
constructor(connection: RemoteConnection);
}
export class RemoteTraversal extends Traversal {
constructor(traversers, sideEffects);
}
interface DriverRemoteConnectionOptions {
ca: string[];
cert: string|string[]|Buffer;
mimeType: string;
pfx: string|Buffer;
reader: GraphSONReader;
traversalSource: string;
writer: GraphSONWriter;
}
export class DriverRemoteConnection extends RemoteConnection {
constructor(url: string, options?: DriverRemoteConnectionOptions);
open(): Promise<void>;
close(): Promise<void>;
}
}
export namespace process {
import RemoteConnection = driver.RemoteConnection;
import Graph = structure.Graph;
export class Bytecode {
constructor(toClone: Bytecode);
addSource(name: string, values: string[]): Bytecode;
addStep(name: string, values: string[]): Bytecode;
toString(): string;
}
export class EnumValue {
public readonly typeName: string;
public readonly elementName: string;
constructor(typeName, elementName);
toString(): string;
}
export class P {
constructor(operator, value, other: any|any[]);
and(arg: any): P;
or(arg: any): P;
static between(args: any[]): P;
static eq(args: any[]): P;
static gt(args: any[]): P;
static gte(args: any[]): P;
static inside(args: any[]): P;
static lt(args: any[]): P;
static lte(args: any[]): P;
static neq(args: any[]): P;
static not(args: any[]): P;
static outside(args: any[]): P;
static test(args: any[]): P;
static within(args: any[]): P;
static without(args: any[]): P;
}
export class Traversal {
constructor(graph: Graph, traversalStrategies: TraversalStrategies, bytecode: Bytecode);
getBytecode(): Bytecode;
toList(): Promise<any[]>;
iterate(): Promise<any>;
next(): Promise<{value, done}>;
toString(): string;
}
export class TraversalSideEffects {
/* actually empty */
}
export class TraversalStrategies {
constructor(parent: TraversalStrategies);
addStrategy(strategy: TraversalStrategy);
applyStrategies(traversal: Traversal);
}
export class TraversalStrategy {
constructor(connection: RemoteConnection);
apply(traversal: Traversal): Promise<void>;
}
export class Traverser {
public readonly object: any;
public readonly bulk: number;
constructor(object: any, bulk: number);
}
export namespace barrier {
export const normSack: EnumValue;
}
export namespace cardinality {
export const list: EnumValue;
export const set: EnumValue;
export const single: EnumValue;
}
export namespace column {
export const keys: EnumValue;
export const values: EnumValue;
}
export namespace direction {
export const BOTH: EnumValue;
export const IN: EnumValue;
export const OUT: EnumValue;
}
export namespace operator {
export const addAll: EnumValue;
export const and: EnumValue;
export const assign: EnumValue;
export const div: EnumValue;
export const max: EnumValue;
export const min: EnumValue;
export const minus: EnumValue;
export const mult: EnumValue;
export const or: EnumValue;
export const sum: EnumValue;
export const sumLong: EnumValue;
}
export namespace order {
export const decr: EnumValue;
export const incr: EnumValue;
export const keyDecr: EnumValue;
export const keyIncr: EnumValue;
export const shuffle: EnumValue;
export const valueDescr: EnumValue;
export const valueIncr: EnumValue;
}
export namespace pop {
export const all: EnumValue;
export const first: EnumValue;
export const last: EnumValue;
}
export namespace scope {
export const global: EnumValue;
export const local: EnumValue;
}
export namespace t {
export const id: EnumValue;
export const key: EnumValue;
export const label: EnumValue;
export const value: EnumValue;
}
export class GraphTraversal extends Traversal {
constructor(graph: Graph, traversalStrategies: TraversalStrategies, bytecode: Bytecode);
V(...args): GraphTraversal;
addE(...args): GraphTraversal;
addInE(...args): GraphTraversal;
addOutE(...args): GraphTraversal;
addV(...args): GraphTraversal;
aggregate(...args): GraphTraversal;
and(...args): GraphTraversal;
as(...args): GraphTraversal;
barrier(...args): GraphTraversal;
both(...args): GraphTraversal;
bothE(...args): GraphTraversal;
bothV(...args): GraphTraversal;
branch(...args): GraphTraversal;
by(...args): GraphTraversal;
cap(...args): GraphTraversal;
choose(...args): GraphTraversal;
coalesce(...args): GraphTraversal;
coin(...args): GraphTraversal;
constant(...args): GraphTraversal;
count(...args): GraphTraversal;
cyclicPath(...args): GraphTraversal;
dedup(...args): GraphTraversal;
drop(...args): GraphTraversal;
emit(...args): GraphTraversal;
filter(...args): GraphTraversal;
flatMap(...args): GraphTraversal;
fold(...args): GraphTraversal;
from_(...args): GraphTraversal;
group(...args): GraphTraversal;
groupCount(...args): GraphTraversal;
groupV3d0(...args): GraphTraversal;
has(...args): GraphTraversal;
hasId(...args): GraphTraversal;
hasKey(...args): GraphTraversal;
hasLabel(...args): GraphTraversal;
hasNot(...args): GraphTraversal;
hasValue(...args): GraphTraversal;
id(...args): GraphTraversal;
identify(...args): GraphTraversal;
in_(...args): GraphTraversal;
inE(...args): GraphTraversal;
inV(...args): GraphTraversal;
inject(...args): GraphTraversal;
is(...args): GraphTraversal;
key(...args): GraphTraversal;
label(...args): GraphTraversal;
limit(...args): GraphTraversal;
local(...args): GraphTraversal;
loops(...args): GraphTraversal;
map(...args): GraphTraversal;
mapKeys(...args): GraphTraversal;
mapValues(...args): GraphTraversal;
match(...args): GraphTraversal;
max(...args): GraphTraversal;
mean(...args): GraphTraversal;
min(...args): GraphTraversal;
not(...args): GraphTraversal;
option(...args): GraphTraversal;
optional(...args): GraphTraversal;
or(...args): GraphTraversal;
order(...args): GraphTraversal;
otherV(...args): GraphTraversal;
out(...args): GraphTraversal;
outE(...args): GraphTraversal;
outV(...args): GraphTraversal;
pageRank(...args): GraphTraversal;
path(...args): GraphTraversal;
peerPressure(...args): GraphTraversal;
profile(...args): GraphTraversal;
program(...args): GraphTraversal;
project(...args): GraphTraversal;
properties(...args): GraphTraversal;
property(...args): GraphTraversal;
propertyMap(...args): GraphTraversal;
range(...args): GraphTraversal;
repeat(...args): GraphTraversal;
sack(...args): GraphTraversal;
sample(...args): GraphTraversal;
select(...args): GraphTraversal;
sideEffect(...args): GraphTraversal;
simplePath(...args): GraphTraversal;
store(...args): GraphTraversal;
subgraph(...args): GraphTraversal;
sum(...args): GraphTraversal;
tail(...args): GraphTraversal;
timeLimit(...args): GraphTraversal;
times(...args): GraphTraversal;
to(...args): GraphTraversal;
toE(...args): GraphTraversal;
toV(...args): GraphTraversal;
tree(...args): GraphTraversal;
unfold(...args): GraphTraversal;
union(...args): GraphTraversal;
until(...args): GraphTraversal;
value(...args): GraphTraversal;
valueMap(...args): GraphTraversal;
values(...args): GraphTraversal;
where(...args): GraphTraversal;
}
export class GraphTraversalSource {
constructor(graph: Graph, traversalStrategies: TraversalStrategies, bytecode: Bytecode);
withRemote(remoteConnection: RemoteConnection): GraphTraversalSource;
toString(): string;
withBulk(...args): GraphTraversalSource;
withPath(...args): GraphTraversalSource;
withSack(...args): GraphTraversalSource;
withSideEffect(...args): GraphTraversalSource;
withStrategies(...args): GraphTraversalSource;
withoutStrategies(...args): GraphTraversalSource;
E(...args): GraphTraversal;
V(...args): GraphTraversal;
addV(...args): GraphTraversal;
inject(...args): GraphTraversal;
}
export namespace statics {
export function V(...args): any
export function addE(...args): any
export function addInE(...args): any
export function addOutE(...args): any
export function addV(...args): any
export function aggregate(...args): any
export function and(...args): any
export function as(...args): any
export function barrier(...args): any
export function both(...args): any
export function bothE(...args): any
export function bothV(...args): any
export function branch(...args): any
export function cap(...args): any
export function choose(...args): any
export function coalesce(...args): any
export function coin(...args): any
export function constant(...args): any
export function count(...args): any
export function cyclicPath(...args): any
export function dedup(...args): any
export function drop(...args): any
export function emit(...args): any
export function filter(...args): any
export function flatMap(...args): any
export function fold(...args): any
export function group(...args): any
export function groupCount(...args): any
export function groupV3d0(...args): any
export function has(...args): any
export function hasId(...args): any
export function hasKey(...args): any
export function hasLabel(...args): any
export function hasNot(...args): any
export function hasValue(...args): any
export function id(...args): any
export function identity(...args): any
export function in_(...args): any
export function inE(...args): any
export function inV(...args): any
export function inject(...args): any
export function is(...args): any
export function key(...args): any
export function label(...args): any
export function limit(...args): any
export function local(...args): any
export function loops(...args): any
export function map(...args): any
export function mapKeys(...args): any
export function mapValues(...args): any
export function match(...args): any
export function max(...args): any
export function mean(...args): any
export function min(...args): any
export function not(...args): any
export function optional(...args): any
export function or(...args): any
export function order(...args): any
export function otherV(...args): any
export function out(...args): any
export function outE(...args): any
export function outV(...args): any
export function path(...args): any
export function project(...args): any
export function properties(...args): any
export function property(...args): any
export function propertyMap(...args): any
export function range(...args): any
export function repeat(...args): any
export function sack(...args): any
export function sample(...args): any
export function select(...args): any
export function sideEffect(...args): any
export function simplePath(...args): any
export function store(...args): any
export function subgraph(...args): any
export function sum(...args): any
export function tail(...args): any
export function timeLimit(...args): any
export function times(...args): any
export function to(...args): any
export function toE(...args): any
export function toV(...args): any
export function tree(...args): any
export function unfold(...args): any
export function union(...args): any
export function until(...args): any
export function value(...args): any
export function valueMap(...args): any
export function values(...args): any
export function where(...args): any
}
}
export namespace structure {
import GraphTraversalSource = process.GraphTraversalSource
export namespace io {
export class GraphSONWriter {
constructor(options: {});
adaptObject(value): any|any[];
}
export class GraphSONReader {
constructor(options: {});
read(obj): any;
}
}
export class Graph {
traversal(): GraphTraversalSource;
toString(): string;
}
export class Element {
public readonly id: string;
public readonly label: string;
constructor(id: string, label: string);
equals(other: Element): boolean;
}
export class Edge extends Element {
public readonly outV: Vertex;
public readonly inV: Vertex;
public readonly properties: {};
constructor(id: string, outV: Vertex, label: string, inV: Vertex, properties: {});
toString(): string;
}
export class Vertex extends Element {
public readonly properties: {};
constructor(id: string, label: string, properties: {});
toString(): string;
}
export class VertexProperty extends Element {
public readonly value: string;
public readonly properties: {};
constructor(id: string, label: string, value: string, properties: {});
toString(): string
}
export class Property {
constructor(key, value);
toString(): string;
equals(other: Property): boolean;
}
export class Path {
constructor(labels: string[], objects: {}[]);
equals(other: Path): boolean;
}
class Long {
public readonly value: string;
}
export function toLong(): Long
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment