Registry / database / google-sql-syntax-ts

google-sql-syntax-ts

JSON →
library1.0.3jsnpmunverified

Provides TypeScript type definitions and a query formatter for GoogleSQL (Google BigQuery SQL), along with a Monaco Editor language configuration for syntax highlighting. Current stable version is 1.0.3, released infrequently as needed. Key differentiators: focused exclusively on GoogleSQL (unlike generic SQL formatters), ships built-in TypeScript types, and integrates directly with Monaco Editor for highlighting. Ideal for BigQuery users building web-based SQL editors or needing programmatic SQL formatting.

npm install google-sql-syntax-ts
INSTALL
IMPORT
SIG · GOOGLE-SQL-SYNTAX-
G
google-sql-syntax-ts
databasejavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

QueryFormatter
import { QueryFormatter } from 'google-sql-syntax-ts'
const { QueryFormatter } = require('google-sql-syntax-ts')
ESM-only package; cannot use require(). Must use dynamic import or ESM.
GoogleSqlDefinition
import { GoogleSqlDefinition } from 'google-sql-syntax-ts'
Default export of the language definition; often used alongside QueryFormatter.
googleSqlLanguageConfiguration
import { googleSqlLanguageConfiguration } from 'google-sql-syntax-ts'
For Monaco Editor only. Import as a named export.

Demonstrates formatting a GoogleSQL query using QueryFormatter and GoogleSqlDefinition.

import { QueryFormatter, GoogleSqlDefinition } from 'google-sql-syntax-ts'; const queryFormatter = new QueryFormatter(new GoogleSqlDefinition()); const formattedQuery = queryFormatter.formatQuery( "SELECT column, REGEXP_CONTAINS(column, r'a') AS column_contains_a FROM `some-table` WHERE date > 1970-01-01" ); console.log(formattedQuery); // Output: // SELECT // COLUMN, // REGEXP_CONTAINS(COLUMN, r'a') AS column_contains_a // FROM // `some-table` // WHERE // date > 1970-01-01
Debug
Known issues
gotchaQueryFormatter converts identifiers to UPPER CASE by default (e.g., 'column' -> 'COLUMN'). This may not be desired for users expecting case preservation.
fix
If you need case preservation, consider using a different SQL formatter or overriding behavior via options (if available).
affects: >=1.0.0
breakingPackage is ESM-only; Node.js versions <12 may not support ESM without experimental flags.
fix
Use Node.js >=12 with "type": "module" in package.json, or use dynamic import for older Node.
affects: >=1.0.0
deprecatedNo version deprecations noted; package is small and stable.
gotchaNo browser bundle provided; importing directly into browser may require bundler (Webpack, Rollup).
fix
Use a bundler to resolve ESM imports. Alternatively, use CDN via esm.sh.
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: The requested module 'google-sql-syntax-ts' does not provide an export named 'QueryFormatter'
CommonJS require() used instead of ESM import.
fix
Replace require() with import statement. If you must use require, use dynamic import: const { QueryFormatter } = await import('google-sql-syntax-ts');
TypeError: GoogleSqlDefinition is not a constructor
Forgot to import GoogleSqlDefinition or used wrong import pattern.
fix
Ensure both imports: import { QueryFormatter, GoogleSqlDefinition } from 'google-sql-syntax-ts';
Cannot find module 'google-sql-syntax-ts'
Package not installed or missing from node_modules.
fix
Run: npm install @google/google-sql-syntax-ts (note scoped package name)
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
Resources
google-sql-syntax-ts — npm install google-sql-syntax-ts · libregistry