Skip to content

Utilities for using Tinkerpop3 via the node-java API in Typescript

License

Notifications You must be signed in to change notification settings

RedSeal-co/ts-tinkerpop

Repository files navigation

ts-tinkerpop

A helper library for Typescript applications using TinkerPop 3 via node-java, with a tsJavaModule.ts interface generated by ts-java.

Build Status

Usage

Import the ts-tinkerpop module, giving it a short name of your choice. Do this everywhere you want to use functions from the ts-tinkerpop module.

import TP = require('ts-tinkerpop');

Requirements

  • Java ^1.8.0-31 (1.8.0-40 recommended, see below)
  • Node ^0.12.
  • node-java ^0.5

NOTE: TinkerPop 3 claims to require Java 1.8.0-40. We currently require 1.8.0-31 only because Travis currently uses 1.8.0-31.

Node-java Initialization

ts-tinkerpop takes advantage of a feature in node-java for coordinating application initialization and JVM creation. ts-tinkerpop registers itself on first import using the java.registerClient function. An application using ts-tinkerpop must therefore create the JVM using the corresponding java.ensureJvm function. However, ts-tinkerpop wraps the java.ensureJvm() function in the method TP.getTinkerpop():

import TP = require('ts-tinkerpop');

TP.getTinkerpop().then(() => {
	// ts-tinkerpop and JVM ready to use here.
});

ts-tinkerpop uses Bluebird promises, and configures node-java for just sync functions, with no suffix, and promises, with the suffix 'P':

java.asyncOptions = {
  syncSuffix: '',
  promiseSuffix: 'P',
  promisify: BluePromise.promisify
};

ts-tinkerpop helper functions

All of the ts-tinkerpop helper functions are in the one source file lib/ts-tinkerpop.ts. See the groc generated documentation in doc/lib/ts-tinkerpop.html. See also the unit tests for examples: test/tinkerpop-test.ts.

Coverage of the Tinkerpop Java API

In addition to the helper functions, ts-tinkerpop exposes much of the Tinkerpop 3 Java API.

ts-tinkerpop is currently up to date with the latest release 3.0.1-incubating. Our intent is to track Tinkerpop releases closely. The NPM version of this module will relate to the corresponding TinkerPop version.

ts-tinkerpop currently exposes a significant subset of the Tinkerpop 3 gremlin-core, gremlin-groovy and tinkergraph-gremlin packages. The set of classes exposed largely aligns with the classes automatically imported by the Gremlin Groovy Console (listed by groovy console command :show imports), with the notable exception that ts-tinkerpop currently does not expose any classes from the gremlin-driver package.

See the tsjava section of package.json to see which packages and classes are included in the configuration, or for the full details, run the tsjava tool as follows:

$ ./node_modules/.bin/ts-java --details
ts-java version 1.2.1
Generated classes:
   co.redseal.gremlinnode.function.GlobFunction
   co.redseal.gremlinnode.function.GroovyLambda
   co.redseal.gremlinnode.testing.TestClass
   co.redseal.util.StringInputStream
   groovy.lang.Binding
   groovy.lang.Closure
   groovy.lang.DelegatingMetaClass
   groovy.lang.GroovyClassLoader
   groovy.lang.GroovyCodeSource
   groovy.lang.GroovyObjectSupport
   groovy.lang.GroovyResourceLoader
   ...

About

Utilities for using Tinkerpop3 via the node-java API in Typescript

Resources

License

Stars

Watchers

Forks

Packages

No packages published