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

@saptools/sqltools

v0.1.3

Published

Export SAP HANA service bindings (VCAP_SERVICES) into VS Code SQLTools connections

Downloads

151

Readme

🗄️ @saptools/sqltools

Stop copy-pasting HANA credentials out of VCAP_SERVICES.

One command turns a SAP BTP Cloud Foundry HANA service binding into a ready-to-use VS Code SQLTools connection — no cockpit clicking, no JSON surgery.

npm version license node install size types

InstallQuick StartCLIAPIFAQ


✨ Features

  • 🔌 One-shot export — pulls VCAP_SERVICES from any CF app and writes .vscode/settings.json with a valid SAPHana connection
  • 🪄 Four input paths — read from a real CF app, a saved JSON file, stdin, or an already-targeted CF session
  • 🧷 Non-destructive — preserves unrelated VS Code settings and, with --merge, unrelated SQLTools connections too
  • 💾 Backup JSON — drops a hana-credentials.json beside the settings so HDI users / URLs / certificates stay within reach
  • 🔒 Type-safe — shipped with full TypeScript definitions for every input and output shape
  • 🪶 Tiny — two runtime deps (@saptools/cf-sync, commander) and zero runtime magic

📦 Install

# Global CLI
npm install -g @saptools/sqltools

# Or as a dependency
npm install @saptools/sqltools
# pnpm add @saptools/sqltools
# yarn add @saptools/sqltools

[!NOTE] Requires Node.js ≥ 20. The from-cf / from-app commands also need the cf CLI on PATH. For from-app, set SAP_EMAIL and SAP_PASSWORD so the tool can authenticate and target the org/space for you.


🚀 Quick Start

# Already logged in and targeted with `cf login`? One command is enough.
sqltools-export from-cf \
  --app my-srv --region eu10 --org my-org --space dev

Result:

✔ Updated SQLTools connections (1) → /workspace/.vscode/settings.json
  Credentials JSON saved → /workspace/hana-credentials.json
  • my-srv (eu10) host.hana.ondemand.com:443 schema=SCHEMA_MY_SRV

Open the workspace in VS Code, install the SQLTools + SQLTools SAP HANA driver extensions, and the new connection is already wired up.


🧰 CLI

Every command identifies an app with the same four labels — they are written into the SQLTools connection name as "<app> (<region>)".

| Flag | Description | Example | | --- | --- | --- | | --app <name> | CF app name (also the label) | my-srv | | --region <key> | CF region key | ap10, eu10, us10 | | --org <name> | CF org name | my-org | | --space <name> | CF space name | dev |

Common output options:

| Flag | Description | | --- | --- | | --cwd <dir> | Workspace root that owns .vscode/settings.json (default: cwd) | | --merge | Merge with existing connections by name (default: overwrite) | | --credentials-out <path> | Custom path for the backup JSON | | --no-credentials-file | Skip writing hana-credentials.json |

🌐 sqltools-export from-app

Full end-to-end: cf apicf authcf targetcf env → write settings. Great for CI and fresh machines.

export SAP_EMAIL="[email protected]"
export SAP_PASSWORD="your-sap-password"

sqltools-export from-app \
  --app my-srv --region eu10 --org my-org --space dev

📡 sqltools-export from-cf

Assumes you are already targeted (cf login && cf target -o ... -s ...). Shells out to cf env <app> and writes the settings.

sqltools-export from-cf --app my-srv --region eu10 --org my-org --space dev

📄 sqltools-export from-file

Already have a VCAP_SERVICES JSON saved somewhere? Point to it.

sqltools-export from-file --input ./vcap.json \
  --app my-srv --region eu10 --org my-org --space dev

📥 sqltools-export from-stdin

Classic pipe:

cf env my-srv | jq '."VCAP_SERVICES"' | sqltools-export from-stdin \
  --app my-srv --region eu10 --org my-org --space dev

🔁 sqltools-export convert

Print a single SQLTools connection JSON to stdout — no files written. Perfect for scripting.

sqltools-export convert --input ./vcap.json \
  --app my-srv --region eu10 --org my-org --space dev

[!TIP] Use --merge to keep hand-crafted connections in .vscode/settings.json untouched while only overwriting the one matching <app> (<region>).


🧑‍💻 Programmatic Usage

import {
  exportFromApp,
  exportFromCf,
  exportFromFile,
  exportFromVcap,
  toSqlToolsConnection,
  buildEntryFromVcap,
} from "@saptools/sqltools";

const context = {
  app: "my-srv",
  region: "eu10",
  org: "my-org",
  space: "dev",
} as const;

// Full login → target → env → write flow
await exportFromApp(
  { context, email: process.env["SAP_EMAIL"]!, password: process.env["SAP_PASSWORD"]! },
  { merge: true },
);

