namirasoft-core 1.4.46 → 1.4.47
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/FilterItem.d.ts +1 -1
- package/dist/FilterItem.js +16 -37
- package/dist/FilterItem.js.map +1 -1
- package/dist/SortItem.d.ts +1 -1
- package/dist/SortItem.js +15 -29
- package/dist/SortItem.js.map +1 -1
- package/package.json +2 -2
- package/src/FilterItem.ts +15 -44
- package/src/SortItem.ts +14 -33
package/dist/FilterItem.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare class FilterItem {
|
|
|
10
10
|
static encode(filters: FilterItem[] | null): string;
|
|
11
11
|
static decode(value: string): FilterItem[] | null;
|
|
12
12
|
static stringify(filters: FilterItem[] | null): string;
|
|
13
|
-
static parse(
|
|
13
|
+
static parse(items: string | null): FilterItem[];
|
|
14
14
|
constructor(table: BaseMetaTable, column: BaseMetaColumn, not: boolean, operator: FilterItemOperator, ...values: string[]);
|
|
15
15
|
getCommand(): string;
|
|
16
16
|
isAllColumns(): boolean;
|
package/dist/FilterItem.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FilterItem = void 0;
|
|
4
|
-
const BaseMetaColumn_1 = require("./BaseMetaColumn");
|
|
5
|
-
const BaseMetaTable_1 = require("./BaseMetaTable");
|
|
6
4
|
const EncodingOperation_1 = require("./EncodingOperation");
|
|
7
5
|
const ErrorOperation_1 = require("./ErrorOperation");
|
|
8
6
|
const FilterItemOperator_1 = require("./FilterItemOperator");
|
|
@@ -16,42 +14,23 @@ class FilterItem {
|
|
|
16
14
|
return this.parse(encoded);
|
|
17
15
|
}
|
|
18
16
|
static stringify(filters) {
|
|
19
|
-
|
|
20
|
-
return filters.map(x => x.getCommand()).join(";");
|
|
21
|
-
return "";
|
|
17
|
+
return JSON.stringify(filters);
|
|
22
18
|
}
|
|
23
|
-
static parse(
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
let table = new BaseMetaTable_1.BaseMetaTable(null, value_table, value_table);
|
|
39
|
-
let value_column = next("Column");
|
|
40
|
-
let column = new BaseMetaColumn_1.BaseMetaColumn(table, value_column, value_column, "", false);
|
|
41
|
-
let value_not = next("Not");
|
|
42
|
-
let not = value_not != "0";
|
|
43
|
-
if (value_not != "0" && value_not != "1")
|
|
44
|
-
ErrorOperation_1.ErrorOperation.throwHTTP(400, `Invalid value '${value_not}' for FilterItem.not, Only 0 and 1 are allowed.`);
|
|
45
|
-
let value_operator = next("Operator");
|
|
46
|
-
let operator = FilterItemOperator_1.FilterItemOperator.getByName(value_operator);
|
|
47
|
-
let values = [];
|
|
48
|
-
for (let j = 0; j < operator.count; j++) {
|
|
49
|
-
let value_value = next("Value Number " + (j + 1));
|
|
50
|
-
let value = value_value.replace(/\\;/gm, ";");
|
|
51
|
-
values.push(value);
|
|
52
|
-
}
|
|
53
|
-
ans.push(new FilterItem(table, column, not, operator, ...values));
|
|
54
|
-
}
|
|
19
|
+
static parse(items) {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f;
|
|
21
|
+
if (!items)
|
|
22
|
+
return [];
|
|
23
|
+
let ans = JSON.parse(items);
|
|
24
|
+
for (let i = 0; i < ans.length; i++) {
|
|
25
|
+
let item = ans[i];
|
|
26
|
+
if (!((_a = item.table) === null || _a === void 0 ? void 0 : _a.name))
|
|
27
|
+
ErrorOperation_1.ErrorOperation.throwHTTP(400, `Invalid value '${(_b = item.table) === null || _b === void 0 ? void 0 : _b.name}' for FilterItem.table.name.`);
|
|
28
|
+
if (!((_c = item.column) === null || _c === void 0 ? void 0 : _c.name))
|
|
29
|
+
ErrorOperation_1.ErrorOperation.throwHTTP(400, `Invalid value '${(_d = item.table) === null || _d === void 0 ? void 0 : _d.name}' for FilterItem.table.name.`);
|
|
30
|
+
if (item.not != false && item.not != true)
|
|
31
|
+
ErrorOperation_1.ErrorOperation.throwHTTP(400, `Invalid value '${item.not}' for FilterItem.not, Only true and false are allowed.`);
|
|
32
|
+
let operator = FilterItemOperator_1.FilterItemOperator.getByName((_f = (_e = item.operator) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : "");
|
|
33
|
+
ans[i] = new FilterItem(item.table, item.column, item.not, operator, ...item.values);
|
|
55
34
|
}
|
|
56
35
|
return ans;
|
|
57
36
|
}
|
package/dist/FilterItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterItem.js","sourceRoot":"","sources":["../src/FilterItem.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"FilterItem.js","sourceRoot":"","sources":["../src/FilterItem.ts"],"names":[],"mappings":";;;AAEA,2DAAwD;AACxD,qDAAkD;AAClD,6DAA0D;AAE1D,MAAa,UAAU;IAOZ,MAAM,CAAC,MAAM,CAAC,OAA4B;QAE7C,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACpC,OAAO,qCAAiB,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IACM,MAAM,CAAC,MAAM,CAAC,KAAa;QAE9B,IAAI,OAAO,GAAG,qCAAiB,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IACM,MAAM,CAAC,SAAS,CAAC,OAA4B;QAEhD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IACM,MAAM,CAAC,KAAK,CAAC,KAAoB;;QAEpC,IAAI,CAAC,KAAK;YACN,OAAO,EAAE,CAAC;QACd,IAAI,GAAG,GAA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M,CAAC,IAAI,CAAC;;gBAE1B,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAC9B,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,IAAI,CAAC,GAAG;YACR,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,IAAI,CAAC,QAAQ,IAAI,uCAAkB,CAAC,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG;YAClF,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;CACJ;AAlFD,gCAkFC"}
|
package/dist/SortItem.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class SortItem {
|
|
|
7
7
|
static encode(sorts: SortItem[] | null): string;
|
|
8
8
|
static decode(value: string): SortItem[] | null;
|
|
9
9
|
static stringify(sorts: SortItem[] | null): string;
|
|
10
|
-
static parse(
|
|
10
|
+
static parse(items: string | null): SortItem[];
|
|
11
11
|
constructor(table: BaseMetaTable, column: BaseMetaColumn, ascending: boolean);
|
|
12
12
|
getCommand(): string;
|
|
13
13
|
toString(): string;
|
package/dist/SortItem.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SortItem = void 0;
|
|
4
|
-
const BaseMetaColumn_1 = require("./BaseMetaColumn");
|
|
5
|
-
const BaseMetaTable_1 = require("./BaseMetaTable");
|
|
6
4
|
const EncodingOperation_1 = require("./EncodingOperation");
|
|
7
5
|
const ErrorOperation_1 = require("./ErrorOperation");
|
|
8
6
|
class SortItem {
|
|
@@ -15,34 +13,22 @@ class SortItem {
|
|
|
15
13
|
return this.parse(encoded);
|
|
16
14
|
}
|
|
17
15
|
static stringify(sorts) {
|
|
18
|
-
|
|
19
|
-
return sorts.map(x => x.getCommand()).join(";");
|
|
20
|
-
return "";
|
|
16
|
+
return JSON.stringify(sorts);
|
|
21
17
|
}
|
|
22
|
-
static parse(
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
let value_table = next("Table");
|
|
37
|
-
let table = new BaseMetaTable_1.BaseMetaTable(null, value_table, value_table);
|
|
38
|
-
let value_column = next("Column");
|
|
39
|
-
let column = new BaseMetaColumn_1.BaseMetaColumn(table, value_column, value_column, "", false);
|
|
40
|
-
let value_asc = next("Asending").toLowerCase();
|
|
41
|
-
let asc = value_asc === "asc";
|
|
42
|
-
if (value_asc != "asc" && value_asc != "desc")
|
|
43
|
-
ErrorOperation_1.ErrorOperation.throwHTTP(400, `Invalid value '${value_asc}' for SortItem.Asending, Only 'Asc' and 'Desc' are allowed.`);
|
|
44
|
-
ans.push(new SortItem(table, column, asc));
|
|
45
|
-
}
|
|
18
|
+
static parse(items) {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
if (!items)
|
|
21
|
+
return [];
|
|
22
|
+
let ans = JSON.parse(items);
|
|
23
|
+
for (let i = 0; i < ans.length; i++) {
|
|
24
|
+
let item = ans[i];
|
|
25
|
+
if (!((_a = item.table) === null || _a === void 0 ? void 0 : _a.name))
|
|
26
|
+
ErrorOperation_1.ErrorOperation.throwHTTP(400, `Invalid value '${(_b = item.table) === null || _b === void 0 ? void 0 : _b.name}' for FilterItem.table.name.`);
|
|
27
|
+
if (!((_c = item.column) === null || _c === void 0 ? void 0 : _c.name))
|
|
28
|
+
ErrorOperation_1.ErrorOperation.throwHTTP(400, `Invalid value '${(_d = item.table) === null || _d === void 0 ? void 0 : _d.name}' for FilterItem.table.name.`);
|
|
29
|
+
if (item.ascending != false && item.ascending != true)
|
|
30
|
+
ErrorOperation_1.ErrorOperation.throwHTTP(400, `Invalid value '${item.ascending}' for FilterItem.ascending, Only true and false are allowed.`);
|
|
31
|
+
ans[i] = new SortItem(item.table, item.column, item.ascending);
|
|
46
32
|
}
|
|
47
33
|
return ans;
|
|
48
34
|
}
|
package/dist/SortItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortItem.js","sourceRoot":"","sources":["../src/SortItem.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SortItem.js","sourceRoot":"","sources":["../src/SortItem.ts"],"names":[],"mappings":";;;AAEA,2DAAwD;AACxD,qDAAkD;AAElD,MAAa,QAAQ;IAKV,MAAM,CAAC,MAAM,CAAC,KAAwB;QAEzC,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAClC,OAAO,qCAAiB,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IACM,MAAM,CAAC,MAAM,CAAC,KAAa;QAE9B,IAAI,OAAO,GAAG,qCAAiB,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IACM,MAAM,CAAC,SAAS,CAAC,KAAwB;QAE5C,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IACM,MAAM,CAAC,KAAK,CAAC,KAAoB;;QAEpC,IAAI,CAAC,KAAK;Y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IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1F,CAAC;IACD,QAAQ;QAEJ,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI;YACf,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;;YAE1B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI;YAChB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;;YAE3B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,IAAI,CAAC,SAAS;YACd,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;;YAEtB,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;CACJ;AAhED,4BAgEC"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"framework": "npm",
|
|
9
9
|
"application": "package",
|
|
10
10
|
"private": false,
|
|
11
|
-
"version": "1.4.
|
|
11
|
+
"version": "1.4.47",
|
|
12
12
|
"author": "Amir Abolhasani",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"main": "./dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"build": ""
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@types/node": "^22.13.
|
|
20
|
+
"@types/node": "^22.13.1",
|
|
21
21
|
"axios": "^1.7.9",
|
|
22
22
|
"buffer": "^6.0.3",
|
|
23
23
|
"moment": "^2.30.1",
|
package/src/FilterItem.ts
CHANGED
|
@@ -23,53 +23,24 @@ export class FilterItem
|
|
|
23
23
|
}
|
|
24
24
|
public static stringify(filters: FilterItem[] | null): string
|
|
25
25
|
{
|
|
26
|
-
|
|
27
|
-
return filters.map(x => x.getCommand()).join(";");
|
|
28
|
-
return "";
|
|
26
|
+
return JSON.stringify(filters);
|
|
29
27
|
}
|
|
30
|
-
public static parse(
|
|
28
|
+
public static parse(items: string | null): FilterItem[]
|
|
31
29
|
{
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
if (!items)
|
|
31
|
+
return [];
|
|
32
|
+
let ans: FilterItem[] = JSON.parse(items);
|
|
33
|
+
for (let i = 0; i < ans.length; i++)
|
|
34
34
|
{
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return items[index++];
|
|
45
|
-
throw ErrorOperation.getHTTP(400, `Next value is required for '${name}'. Must be separated by ;`);
|
|
46
|
-
};
|
|
47
|
-
while (thereIsMore())
|
|
48
|
-
{
|
|
49
|
-
let value_table = next("Table");
|
|
50
|
-
let table = new BaseMetaTable(null, value_table, value_table);
|
|
51
|
-
|
|
52
|
-
let value_column = next("Column");
|
|
53
|
-
let column = new BaseMetaColumn(table, value_column, value_column, "", false)
|
|
54
|
-
|
|
55
|
-
let value_not = next("Not");
|
|
56
|
-
let not = value_not != "0"
|
|
57
|
-
if (value_not != "0" && value_not != "1")
|
|
58
|
-
ErrorOperation.throwHTTP(400, `Invalid value '${value_not}' for FilterItem.not, Only 0 and 1 are allowed.`);
|
|
59
|
-
|
|
60
|
-
let value_operator = next("Operator");
|
|
61
|
-
let operator = FilterItemOperator.getByName(value_operator);
|
|
62
|
-
|
|
63
|
-
let values: string[] = [];
|
|
64
|
-
for (let j = 0; j < operator.count; j++)
|
|
65
|
-
{
|
|
66
|
-
let value_value = next("Value Number " + (j + 1));
|
|
67
|
-
let value = value_value.replace(/\\;/gm, ";");
|
|
68
|
-
values.push(value);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
ans.push(new FilterItem(table, column, not, operator, ...values));
|
|
72
|
-
}
|
|
35
|
+
let item = ans[i];
|
|
36
|
+
if (!(item.table?.name))
|
|
37
|
+
ErrorOperation.throwHTTP(400, `Invalid value '${item.table?.name}' for FilterItem.table.name.`);
|
|
38
|
+
if (!(item.column?.name))
|
|
39
|
+
ErrorOperation.throwHTTP(400, `Invalid value '${item.table?.name}' for FilterItem.table.name.`);
|
|
40
|
+
if (item.not != false && item.not != true)
|
|
41
|
+
ErrorOperation.throwHTTP(400, `Invalid value '${item.not}' for FilterItem.not, Only true and false are allowed.`);
|
|
42
|
+
let operator = FilterItemOperator.getByName(item.operator?.name ?? "");
|
|
43
|
+
ans[i] = new FilterItem(item.table, item.column, item.not, operator, ...item.values);
|
|
73
44
|
}
|
|
74
45
|
return ans;
|
|
75
46
|
}
|
package/src/SortItem.ts
CHANGED
|
@@ -20,42 +20,23 @@ export class SortItem
|
|
|
20
20
|
}
|
|
21
21
|
public static stringify(sorts: SortItem[] | null): string
|
|
22
22
|
{
|
|
23
|
-
|
|
24
|
-
return sorts.map(x => x.getCommand()).join(";");
|
|
25
|
-
return "";
|
|
23
|
+
return JSON.stringify(sorts);
|
|
26
24
|
}
|
|
27
|
-
public static parse(
|
|
25
|
+
public static parse(items: string | null): SortItem[]
|
|
28
26
|
{
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
if (!items)
|
|
28
|
+
return [];
|
|
29
|
+
let ans: SortItem[] = JSON.parse(items);
|
|
30
|
+
for (let i = 0; i < ans.length; i++)
|
|
31
31
|
{
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (thereIsMore())
|
|
41
|
-
return items[index++];
|
|
42
|
-
throw ErrorOperation.getHTTP(400, `Next value is required for '${name}'. Must be separated by ;`);
|
|
43
|
-
};
|
|
44
|
-
while (thereIsMore())
|
|
45
|
-
{
|
|
46
|
-
let value_table = next("Table");
|
|
47
|
-
let table = new BaseMetaTable(null, value_table, value_table);
|
|
48
|
-
|
|
49
|
-
let value_column = next("Column");
|
|
50
|
-
let column = new BaseMetaColumn(table, value_column, value_column, "", false)
|
|
51
|
-
|
|
52
|
-
let value_asc = next("Asending").toLowerCase();
|
|
53
|
-
let asc = value_asc === "asc"
|
|
54
|
-
if (value_asc != "asc" && value_asc != "desc")
|
|
55
|
-
ErrorOperation.throwHTTP(400, `Invalid value '${value_asc}' for SortItem.Asending, Only 'Asc' and 'Desc' are allowed.`);
|
|
56
|
-
|
|
57
|
-
ans.push(new SortItem(table, column, asc));
|
|
58
|
-
}
|
|
32
|
+
let item = ans[i];
|
|
33
|
+
if (!(item.table?.name))
|
|
34
|
+
ErrorOperation.throwHTTP(400, `Invalid value '${item.table?.name}' for FilterItem.table.name.`);
|
|
35
|
+
if (!(item.column?.name))
|
|
36
|
+
ErrorOperation.throwHTTP(400, `Invalid value '${item.table?.name}' for FilterItem.table.name.`);
|
|
37
|
+
if (item.ascending != false && item.ascending != true)
|
|
38
|
+
ErrorOperation.throwHTTP(400, `Invalid value '${item.ascending}' for FilterItem.ascending, Only true and false are allowed.`);
|
|
39
|
+
ans[i] = new SortItem(item.table, item.column, item.ascending);
|
|
59
40
|
}
|
|
60
41
|
return ans;
|
|
61
42
|
}
|