pgsql-parse 0.3.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.js +2 -2
- package/esm/parse.js +1 -1
- package/esm/scanner.js +2 -2
- package/index.d.ts +1 -1
- package/index.js +3 -3
- package/package.json +5 -5
- package/parse.js +3 -3
- package/scanner.d.ts +1 -1
- package/scanner.js +3 -3
package/esm/index.js
CHANGED
|
@@ -18,8 +18,8 @@ export { parse, parseSync } from './parse';
|
|
|
18
18
|
export { deparseEnhanced, deparseEnhancedSync, Deparser } from './deparse';
|
|
19
19
|
// Re-export standard deparse for non-enhanced use
|
|
20
20
|
export { deparse, deparseSync } from 'pgsql-deparser';
|
|
21
|
-
// Re-export loadModule from
|
|
22
|
-
export { loadModule } from '
|
|
21
|
+
// Re-export loadModule from libpg-query
|
|
22
|
+
export { loadModule } from 'libpg-query';
|
|
23
23
|
// Types
|
|
24
24
|
export { isRawComment, isRawWhitespace, isRawStmt, } from './types';
|
|
25
25
|
// Scanner (for advanced use)
|
package/esm/parse.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* by interleaving synthetic RawComment and RawWhitespace nodes into the
|
|
4
4
|
* parse result's stmts array.
|
|
5
5
|
*/
|
|
6
|
-
import { parse as libParse, parseSync as libParseSync } from '
|
|
6
|
+
import { parse as libParse, parseSync as libParseSync } from 'libpg-query';
|
|
7
7
|
import { scanComments } from './scanner';
|
|
8
8
|
/**
|
|
9
9
|
* Find the actual SQL start position for a statement by skipping
|
package/esm/scanner.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Scanner for extracting comments and vertical whitespace
|
|
3
3
|
* from PostgreSQL SQL source text.
|
|
4
4
|
*
|
|
5
|
-
* Uses PostgreSQL's real lexer via
|
|
5
|
+
* Uses PostgreSQL's real lexer via libpg-query's scanSync()
|
|
6
6
|
* to identify SQL_COMMENT tokens with exact byte positions.
|
|
7
7
|
* Whitespace detection uses token gaps to find blank lines
|
|
8
8
|
* between statements/comments.
|
|
9
9
|
*/
|
|
10
|
-
import { scanSync } from '
|
|
10
|
+
import { scanSync } from 'libpg-query';
|
|
11
11
|
/** Token type for -- line comments from PostgreSQL's lexer */
|
|
12
12
|
const SQL_COMMENT = 275;
|
|
13
13
|
/**
|
package/index.d.ts
CHANGED
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
export { parse, parseSync } from './parse';
|
|
16
16
|
export { deparseEnhanced, deparseEnhancedSync, Deparser, DeparserOptions } from './deparse';
|
|
17
17
|
export { deparse, deparseSync } from 'pgsql-deparser';
|
|
18
|
-
export { loadModule } from '
|
|
18
|
+
export { loadModule } from 'libpg-query';
|
|
19
19
|
export { RawComment, RawWhitespace, EnhancedStmt, EnhancedParseResult, isRawComment, isRawWhitespace, isRawStmt, } from './types';
|
|
20
20
|
export { scanComments, ScannedComment, ScannedWhitespace, ScannedElement } from './scanner';
|
package/index.js
CHANGED
|
@@ -28,9 +28,9 @@ Object.defineProperty(exports, "Deparser", { enumerable: true, get: function ()
|
|
|
28
28
|
var pgsql_deparser_1 = require("pgsql-deparser");
|
|
29
29
|
Object.defineProperty(exports, "deparse", { enumerable: true, get: function () { return pgsql_deparser_1.deparse; } });
|
|
30
30
|
Object.defineProperty(exports, "deparseSync", { enumerable: true, get: function () { return pgsql_deparser_1.deparseSync; } });
|
|
31
|
-
// Re-export loadModule from
|
|
32
|
-
var
|
|
33
|
-
Object.defineProperty(exports, "loadModule", { enumerable: true, get: function () { return
|
|
31
|
+
// Re-export loadModule from libpg-query
|
|
32
|
+
var libpg_query_1 = require("libpg-query");
|
|
33
|
+
Object.defineProperty(exports, "loadModule", { enumerable: true, get: function () { return libpg_query_1.loadModule; } });
|
|
34
34
|
// Types
|
|
35
35
|
var types_1 = require("./types");
|
|
36
36
|
Object.defineProperty(exports, "isRawComment", { enumerable: true, get: function () { return types_1.isRawComment; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-parse",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "Comment and whitespace preserving PostgreSQL parser",
|
|
6
6
|
"main": "index.js",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"round-trip"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
45
|
-
"pgsql-deparser": "
|
|
43
|
+
"@pgsql/types": "^18.0.0",
|
|
44
|
+
"libpg-query": "18.1.1",
|
|
45
|
+
"pgsql-deparser": "18.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"makage": "^0.1.8"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "f700ee16d18aeacd2788eeb4410d73928cd11a5f"
|
|
51
51
|
}
|
package/parse.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.parse = parse;
|
|
9
9
|
exports.parseSync = parseSync;
|
|
10
|
-
const
|
|
10
|
+
const libpg_query_1 = require("libpg-query");
|
|
11
11
|
const scanner_1 = require("./scanner");
|
|
12
12
|
/**
|
|
13
13
|
* Find the actual SQL start position for a statement by skipping
|
|
@@ -124,7 +124,7 @@ function interleave(parseResult, sql, elements) {
|
|
|
124
124
|
* original source text.
|
|
125
125
|
*/
|
|
126
126
|
async function parse(sql) {
|
|
127
|
-
const parseResult = await (0,
|
|
127
|
+
const parseResult = await (0, libpg_query_1.parse)(sql);
|
|
128
128
|
const elements = (0, scanner_1.scanComments)(sql);
|
|
129
129
|
return interleave(parseResult, sql, elements);
|
|
130
130
|
}
|
|
@@ -132,7 +132,7 @@ async function parse(sql) {
|
|
|
132
132
|
* Parse SQL with comment and whitespace preservation (sync).
|
|
133
133
|
*/
|
|
134
134
|
function parseSync(sql) {
|
|
135
|
-
const parseResult = (0,
|
|
135
|
+
const parseResult = (0, libpg_query_1.parseSync)(sql);
|
|
136
136
|
const elements = (0, scanner_1.scanComments)(sql);
|
|
137
137
|
return interleave(parseResult, sql, elements);
|
|
138
138
|
}
|
package/scanner.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Scanner for extracting comments and vertical whitespace
|
|
3
3
|
* from PostgreSQL SQL source text.
|
|
4
4
|
*
|
|
5
|
-
* Uses PostgreSQL's real lexer via
|
|
5
|
+
* Uses PostgreSQL's real lexer via libpg-query's scanSync()
|
|
6
6
|
* to identify SQL_COMMENT tokens with exact byte positions.
|
|
7
7
|
* Whitespace detection uses token gaps to find blank lines
|
|
8
8
|
* between statements/comments.
|
package/scanner.js
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* Scanner for extracting comments and vertical whitespace
|
|
4
4
|
* from PostgreSQL SQL source text.
|
|
5
5
|
*
|
|
6
|
-
* Uses PostgreSQL's real lexer via
|
|
6
|
+
* Uses PostgreSQL's real lexer via libpg-query's scanSync()
|
|
7
7
|
* to identify SQL_COMMENT tokens with exact byte positions.
|
|
8
8
|
* Whitespace detection uses token gaps to find blank lines
|
|
9
9
|
* between statements/comments.
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.scanComments = scanComments;
|
|
13
|
-
const
|
|
13
|
+
const libpg_query_1 = require("libpg-query");
|
|
14
14
|
/** Token type for -- line comments from PostgreSQL's lexer */
|
|
15
15
|
const SQL_COMMENT = 275;
|
|
16
16
|
/**
|
|
@@ -38,7 +38,7 @@ function scanComments(sql) {
|
|
|
38
38
|
const elements = [];
|
|
39
39
|
let tokens;
|
|
40
40
|
try {
|
|
41
|
-
const scanResult = (0,
|
|
41
|
+
const scanResult = (0, libpg_query_1.scanSync)(sql);
|
|
42
42
|
tokens = scanResult.tokens;
|
|
43
43
|
}
|
|
44
44
|
catch {
|