npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hpcc-js/comms

v3.23.1

Published

hpcc-js - Communications

Readme

@hpcc-js/comms

This package is part of the mono repository "@hpcc-js" (aka Visualization Framework), for more information including Quick Start, Gallery and Tutorials, please visit the main page on GitHub: hpcc-systems/Visualization.

WsSQL2

SQL2Service exposes the WsSQL2 operations (ExecuteQuery, ExplainQuery, FetchResultSet, CloseResultSet, LogicalFileMetadata, SplitQuery, and Ping) with request and response types in WsSQL2.

import { SQL2Service } from "@hpcc-js/comms";

const sql = new SQL2Service({ baseUrl: "http://localhost:8510" });
const { CursorId, ResultSetMetadata } = await sql.ExecuteQuery({
    SQLText: "SELECT 1", IncludeResultSetMetadata: true
});
try {
    const { RowsJSON, Complete } = await sql.FetchResultSet({ CursorId, RowCount: 100 });
    console.log(ResultSetMetadata, RowsJSON, Complete);
} finally {
    await sql.CloseResultSet({ CursorId });
}

To regenerate the WsSQL2 TypeScript bindings from the local WSDL, run npm run wsdl-sql2 in this package. ExplainQuery returns Plan / PlanJson; a fetch may include RuntimeGraph / RuntimeGraphJson when ExecuteQuery requests IncludeRuntimeGraph.

For small results, queryRows() collects rows as objects keyed by column label and closes its statement automatically:

import { SQLConnection } from "@hpcc-js/comms";

const connection = new SQLConnection({ baseUrl: "http://localhost:8510" });
try {
    const rows = await connection.queryRows("SELECT id FROM hpcc_scan('example::file')", 100);
    console.log(rows[0]?.id);
    const { Plan } = await connection.explainQuery("SELECT 1");
    const file = await connection.logicalFileMeta("example::file");
    const available = await connection.ping();
} finally {
    await connection.close();
}

queryRows() preserves native JSON values (including null) and rejects missing or duplicate column labels, ignoring case. It holds all rows in memory; use createStatement() and next() below for large results or early cancellation. explainQuery() returns the typed service response, logicalFileMeta() returns the file metadata or undefined, and ping() returns true on success (or rejects on failure).

For a JDBC-style, forward-only client, use the async SQLConnection helper:

import { SQLConnection } from "@hpcc-js/comms";

const connection = new SQLConnection({ baseUrl: "http://localhost:8510" });
try {
    const statement = connection.createStatement();
    statement.setFetchSize(100);
    const statements = await connection.splitQuery("SELECT 1; SELECT 2;");
    const result = await statement.executeQuery("SELECT id FROM hpcc_scan('example::file')");
    while (await result.next()) {
        console.log(result.getObject("id"));
    }
} finally {
    await connection.close();
}

executeQuery prepares SQL and returns metadata and a cursor without executing it. The first next() initiates execution; subsequent calls fetch pages on demand until Complete is true, including empty intermediate pages. getObject accepts a 1-based column index or a case-insensitive label, and getMetaData() exposes the WsSQL2 column descriptors. Always await close() on the result, statement, or connection when finished: it releases any active server cursor. All three support Symbol.asyncDispose, so await using also closes their owned cursors on scope exit; synchronous disposal cannot wait for the server. statement.cancel() or result.cancel() closes the cursor immediately, even while a fetch is in progress, and ends that result's iteration. Executing another query on the same statement closes its previous result first. This helper does not implement transactions, parameter binding, or JDBC type conversions. connection.splitQuery(sql) delegates statement splitting to the server and returns the individual SQL strings (or [] for a comment-only script); it does not execute them. Pass each statement to executeQuery() separately when running a multi-statement script. If CloseResultSet fails, the failure is reported and the cursor ID is retained; retry close() on the result, statement, or connection to attempt cleanup again.

The integration tests in tests/wsSQL2.spec.ts run in both the Node and browser test projects. They require ESP at http://127.0.0.1:8010/ and WsSQL2 at http://127.0.0.1:8510/; service-backed tests are skipped when the WsSQL2 ping fails. One test creates a unique 1,000-row logical file, verifies paging and early cursor close, then removes the file and its workunit.

Exported Widgets

Stand-alone HTML Example

<html>
    <head>
        <title>Simple Connection+Codemirror</title>
        <script src="https://unpkg.com/@hpcc-js/util"></script>
        <script src="https://unpkg.com/@hpcc-js/common"></script>
        <script src="https://unpkg.com/@hpcc-js/api"></script>
        <script src="https://unpkg.com/@hpcc-js/comms"></script>
        <script src="https://unpkg.com/@hpcc-js/codemirror"></script>
    </head>
    <body>
        <div id="placeholder" style="width:800px;height:600px;"></div>
        <script>
            new window["@hpcc-js/comms"].Connection({
                    baseUrl: "https://api.pushshift.io/",
                    type: "get"
                })
                .send("reddit/search/submission/", {
                    "subreddit":"askreddit",
                    "sort":"desc",
                    "sort_type":"created_utc",
                    "size":"5",
                }).then((json) => {
                    new window["@hpcc-js/codemirror"].JSONEditor()
                        .target("placeholder")
                        .json(json)
                        .render()
                        ;
                })
                .catch((e) => {
                    console.error(e);
                })
                ;
        </script>
    </body>
</html>

Getting Started with @hpccjs