namirasoft-core
Advanced tools
Comparing version 1.3.63 to 1.3.64
@@ -17,24 +17,30 @@ "use strict"; | ||
if (item) { | ||
let index = 0; | ||
let items = item.split(/(?<!\\);/); | ||
for (let i = 0; i < items.length;) { | ||
if (i + 4 >= items.length) | ||
ErrorOperation_1.ErrorOperation.throwHTTP(400, "Invalid value for FilterItem: " + item); | ||
let tableIndex = i; | ||
let columnIndex = i + 1; | ||
let notIndex = i + 2; | ||
let operatorIndex = i + 3; | ||
let valueIndex = i + 4; | ||
let table = items[tableIndex]; | ||
let column = items[columnIndex]; | ||
let not = items[notIndex] != "0"; | ||
if (items[notIndex] != "0" && items[notIndex] != "1") | ||
ErrorOperation_1.ErrorOperation.throwHTTP(400, "Invalid value for FilterItem.not: " + items[notIndex]); | ||
let operator = FilterItemOperator_1.FilterItemOperator.getByName(items[operatorIndex]); | ||
let thereIsMore = () => { | ||
return index < items.length; | ||
}; | ||
let next = (name) => { | ||
if (thereIsMore()) | ||
return items[index++]; | ||
throw ErrorOperation_1.ErrorOperation.getHTTP(400, `Next value is required for '${name}'. Must be separated by ;`); | ||
}; | ||
while (thereIsMore()) { | ||
let value_table = next("Table"); | ||
let table = new BaseMetaTable_1.BaseMetaTable(value_table, value_table); | ||
let value_column = next("Column"); | ||
let column = new BaseMetaColumn_1.BaseMetaColumn(value_column, value_column, "", false); | ||
let value_not = next("Not"); | ||
let not = value_not != "0"; | ||
if (value_not != "0" && value_not != "1") | ||
ErrorOperation_1.ErrorOperation.throwHTTP(400, `Invalid value '${value_not}' for FilterItem.not, Only 0 and 1 are allowed.`); | ||
let value_operator = next("Operator"); | ||
let operator = FilterItemOperator_1.FilterItemOperator.getByName(value_operator); | ||
let values = []; | ||
for (let j = 0; j < operator.count; j++) { | ||
let value = items[valueIndex + j].replace(/\\;/gm, ";"); | ||
let value_value = next("Value Number " + (j + 1)); | ||
let value = value_value.replace(/\\;/gm, ";"); | ||
values.push(value); | ||
} | ||
ans.push(new FilterItem(new BaseMetaTable_1.BaseMetaTable(table, table), new BaseMetaColumn_1.BaseMetaColumn(column, column, "", false), not, operator, ...values)); | ||
i += 4 + operator.count; | ||
ans.push(new FilterItem(table, column, not, operator, ...values)); | ||
} | ||
@@ -51,3 +57,3 @@ } | ||
if (this.values.length != operator.count) | ||
throw new Error(`Invalid count of values: ${this.values.length}. ${operator.count} is required.`); | ||
throw new Error(`Invalid count of values: ${this.values.length}.${operator.count} is required.`); | ||
} | ||
@@ -54,0 +60,0 @@ getCommand() { |
@@ -11,3 +11,3 @@ { | ||
"private": false, | ||
"version": "1.3.63", | ||
"version": "1.3.64", | ||
"author": "Amir Abolhasani", | ||
@@ -21,3 +21,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@types/node": "^20.14.6", | ||
"@types/node": "^20.14.7", | ||
"axios": "^1.7.2", | ||
@@ -24,0 +24,0 @@ "moment": "^2.30.1", |
@@ -24,26 +24,39 @@ import { BaseMetaColumn } from "./BaseMetaColumn"; | ||
{ | ||
let index = 0; | ||
let items = item.split(/(?<!\\);/); | ||
for (let i = 0; i < items.length;) | ||
let thereIsMore = (): boolean => | ||
{ | ||
if (i + 4 >= items.length) | ||
ErrorOperation.throwHTTP(400, "Invalid value for FilterItem: " + item); | ||
let tableIndex = i; | ||
let columnIndex = i + 1; | ||
let notIndex = i + 2; | ||
let operatorIndex = i + 3; | ||
let valueIndex = i + 4; | ||
let table = items[tableIndex]; | ||
let column = items[columnIndex]; | ||
let not = items[notIndex] != "0"; | ||
if (items[notIndex] != "0" && items[notIndex] != "1") | ||
ErrorOperation.throwHTTP(400, "Invalid value for FilterItem.not: " + items[notIndex]); | ||
let operator = FilterItemOperator.getByName(items[operatorIndex]); | ||
return index < items.length; | ||
}; | ||
let next = (name: string): string => | ||
{ | ||
if (thereIsMore()) | ||
return items[index++]; | ||
throw ErrorOperation.getHTTP(400, `Next value is required for '${name}'. Must be separated by ;`); | ||
}; | ||
while (thereIsMore()) | ||
{ | ||
let value_table = next("Table"); | ||
let table = new BaseMetaTable(value_table, value_table); | ||
let value_column = next("Column"); | ||
let column = new BaseMetaColumn(value_column, value_column, "", false) | ||
let value_not = next("Not"); | ||
let not = value_not != "0" | ||
if (value_not != "0" && value_not != "1") | ||
ErrorOperation.throwHTTP(400, `Invalid value '${value_not}' for FilterItem.not, Only 0 and 1 are allowed.`); | ||
let value_operator = next("Operator"); | ||
let operator = FilterItemOperator.getByName(value_operator); | ||
let values: string[] = []; | ||
for (let j = 0; j < operator.count; j++) | ||
{ | ||
let value = items[valueIndex + j].replace(/\\;/gm, ";"); | ||
let value_value = next("Value Number " + (j + 1)); | ||
let value = value_value.replace(/\\;/gm, ";"); | ||
values.push(value); | ||
} | ||
ans.push(new FilterItem(new BaseMetaTable(table, table), new BaseMetaColumn(column, column, "", false), not, operator, ...values)); | ||
i += 4 + operator.count; | ||
ans.push(new FilterItem(table, column, not, operator, ...values)); | ||
} | ||
@@ -61,3 +74,3 @@ } | ||
if (this.values.length != operator.count) | ||
throw new Error(`Invalid count of values: ${this.values.length}. ${operator.count} is required.`); | ||
throw new Error(`Invalid count of values: ${this.values.length}.${operator.count} is required.`); | ||
} | ||
@@ -64,0 +77,0 @@ getCommand() |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
360191
4594
Updated@types/node@^20.14.7