@noormdev/sdk 1.4.1 → 1.5.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/dist/chunk-6LG4ENOJ.js +1523 -0
- package/dist/{chunk-G4B7EHL7.js → chunk-M7Q44VFJ.js} +5 -4
- package/dist/chunk-OXTXFKWJ.js +188 -0
- package/dist/{chunk-LY2F7ZFI.js → chunk-TXDGFA44.js} +3 -1518
- package/dist/{chunk-FSVO6NAJ.js → chunk-WUMCIKEQ.js} +4 -3
- package/dist/{engine-MZQ364EH.js → engine-P74UTJQO.js} +5 -4
- package/dist/index.d.ts +55 -0
- package/dist/index.js +480 -67
- package/dist/{mssql-3BQB6ACD.js → mssql-II62FO2B.js} +22 -39
- package/dist/{storage-V5I67ANZ.js → storage-FBDOY3MC.js} +5 -4
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
|
+
import { explainMssqlLoginFailure } from './chunk-OXTXFKWJ.js';
|
|
3
|
+
import { attempt } from './chunk-TXDGFA44.js';
|
|
2
4
|
import { DEFAULT_PORTS, connectTimeoutFor } from './chunk-WE2JLJMT.js';
|
|
3
5
|
import './chunk-D2XW2UOP.js';
|
|
4
6
|
import { isIP } from 'net';
|
|
@@ -73,7 +75,7 @@ function resolveTlsServerName(config) {
|
|
|
73
75
|
}
|
|
74
76
|
return UNVERIFIED_TLS_SERVER_NAME;
|
|
75
77
|
}
|
|
76
|
-
function buildTediousOptions(config
|
|
78
|
+
function buildTediousOptions(config) {
|
|
77
79
|
return {
|
|
78
80
|
server: config.host ?? "localhost",
|
|
79
81
|
authentication: {
|
|
@@ -85,7 +87,7 @@ function buildTediousOptions(config, database) {
|
|
|
85
87
|
},
|
|
86
88
|
options: {
|
|
87
89
|
port: config.port ?? DEFAULT_PORTS.mssql,
|
|
88
|
-
database:
|
|
90
|
+
database: config.database,
|
|
89
91
|
trustServerCertificate: !config.ssl,
|
|
90
92
|
encrypt: true,
|
|
91
93
|
serverName: resolveTlsServerName(config),
|
|
@@ -98,46 +100,19 @@ function buildTediousOptions(config, database) {
|
|
|
98
100
|
}
|
|
99
101
|
};
|
|
100
102
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
tarn: {
|
|
108
|
-
...Tarn,
|
|
109
|
-
options: {
|
|
110
|
-
min: 0,
|
|
111
|
-
max: 1,
|
|
112
|
-
propagateCreateError: true
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
tedious: {
|
|
116
|
-
...Tedious,
|
|
117
|
-
connectionFactory: () => buildTediousConfig(Tedious, config, "master")
|
|
118
|
-
}
|
|
119
|
-
}),
|
|
120
|
-
plugins: [new MssqlLimitPlugin()]
|
|
121
|
-
});
|
|
122
|
-
try {
|
|
123
|
-
const { rows } = await sql`
|
|
124
|
-
SELECT name FROM sys.databases WHERE name = ${config.database}
|
|
125
|
-
`.execute(masterDb);
|
|
126
|
-
if (rows.length === 0) {
|
|
127
|
-
throw new Error(
|
|
128
|
-
`Database '${config.database}' does not exist on ${config.host ?? "localhost"}:${config.port ?? DEFAULT_PORTS.mssql}`
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
} finally {
|
|
132
|
-
await masterDb.destroy();
|
|
133
|
-
}
|
|
103
|
+
function buildTediousConnection(Tedious, config, loginErrors) {
|
|
104
|
+
const connection = new Tedious.Connection(buildTediousOptions(config));
|
|
105
|
+
const record = (token) => loginErrors.push({ number: token.number, message: token.message });
|
|
106
|
+
connection.on("errorMessage", record);
|
|
107
|
+
connection.once("connect", () => connection.removeListener("errorMessage", record));
|
|
108
|
+
return connection;
|
|
134
109
|
}
|
|
135
110
|
async function createMssqlConnection(config) {
|
|
136
111
|
const TediousImport = await import('tedious');
|
|
137
112
|
const TarnImport = await import('tarn');
|
|
138
113
|
const Tedious = TediousImport.default ?? TediousImport;
|
|
139
114
|
const Tarn = TarnImport.default ?? TarnImport;
|
|
140
|
-
|
|
115
|
+
let loginErrors = [];
|
|
141
116
|
const db = new Kysely({
|
|
142
117
|
dialect: new MssqlDialect({
|
|
143
118
|
tarn: {
|
|
@@ -150,11 +125,19 @@ async function createMssqlConnection(config) {
|
|
|
150
125
|
},
|
|
151
126
|
tedious: {
|
|
152
127
|
...Tedious,
|
|
153
|
-
connectionFactory: () =>
|
|
128
|
+
connectionFactory: () => {
|
|
129
|
+
loginErrors = [];
|
|
130
|
+
return buildTediousConnection(Tedious, config, loginErrors);
|
|
131
|
+
}
|
|
154
132
|
}
|
|
155
133
|
}),
|
|
156
134
|
plugins: [new MssqlLimitPlugin()]
|
|
157
135
|
});
|
|
136
|
+
const [, connectErr] = await attempt(() => sql`SELECT 1`.execute(db));
|
|
137
|
+
if (connectErr) {
|
|
138
|
+
await db.destroy();
|
|
139
|
+
throw explainMssqlLoginFailure(loginErrors, connectErr, config);
|
|
140
|
+
}
|
|
158
141
|
return {
|
|
159
142
|
db,
|
|
160
143
|
dialect: "mssql",
|
|
@@ -163,5 +146,5 @@ async function createMssqlConnection(config) {
|
|
|
163
146
|
}
|
|
164
147
|
|
|
165
148
|
export { MssqlTlsServerNameError, UNVERIFIED_TLS_SERVER_NAME, buildTediousOptions, createMssqlConnection, resolveTlsServerName };
|
|
166
|
-
//# sourceMappingURL=mssql-
|
|
167
|
-
//# sourceMappingURL=mssql-
|
|
149
|
+
//# sourceMappingURL=mssql-II62FO2B.js.map
|
|
150
|
+
//# sourceMappingURL=mssql-II62FO2B.js.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
|
-
export { deleteVaultSecret, deleteVaultSecretChecked, getAllVaultSecrets, getVaultKey, getVaultKeyChecked, getVaultSecret, getVaultStatus, initializeVault, initializeVaultChecked, listVaultSecretKeys, listVaultSecretKeysChecked, setVaultSecret, setVaultSecretChecked, vaultSecretExists } from './chunk-
|
|
3
|
-
import './chunk-
|
|
2
|
+
export { deleteVaultSecret, deleteVaultSecretChecked, getAllVaultSecrets, getVaultKey, getVaultKeyChecked, getVaultSecret, getVaultStatus, initializeVault, initializeVaultChecked, listVaultSecretKeys, listVaultSecretKeysChecked, setVaultSecret, setVaultSecretChecked, vaultSecretExists } from './chunk-WUMCIKEQ.js';
|
|
3
|
+
import './chunk-6LG4ENOJ.js';
|
|
4
|
+
import './chunk-TXDGFA44.js';
|
|
4
5
|
import './chunk-D2XW2UOP.js';
|
|
5
6
|
|
|
6
7
|
createRequire(import.meta.url);
|
|
7
|
-
//# sourceMappingURL=storage-
|
|
8
|
-
//# sourceMappingURL=storage-
|
|
8
|
+
//# sourceMappingURL=storage-FBDOY3MC.js.map
|
|
9
|
+
//# sourceMappingURL=storage-FBDOY3MC.js.map
|