Commit iniziale
This commit is contained in:
21
node_modules/@tediousjs/connection-string/LICENSE
generated
vendored
Normal file
21
node_modules/@tediousjs/connection-string/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Daniel Hensby
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
65
node_modules/@tediousjs/connection-string/README.md
generated
vendored
Normal file
65
node_modules/@tediousjs/connection-string/README.md
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
# Connection String Parser
|
||||
|
||||
[](https://www.npmjs.com/package/@tediousjs/connection-string)
|
||||
[](https://github.com/tediousjs/connection-string/actions/workflows/nodejs.yml)
|
||||
|
||||
This node library is designed to allow the parsing of Connection Strings see https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring
|
||||
|
||||
The library also provides the ability to parse SQL Connection Strings.
|
||||
|
||||
# Usage
|
||||
|
||||
## Parsing connection strings
|
||||
|
||||
The library comes with a generic connection string parser that will parse through valid connections strings and produce a key-value
|
||||
map of the entries in that string. No additional validation is performed.
|
||||
|
||||
```js
|
||||
const { parseConnectionString } = require('@tediousjs/connection-string');
|
||||
|
||||
const connectionString = 'User ID=user;Password=password;Initial Catalog=AdventureWorks;Server=MySqlServer';
|
||||
|
||||
const parsed = parseConnectionString(connectionString);
|
||||
|
||||
console.log(parsed);
|
||||
```
|
||||
|
||||
Output to the console will be:
|
||||
|
||||
```json
|
||||
{
|
||||
"User id": "user",
|
||||
"password": "password",
|
||||
"initial catalog": "AdventureWorks",
|
||||
"server": "MySqlServer"
|
||||
}
|
||||
```
|
||||
|
||||
## Parsing SQL connection strings
|
||||
|
||||
There is a specific helper for parsing SQL connection strings and this comes with a value normaliser and validation. It also has an
|
||||
option to "canonicalise" the properties. For many properties in an SQL connections string, there are aliases, when canonical properties
|
||||
are being used, these aliases will be returned as the canonical property.
|
||||
|
||||
```js
|
||||
const { parseSqlConnectionString } = require('@tediousjs/connection-string');
|
||||
|
||||
const connectionString = 'User ID=user;Password=password;Initial Catalog=AdventureWorks;Server=MySqlServer';
|
||||
|
||||
const parsed = parseSqlConnectionString(connectionString, true);
|
||||
|
||||
console.log(parsed);
|
||||
```
|
||||
|
||||
Output to console will be:
|
||||
|
||||
```json
|
||||
{
|
||||
"user id": "user",
|
||||
"password": "password",
|
||||
"initial catalog": "AdventureWorks",
|
||||
"data source": "MySqlServer"
|
||||
}
|
||||
```
|
||||
|
||||
NB: The `Server` property from the connection string has been re-written to the value `Data Source`
|
||||
6
node_modules/@tediousjs/connection-string/lib/builder/index.d.ts
generated
vendored
Normal file
6
node_modules/@tediousjs/connection-string/lib/builder/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
type ValidDataTypes = string | boolean | number | null | undefined | {
|
||||
toString(): string;
|
||||
};
|
||||
export declare function buildConnectionString(data: Record<string, ValidDataTypes>): string;
|
||||
export {};
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/@tediousjs/connection-string/lib/builder/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@tediousjs/connection-string/lib/builder/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builder/index.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG;IAAE,QAAQ,IAAI,MAAM,CAAA;CAAE,CAAC;AA4C5F,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,MAAM,CAIlF"}
|
||||
52
node_modules/@tediousjs/connection-string/lib/builder/index.js
generated
vendored
Normal file
52
node_modules/@tediousjs/connection-string/lib/builder/index.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.buildConnectionString = void 0;
|
||||
function isQuoted(val) {
|
||||
if (val[0] !== '{') {
|
||||
return false;
|
||||
}
|
||||
for (let i = 1; i < val.length; i++) {
|
||||
if (val[i] === '}') {
|
||||
if (i + 1 === val.length) {
|
||||
// if last char, then it's quoted properly
|
||||
return true;
|
||||
}
|
||||
else if (val[i + 1] !== '}') {
|
||||
// the next char is no a `}` so there is no valid escaping here
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// we are seeing an escaped `}`, so skip ahead
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function needsQuotes(val) {
|
||||
var _a;
|
||||
return !isQuoted(val) && !!((_a = val.match(/\[|]|{|}|\|\(|\)|,|;|\?|\*|=|!|@/)) === null || _a === void 0 ? void 0 : _a.length);
|
||||
}
|
||||
function encodeTuple(key, value) {
|
||||
if (value === null || value === undefined) {
|
||||
return [key, ''];
|
||||
}
|
||||
switch (typeof value) {
|
||||
case 'boolean':
|
||||
return [key, value ? 'Yes' : 'No'];
|
||||
default: {
|
||||
const strVal = value.toString();
|
||||
if (needsQuotes(strVal)) {
|
||||
return [key, `{${strVal.replace(/}/g, '}}')}}`];
|
||||
}
|
||||
return [key, strVal];
|
||||
}
|
||||
}
|
||||
}
|
||||
function buildConnectionString(data) {
|
||||
return Object.entries(data).map(([key, value]) => {
|
||||
return encodeTuple(key.trim(), value).join('=');
|
||||
}).join(';');
|
||||
}
|
||||
exports.buildConnectionString = buildConnectionString;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@tediousjs/connection-string/lib/builder/index.js.map
generated
vendored
Normal file
1
node_modules/@tediousjs/connection-string/lib/builder/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/builder/index.ts"],"names":[],"mappings":";;;AAEA,SAAS,QAAQ,CAAC,GAAW;IACzB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QAChB,OAAO,KAAK,CAAC;KAChB;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACjC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YAChB,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM,EAAE;gBACtB,0CAA0C;gBAC1C,OAAO,IAAI,CAAC;aACf;iBAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;gBAC3B,+DAA+D;gBAC/D,OAAO,KAAK,CAAC;aAChB;iBAAM;gBACH,8CAA8C;gBAC9C,CAAC,EAAE,CAAC;aACP;SACJ;KACJ;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA,MAAA,GAAG,CAAC,KAAK,CAAC,kCAAkC,CAAC,0CAAE,MAAM,CAAA,CAAC;AACrF,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAE,KAAqB;IACnD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACvC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;KACpB;IACD,QAAQ,OAAO,KAAK,EAAE;QAClB,KAAK,SAAS;YACV,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACvC,OAAO,CAAC,CAAC;YACL,MAAM,MAAM,GAAI,KAAgC,CAAC,QAAQ,EAAE,CAAC;YAC5D,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE;gBACrB,OAAO,CAAC,GAAG,EAAE,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;aACnD;YACD,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;SACxB;KACJ;AACL,CAAC;AAED,SAAgB,qBAAqB,CAAC,IAAoC;IACtE,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC7C,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACjB,CAAC;AAJD,sDAIC"}
|
||||
5
node_modules/@tediousjs/connection-string/lib/index.d.ts
generated
vendored
Normal file
5
node_modules/@tediousjs/connection-string/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import parseConnectionString from './parser/connection-string';
|
||||
import parseSqlConnectionString from './parser/sql-connection-string';
|
||||
export * from './builder';
|
||||
export { parseConnectionString, parseSqlConnectionString, };
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/@tediousjs/connection-string/lib/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@tediousjs/connection-string/lib/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,wBAAwB,MAAM,gCAAgC,CAAC;AAEtE,cAAc,WAAW,CAAC;AAE1B,OAAO,EACH,qBAAqB,EACrB,wBAAwB,GAC3B,CAAC"}
|
||||
26
node_modules/@tediousjs/connection-string/lib/index.js
generated
vendored
Normal file
26
node_modules/@tediousjs/connection-string/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseSqlConnectionString = exports.parseConnectionString = void 0;
|
||||
const connection_string_1 = __importDefault(require("./parser/connection-string"));
|
||||
exports.parseConnectionString = connection_string_1.default;
|
||||
const sql_connection_string_1 = __importDefault(require("./parser/sql-connection-string"));
|
||||
exports.parseSqlConnectionString = sql_connection_string_1.default;
|
||||
__exportStar(require("./builder"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@tediousjs/connection-string/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@tediousjs/connection-string/lib/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,mFAA+D;AAM3D,gCANG,2BAAqB,CAMH;AALzB,2FAAsE;AAMlE,mCANG,+BAAwB,CAMH;AAJ5B,4CAA0B"}
|
||||
10
node_modules/@tediousjs/connection-string/lib/parser/connection-string.d.ts
generated
vendored
Normal file
10
node_modules/@tediousjs/connection-string/lib/parser/connection-string.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export interface CollectionConfig {
|
||||
terminator: string;
|
||||
quotes: Record<string, string>;
|
||||
}
|
||||
export interface ParserConfig {
|
||||
key: CollectionConfig;
|
||||
value: CollectionConfig;
|
||||
}
|
||||
export default function connectionStringParser(connectionString: string, parserConfig?: ParserConfig): object;
|
||||
//# sourceMappingURL=connection-string.d.ts.map
|
||||
1
node_modules/@tediousjs/connection-string/lib/parser/connection-string.d.ts.map
generated
vendored
Normal file
1
node_modules/@tediousjs/connection-string/lib/parser/connection-string.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"connection-string.d.ts","sourceRoot":"","sources":["../../src/parser/connection-string.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,YAAY;IACzB,GAAG,EAAE,gBAAgB,CAAC;IACtB,KAAK,EAAE,gBAAgB,CAAC;CAC3B;AAsBD,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,EAAE,YAAY,GAAE,YAAqB,GAAG,MAAM,CAiHpH"}
|
||||
135
node_modules/@tediousjs/connection-string/lib/parser/connection-string.js
generated
vendored
Normal file
135
node_modules/@tediousjs/connection-string/lib/parser/connection-string.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var CollectionMode;
|
||||
(function (CollectionMode) {
|
||||
CollectionMode[CollectionMode["key"] = 0] = "key";
|
||||
CollectionMode[CollectionMode["value"] = 1] = "value";
|
||||
})(CollectionMode || (CollectionMode = {}));
|
||||
const CONFIG = Object.freeze({
|
||||
key: {
|
||||
terminator: '=',
|
||||
quotes: {},
|
||||
},
|
||||
value: {
|
||||
terminator: ';',
|
||||
quotes: {
|
||||
'"': '"',
|
||||
"'": "'",
|
||||
'{': '}',
|
||||
},
|
||||
},
|
||||
});
|
||||
function connectionStringParser(connectionString, parserConfig = CONFIG) {
|
||||
const parsed = {};
|
||||
let collectionMode = CollectionMode.key;
|
||||
let started = false;
|
||||
let finished = false;
|
||||
let quoted = false;
|
||||
let quote = '';
|
||||
let buffer = '';
|
||||
let currentKey = '';
|
||||
let pointer = 0;
|
||||
function start() {
|
||||
started = true;
|
||||
}
|
||||
function finish() {
|
||||
finished = true;
|
||||
}
|
||||
function reset() {
|
||||
started = false;
|
||||
finished = false;
|
||||
quoted = false;
|
||||
quote = '';
|
||||
buffer = '';
|
||||
}
|
||||
function config() {
|
||||
return collectionMode === CollectionMode.key ? parserConfig.key : parserConfig.value;
|
||||
}
|
||||
function isTerminator(char) {
|
||||
return config().terminator === char;
|
||||
}
|
||||
function isStartQuote(char) {
|
||||
return Object.keys(config().quotes).some((val) => char === val);
|
||||
}
|
||||
function isEndQuote(char) {
|
||||
return quoted && char === config().quotes[quote];
|
||||
}
|
||||
function push(char) {
|
||||
buffer += char;
|
||||
}
|
||||
function collect() {
|
||||
if (!quoted) {
|
||||
buffer = buffer.trim();
|
||||
}
|
||||
switch (collectionMode) {
|
||||
case CollectionMode.key:
|
||||
currentKey = buffer.toLowerCase();
|
||||
collectionMode = CollectionMode.value;
|
||||
break;
|
||||
case CollectionMode.value:
|
||||
collectionMode = CollectionMode.key;
|
||||
parsed[currentKey] = buffer;
|
||||
currentKey = '';
|
||||
break;
|
||||
}
|
||||
reset();
|
||||
}
|
||||
while (pointer < connectionString.length) {
|
||||
const current = connectionString.charAt(pointer);
|
||||
if (!finished) {
|
||||
if (!started) {
|
||||
if (current.trim()) {
|
||||
start();
|
||||
if (isStartQuote(current)) {
|
||||
quoted = true;
|
||||
quote = current;
|
||||
}
|
||||
else {
|
||||
push(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (quoted && isEndQuote(current)) {
|
||||
const next = connectionString.charAt(pointer + 1);
|
||||
if (current === next) {
|
||||
push(current);
|
||||
pointer++;
|
||||
}
|
||||
else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
else if (!quoted && isTerminator(current)) {
|
||||
const next = connectionString.charAt(pointer + 1);
|
||||
if (current === next) {
|
||||
push(current);
|
||||
pointer++;
|
||||
}
|
||||
else {
|
||||
collect();
|
||||
}
|
||||
}
|
||||
else {
|
||||
push(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isTerminator(current)) {
|
||||
collect();
|
||||
}
|
||||
else if (current.trim()) {
|
||||
throw new Error('Malformed connection string');
|
||||
}
|
||||
pointer++;
|
||||
}
|
||||
if (quoted && !finished) {
|
||||
throw new Error('Connection string terminated unexpectedly');
|
||||
}
|
||||
else {
|
||||
collect();
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
exports.default = connectionStringParser;
|
||||
//# sourceMappingURL=connection-string.js.map
|
||||
1
node_modules/@tediousjs/connection-string/lib/parser/connection-string.js.map
generated
vendored
Normal file
1
node_modules/@tediousjs/connection-string/lib/parser/connection-string.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"connection-string.js","sourceRoot":"","sources":["../../src/parser/connection-string.ts"],"names":[],"mappings":";;AAUA,IAAK,cAGJ;AAHD,WAAK,cAAc;IACf,iDAAG,CAAA;IACH,qDAAK,CAAA;AACT,CAAC,EAHI,cAAc,KAAd,cAAc,QAGlB;AAED,MAAM,MAAM,GAAiB,MAAM,CAAC,MAAM,CAAC;IACvC,GAAG,EAAE;QACD,UAAU,EAAE,GAAG;QACf,MAAM,EAAE,EAAE;KACb;IACD,KAAK,EAAE;QACH,UAAU,EAAE,GAAG;QACf,MAAM,EAAE;YACJ,GAAG,EAAE,GAAG;YACR,GAAG,EAAE,GAAG;YACR,GAAG,EAAE,GAAG;SACX;KACJ;CACJ,CAAC,CAAC;AAEH,SAAwB,sBAAsB,CAAC,gBAAwB,EAAE,eAA6B,MAAM;IACxG,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,IAAI,cAAc,GAAG,cAAc,CAAC,GAAG,CAAC;IACxC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,SAAS,KAAK;QACV,OAAO,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,SAAS,MAAM;QACX,QAAQ,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,SAAS,KAAK;QACV,OAAO,GAAG,KAAK,CAAC;QAChB,QAAQ,GAAG,KAAK,CAAC;QACjB,MAAM,GAAG,KAAK,CAAC;QACf,KAAK,GAAG,EAAE,CAAC;QACX,MAAM,GAAG,EAAE,CAAC;IAChB,CAAC;IAED,SAAS,MAAM;QACX,OAAO,cAAc,KAAK,cAAc,CAAC,GA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C;AAClB,CAAC;AAjHD,yCAiHC"}
|
||||
23
node_modules/@tediousjs/connection-string/lib/parser/sql-connection-string.d.ts
generated
vendored
Normal file
23
node_modules/@tediousjs/connection-string/lib/parser/sql-connection-string.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
export declare enum SchemaTypes {
|
||||
BOOL = 0,
|
||||
STRING = 1,
|
||||
NUMBER = 2
|
||||
}
|
||||
type Coercer = (val: string) => string | number | boolean | null;
|
||||
type Validator = (val: string | number | boolean) => boolean;
|
||||
export interface SchemaItem {
|
||||
type: SchemaTypes;
|
||||
allowedValues?: (string | number | boolean)[];
|
||||
default?: string | number | boolean;
|
||||
aliases?: string[];
|
||||
canonical?: string;
|
||||
coerce?: Coercer;
|
||||
validator?: Validator;
|
||||
}
|
||||
export interface SchemaDefinition {
|
||||
[name: string]: SchemaItem;
|
||||
}
|
||||
export declare const SCHEMA: SchemaDefinition;
|
||||
export default function parseSqlConnectionString(connectionString: string, canonicalProps?: boolean, allowUnknown?: boolean, strict?: boolean, schema?: SchemaDefinition): Record<string, string | number | boolean>;
|
||||
export {};
|
||||
//# sourceMappingURL=sql-connection-string.d.ts.map
|
||||
1
node_modules/@tediousjs/connection-string/lib/parser/sql-connection-string.d.ts.map
generated
vendored
Normal file
1
node_modules/@tediousjs/connection-string/lib/parser/sql-connection-string.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sql-connection-string.d.ts","sourceRoot":"","sources":["../../src/parser/sql-connection-string.ts"],"names":[],"mappings":"AAEA,oBAAY,WAAW;IACnB,IAAI,IAAA;IACJ,MAAM,IAAA;IACN,MAAM,IAAA;CACT;AAED,KAAK,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AACjE,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,KAAK,OAAO,CAAC;AAE7D,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,aAAa,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,SAAS,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC7B,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAC9B;AAGD,eAAO,MAAM,MAAM,EAAE,gBAqMpB,CAAC;AAmDF,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,EAAE,cAAc,UAAQ,EAAE,YAAY,UAAQ,EAAE,MAAM,UAAQ,EAAE,MAAM,GAAE,gBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CA6BrN"}
|
||||
290
node_modules/@tediousjs/connection-string/lib/parser/sql-connection-string.js
generated
vendored
Normal file
290
node_modules/@tediousjs/connection-string/lib/parser/sql-connection-string.js
generated
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SCHEMA = exports.SchemaTypes = void 0;
|
||||
const connection_string_1 = __importDefault(require("./connection-string"));
|
||||
var SchemaTypes;
|
||||
(function (SchemaTypes) {
|
||||
SchemaTypes[SchemaTypes["BOOL"] = 0] = "BOOL";
|
||||
SchemaTypes[SchemaTypes["STRING"] = 1] = "STRING";
|
||||
SchemaTypes[SchemaTypes["NUMBER"] = 2] = "NUMBER";
|
||||
})(SchemaTypes = exports.SchemaTypes || (exports.SchemaTypes = {}));
|
||||
// schema for MSSQL connection strings (https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring)
|
||||
exports.SCHEMA = {
|
||||
'Application Name': {
|
||||
type: SchemaTypes.STRING,
|
||||
aliases: ['App'],
|
||||
validator(val) {
|
||||
return typeof val === 'string' && val.length <= 128;
|
||||
},
|
||||
},
|
||||
'ApplicationIntent': {
|
||||
type: SchemaTypes.STRING,
|
||||
allowedValues: ['ReadOnly', 'ReadWrite'],
|
||||
default: 'ReadWrite',
|
||||
},
|
||||
'Asynchronous Processing': {
|
||||
type: SchemaTypes.BOOL,
|
||||
default: false,
|
||||
aliases: ['Async'],
|
||||
},
|
||||
'AttachDBFilename': {
|
||||
type: SchemaTypes.STRING,
|
||||
aliases: ['Extended Properties', 'Initial File Name'],
|
||||
},
|
||||
'Authentication': {
|
||||
type: SchemaTypes.STRING,
|
||||
allowedValues: ['Active Directory Integrated', 'Active Directory Password', 'Sql Password'],
|
||||
},
|
||||
'Column Encryption Setting': {
|
||||
type: SchemaTypes.STRING,
|
||||
},
|
||||
'Connection Timeout': {
|
||||
type: SchemaTypes.NUMBER,
|
||||
aliases: ['Connect Timeout', 'Timeout'],
|
||||
default: 15,
|
||||
},
|
||||
'Connection Lifetime': {
|
||||
type: SchemaTypes.NUMBER,
|
||||
aliases: ['Load Balance Timeout'],
|
||||
default: 0,
|
||||
},
|
||||
'ConnectRetryCount': {
|
||||
type: SchemaTypes.NUMBER,
|
||||
default: 1,
|
||||
validator(val) {
|
||||
return val > 0 && val <= 255;
|
||||
},
|
||||
},
|
||||
'ConnectRetryInterval': {
|
||||
type: SchemaTypes.NUMBER,
|
||||
default: 10,
|
||||
},
|
||||
'Context Connection': {
|
||||
type: SchemaTypes.BOOL,
|
||||
default: false,
|
||||
},
|
||||
'Current Language': {
|
||||
aliases: ['Language'],
|
||||
type: SchemaTypes.STRING,
|
||||
validator(val) {
|
||||
return typeof val === 'string' && val.length <= 128;
|
||||
},
|
||||
},
|
||||
'Data Source': {
|
||||
aliases: ['Addr', 'Address', 'Server', 'Network Address'],
|
||||
type: SchemaTypes.STRING,
|
||||
},
|
||||
'Encrypt': {
|
||||
type: SchemaTypes.BOOL,
|
||||
default: false,
|
||||
},
|
||||
'Enlist': {
|
||||
type: SchemaTypes.BOOL,
|
||||
default: true,
|
||||
},
|
||||
'Failover Partner': {
|
||||
type: SchemaTypes.STRING,
|
||||
},
|
||||
'Initial Catalog': {
|
||||
type: SchemaTypes.STRING,
|
||||
aliases: ['Database'],
|
||||
validator(val) {
|
||||
return typeof val === 'string' && val.length <= 128;
|
||||
},
|
||||
},
|
||||
'Integrated Security': {
|
||||
type: SchemaTypes.BOOL,
|
||||
aliases: ['Trusted_Connection'],
|
||||
coerce(val) {
|
||||
return val === 'sspi' || null;
|
||||
},
|
||||
},
|
||||
'Max Pool Size': {
|
||||
type: SchemaTypes.NUMBER,
|
||||
default: 100,
|
||||
validator(val) {
|
||||
return val >= 1;
|
||||
},
|
||||
},
|
||||
'Min Pool Size': {
|
||||
type: SchemaTypes.NUMBER,
|
||||
default: 0,
|
||||
validator(val) {
|
||||
return val >= 0;
|
||||
},
|
||||
},
|
||||
'MultipleActiveResultSets': {
|
||||
type: SchemaTypes.BOOL,
|
||||
default: false,
|
||||
},
|
||||
'MultiSubnetFailover': {
|
||||
type: SchemaTypes.BOOL,
|
||||
default: false,
|
||||
},
|
||||
'Network Library': {
|
||||
type: SchemaTypes.STRING,
|
||||
aliases: ['Network', 'Net'],
|
||||
allowedValues: ['dbnmpntw', 'dbmsrpcn', 'dbmsadsn', 'dbmsgnet', 'dbmslpcn', 'dbmsspxn', 'dbmssocn', 'Dbmsvinn'],
|
||||
},
|
||||
'Packet Size': {
|
||||
type: SchemaTypes.NUMBER,
|
||||
default: 8000,
|
||||
validator(val) {
|
||||
return val >= 512 && val <= 32768;
|
||||
},
|
||||
},
|
||||
'Password': {
|
||||
type: SchemaTypes.STRING,
|
||||
aliases: ['PWD'],
|
||||
validator(val) {
|
||||
return typeof val === 'string' && val.length <= 128;
|
||||
},
|
||||
},
|
||||
'Persist Security Info': {
|
||||
type: SchemaTypes.BOOL,
|
||||
aliases: ['PersistSecurityInfo'],
|
||||
default: false,
|
||||
},
|
||||
'PoolBlockingPeriod': {
|
||||
type: SchemaTypes.NUMBER,
|
||||
default: 0,
|
||||
coerce(val) {
|
||||
if (typeof val !== 'string') {
|
||||
return null;
|
||||
}
|
||||
switch (val.toLowerCase()) {
|
||||
case 'alwaysblock':
|
||||
return 1;
|
||||
case 'auto':
|
||||
return 0;
|
||||
case 'neverblock':
|
||||
return 2;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
},
|
||||
'Pooling': {
|
||||
type: SchemaTypes.BOOL,
|
||||
default: true,
|
||||
},
|
||||
'Replication': {
|
||||
type: SchemaTypes.BOOL,
|
||||
default: false,
|
||||
},
|
||||
'Transaction Binding': {
|
||||
type: SchemaTypes.STRING,
|
||||
allowedValues: ['Implicit Unbind', 'Explicit Unbind'],
|
||||
default: 'Implicit Unbind',
|
||||
},
|
||||
'TransparentNetworkIPResolution': {
|
||||
type: SchemaTypes.BOOL,
|
||||
default: true,
|
||||
},
|
||||
'TrustServerCertificate': {
|
||||
type: SchemaTypes.BOOL,
|
||||
default: false,
|
||||
},
|
||||
'Type System Version': {
|
||||
type: SchemaTypes.STRING,
|
||||
allowedValues: ['SQL Server 2012', 'SQL Server 2008', 'SQL Server 2005', 'Latest'],
|
||||
},
|
||||
'User ID': {
|
||||
type: SchemaTypes.STRING,
|
||||
aliases: ['UID'],
|
||||
validator(val) {
|
||||
return typeof val === 'string' && val.length <= 128;
|
||||
},
|
||||
},
|
||||
'User Instance': {
|
||||
type: SchemaTypes.BOOL,
|
||||
default: false,
|
||||
},
|
||||
'Workstation ID': {
|
||||
type: SchemaTypes.STRING,
|
||||
aliases: ['WSID'],
|
||||
validator(val) {
|
||||
return typeof val === 'string' && val.length <= 128;
|
||||
},
|
||||
},
|
||||
};
|
||||
function guessType(value) {
|
||||
if (value.trim() === '') {
|
||||
return SchemaTypes.STRING;
|
||||
}
|
||||
const asNum = parseInt(value, 10);
|
||||
if (!Number.isNaN(asNum) && asNum.toString() === value) {
|
||||
return SchemaTypes.NUMBER;
|
||||
}
|
||||
if (['true', 'false', 'yes', 'no'].includes(value.toLowerCase())) {
|
||||
return SchemaTypes.BOOL;
|
||||
}
|
||||
return SchemaTypes.STRING;
|
||||
}
|
||||
function coerce(value, type, coercer) {
|
||||
if (coercer) {
|
||||
const coerced = coercer(value);
|
||||
if (coerced !== null) {
|
||||
return coerced;
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case SchemaTypes.BOOL:
|
||||
if (['true', 'yes', '1'].includes(value.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
if (['false', 'no', '0'].includes(value.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
return value;
|
||||
case SchemaTypes.NUMBER:
|
||||
return parseInt(value, 10);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function validate(value, allowedValues, validator) {
|
||||
let valid = true;
|
||||
if (validator) {
|
||||
valid = validator(value);
|
||||
}
|
||||
if (valid) {
|
||||
valid = (allowedValues === null || allowedValues === void 0 ? void 0 : allowedValues.includes(value)) || false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
function parseSqlConnectionString(connectionString, canonicalProps = false, allowUnknown = false, strict = false, schema = exports.SCHEMA) {
|
||||
const flattenedSchema = Object.entries(schema).reduce((flattened, [key, item]) => {
|
||||
var _a;
|
||||
Object.assign(flattened, {
|
||||
[key.toLowerCase()]: item,
|
||||
});
|
||||
return ((_a = item.aliases) === null || _a === void 0 ? void 0 : _a.reduce((accum, alias) => {
|
||||
return Object.assign(accum, {
|
||||
[alias.toLowerCase()]: {
|
||||
...item,
|
||||
canonical: key.toLowerCase(),
|
||||
},
|
||||
});
|
||||
}, flattened)) || flattened;
|
||||
}, {});
|
||||
return Object.entries((0, connection_string_1.default)(connectionString)).reduce((config, [prop, value]) => {
|
||||
if (!Object.prototype.hasOwnProperty.call(flattenedSchema, prop)) {
|
||||
return Object.assign(config, {
|
||||
[prop]: coerce(value, guessType(value)),
|
||||
});
|
||||
}
|
||||
let coercedValue = coerce(value, flattenedSchema[prop].type, flattenedSchema[prop].coerce);
|
||||
if (strict && !validate(coercedValue, flattenedSchema[prop].allowedValues, flattenedSchema[prop].validator)) {
|
||||
coercedValue = flattenedSchema[prop].default;
|
||||
}
|
||||
const propName = canonicalProps ? flattenedSchema[prop].canonical || prop : prop;
|
||||
return Object.assign(config, {
|
||||
[propName]: coercedValue,
|
||||
});
|
||||
}, {});
|
||||
}
|
||||
exports.default = parseSqlConnectionString;
|
||||
//# sourceMappingURL=sql-connection-string.js.map
|
||||
1
node_modules/@tediousjs/connection-string/lib/parser/sql-connection-string.js.map
generated
vendored
Normal file
1
node_modules/@tediousjs/connection-string/lib/parser/sql-connection-string.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
60
node_modules/@tediousjs/connection-string/package.json
generated
vendored
Normal file
60
node_modules/@tediousjs/connection-string/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "@tediousjs/connection-string",
|
||||
"version": "0.5.0",
|
||||
"description": "SQL ConnectionString parser",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tediousjs/connection-string"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/tediousjs/connection-string/issues"
|
||||
},
|
||||
"homepage": "https://github.com/tediousjs/connection-string#readme",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"scripts": {
|
||||
"prepare": "tsc",
|
||||
"build": "tsc",
|
||||
"lint": "eslint .",
|
||||
"test": "mocha -r ts-node/register test/**/*",
|
||||
"test:coverage": "nyc --reporter=cobertura",
|
||||
"test:workflow": "npm run test --silent -- --forbid-only"
|
||||
},
|
||||
"keywords": [
|
||||
"mssql",
|
||||
"tsql",
|
||||
"connectionstring"
|
||||
],
|
||||
"author": "Dan Hensby <git@hens.by>",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"/lib/**"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^17.6.7",
|
||||
"@commitlint/config-conventional": "^17.6.7",
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
||||
"@semantic-release/changelog": "^6.0.3",
|
||||
"@semantic-release/commit-analyzer": "^10.0.1",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@semantic-release/github": "^9.0.4",
|
||||
"@semantic-release/npm": "^10.0.4",
|
||||
"@semantic-release/release-notes-generator": "^11.0.4",
|
||||
"@tsconfig/node10": "^1.0.8",
|
||||
"@types/chai": "^4.3.1",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@types/node": "^10.17.60",
|
||||
"@typescript-eslint/eslint-plugin": "^6.2.1",
|
||||
"@typescript-eslint/parser": "^6.2.1",
|
||||
"chai": "^4.2.0",
|
||||
"eslint": "^8.46.0",
|
||||
"mocha": "^10.2.0",
|
||||
"nyc": "^15.1.0",
|
||||
"semantic-release": "^21.0.7",
|
||||
"ts-node": "^10.7.0",
|
||||
"typescript": "^4.1.3"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user