Initial commit: n8n Strike API node
- Add Strike API credentials configuration - Implement Strike node with 9 resources (Account, Balance, Currency Exchange, Deposit, Invoice, Payment, Payment Method, Payout, Rates) - Add comprehensive operation descriptions for all resources - Include CLAUDE.MD documentation - Set up build configuration with TypeScript, ESLint, and Prettier 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
69
node_modules/jsonrepair/lib/esm/streaming/buffer/InputBuffer.js
generated
vendored
Normal file
69
node_modules/jsonrepair/lib/esm/streaming/buffer/InputBuffer.js
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
export function createInputBuffer() {
|
||||
let buffer = '';
|
||||
let offset = 0;
|
||||
let currentLength = 0;
|
||||
let closed = false;
|
||||
function ensure(index) {
|
||||
if (index < offset) {
|
||||
throw new Error(`${indexOutOfRangeMessage} (index: ${index}, offset: ${offset})`);
|
||||
}
|
||||
if (index >= currentLength) {
|
||||
if (!closed) {
|
||||
throw new Error(`${indexOutOfRangeMessage} (index: ${index})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
function push(chunk) {
|
||||
buffer += chunk;
|
||||
currentLength += chunk.length;
|
||||
}
|
||||
function flush(position) {
|
||||
if (position > currentLength) {
|
||||
return;
|
||||
}
|
||||
buffer = buffer.substring(position - offset);
|
||||
offset = position;
|
||||
}
|
||||
function charAt(index) {
|
||||
ensure(index);
|
||||
return buffer.charAt(index - offset);
|
||||
}
|
||||
function charCodeAt(index) {
|
||||
ensure(index);
|
||||
return buffer.charCodeAt(index - offset);
|
||||
}
|
||||
function substring(start, end) {
|
||||
ensure(end - 1); // -1 because end is excluded
|
||||
ensure(start);
|
||||
return buffer.slice(start - offset, end - offset);
|
||||
}
|
||||
function length() {
|
||||
if (!closed) {
|
||||
throw new Error('Cannot get length: input is not yet closed');
|
||||
}
|
||||
return currentLength;
|
||||
}
|
||||
function isEnd(index) {
|
||||
if (!closed) {
|
||||
ensure(index);
|
||||
}
|
||||
return index >= currentLength;
|
||||
}
|
||||
function close() {
|
||||
closed = true;
|
||||
}
|
||||
return {
|
||||
push,
|
||||
flush,
|
||||
charAt,
|
||||
charCodeAt,
|
||||
substring,
|
||||
length,
|
||||
currentLength: () => currentLength,
|
||||
currentBufferSize: () => buffer.length,
|
||||
isEnd,
|
||||
close
|
||||
};
|
||||
}
|
||||
const indexOutOfRangeMessage = 'Index out of range, please configure a larger buffer size';
|
||||
//# sourceMappingURL=InputBuffer.js.map
|
||||
1
node_modules/jsonrepair/lib/esm/streaming/buffer/InputBuffer.js.map
generated
vendored
Normal file
1
node_modules/jsonrepair/lib/esm/streaming/buffer/InputBuffer.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"InputBuffer.js","names":["createInputBuffer","buffer","offset","currentLength","closed","ensure","index","Error","indexOutOfRangeMessage","push","chunk","length","flush","position","substring","charAt","charCodeAt","start","end","slice","isEnd","close","currentBufferSize"],"sources":["../../../../src/streaming/buffer/InputBuffer.ts"],"sourcesContent":["export interface InputBuffer {\n push: (chunk: string) => void\n flush: (position: number) => void\n charAt: (index: number) => string\n charCodeAt: (index: number) => number\n substring: (start: number, end: number) => string\n length: () => number\n currentLength: () => number\n currentBufferSize: () => number\n isEnd: (index: number) => boolean\n close: () => void\n}\n\nexport function createInputBuffer(): InputBuffer {\n let buffer = ''\n let offset = 0\n let currentLength = 0\n let closed = false\n\n function ensure(index: number) {\n if (index < offset) {\n throw new Error(`${indexOutOfRangeMessage} (index: ${index}, offset: ${offset})`)\n }\n\n if (index >= currentLength) {\n if (!closed) {\n throw new Error(`${indexOutOfRangeMessage} (index: ${index})`)\n }\n }\n }\n\n function push(chunk: string) {\n buffer += chunk\n currentLength += chunk.length\n }\n\n function flush(position: number) {\n if (position > currentLength) {\n return\n }\n\n buffer = buffer.substring(position - offset)\n offset = position\n }\n\n function charAt(index: number): string {\n ensure(index)\n\n return buffer.charAt(index - offset)\n }\n\n function charCodeAt(index: number): number {\n ensure(index)\n\n return buffer.charCodeAt(index - offset)\n }\n\n function substring(start: number, end: number): string {\n ensure(end - 1) // -1 because end is excluded\n ensure(start)\n\n return buffer.slice(start - offset, end - offset)\n }\n\n function length(): number {\n if (!closed) {\n throw new Error('Cannot get length: input is not yet closed')\n }\n\n return currentLength\n }\n\n function isEnd(index: number): boolean {\n if (!closed) {\n ensure(index)\n }\n\n return index >= currentLength\n }\n\n function close() {\n closed = true\n }\n\n return {\n push,\n flush,\n charAt,\n charCodeAt,\n substring,\n length,\n currentLength: () => currentLength,\n currentBufferSize: () => buffer.length,\n isEnd,\n close\n }\n}\n\nconst indexOutOfRangeMessage = 'Index out of range, please configure a larger buffer size'\n"],"mappings":"AAaA,OAAO,SAASA,iBAAiBA,CAAA,EAAgB;EAC/C,IAAIC,MAAM,GAAG,EAAE;EACf,IAAIC,MAAM,GAAG,CAAC;EACd,IAAIC,aAAa,GAAG,CAAC;EACrB,IAAIC,MAAM,GAAG,KAAK;EAElB,SAASC,MAAMA,CAACC,KAAa,EAAE;IAC7B,IAAIA,KAAK,GAAGJ,MAAM,EAAE;MAClB,MAAM,IAAIK,KAAK,CAAC,GAAGC,sBAAsB,YAAYF,KAAK,aAAaJ,MAAM,GAAG,CAAC;IACnF;IAEA,IAAII,KAAK,IAAIH,aAAa,EAAE;MAC1B,IAAI,CAACC,MAAM,EAAE;QACX,MAAM,IAAIG,KAAK,CAAC,GAAGC,sBAAsB,YAAYF,KAAK,GAAG,CAAC;MAChE;IACF;EACF;EAEA,SAASG,IAAIA,CAACC,KAAa,EAAE;IAC3BT,MAAM,IAAIS,KAAK;IACfP,aAAa,IAAIO,KAAK,CAACC,MAAM;EAC/B;EAEA,SAASC,KAAKA,CAACC,QAAgB,EAAE;IAC/B,IAAIA,QAAQ,GAAGV,aAAa,EAAE;MAC5B;IACF;IAEAF,MAAM,GAAGA,MAAM,CAACa,SAAS,CAACD,QAAQ,GAAGX,MAAM,CAAC;IAC5CA,MAAM,GAAGW,QAAQ;EACnB;EAEA,SAASE,MAAMA,CAACT,KAAa,EAAU;IACrCD,MAAM,CAACC,KAAK,CAAC;IAEb,OAAOL,MAAM,CAACc,MAAM,CAACT,KAAK,GAAGJ,MAAM,CAAC;EACtC;EAEA,SAASc,UAAUA,CAACV,KAAa,EAAU;IACzCD,MAAM,CAACC,KAAK,CAAC;IAEb,OAAOL,MAAM,CAACe,UAAU,CAACV,KAAK,GAAGJ,MAAM,CAAC;EAC1C;EAEA,SAASY,SAASA,CAACG,KAAa,EAAEC,GAAW,EAAU;IACrDb,MAAM,CAACa,GAAG,GAAG,CAAC,CAAC,EAAC;IAChBb,MAAM,CAACY,KAAK,CAAC;IAEb,OAAOhB,MAAM,CAACkB,KAAK,CAACF,KAAK,GAAGf,MAAM,EAAEgB,GAAG,GAAGhB,MAAM,CAAC;EACnD;EAEA,SAASS,MAAMA,CAAA,EAAW;IACxB,IAAI,CAACP,MAAM,EAAE;MACX,MAAM,IAAIG,KAAK,CAAC,4CAA4C,CAAC;IAC/D;IAEA,OAAOJ,aAAa;EACtB;EAEA,SAASiB,KAAKA,CAACd,KAAa,EAAW;IACrC,IAAI,CAACF,MAAM,EAAE;MACXC,MAAM,CAACC,KAAK,CAAC;IACf;IAEA,OAAOA,KAAK,IAAIH,aAAa;EAC/B;EAEA,SAASkB,KAAKA,CAAA,EAAG;IACfjB,MAAM,GAAG,IAAI;EACf;EAEA,OAAO;IACLK,IAAI;IACJG,KAAK;IACLG,MAAM;IACNC,UAAU;IACVF,SAAS;IACTH,MAAM;IACNR,aAAa,EAAEA,CAAA,KAAMA,aAAa;IAClCmB,iBAAiB,EAAEA,CAAA,KAAMrB,MAAM,CAACU,MAAM;IACtCS,KAAK;IACLC;EACF,CAAC;AACH;AAEA,MAAMb,sBAAsB,GAAG,2DAA2D","ignoreList":[]}
|
||||
111
node_modules/jsonrepair/lib/esm/streaming/buffer/OutputBuffer.js
generated
vendored
Normal file
111
node_modules/jsonrepair/lib/esm/streaming/buffer/OutputBuffer.js
generated
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
import { isWhitespace } from '../../utils/stringUtils.js';
|
||||
export function createOutputBuffer(_ref) {
|
||||
let {
|
||||
write,
|
||||
chunkSize,
|
||||
bufferSize
|
||||
} = _ref;
|
||||
let buffer = '';
|
||||
let offset = 0;
|
||||
function flushChunks() {
|
||||
let minSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : bufferSize;
|
||||
while (buffer.length >= minSize + chunkSize) {
|
||||
const chunk = buffer.substring(0, chunkSize);
|
||||
write(chunk);
|
||||
offset += chunkSize;
|
||||
buffer = buffer.substring(chunkSize);
|
||||
}
|
||||
}
|
||||
function flush() {
|
||||
flushChunks(0);
|
||||
if (buffer.length > 0) {
|
||||
write(buffer);
|
||||
offset += buffer.length;
|
||||
buffer = '';
|
||||
}
|
||||
}
|
||||
function push(text) {
|
||||
buffer += text;
|
||||
flushChunks();
|
||||
}
|
||||
function unshift(text) {
|
||||
if (offset > 0) {
|
||||
throw new Error(`Cannot unshift: ${flushedMessage}`);
|
||||
}
|
||||
buffer = text + buffer;
|
||||
flushChunks();
|
||||
}
|
||||
function remove(start, end) {
|
||||
if (start < offset) {
|
||||
throw new Error(`Cannot remove: ${flushedMessage}`);
|
||||
}
|
||||
if (end !== undefined) {
|
||||
buffer = buffer.substring(0, start - offset) + buffer.substring(end - offset);
|
||||
} else {
|
||||
buffer = buffer.substring(0, start - offset);
|
||||
}
|
||||
}
|
||||
function insertAt(index, text) {
|
||||
if (index < offset) {
|
||||
throw new Error(`Cannot insert: ${flushedMessage}`);
|
||||
}
|
||||
buffer = buffer.substring(0, index - offset) + text + buffer.substring(index - offset);
|
||||
}
|
||||
function length() {
|
||||
return offset + buffer.length;
|
||||
}
|
||||
function stripLastOccurrence(textToStrip) {
|
||||
let stripRemainingText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
const bufferIndex = buffer.lastIndexOf(textToStrip);
|
||||
if (bufferIndex !== -1) {
|
||||
if (stripRemainingText) {
|
||||
buffer = buffer.substring(0, bufferIndex);
|
||||
} else {
|
||||
buffer = buffer.substring(0, bufferIndex) + buffer.substring(bufferIndex + textToStrip.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
function insertBeforeLastWhitespace(textToInsert) {
|
||||
let bufferIndex = buffer.length; // index relative to the start of the buffer, not taking `offset` into account
|
||||
|
||||
if (!isWhitespace(buffer, bufferIndex - 1)) {
|
||||
// no trailing whitespaces
|
||||
push(textToInsert);
|
||||
return;
|
||||
}
|
||||
while (isWhitespace(buffer, bufferIndex - 1)) {
|
||||
bufferIndex--;
|
||||
}
|
||||
if (bufferIndex <= 0) {
|
||||
throw new Error(`Cannot insert: ${flushedMessage}`);
|
||||
}
|
||||
buffer = buffer.substring(0, bufferIndex) + textToInsert + buffer.substring(bufferIndex);
|
||||
flushChunks();
|
||||
}
|
||||
function endsWithIgnoringWhitespace(char) {
|
||||
let i = buffer.length - 1;
|
||||
while (i > 0) {
|
||||
if (char === buffer.charAt(i)) {
|
||||
return true;
|
||||
}
|
||||
if (!isWhitespace(buffer, i)) {
|
||||
return false;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return {
|
||||
push,
|
||||
unshift,
|
||||
remove,
|
||||
insertAt,
|
||||
length,
|
||||
flush,
|
||||
stripLastOccurrence,
|
||||
insertBeforeLastWhitespace,
|
||||
endsWithIgnoringWhitespace
|
||||
};
|
||||
}
|
||||
const flushedMessage = 'start of the output is already flushed from the buffer';
|
||||
//# sourceMappingURL=OutputBuffer.js.map
|
||||
1
node_modules/jsonrepair/lib/esm/streaming/buffer/OutputBuffer.js.map
generated
vendored
Normal file
1
node_modules/jsonrepair/lib/esm/streaming/buffer/OutputBuffer.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
818
node_modules/jsonrepair/lib/esm/streaming/core.js
generated
vendored
Normal file
818
node_modules/jsonrepair/lib/esm/streaming/core.js
generated
vendored
Normal file
@ -0,0 +1,818 @@
|
||||
import { JSONRepairError } from '../utils/JSONRepairError.js';
|
||||
import { isControlCharacter, isDelimiter, isDigit, isDoubleQuote, isDoubleQuoteLike, isFunctionNameChar, isFunctionNameCharStart, isHex, isQuote, isSingleQuote, isSingleQuoteLike, isSpecialWhitespace, isStartOfValue, isUnquotedStringDelimiter, isValidStringCharacter, isWhitespace, isWhitespaceExceptNewline, regexUrlChar, regexUrlStart } from '../utils/stringUtils.js';
|
||||
import { createInputBuffer } from './buffer/InputBuffer.js';
|
||||
import { createOutputBuffer } from './buffer/OutputBuffer.js';
|
||||
import { Caret, createStack, StackType } from './stack.js';
|
||||
const controlCharacters = {
|
||||
'\b': '\\b',
|
||||
'\f': '\\f',
|
||||
'\n': '\\n',
|
||||
'\r': '\\r',
|
||||
'\t': '\\t'
|
||||
};
|
||||
|
||||
// map with all escape characters
|
||||
const escapeCharacters = {
|
||||
'"': '"',
|
||||
'\\': '\\',
|
||||
'/': '/',
|
||||
b: '\b',
|
||||
f: '\f',
|
||||
n: '\n',
|
||||
r: '\r',
|
||||
t: '\t'
|
||||
// note that \u is handled separately in parseString()
|
||||
};
|
||||
export function jsonrepairCore(_ref) {
|
||||
let {
|
||||
onData,
|
||||
bufferSize = 65536,
|
||||
chunkSize = 65536
|
||||
} = _ref;
|
||||
const input = createInputBuffer();
|
||||
const output = createOutputBuffer({
|
||||
write: onData,
|
||||
bufferSize,
|
||||
chunkSize
|
||||
});
|
||||
let i = 0;
|
||||
let iFlushed = 0;
|
||||
const stack = createStack();
|
||||
function flushInputBuffer() {
|
||||
while (iFlushed < i - bufferSize - chunkSize) {
|
||||
iFlushed += chunkSize;
|
||||
input.flush(iFlushed);
|
||||
}
|
||||
}
|
||||
function transform(chunk) {
|
||||
input.push(chunk);
|
||||
while (i < input.currentLength() - bufferSize && parse()) {
|
||||
// loop until there is nothing more to process
|
||||
}
|
||||
flushInputBuffer();
|
||||
}
|
||||
function flush() {
|
||||
input.close();
|
||||
while (parse()) {
|
||||
// loop until there is nothing more to process
|
||||
}
|
||||
output.flush();
|
||||
}
|
||||
function parse() {
|
||||
parseWhitespaceAndSkipComments();
|
||||
switch (stack.type) {
|
||||
case StackType.object:
|
||||
{
|
||||
switch (stack.caret) {
|
||||
case Caret.beforeKey:
|
||||
return skipEllipsis() || parseObjectKey() || parseUnexpectedColon() || parseRepairTrailingComma() || parseRepairObjectEndOrComma();
|
||||
case Caret.beforeValue:
|
||||
return parseValue() || parseRepairMissingObjectValue();
|
||||
case Caret.afterValue:
|
||||
return parseObjectComma() || parseObjectEnd() || parseRepairObjectEndOrComma();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case StackType.array:
|
||||
{
|
||||
switch (stack.caret) {
|
||||
case Caret.beforeValue:
|
||||
return skipEllipsis() || parseValue() || parseRepairTrailingComma() || parseRepairArrayEnd();
|
||||
case Caret.afterValue:
|
||||
return parseArrayComma() || parseArrayEnd() || parseRepairMissingComma() || parseRepairArrayEnd();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case StackType.ndJson:
|
||||
{
|
||||
switch (stack.caret) {
|
||||
case Caret.beforeValue:
|
||||
return parseValue() || parseRepairTrailingComma();
|
||||
case Caret.afterValue:
|
||||
return parseArrayComma() || parseRepairMissingComma() || parseRepairNdJsonEnd();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case StackType.functionCall:
|
||||
{
|
||||
switch (stack.caret) {
|
||||
case Caret.beforeValue:
|
||||
return parseValue();
|
||||
case Caret.afterValue:
|
||||
return parseFunctionCallEnd();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case StackType.root:
|
||||
{
|
||||
switch (stack.caret) {
|
||||
case Caret.beforeValue:
|
||||
return parseRootStart();
|
||||
case Caret.afterValue:
|
||||
return parseRootEnd();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function parseValue() {
|
||||
return parseObjectStart() || parseArrayStart() || parseString() || parseNumber() || parseKeywords() || parseRepairUnquotedString() || parseRepairRegex();
|
||||
}
|
||||
function parseObjectStart() {
|
||||
if (parseCharacter('{')) {
|
||||
parseWhitespaceAndSkipComments();
|
||||
skipEllipsis();
|
||||
if (skipCharacter(',')) {
|
||||
parseWhitespaceAndSkipComments();
|
||||
}
|
||||
if (parseCharacter('}')) {
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
return stack.push(StackType.object, Caret.beforeKey);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseArrayStart() {
|
||||
if (parseCharacter('[')) {
|
||||
parseWhitespaceAndSkipComments();
|
||||
skipEllipsis();
|
||||
if (skipCharacter(',')) {
|
||||
parseWhitespaceAndSkipComments();
|
||||
}
|
||||
if (parseCharacter(']')) {
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
return stack.push(StackType.array, Caret.beforeValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseRepairUnquotedString() {
|
||||
let j = i;
|
||||
if (isFunctionNameCharStart(input.charAt(j))) {
|
||||
while (!input.isEnd(j) && isFunctionNameChar(input.charAt(j))) {
|
||||
j++;
|
||||
}
|
||||
let k = j;
|
||||
while (isWhitespace(input, k)) {
|
||||
k++;
|
||||
}
|
||||
if (input.charAt(k) === '(') {
|
||||
// repair a MongoDB function call like NumberLong("2")
|
||||
// repair a JSONP function call like callback({...});
|
||||
k++;
|
||||
i = k;
|
||||
return stack.push(StackType.functionCall, Caret.beforeValue);
|
||||
}
|
||||
}
|
||||
j = findNextDelimiter(false, j);
|
||||
if (j !== null) {
|
||||
// test start of an url like "https://..." (this would be parsed as a comment)
|
||||
if (input.charAt(j - 1) === ':' && regexUrlStart.test(input.substring(i, j + 2))) {
|
||||
while (!input.isEnd(j) && regexUrlChar.test(input.charAt(j))) {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
const symbol = input.substring(i, j);
|
||||
i = j;
|
||||
output.push(symbol === 'undefined' ? 'null' : JSON.stringify(symbol));
|
||||
if (input.charAt(i) === '"') {
|
||||
// we had a missing start quote, but now we encountered the end quote, so we can skip that one
|
||||
i++;
|
||||
}
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseRepairRegex() {
|
||||
if (input.charAt(i) === '/') {
|
||||
const start = i;
|
||||
i++;
|
||||
while (!input.isEnd(i) && (input.charAt(i) !== '/' || input.charAt(i - 1) === '\\')) {
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
output.push(`"${input.substring(start, i)}"`);
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
}
|
||||
function parseRepairMissingObjectValue() {
|
||||
// repair missing object value
|
||||
output.push('null');
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
function parseRepairTrailingComma() {
|
||||
// repair trailing comma
|
||||
if (output.endsWithIgnoringWhitespace(',')) {
|
||||
output.stripLastOccurrence(',');
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseUnexpectedColon() {
|
||||
if (input.charAt(i) === ':') {
|
||||
throwObjectKeyExpected();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseUnexpectedEnd() {
|
||||
if (input.isEnd(i)) {
|
||||
throwUnexpectedEnd();
|
||||
} else {
|
||||
throwUnexpectedCharacter();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseObjectKey() {
|
||||
const parsedKey = parseString() || parseUnquotedKey();
|
||||
if (parsedKey) {
|
||||
parseWhitespaceAndSkipComments();
|
||||
if (parseCharacter(':')) {
|
||||
// expect a value after the :
|
||||
return stack.update(Caret.beforeValue);
|
||||
}
|
||||
const truncatedText = input.isEnd(i);
|
||||
if (isStartOfValue(input.charAt(i)) || truncatedText) {
|
||||
// repair missing colon
|
||||
output.insertBeforeLastWhitespace(':');
|
||||
return stack.update(Caret.beforeValue);
|
||||
}
|
||||
throwColonExpected();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseObjectComma() {
|
||||
if (parseCharacter(',')) {
|
||||
return stack.update(Caret.beforeKey);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseObjectEnd() {
|
||||
if (parseCharacter('}')) {
|
||||
return stack.pop();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseRepairObjectEndOrComma() {
|
||||
// repair missing object end and trailing comma
|
||||
if (input.charAt(i) === '{') {
|
||||
output.stripLastOccurrence(',');
|
||||
output.insertBeforeLastWhitespace('}');
|
||||
return stack.pop();
|
||||
}
|
||||
|
||||
// repair missing comma
|
||||
if (!input.isEnd(i) && isStartOfValue(input.charAt(i))) {
|
||||
output.insertBeforeLastWhitespace(',');
|
||||
return stack.update(Caret.beforeKey);
|
||||
}
|
||||
|
||||
// repair missing closing brace
|
||||
output.insertBeforeLastWhitespace('}');
|
||||
return stack.pop();
|
||||
}
|
||||
function parseArrayComma() {
|
||||
if (parseCharacter(',')) {
|
||||
return stack.update(Caret.beforeValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseArrayEnd() {
|
||||
if (parseCharacter(']')) {
|
||||
return stack.pop();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseRepairMissingComma() {
|
||||
// repair missing comma
|
||||
if (!input.isEnd(i) && isStartOfValue(input.charAt(i))) {
|
||||
output.insertBeforeLastWhitespace(',');
|
||||
return stack.update(Caret.beforeValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseRepairArrayEnd() {
|
||||
// repair missing closing bracket
|
||||
output.insertBeforeLastWhitespace(']');
|
||||
return stack.pop();
|
||||
}
|
||||
function parseRepairNdJsonEnd() {
|
||||
if (input.isEnd(i)) {
|
||||
output.push('\n]');
|
||||
return stack.pop();
|
||||
}
|
||||
throwUnexpectedEnd();
|
||||
return false; // just to make TS happy
|
||||
}
|
||||
function parseFunctionCallEnd() {
|
||||
if (skipCharacter(')')) {
|
||||
skipCharacter(';');
|
||||
}
|
||||
return stack.pop();
|
||||
}
|
||||
function parseRootStart() {
|
||||
parseMarkdownCodeBlock(['```', '[```', '{```']);
|
||||
return parseValue() || parseUnexpectedEnd();
|
||||
}
|
||||
function parseRootEnd() {
|
||||
parseMarkdownCodeBlock(['```', '```]', '```}']);
|
||||
const parsedComma = parseCharacter(',');
|
||||
parseWhitespaceAndSkipComments();
|
||||
if (isStartOfValue(input.charAt(i)) && (output.endsWithIgnoringWhitespace(',') || output.endsWithIgnoringWhitespace('\n'))) {
|
||||
// start of a new value after end of the root level object: looks like
|
||||
// newline delimited JSON -> turn into a root level array
|
||||
if (!parsedComma) {
|
||||
// repair missing comma
|
||||
output.insertBeforeLastWhitespace(',');
|
||||
}
|
||||
output.unshift('[\n');
|
||||
return stack.push(StackType.ndJson, Caret.beforeValue);
|
||||
}
|
||||
if (parsedComma) {
|
||||
// repair: remove trailing comma
|
||||
output.stripLastOccurrence(',');
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
|
||||
// repair redundant end braces and brackets
|
||||
while (input.charAt(i) === '}' || input.charAt(i) === ']') {
|
||||
i++;
|
||||
parseWhitespaceAndSkipComments();
|
||||
}
|
||||
if (!input.isEnd(i)) {
|
||||
throwUnexpectedCharacter();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseWhitespaceAndSkipComments() {
|
||||
let skipNewline = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
||||
const start = i;
|
||||
let changed = parseWhitespace(skipNewline);
|
||||
do {
|
||||
changed = parseComment();
|
||||
if (changed) {
|
||||
changed = parseWhitespace(skipNewline);
|
||||
}
|
||||
} while (changed);
|
||||
return i > start;
|
||||
}
|
||||
function parseWhitespace(skipNewline) {
|
||||
const _isWhiteSpace = skipNewline ? isWhitespace : isWhitespaceExceptNewline;
|
||||
let whitespace = '';
|
||||
while (true) {
|
||||
if (_isWhiteSpace(input, i)) {
|
||||
whitespace += input.charAt(i);
|
||||
i++;
|
||||
} else if (isSpecialWhitespace(input, i)) {
|
||||
// repair special whitespace
|
||||
whitespace += ' ';
|
||||
i++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (whitespace.length > 0) {
|
||||
output.push(whitespace);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseComment() {
|
||||
// find a block comment '/* ... */'
|
||||
if (input.charAt(i) === '/' && input.charAt(i + 1) === '*') {
|
||||
// repair block comment by skipping it
|
||||
while (!input.isEnd(i) && !atEndOfBlockComment(i)) {
|
||||
i++;
|
||||
}
|
||||
i += 2;
|
||||
return true;
|
||||
}
|
||||
|
||||
// find a line comment '// ...'
|
||||
if (input.charAt(i) === '/' && input.charAt(i + 1) === '/') {
|
||||
// repair line comment by skipping it
|
||||
while (!input.isEnd(i) && input.charAt(i) !== '\n') {
|
||||
i++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseMarkdownCodeBlock(blocks) {
|
||||
// find and skip over a Markdown fenced code block:
|
||||
// ``` ... ```
|
||||
// or
|
||||
// ```json ... ```
|
||||
if (skipMarkdownCodeBlock(blocks)) {
|
||||
if (isFunctionNameCharStart(input.charAt(i))) {
|
||||
// strip the optional language specifier like "json"
|
||||
while (!input.isEnd(i) && isFunctionNameChar(input.charAt(i))) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
parseWhitespaceAndSkipComments();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function skipMarkdownCodeBlock(blocks) {
|
||||
for (const block of blocks) {
|
||||
const end = i + block.length;
|
||||
if (input.substring(i, end) === block) {
|
||||
i = end;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseCharacter(char) {
|
||||
if (input.charAt(i) === char) {
|
||||
output.push(input.charAt(i));
|
||||
i++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function skipCharacter(char) {
|
||||
if (input.charAt(i) === char) {
|
||||
i++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function skipEscapeCharacter() {
|
||||
return skipCharacter('\\');
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip ellipsis like "[1,2,3,...]" or "[1,2,3,...,9]" or "[...,7,8,9]"
|
||||
* or a similar construct in objects.
|
||||
*/
|
||||
function skipEllipsis() {
|
||||
parseWhitespaceAndSkipComments();
|
||||
if (input.charAt(i) === '.' && input.charAt(i + 1) === '.' && input.charAt(i + 2) === '.') {
|
||||
// repair: remove the ellipsis (three dots) and optionally a comma
|
||||
i += 3;
|
||||
parseWhitespaceAndSkipComments();
|
||||
skipCharacter(',');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a string enclosed by double quotes "...". Can contain escaped quotes
|
||||
* Repair strings enclosed in single quotes or special quotes
|
||||
* Repair an escaped string
|
||||
*
|
||||
* The function can run in two stages:
|
||||
* - First, it assumes the string has a valid end quote
|
||||
* - If it turns out that the string does not have a valid end quote followed
|
||||
* by a delimiter (which should be the case), the function runs again in a
|
||||
* more conservative way, stopping the string at the first next delimiter
|
||||
* and fixing the string by inserting a quote there, or stopping at a
|
||||
* stop index detected in the first iteration.
|
||||
*/
|
||||
function parseString() {
|
||||
let stopAtDelimiter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
||||
let stopAtIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
|
||||
let skipEscapeChars = input.charAt(i) === '\\';
|
||||
if (skipEscapeChars) {
|
||||
// repair: remove the first escape character
|
||||
i++;
|
||||
skipEscapeChars = true;
|
||||
}
|
||||
if (isQuote(input.charAt(i))) {
|
||||
// double quotes are correct JSON,
|
||||
// single quotes come from JavaScript for example, we assume it will have a correct single end quote too
|
||||
// otherwise, we will match any double-quote-like start with a double-quote-like end,
|
||||
// or any single-quote-like start with a single-quote-like end
|
||||
const isEndQuote = isDoubleQuote(input.charAt(i)) ? isDoubleQuote : isSingleQuote(input.charAt(i)) ? isSingleQuote : isSingleQuoteLike(input.charAt(i)) ? isSingleQuoteLike : isDoubleQuoteLike;
|
||||
const iBefore = i;
|
||||
const oBefore = output.length();
|
||||
output.push('"');
|
||||
i++;
|
||||
while (true) {
|
||||
if (input.isEnd(i)) {
|
||||
// end of text, we have a missing quote somewhere
|
||||
|
||||
const iPrev = prevNonWhitespaceIndex(i - 1);
|
||||
if (!stopAtDelimiter && isDelimiter(input.charAt(iPrev))) {
|
||||
// if the text ends with a delimiter, like ["hello],
|
||||
// so the missing end quote should be inserted before this delimiter
|
||||
// retry parsing the string, stopping at the first next delimiter
|
||||
i = iBefore;
|
||||
output.remove(oBefore);
|
||||
return parseString(true);
|
||||
}
|
||||
|
||||
// repair missing quote
|
||||
output.insertBeforeLastWhitespace('"');
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
if (i === stopAtIndex) {
|
||||
// use the stop index detected in the first iteration, and repair end quote
|
||||
output.insertBeforeLastWhitespace('"');
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
if (isEndQuote(input.charAt(i))) {
|
||||
// end quote
|
||||
// let us check what is before and after the quote to verify whether this is a legit end quote
|
||||
const iQuote = i;
|
||||
const oQuote = output.length();
|
||||
output.push('"');
|
||||
i++;
|
||||
parseWhitespaceAndSkipComments(false);
|
||||
if (stopAtDelimiter || input.isEnd(i) || isDelimiter(input.charAt(i)) || isQuote(input.charAt(i)) || isDigit(input.charAt(i))) {
|
||||
// The quote is followed by the end of the text, a delimiter, or a next value
|
||||
// so the quote is indeed the end of the string
|
||||
parseConcatenatedString();
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
const iPrevChar = prevNonWhitespaceIndex(iQuote - 1);
|
||||
const prevChar = input.charAt(iPrevChar);
|
||||
if (prevChar === ',') {
|
||||
// A comma followed by a quote, like '{"a":"b,c,"d":"e"}'.
|
||||
// We assume that the quote is a start quote, and that the end quote
|
||||
// should have been located right before the comma but is missing.
|
||||
i = iBefore;
|
||||
output.remove(oBefore);
|
||||
return parseString(false, iPrevChar);
|
||||
}
|
||||
if (isDelimiter(prevChar)) {
|
||||
// This is not the right end quote: it is preceded by a delimiter,
|
||||
// and NOT followed by a delimiter. So, there is an end quote missing
|
||||
// parse the string again and then stop at the first next delimiter
|
||||
i = iBefore;
|
||||
output.remove(oBefore);
|
||||
return parseString(true);
|
||||
}
|
||||
|
||||
// revert to right after the quote but before any whitespace, and continue parsing the string
|
||||
output.remove(oQuote + 1);
|
||||
i = iQuote + 1;
|
||||
|
||||
// repair unescaped quote
|
||||
output.insertAt(oQuote, '\\');
|
||||
} else if (stopAtDelimiter && isUnquotedStringDelimiter(input.charAt(i))) {
|
||||
// we're in the mode to stop the string at the first delimiter
|
||||
// because there is an end quote missing
|
||||
|
||||
// test start of an url like "https://..." (this would be parsed as a comment)
|
||||
if (input.charAt(i - 1) === ':' && regexUrlStart.test(input.substring(iBefore + 1, i + 2))) {
|
||||
while (!input.isEnd(i) && regexUrlChar.test(input.charAt(i))) {
|
||||
output.push(input.charAt(i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// repair missing quote
|
||||
output.insertBeforeLastWhitespace('"');
|
||||
parseConcatenatedString();
|
||||
return stack.update(Caret.afterValue);
|
||||
} else if (input.charAt(i) === '\\') {
|
||||
// handle escaped content like \n or \u2605
|
||||
const char = input.charAt(i + 1);
|
||||
const escapeChar = escapeCharacters[char];
|
||||
if (escapeChar !== undefined) {
|
||||
output.push(input.substring(i, i + 2));
|
||||
i += 2;
|
||||
} else if (char === 'u') {
|
||||
let j = 2;
|
||||
while (j < 6 && isHex(input.charAt(i + j))) {
|
||||
j++;
|
||||
}
|
||||
if (j === 6) {
|
||||
output.push(input.substring(i, i + 6));
|
||||
i += 6;
|
||||
} else if (input.isEnd(i + j)) {
|
||||
// repair invalid or truncated unicode char at the end of the text
|
||||
// by removing the unicode char and ending the string here
|
||||
i += j;
|
||||
} else {
|
||||
throwInvalidUnicodeCharacter();
|
||||
}
|
||||
} else {
|
||||
// repair invalid escape character: remove it
|
||||
output.push(char);
|
||||
i += 2;
|
||||
}
|
||||
} else {
|
||||
// handle regular characters
|
||||
const char = input.charAt(i);
|
||||
if (char === '"' && input.charAt(i - 1) !== '\\') {
|
||||
// repair unescaped double quote
|
||||
output.push(`\\${char}`);
|
||||
i++;
|
||||
} else if (isControlCharacter(char)) {
|
||||
// unescaped control character
|
||||
output.push(controlCharacters[char]);
|
||||
i++;
|
||||
} else {
|
||||
if (!isValidStringCharacter(char)) {
|
||||
throwInvalidCharacter(char);
|
||||
}
|
||||
output.push(char);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (skipEscapeChars) {
|
||||
// repair: skipped escape character (nothing to do)
|
||||
skipEscapeCharacter();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repair concatenated strings like "hello" + "world", change this into "helloworld"
|
||||
*/
|
||||
function parseConcatenatedString() {
|
||||
let parsed = false;
|
||||
parseWhitespaceAndSkipComments();
|
||||
while (input.charAt(i) === '+') {
|
||||
parsed = true;
|
||||
i++;
|
||||
parseWhitespaceAndSkipComments();
|
||||
|
||||
// repair: remove the end quote of the first string
|
||||
output.stripLastOccurrence('"', true);
|
||||
const start = output.length();
|
||||
const parsedStr = parseString();
|
||||
if (parsedStr) {
|
||||
// repair: remove the start quote of the second string
|
||||
output.remove(start, start + 1);
|
||||
} else {
|
||||
// repair: remove the + because it is not followed by a string
|
||||
output.insertBeforeLastWhitespace('"');
|
||||
}
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a number like 2.4 or 2.4e6
|
||||
*/
|
||||
function parseNumber() {
|
||||
const start = i;
|
||||
if (input.charAt(i) === '-') {
|
||||
i++;
|
||||
if (atEndOfNumber()) {
|
||||
repairNumberEndingWithNumericSymbol(start);
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
if (!isDigit(input.charAt(i))) {
|
||||
i = start;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Note that in JSON leading zeros like "00789" are not allowed.
|
||||
// We will allow all leading zeros here though and at the end of parseNumber
|
||||
// check against trailing zeros and repair that if needed.
|
||||
// Leading zeros can have meaning, so we should not clear them.
|
||||
while (isDigit(input.charAt(i))) {
|
||||
i++;
|
||||
}
|
||||
if (input.charAt(i) === '.') {
|
||||
i++;
|
||||
if (atEndOfNumber()) {
|
||||
repairNumberEndingWithNumericSymbol(start);
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
if (!isDigit(input.charAt(i))) {
|
||||
i = start;
|
||||
return false;
|
||||
}
|
||||
while (isDigit(input.charAt(i))) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (input.charAt(i) === 'e' || input.charAt(i) === 'E') {
|
||||
i++;
|
||||
if (input.charAt(i) === '-' || input.charAt(i) === '+') {
|
||||
i++;
|
||||
}
|
||||
if (atEndOfNumber()) {
|
||||
repairNumberEndingWithNumericSymbol(start);
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
if (!isDigit(input.charAt(i))) {
|
||||
i = start;
|
||||
return false;
|
||||
}
|
||||
while (isDigit(input.charAt(i))) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// if we're not at the end of the number by this point, allow this to be parsed as another type
|
||||
if (!atEndOfNumber()) {
|
||||
i = start;
|
||||
return false;
|
||||
}
|
||||
if (i > start) {
|
||||
// repair a number with leading zeros like "00789"
|
||||
const num = input.substring(start, i);
|
||||
const hasInvalidLeadingZero = /^0\d/.test(num);
|
||||
output.push(hasInvalidLeadingZero ? `"${num}"` : num);
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse keywords true, false, null
|
||||
* Repair Python keywords True, False, None
|
||||
*/
|
||||
function parseKeywords() {
|
||||
return parseKeyword('true', 'true') || parseKeyword('false', 'false') || parseKeyword('null', 'null') ||
|
||||
// repair Python keywords True, False, None
|
||||
parseKeyword('True', 'true') || parseKeyword('False', 'false') || parseKeyword('None', 'null');
|
||||
}
|
||||
function parseKeyword(name, value) {
|
||||
if (input.substring(i, i + name.length) === name) {
|
||||
output.push(value);
|
||||
i += name.length;
|
||||
return stack.update(Caret.afterValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseUnquotedKey() {
|
||||
let end = findNextDelimiter(true, i);
|
||||
if (end !== null) {
|
||||
// first, go back to prevent getting trailing whitespaces in the string
|
||||
while (isWhitespace(input, end - 1) && end > i) {
|
||||
end--;
|
||||
}
|
||||
const symbol = input.substring(i, end);
|
||||
output.push(JSON.stringify(symbol));
|
||||
i = end;
|
||||
if (input.charAt(i) === '"') {
|
||||
// we had a missing start quote, but now we encountered the end quote, so we can skip that one
|
||||
i++;
|
||||
}
|
||||
return stack.update(Caret.afterValue); // we do not have a state Caret.afterKey, therefore we use afterValue here
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function findNextDelimiter(isKey, start) {
|
||||
// note that the symbol can end with whitespaces: we stop at the next delimiter
|
||||
// also, note that we allow strings to contain a slash / in order to support repairing regular expressions
|
||||
let j = start;
|
||||
while (!input.isEnd(j) && !isUnquotedStringDelimiter(input.charAt(j)) && !isQuote(input.charAt(j)) && (!isKey || input.charAt(j) !== ':')) {
|
||||
j++;
|
||||
}
|
||||
return j > i ? j : null;
|
||||
}
|
||||
function prevNonWhitespaceIndex(start) {
|
||||
let prev = start;
|
||||
while (prev > 0 && isWhitespace(input, prev)) {
|
||||
prev--;
|
||||
}
|
||||
return prev;
|
||||
}
|
||||
function atEndOfNumber() {
|
||||
return input.isEnd(i) || isDelimiter(input.charAt(i)) || isWhitespace(input, i);
|
||||
}
|
||||
function repairNumberEndingWithNumericSymbol(start) {
|
||||
// repair numbers cut off at the end
|
||||
// this will only be called when we end after a '.', '-', or 'e' and does not
|
||||
// change the number more than it needs to make it valid JSON
|
||||
output.push(`${input.substring(start, i)}0`);
|
||||
}
|
||||
function throwInvalidCharacter(char) {
|
||||
throw new JSONRepairError(`Invalid character ${JSON.stringify(char)}`, i);
|
||||
}
|
||||
function throwUnexpectedCharacter() {
|
||||
throw new JSONRepairError(`Unexpected character ${JSON.stringify(input.charAt(i))}`, i);
|
||||
}
|
||||
function throwUnexpectedEnd() {
|
||||
throw new JSONRepairError('Unexpected end of json string', i);
|
||||
}
|
||||
function throwObjectKeyExpected() {
|
||||
throw new JSONRepairError('Object key expected', i);
|
||||
}
|
||||
function throwColonExpected() {
|
||||
throw new JSONRepairError('Colon expected', i);
|
||||
}
|
||||
function throwInvalidUnicodeCharacter() {
|
||||
const chars = input.substring(i, i + 6);
|
||||
throw new JSONRepairError(`Invalid unicode character "${chars}"`, i);
|
||||
}
|
||||
function atEndOfBlockComment(i) {
|
||||
return input.charAt(i) === '*' && input.charAt(i + 1) === '/';
|
||||
}
|
||||
return {
|
||||
transform,
|
||||
flush
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=core.js.map
|
||||
1
node_modules/jsonrepair/lib/esm/streaming/core.js.map
generated
vendored
Normal file
1
node_modules/jsonrepair/lib/esm/streaming/core.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
44
node_modules/jsonrepair/lib/esm/streaming/stack.js
generated
vendored
Normal file
44
node_modules/jsonrepair/lib/esm/streaming/stack.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
export let Caret = /*#__PURE__*/function (Caret) {
|
||||
Caret["beforeValue"] = "beforeValue";
|
||||
Caret["afterValue"] = "afterValue";
|
||||
Caret["beforeKey"] = "beforeKey";
|
||||
return Caret;
|
||||
}({});
|
||||
export let StackType = /*#__PURE__*/function (StackType) {
|
||||
StackType["root"] = "root";
|
||||
StackType["object"] = "object";
|
||||
StackType["array"] = "array";
|
||||
StackType["ndJson"] = "ndJson";
|
||||
StackType["functionCall"] = "dataType";
|
||||
return StackType;
|
||||
}({});
|
||||
export function createStack() {
|
||||
const stack = [StackType.root];
|
||||
let caret = Caret.beforeValue;
|
||||
return {
|
||||
get type() {
|
||||
return last(stack);
|
||||
},
|
||||
get caret() {
|
||||
return caret;
|
||||
},
|
||||
pop() {
|
||||
stack.pop();
|
||||
caret = Caret.afterValue;
|
||||
return true;
|
||||
},
|
||||
push(type, newCaret) {
|
||||
stack.push(type);
|
||||
caret = newCaret;
|
||||
return true;
|
||||
},
|
||||
update(newCaret) {
|
||||
caret = newCaret;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
function last(array) {
|
||||
return array[array.length - 1];
|
||||
}
|
||||
//# sourceMappingURL=stack.js.map
|
||||
1
node_modules/jsonrepair/lib/esm/streaming/stack.js.map
generated
vendored
Normal file
1
node_modules/jsonrepair/lib/esm/streaming/stack.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"stack.js","names":["Caret","StackType","createStack","stack","root","caret","beforeValue","type","last","pop","afterValue","push","newCaret","update","array","length"],"sources":["../../../src/streaming/stack.ts"],"sourcesContent":["export enum Caret {\n beforeValue = 'beforeValue',\n afterValue = 'afterValue',\n beforeKey = 'beforeKey'\n}\n\nexport enum StackType {\n root = 'root',\n object = 'object',\n array = 'array',\n ndJson = 'ndJson',\n functionCall = 'dataType'\n}\n\nexport function createStack() {\n const stack: StackType[] = [StackType.root]\n let caret = Caret.beforeValue\n\n return {\n get type() {\n return last(stack)\n },\n\n get caret() {\n return caret\n },\n\n pop(): true {\n stack.pop()\n caret = Caret.afterValue\n\n return true\n },\n\n push(type: StackType, newCaret: Caret): true {\n stack.push(type)\n caret = newCaret\n\n return true\n },\n\n update(newCaret: Caret): true {\n caret = newCaret\n\n return true\n }\n }\n}\n\nfunction last<T>(array: T[]): T | undefined {\n return array[array.length - 1]\n}\n"],"mappings":"AAAA,WAAYA,KAAK,0BAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAAA,OAALA,KAAK;AAAA;AAMjB,WAAYC,SAAS,0BAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAAA,OAATA,SAAS;AAAA;AAQrB,OAAO,SAASC,WAAWA,CAAA,EAAG;EAC5B,MAAMC,KAAkB,GAAG,CAACF,SAAS,CAACG,IAAI,CAAC;EAC3C,IAAIC,KAAK,GAAGL,KAAK,CAACM,WAAW;EAE7B,OAAO;IACL,IAAIC,IAAIA,CAAA,EAAG;MACT,OAAOC,IAAI,CAACL,KAAK,CAAC;IACpB,CAAC;IAED,IAAIE,KAAKA,CAAA,EAAG;MACV,OAAOA,KAAK;IACd,CAAC;IAEDI,GAAGA,CAAA,EAAS;MACVN,KAAK,CAACM,GAAG,CAAC,CAAC;MACXJ,KAAK,GAAGL,KAAK,CAACU,UAAU;MAExB,OAAO,IAAI;IACb,CAAC;IAEDC,IAAIA,CAACJ,IAAe,EAAEK,QAAe,EAAQ;MAC3CT,KAAK,CAACQ,IAAI,CAACJ,IAAI,CAAC;MAChBF,KAAK,GAAGO,QAAQ;MAEhB,OAAO,IAAI;IACb,CAAC;IAEDC,MAAMA,CAACD,QAAe,EAAQ;MAC5BP,KAAK,GAAGO,QAAQ;MAEhB,OAAO,IAAI;IACb;EACF,CAAC;AACH;AAEA,SAASJ,IAAIA,CAAIM,KAAU,EAAiB;EAC1C,OAAOA,KAAK,CAACA,KAAK,CAACC,MAAM,GAAG,CAAC,CAAC;AAChC","ignoreList":[]}
|
||||
31
node_modules/jsonrepair/lib/esm/streaming/stream.js
generated
vendored
Normal file
31
node_modules/jsonrepair/lib/esm/streaming/stream.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
import { Transform } from 'node:stream';
|
||||
import { jsonrepairCore } from './core.js';
|
||||
export function jsonrepairTransform(options) {
|
||||
const repair = jsonrepairCore({
|
||||
onData: chunk => transform.push(chunk),
|
||||
bufferSize: options?.bufferSize,
|
||||
chunkSize: options?.chunkSize
|
||||
});
|
||||
const transform = new Transform({
|
||||
transform(chunk, _encoding, callback) {
|
||||
try {
|
||||
repair.transform(chunk.toString());
|
||||
} catch (err) {
|
||||
this.emit('error', err);
|
||||
} finally {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
flush(callback) {
|
||||
try {
|
||||
repair.flush();
|
||||
} catch (err) {
|
||||
this.emit('error', err);
|
||||
} finally {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
return transform;
|
||||
}
|
||||
//# sourceMappingURL=stream.js.map
|
||||
1
node_modules/jsonrepair/lib/esm/streaming/stream.js.map
generated
vendored
Normal file
1
node_modules/jsonrepair/lib/esm/streaming/stream.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"stream.js","names":["Transform","jsonrepairCore","jsonrepairTransform","options","repair","onData","chunk","transform","push","bufferSize","chunkSize","_encoding","callback","toString","err","emit","flush"],"sources":["../../../src/streaming/stream.ts"],"sourcesContent":["import { Transform } from 'node:stream'\nimport { jsonrepairCore } from './core.js'\n\nexport interface JsonRepairTransformOptions {\n chunkSize?: number\n bufferSize?: number\n}\n\nexport function jsonrepairTransform(options?: JsonRepairTransformOptions): Transform {\n const repair = jsonrepairCore({\n onData: (chunk) => transform.push(chunk),\n bufferSize: options?.bufferSize,\n chunkSize: options?.chunkSize\n })\n\n const transform = new Transform({\n transform(chunk, _encoding, callback) {\n try {\n repair.transform(chunk.toString())\n } catch (err) {\n this.emit('error', err)\n } finally {\n callback()\n }\n },\n\n flush(callback) {\n try {\n repair.flush()\n } catch (err) {\n this.emit('error', err)\n } finally {\n callback()\n }\n }\n })\n\n return transform\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa;AACvC,SAASC,cAAc,QAAQ,WAAW;AAO1C,OAAO,SAASC,mBAAmBA,CAACC,OAAoC,EAAa;EACnF,MAAMC,MAAM,GAAGH,cAAc,CAAC;IAC5BI,MAAM,EAAGC,KAAK,IAAKC,SAAS,CAACC,IAAI,CAACF,KAAK,CAAC;IACxCG,UAAU,EAAEN,OAAO,EAAEM,UAAU;IAC/BC,SAAS,EAAEP,OAAO,EAAEO;EACtB,CAAC,CAAC;EAEF,MAAMH,SAAS,GAAG,IAAIP,SAAS,CAAC;IAC9BO,SAASA,CAACD,KAAK,EAAEK,SAAS,EAAEC,QAAQ,EAAE;MACpC,IAAI;QACFR,MAAM,CAACG,SAAS,CAACD,KAAK,CAACO,QAAQ,CAAC,CAAC,CAAC;MACpC,CAAC,CAAC,OAAOC,GAAG,EAAE;QACZ,IAAI,CAACC,IAAI,CAAC,OAAO,EAAED,GAAG,CAAC;MACzB,CAAC,SAAS;QACRF,QAAQ,CAAC,CAAC;MACZ;IACF,CAAC;IAEDI,KAAKA,CAACJ,QAAQ,EAAE;MACd,IAAI;QACFR,MAAM,CAACY,KAAK,CAAC,CAAC;MAChB,CAAC,CAAC,OAAOF,GAAG,EAAE;QACZ,IAAI,CAACC,IAAI,CAAC,OAAO,EAAED,GAAG,CAAC;MACzB,CAAC,SAAS;QACRF,QAAQ,CAAC,CAAC;MACZ;IACF;EACF,CAAC,CAAC;EAEF,OAAOL,SAAS;AAClB","ignoreList":[]}
|
||||
Reference in New Issue
Block a user