@@ -123,6 +123,13 @@ might apply.
123123
124124* JavaScript GLV
125125** `mimeType` setting has been removed. Use `reader` and `writer` options directly to control serialization format.
126+ ** `authenticator` option has been removed. Use `interceptors` with `auth.basic()` or `auth.sigv4()` instead.
127+ ** `session` option has been removed.
128+ ** `interceptors` option has been added to `Client` and `DriverRemoteConnection` for HTTP request modification.
129+ ** `writer` can be set to `null` to skip request serialization, allowing interceptors to handle it directly.
130+ ** `bulkResults` has been added as a request option. `DriverRemoteConnection` defaults it to `true`.
131+ ** `Bytecode` has been replaced with `GremlinLang`.
132+ ** Serialization updated to GraphBinary 4.
126133* .NET GLV
127134** `ConnectionPoolSettings` has been replaced with `ConnectionSettings` for HTTP connection configuration.
128135** `webSocketConfiguration` parameter has been removed.
@@ -223,6 +230,112 @@ The WebSocket-specific settings (`TransporterType`, `ReadBufferSize`, `WriteBuff
223230`NewConnectionThreshold`, `Session`) have been removed. New HTTP connection pool settings have been added:
224231`MaximumConcurrentConnections`, `MaxIdleConnections`, `IdleConnectionTimeout`, and `KeepAliveInterval`.
225232
233+ [[javascript-typescript-esm]]
234+ ==== Gremlin-JavaScript TypeScript and ESM Migration
235+
236+ The `gremlin-javascript` driver has been rewritten in TypeScript and now ships with built-in type declarations. The
237+ package publishes dual ESM and CommonJS builds, so both `import` and `require` work out of the box.
238+
239+ ===== Module format changes
240+
241+ The package now sets `"type": "module"` in `package.json` and uses conditional `exports`:
242+
243+ - ESM: `import gremlin from 'gremlin'` resolves to `build/esm/index.js`
244+ - CJS: `const gremlin = require('gremlin')` resolves to `build/cjs/index.cjs`
245+
246+ Existing CommonJS applications using `require('gremlin')` will continue to work without changes. Applications using
247+ ESM can now use `import` directly:
248+
249+ [source,javascript]
250+ ----
251+ // CommonJS (still works)
252+ const gremlin = require('gremlin');
253+
254+ // ESM — default import
255+ import gremlin from 'gremlin';
256+
257+ // ESM — named imports
258+ import { driver, process, structure } from 'gremlin';
259+ ----
260+
261+ ===== TypeScript support
262+
263+ Type declarations (`.d.ts`) are included in the published package. TypeScript projects can import the driver directly
264+ without installing separate `@types` packages:
265+
266+ [source,typescript]
267+ ----
268+ import gremlin from 'gremlin';
269+ import type { ConnectionOptions } from 'gremlin/build/esm/driver/connection.js';
270+
271+ const connection = new gremlin.driver.DriverRemoteConnection('http://localhost:8182/gremlin');
272+ const g = gremlin.process.traversal().with_(connection);
273+ ----
274+
275+ ===== Breaking changes to exports
276+
277+ Several exports have been removed or renamed compared to 3.x:
278+
279+ - `process.Bytecode` has been removed. Use `process.GremlinLang` instead.
280+ - `process.Translator` has been removed. To produce a canonical gremlin script from a `Traversal`, use
281+ `process.GremlinLang` instead (e.g. `traversal.getGremlinLang().getGremlin()`).
282+ - `driver.auth.Authenticator` and `driver.auth.PlainTextSaslAuthenticator` have been removed. Use `driver.auth.basic()`
283+ and `driver.auth.sigv4()` interceptor factories instead.
284+ - `structure.io` (the serializer namespace) has been removed. Serialization is now internal to the driver.
285+ - `Graph.traversal()` has been removed. Use the `process.traversal()` function instead.
286+
287+ For example, authentication that previously used `PlainTextSaslAuthenticator`:
288+
289+ [source,javascript]
290+ ----
291+ // 3.x
292+ const authenticator = new gremlin.driver.auth.PlainTextSaslAuthenticator('username', 'password');
293+ const client = new gremlin.driver.Client('ws://localhost:8182/gremlin', { authenticator });
294+
295+ // 4.x
296+ const client = new gremlin.driver.Client('http://localhost:8182/gremlin', {
297+ interceptors: gremlin.driver.auth.basic('username', 'password'),
298+ });
299+ ----
300+
301+ [[javascript-http-interceptor]]
302+ ==== Gremlin-JavaScript HTTP and Interceptor Changes
303+
304+ The `gremlin-javascript` driver has been updated to use HTTP instead of WebSockets. The `Connection` class now uses
305+ Node.js `fetch` internally and sends requests via HTTP POST to Gremlin Server.
306+
307+ `Bytecode` has been replaced with `GremlinLang`, which builds a gremlin-lang compatible string representation of a
308+ traversal along with a map of named parameters. Traversals now produce gremlin-lang strings that are sent to the server
309+ rather than serialized bytecode.
310+
311+ HTTP interceptors have been added to `gremlin-javascript`. Interceptors can be passed to the `Client` or
312+ `DriverRemoteConnection` constructor using the `interceptors` option. A `RequestInterceptor` is a function that receives
313+ an `HttpRequest` object containing the HTTP method, URL, headers, and body, and returns the (possibly modified) request
314+ or a `Promise` resolving to one. Interceptors are executed in order before the request is sent.
315+
316+ Authentication is now handled through interceptors rather than the previous `authenticator` option. The `auth` module
317+ provides factory functions for built-in interceptors:
318+
319+ [source,javascript]
320+ ----
321+ import gremlin from 'gremlin';
322+
323+ const { DriverRemoteConnection, auth } = gremlin.driver;
324+
325+ // Basic authentication
326+ const connection = new DriverRemoteConnection('https://localhost:8182/gremlin', {
327+ interceptors: auth.basic('username', 'password'),
328+ });
329+
330+ // SigV4 authentication
331+ const connection = new DriverRemoteConnection('https://localhost:8182/gremlin', {
332+ interceptors: auth.sigv4('service-region', 'service-name'),
333+ });
334+ ----
335+
336+ Setting the `writer` option to `null` prevents the `RequestMessage` from being serialized before interceptors run,
337+ allowing an interceptor to handle serialization directly where desired.
338+
226339==== Transactions Re-enabled
227340
228341IMPORTANT: The remote transaction API is still under active discussion and the specification has not been finalized.
0 commit comments