// Or: already targeted, just run `cf env`
await exportFromCf({ context });

// Or: in-memory VCAP from your own source
const vcapServices = JSON.stringify({ hana: [/* … */] });
const result = await exportFromVcap({ vcapServices, context });
console.log(result.settingsPath, result.connectionCount);

// Or: one-off convert without touching the workspace
const entry = buildEntryFromVcap({ vcapServices, context });
if (entry !== null) {
  console.log(toSqlToolsConnection(entry));
}

| Export | Description | | --- | --- | | exportFromApp(input, options?) | CF login + target + env + write settings | | exportFromCf(input, options?) | Shell cf env <app> and write settings | | exportFromFile(input, options?) | Read VCAP JSON from disk and write settings | | exportFromVcap(input, options?) | Accept in-memory VCAP JSON and write settings | | buildEntryFromVcap(input) | Parse a VCAP payload into a typed AppHanaEntry | | toSqlToolsConnection(entry) | Convert an entry into a single SQLTools connection | | updateVscodeConnections(entries, options?) | Low-level .vscode/settings.json writer | | writeCredentials(entries, options?) | Low-level hana-credentials.json writer | | parseVcapServices(raw) | Strict VCAP JSON parser | | extractHanaCredentials(binding) | Map snake_casecamelCase | | extractVcapServicesSection(stdout) | Isolate the VCAP block from cf env output | | cfLoginAndTarget(input) | cf api + cf auth + cf target -o -s | | cfAppVcapServices(app) | Run cf env and return the VCAP JSON | | assertRegionKey(region) | Guard an unknown string as a known CF region | | Constants | DRIVER, HANA_OPTIONS, CONNECTION_TIMEOUT, PREVIEW_LIMIT, SQLTOOLS_CONNECTIONS_KEY, SQLTOOLS_USE_NODE_RUNTIME_KEY, VSCODE_SETTINGS_REL_PATH, OUTPUT_FILENAME |


📁 Output Files

After a successful export you get two files in the workspace root:

.vscode/settings.json     # SQLTools connections + sqltools.useNodeRuntime
hana-credentials.json     # Backup of every extracted binding (HDI user, URL, cert…)
{
  "sqltools.useNodeRuntime": true,
  "sqltools.connections": [
    {
      "name": "my-srv (eu10)",
      "driver": "SAPHana",
      "server": "host.hana.ondemand.com",
      "port": 443,
      "username": "USER_1",
      "password": "…",
      "database": "SCHEMA_MY_SRV",
      "connectionTimeout": 30,
      "previewLimit": 50,
      "hanaOptions": {
        "encrypt": true,
        "sslValidateCertificate": true,
        "sslCryptoProvider": "openssl"
      }
    }
  ]
}

[!IMPORTANT] Both files contain live HANA credentials. They live inside your workspace, not under ~ — keep them out of git (add to .gitignore if your repo doesn't already exclude hana-credentials.json).


❓ FAQ

Yes. @saptools/sqltools only writes the connection definition. You still need the SQLTools extension and the SQLTools SAP HANA driver to actually run queries.

By default, yes — sqltools.connections is replaced with the newly-exported entries, while every other key in settings.json is preserved. Pass --merge to keep existing connections whose name does not match <app> (<region>).

No. hana-credentials.json contains the HANA password, schema, HDI user, and the certificate payload. Add it to .gitignore.

They are only read by from-app. The tool forwards them directly to cf auth — no storage, no logging. from-cf assumes you are already targeted and ignores both env vars.

Not yet. The parser looks for the hana service label (the default for SAP HANA Cloud / HDI service bindings on BTP). If you have a bespoke label, open an issue and we'll add support.


🛠️ Development

From the monorepo root:

pnpm install
pnpm --filter @saptools/sqltools... build
pnpm --filter @saptools/sqltools typecheck
pnpm --filter @saptools/sqltools lint
pnpm --filter @saptools/sqltools test:unit
pnpm --filter @saptools/sqltools test:e2e:fake
pnpm --filter @saptools/sqltools test:e2e:live   # needs SAP_EMAIL / SAP_PASSWORD

The live e2e suite auto-discovers a real CF app with a hana service binding by scoring candidates from ~/.saptools/cf-structure.json (populated by cf-sync). To pin a specific target:

export E2E_TARGET="eu10/my-org/my-space/my-srv"

Live e2e only performs read-only CF operations (cf api, cf auth, cf target, cf env) — nothing is created, updated, or deleted in Cloud Foundry.


🌐 Related


Made with ❤️ for SAP BTP developers who want to query HANA in VS Code without leaving the editor.

License · MIT