Estructura inicial del proyecto

This commit is contained in:
2026-06-02 16:57:08 +00:00
commit 8b306b9afc
9864 changed files with 1435687 additions and 0 deletions

View 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): Record<string, string>;
//# sourceMappingURL=connection-string-parser.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"connection-string-parser.d.ts","sourceRoot":"","sources":["../../src/parser/connection-string-parser.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,CAAC,MAAM,EAAE,MAAM,CAAC,CAiHpI"}

View File

@ -0,0 +1,135 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = connectionStringParser;
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;
}
//# sourceMappingURL=connection-string-parser.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"connection-string-parser.js","sourceRoot":"","sources":["../../src/parser/connection-string-parser.ts"],"names":[],"mappings":";;AA8BA,yCAiHC;AArID,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,G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