datapeek 0.1.8 → 0.1.9

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.
@@ -1,108 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/server/db/mssql.ts
4
- import sql from "mssql";
5
- var pool = null;
6
- function parseConnectionString(connectionString) {
7
- const config = {
8
- server: "",
9
- database: "",
10
- options: {
11
- encrypt: true,
12
- trustServerCertificate: false,
13
- enableArithAbort: true
14
- }
15
- };
16
- const parts = connectionString.split(";");
17
- for (const part of parts) {
18
- const [key, ...valueParts] = part.split("=");
19
- const value = valueParts.join("=").trim();
20
- switch (key.trim().toLowerCase()) {
21
- case "server":
22
- case "data source":
23
- config.server = value;
24
- break;
25
- case "database":
26
- case "initial catalog":
27
- config.database = value;
28
- break;
29
- case "user id":
30
- case "uid":
31
- config.user = value;
32
- break;
33
- case "password":
34
- case "pwd":
35
- config.password = value;
36
- break;
37
- case "port":
38
- config.port = parseInt(value, 10);
39
- break;
40
- case "encrypt":
41
- config.options.encrypt = value.toLowerCase() === "true";
42
- break;
43
- case "trustservercertificate":
44
- case "trust server certificate":
45
- config.options.trustServerCertificate = value.toLowerCase() === "true";
46
- break;
47
- }
48
- }
49
- return config;
50
- }
51
- async function testConnection(config) {
52
- const testPool = typeof config === "string" ? new sql.ConnectionPool(parseConnectionString(config)) : new sql.ConnectionPool(config);
53
- try {
54
- await testPool.connect();
55
- await testPool.close();
56
- } catch (error) {
57
- throw error;
58
- }
59
- }
60
- async function connect(config) {
61
- await disconnect();
62
- const connectionConfig = typeof config === "string" ? parseConnectionString(config) : config;
63
- pool = new sql.ConnectionPool(connectionConfig);
64
- try {
65
- await pool.connect();
66
- } catch (error) {
67
- pool = null;
68
- throw error;
69
- }
70
- }
71
- async function disconnect() {
72
- if (pool) {
73
- try {
74
- await pool.close();
75
- } catch (error) {
76
- }
77
- pool = null;
78
- }
79
- }
80
- function getConnection() {
81
- return pool;
82
- }
83
- async function executeQuery(query, parameters) {
84
- if (!pool || !pool.connected) {
85
- throw new Error("Not connected to database");
86
- }
87
- const request = pool.request();
88
- if (parameters) {
89
- for (const param of parameters) {
90
- if (param.type) {
91
- request.input(param.name, param.type, param.value);
92
- } else {
93
- request.input(param.name, param.value);
94
- }
95
- }
96
- }
97
- const result = await request.query(query);
98
- return result.recordset || [];
99
- }
100
-
101
- export {
102
- parseConnectionString,
103
- testConnection,
104
- connect,
105
- disconnect,
106
- getConnection,
107
- executeQuery
108
- };
@@ -1,119 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
-
4
- // src/server/db/mssql.ts
5
- import sql from "mssql";
6
- var pool = null;
7
- function parseConnectionString(connectionString) {
8
- const config = {
9
- server: "",
10
- database: "",
11
- options: {
12
- encrypt: true,
13
- trustServerCertificate: false,
14
- enableArithAbort: true
15
- }
16
- };
17
- const parts = connectionString.split(";");
18
- for (const part of parts) {
19
- const [key, ...valueParts] = part.split("=");
20
- const value = valueParts.join("=").trim();
21
- const keyLower = key.trim().toLowerCase();
22
- switch (keyLower) {
23
- case "server":
24
- case "data source":
25
- let serverValue = value;
26
- if (serverValue.startsWith("tcp:")) {
27
- serverValue = serverValue.substring(4);
28
- }
29
- const [serverHost, serverPort] = serverValue.split(",");
30
- config.server = serverHost.trim();
31
- if (serverPort) {
32
- config.port = parseInt(serverPort.trim(), 10);
33
- }
34
- break;
35
- case "database":
36
- case "initial catalog":
37
- config.database = value;
38
- break;
39
- case "user id":
40
- case "userid":
41
- case "uid":
42
- config.user = value;
43
- break;
44
- case "password":
45
- case "pwd":
46
- config.password = value;
47
- break;
48
- case "port":
49
- config.port = parseInt(value, 10);
50
- break;
51
- case "encrypt":
52
- config.options.encrypt = value.toLowerCase() === "true";
53
- break;
54
- case "trustservercertificate":
55
- case "trust server certificate":
56
- config.options.trustServerCertificate = value.toLowerCase() === "true";
57
- break;
58
- }
59
- }
60
- return config;
61
- }
62
- async function testConnection(config) {
63
- const testPool = typeof config === "string" ? new sql.ConnectionPool(parseConnectionString(config)) : new sql.ConnectionPool(config);
64
- try {
65
- await testPool.connect();
66
- await testPool.close();
67
- } catch (error) {
68
- throw error;
69
- }
70
- }
71
- async function connect(config) {
72
- await disconnect();
73
- const connectionConfig = typeof config === "string" ? parseConnectionString(config) : config;
74
- pool = new sql.ConnectionPool(connectionConfig);
75
- try {
76
- await pool.connect();
77
- } catch (error) {
78
- pool = null;
79
- throw error;
80
- }
81
- }
82
- async function disconnect() {
83
- if (pool) {
84
- try {
85
- await pool.close();
86
- } catch (error) {
87
- }
88
- pool = null;
89
- }
90
- }
91
- function getConnection() {
92
- return pool;
93
- }
94
- async function executeQuery(query, parameters) {
95
- if (!pool || !pool.connected) {
96
- throw new Error("Not connected to database");
97
- }
98
- const request = pool.request();
99
- if (parameters) {
100
- for (const param of parameters) {
101
- if (param.type) {
102
- request.input(param.name, param.type, param.value);
103
- } else {
104
- request.input(param.name, param.value);
105
- }
106
- }
107
- }
108
- const result = await request.query(query);
109
- return result.recordset || [];
110
- }
111
-
112
- export {
113
- parseConnectionString,
114
- testConnection,
115
- connect,
116
- disconnect,
117
- getConnection,
118
- executeQuery
119
- };
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- connect,
4
- disconnect,
5
- executeQuery,
6
- getConnection,
7
- parseConnectionString,
8
- testConnection
9
- } from "./chunk-IPR5JXB5.js";
10
- export {
11
- connect,
12
- disconnect,
13
- executeQuery,
14
- getConnection,
15
- parseConnectionString,
16
- testConnection
17
- };
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- connect,
4
- disconnect,
5
- executeQuery,
6
- getConnection,
7
- parseConnectionString,
8
- testConnection
9
- } from "./chunk-4IGBRCNN.js";
10
- export {
11
- connect,
12
- disconnect,
13
- executeQuery,
14
- getConnection,
15
- parseConnectionString,
16
- testConnection
17
- };
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import {
4
- connect,
5
- disconnect,
6
- executeQuery,
7
- getConnection,
8
- parseConnectionString,
9
- testConnection
10
- } from "./chunk-PTI2CUG6.js";
11
- export {
12
- connect,
13
- disconnect,
14
- executeQuery,
15
- getConnection,
16
- parseConnectionString,
17
- testConnection
18
- };