gridify-client 2.0.0-preview.1 → 2.0.0-preview.3

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.
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var r,e,t={d:(r,e)=>{for(var o in e)t.o(e,o)&&!t.o(r,o)&&Object.defineProperty(r,o,{enumerable:!0,get:e[o]})},o:(r,e)=>Object.prototype.hasOwnProperty.call(r,e),r:r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}},o={};t.r(o),t.d(o,{ConditionalOperator:()=>r,GridifyQueryBuilder:()=>i,LogicalOperator:()=>e}),function(r){r.Equal="=",r.NotEqual="!=",r.LessThan="<",r.GreaterThan=">",r.GreaterThanOrEqual=">=",r.LessThanOrEqual="<=",r.Contains="*",r.NotContains="!*",r.StartsWith="^",r.NotStartsWith="!^",r.EndsWith="$",r.NotEndsWith="!$"}(r||(r={})),function(r){r.And=",",r.Or="|"}(e||(e={}));const i=class{constructor(){this.query={page:1,pageSize:20,orderBy:"",filter:""},this.filteringExpressions=[]}setPage(r){return this.query.page=r,this}setPageSize(r){return this.query.pageSize=r,this}addOrderBy(r,e=!1){const t=`${r.trim()} ${e?"desc":""}`.trim();return this.query.orderBy=this.query.orderBy?`${this.query.orderBy}, ${t}`:t,this}addCondition(r,e,t,o=!0,i=!0){let n=t;i&&"string"==typeof t&&(n=t.replace(/([(),|]|\/i)/g,"\\$1")),n=o?n.toString():`${n.toString()}/i`;var s=`${r.trim()}${e}${n}`;return this.filteringExpressions.push({value:s,type:"filter"}),this}startGroup(){return this.filteringExpressions.push({value:"(",type:"startGroup"}),this}endGroup(){return this.filteringExpressions.push({value:")",type:"endGroup"}),this}and(){return this.filteringExpressions.push({value:e.And,type:"op"}),this}or(){return this.filteringExpressions.push({value:e.Or,type:"op"}),this}build(){let r=null,e=0;if(this.filteringExpressions.forEach((t=>{if("startGroup"===t.type&&e++,"endGroup"===t.type&&e--,null===r&&"op"===t.type)throw new Error("expression cannot start with a logical operator");if("filter"===r&&"filter"===t.type)throw new Error("consecutive conditions are not allowed, consider adding a logical operator");if("op"===r&&"op"===t.type)throw new Error("consecutive operators are not allowed, consider adding a filter");if("startGroup"===r&&"op"===t.type)throw new Error("logical operator immediately after startGroup is not allowed");if("endGroup"===r&&"filter"===t.type)throw new Error("Missing logical operator after endGroup");if("startGroup"===r&&"endGroup"===t.type)throw new Error("Empty groups are not allowed");if("endGroup"===r&&"startGroup"===t.type)throw new Error("Missing a logical operator between groups");r=t.type,this.query.filter+=t.value})),0!=e)throw new Error("Group not properly closed");return this.query}};module.exports.GridifyClient=o})();
@@ -0,0 +1,3 @@
1
+ export { default as GridifyQueryBuilder } from './GridifyQueryBuilder';
2
+ export type { default as IGridifyQuery } from './IGridifyQuery';
3
+ export * from './GridifyOperator';
@@ -0,0 +1 @@
1
+ var r,t,e={d:(r,t)=>{for(var o in t)e.o(t,o)&&!e.o(r,o)&&Object.defineProperty(r,o,{enumerable:!0,get:t[o]})},o:(r,t)=>Object.prototype.hasOwnProperty.call(r,t)},o={};e.d(o,{SQ:()=>r,Fw:()=>i,Fn:()=>t}),function(r){r.Equal="=",r.NotEqual="!=",r.LessThan="<",r.GreaterThan=">",r.GreaterThanOrEqual=">=",r.LessThanOrEqual="<=",r.Contains="*",r.NotContains="!*",r.StartsWith="^",r.NotStartsWith="!^",r.EndsWith="$",r.NotEndsWith="!$"}(r||(r={})),function(r){r.And=",",r.Or="|"}(t||(t={}));const i=class{constructor(){this.query={page:1,pageSize:20,orderBy:"",filter:""},this.filteringExpressions=[]}setPage(r){return this.query.page=r,this}setPageSize(r){return this.query.pageSize=r,this}addOrderBy(r,t=!1){const e=`${r.trim()} ${t?"desc":""}`.trim();return this.query.orderBy=this.query.orderBy?`${this.query.orderBy}, ${e}`:e,this}addCondition(r,t,e,o=!0,i=!0){let s=e;i&&"string"==typeof e&&(s=e.replace(/([(),|]|\/i)/g,"\\$1")),s=o?s.toString():`${s.toString()}/i`;var n=`${r.trim()}${t}${s}`;return this.filteringExpressions.push({value:n,type:"filter"}),this}startGroup(){return this.filteringExpressions.push({value:"(",type:"startGroup"}),this}endGroup(){return this.filteringExpressions.push({value:")",type:"endGroup"}),this}and(){return this.filteringExpressions.push({value:t.And,type:"op"}),this}or(){return this.filteringExpressions.push({value:t.Or,type:"op"}),this}build(){let r=null,t=0;if(this.filteringExpressions.forEach((e=>{if("startGroup"===e.type&&t++,"endGroup"===e.type&&t--,null===r&&"op"===e.type)throw new Error("expression cannot start with a logical operator");if("filter"===r&&"filter"===e.type)throw new Error("consecutive conditions are not allowed, consider adding a logical operator");if("op"===r&&"op"===e.type)throw new Error("consecutive operators are not allowed, consider adding a filter");if("startGroup"===r&&"op"===e.type)throw new Error("logical operator immediately after startGroup is not allowed");if("endGroup"===r&&"filter"===e.type)throw new Error("Missing logical operator after endGroup");if("startGroup"===r&&"endGroup"===e.type)throw new Error("Empty groups are not allowed");if("endGroup"===r&&"startGroup"===e.type)throw new Error("Missing a logical operator between groups");r=e.type,this.query.filter+=e.value})),0!=t)throw new Error("Group not properly closed");return this.query}};var s=o.SQ,n=o.Fw,a=o.Fn;export{s as ConditionalOperator,n as GridifyQueryBuilder,a as LogicalOperator};
@@ -0,0 +1 @@
1
+ !function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.GridifyClient=e():r.GridifyClient=e()}(this,(()=>(()=>{"use strict";var r,e,t={d:(r,e)=>{for(var o in e)t.o(e,o)&&!t.o(r,o)&&Object.defineProperty(r,o,{enumerable:!0,get:e[o]})},o:(r,e)=>Object.prototype.hasOwnProperty.call(r,e),r:r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}},o={};t.r(o),t.d(o,{ConditionalOperator:()=>r,GridifyQueryBuilder:()=>i,LogicalOperator:()=>e}),function(r){r.Equal="=",r.NotEqual="!=",r.LessThan="<",r.GreaterThan=">",r.GreaterThanOrEqual=">=",r.LessThanOrEqual="<=",r.Contains="*",r.NotContains="!*",r.StartsWith="^",r.NotStartsWith="!^",r.EndsWith="$",r.NotEndsWith="!$"}(r||(r={})),function(r){r.And=",",r.Or="|"}(e||(e={}));const i=class{constructor(){this.query={page:1,pageSize:20,orderBy:"",filter:""},this.filteringExpressions=[]}setPage(r){return this.query.page=r,this}setPageSize(r){return this.query.pageSize=r,this}addOrderBy(r,e=!1){const t=`${r.trim()} ${e?"desc":""}`.trim();return this.query.orderBy=this.query.orderBy?`${this.query.orderBy}, ${t}`:t,this}addCondition(r,e,t,o=!0,i=!0){let n=t;i&&"string"==typeof t&&(n=t.replace(/([(),|]|\/i)/g,"\\$1")),n=o?n.toString():`${n.toString()}/i`;var s=`${r.trim()}${e}${n}`;return this.filteringExpressions.push({value:s,type:"filter"}),this}startGroup(){return this.filteringExpressions.push({value:"(",type:"startGroup"}),this}endGroup(){return this.filteringExpressions.push({value:")",type:"endGroup"}),this}and(){return this.filteringExpressions.push({value:e.And,type:"op"}),this}or(){return this.filteringExpressions.push({value:e.Or,type:"op"}),this}build(){let r=null,e=0;if(this.filteringExpressions.forEach((t=>{if("startGroup"===t.type&&e++,"endGroup"===t.type&&e--,null===r&&"op"===t.type)throw new Error("expression cannot start with a logical operator");if("filter"===r&&"filter"===t.type)throw new Error("consecutive conditions are not allowed, consider adding a logical operator");if("op"===r&&"op"===t.type)throw new Error("consecutive operators are not allowed, consider adding a filter");if("startGroup"===r&&"op"===t.type)throw new Error("logical operator immediately after startGroup is not allowed");if("endGroup"===r&&"filter"===t.type)throw new Error("Missing logical operator after endGroup");if("startGroup"===r&&"endGroup"===t.type)throw new Error("Empty groups are not allowed");if("endGroup"===r&&"startGroup"===t.type)throw new Error("Missing a logical operator between groups");r=t.type,this.query.filter+=t.value})),0!=e)throw new Error("Group not properly closed");return this.query}};return o})()));
package/package.json CHANGED
@@ -1,23 +1,30 @@
1
1
  {
2
2
  "name": "gridify-client",
3
- "version": "2.0.0-preview.1",
3
+ "version": "2.0.0-preview.3",
4
4
  "description": "Client JS library for the dotnet Gridify project",
5
- "main": "dist/GridifyQueryBuilder.js",
6
- "types": "dist/GridifyQueryBuilder.d.ts",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
7
8
  "repository": "https://github.com/alirezanet/Gridify/",
8
9
  "homepage": "https://alirezanet.github.io/Gridify/guide/gridify-client/",
9
10
  "author": "AliReza Sabouri",
10
11
  "license": "MIT",
11
12
  "scripts": {
12
- "build": "tsc",
13
- "watch": "tsc -w",
13
+ "build": "webpack",
14
+ "watch": "webpack --watch",
14
15
  "test": "jest"
15
16
  },
16
17
  "devDependencies": {
17
18
  "@types/jest": "^29.5.8",
18
19
  "jest": "^29.7.0",
20
+ "terser-webpack-plugin": "^5.3.9",
19
21
  "ts-jest": "^29.1.1",
20
- "typescript": "^5.2.2"
22
+ "ts-loader": "^9.5.0",
23
+ "typescript": "^5.2.2",
24
+ "uglifyjs-webpack-plugin": "^2.2.0",
25
+ "webpack": "^5.89.0",
26
+ "webpack-cli": "^5.1.4",
27
+ "webpack-merge": "^5.10.0"
21
28
  },
22
29
  "files": [
23
30
  "dist/**/*"
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LogicalOperator = exports.ConditionalOperator = void 0;
4
- var ConditionalOperator;
5
- (function (ConditionalOperator) {
6
- ConditionalOperator["Equal"] = "=";
7
- ConditionalOperator["NotEqual"] = "!=";
8
- ConditionalOperator["LessThan"] = "<";
9
- ConditionalOperator["GreaterThan"] = ">";
10
- ConditionalOperator["GreaterThanOrEqual"] = ">=";
11
- ConditionalOperator["LessThanOrEqual"] = "<=";
12
- ConditionalOperator["Contains"] = "*";
13
- ConditionalOperator["NotContains"] = "!*";
14
- ConditionalOperator["StartsWith"] = "^";
15
- ConditionalOperator["NotStartsWith"] = "!^";
16
- ConditionalOperator["EndsWith"] = "$";
17
- ConditionalOperator["NotEndsWith"] = "!$";
18
- })(ConditionalOperator || (exports.ConditionalOperator = ConditionalOperator = {}));
19
- var LogicalOperator;
20
- (function (LogicalOperator) {
21
- LogicalOperator["And"] = ",";
22
- LogicalOperator["Or"] = "|";
23
- })(LogicalOperator || (exports.LogicalOperator = LogicalOperator = {}));
@@ -1,111 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const GridifyOperator_1 = require("./GridifyOperator");
4
- class GridifyQueryBuilder {
5
- constructor() {
6
- this.query = {
7
- page: 1,
8
- pageSize: 20,
9
- orderBy: "",
10
- filter: "",
11
- };
12
- this.filteringExpressions = [];
13
- }
14
- setPage(page) {
15
- this.query.page = page;
16
- return this;
17
- }
18
- setPageSize(pageSize) {
19
- this.query.pageSize = pageSize;
20
- return this;
21
- }
22
- addOrderBy(field, descending = false) {
23
- const orderBy = `${field.trim()} ${descending ? "desc" : ""}`.trim();
24
- if (this.query.orderBy) {
25
- this.query.orderBy += `, ${orderBy}`;
26
- }
27
- this.query.orderBy = orderBy;
28
- return this;
29
- }
30
- addCondition(field, operator, value, caseSensitive = true, escapeValue = true) {
31
- let filterValue = value;
32
- if (escapeValue && typeof value === "string") {
33
- filterValue = value.replace(/([(),|]|\/i)/g, "\\$1");
34
- }
35
- filterValue = caseSensitive
36
- ? filterValue.toString()
37
- : `${filterValue.toString()}/i`;
38
- var filterExpression = `${field.trim()}${operator}${filterValue}`;
39
- this.filteringExpressions.push({
40
- value: filterExpression,
41
- type: "filter",
42
- });
43
- return this;
44
- }
45
- startGroup() {
46
- this.filteringExpressions.push({ value: "(", type: "startGroup" });
47
- return this;
48
- }
49
- endGroup() {
50
- this.filteringExpressions.push({ value: ")", type: "endGroup" });
51
- return this;
52
- }
53
- and() {
54
- this.filteringExpressions.push({
55
- value: GridifyOperator_1.LogicalOperator.And,
56
- type: "op",
57
- });
58
- return this;
59
- }
60
- or() {
61
- this.filteringExpressions.push({ value: GridifyOperator_1.LogicalOperator.Or, type: "op" });
62
- return this;
63
- }
64
- build() {
65
- let previousType = null;
66
- let groupCounter = 0;
67
- this.filteringExpressions.forEach((exp) => {
68
- if (exp.type === "startGroup") {
69
- groupCounter++;
70
- }
71
- if (exp.type === "endGroup") {
72
- groupCounter--;
73
- }
74
- //,
75
- if (previousType === null && exp.type === "op") {
76
- throw new Error("expression cannot start with a logical operator");
77
- }
78
- // filter filter
79
- if (previousType === "filter" && exp.type === "filter") {
80
- throw new Error("consecutive conditions are not allowed, consider adding a logical operator");
81
- }
82
- // ,,
83
- if (previousType === "op" && exp.type === "op") {
84
- throw new Error("consecutive operators are not allowed, consider adding a filter");
85
- }
86
- // (,
87
- if (previousType === "startGroup" && exp.type === "op") {
88
- throw new Error("logical operator immediately after startGroup is not allowed");
89
- }
90
- // )filter
91
- if (previousType === "endGroup" && exp.type === "filter") {
92
- throw new Error("Missing logical operator after endGroup");
93
- }
94
- // ()
95
- if (previousType === "startGroup" && exp.type === "endGroup") {
96
- throw new Error("Empty groups are not allowed");
97
- }
98
- // )(
99
- if (previousType === "endGroup" && exp.type === "startGroup") {
100
- throw new Error("Missing a logical operator between groups");
101
- }
102
- previousType = exp.type;
103
- this.query.filter += exp.value;
104
- });
105
- if (groupCounter != 0) {
106
- throw new Error("Group not properly closed");
107
- }
108
- return this.query;
109
- }
110
- }
111
- exports.default = GridifyQueryBuilder;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });