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

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 t,e,o,r={d:(t,e)=>{for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},a={};r.r(a),r.d(a,{ConditionalOperator:()=>t,LogicalOperator:()=>e}),function(t){t.Equal="=",t.NotEqual="!=",t.LessThan="<",t.GreaterThan=">",t.GreaterThanOrEqual=">=",t.LessThanOrEqual="<=",t.Contains="*",t.NotContains="!*",t.StartsWith="^",t.NotStartsWith="!^",t.EndsWith="$",t.NotEndsWith="!$"}(t||(t={})),(o=e||(e={})).And=",",o.Or="|",module.exports=a})();
@@ -0,0 +1,3 @@
1
+ export * from './GridifyQueryBuilder';
2
+ export * from './GridifyOperator';
3
+ export * from './IGridifyQuery';
@@ -0,0 +1 @@
1
+ var t,a,r,o={d:(t,a)=>{for(var r in a)o.o(a,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(t,a)=>Object.prototype.hasOwnProperty.call(t,a)},e={};o.d(e,{S:()=>t,F:()=>a}),function(t){t.Equal="=",t.NotEqual="!=",t.LessThan="<",t.GreaterThan=">",t.GreaterThanOrEqual=">=",t.LessThanOrEqual="<=",t.Contains="*",t.NotContains="!*",t.StartsWith="^",t.NotStartsWith="!^",t.EndsWith="$",t.NotEndsWith="!$"}(t||(t={})),(r=a||(a={})).And=",",r.Or="|";var n=e.S,s=e.F;export{n as ConditionalOperator,s as LogicalOperator};
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.GridifyQueryBuilder=t():e.GridifyQueryBuilder=t()}(this,(()=>(()=>{"use strict";var e,t,o,r={d:(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};return r.r(n),r.d(n,{ConditionalOperator:()=>e,LogicalOperator:()=>t}),function(e){e.Equal="=",e.NotEqual="!=",e.LessThan="<",e.GreaterThan=">",e.GreaterThanOrEqual=">=",e.LessThanOrEqual="<=",e.Contains="*",e.NotContains="!*",e.StartsWith="^",e.NotStartsWith="!^",e.EndsWith="$",e.NotEndsWith="!$"}(e||(e={})),(o=t||(t={})).And=",",o.Or="|",n})()));
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.2",
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/**/*"
package/README.md DELETED
@@ -1,59 +0,0 @@
1
- # Gridify (A Modern Dynamic LINQ library)
2
-
3
- ![GitHub](https://img.shields.io/github/license/alirezanet/gridify)
4
- ![Nuget](https://img.shields.io/nuget/dt/gridify?color=%239100ff)
5
- ![Nuget](https://img.shields.io/nuget/v/gridify?label=stable)
6
- ![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/gridify?label=latest)
7
- [![NuGet version (Gridify)](https://img.shields.io/nuget/v/Gridify.svg?style=flat-square)](https://www.nuget.org/packages/Gridify/)
8
- ![CodeQL](https://github.com/alirezanet/Gridify/actions/workflows/codeql.yml/badge.svg)
9
- [![Static Badge](https://img.shields.io/badge/fuget-f88445?logo=readme&logoColor=white)](https://www.fuget.org/packages/Gridify)
10
- [![Static Badge](https://img.shields.io/badge/Documentation-42bc00?logo=readme&logoColor=white)](https://alirezanet.github.io/Gridify/)
11
- [![Discord](https://img.shields.io/badge/Discord-Join%20our%20server-blue?style=flat-square&logo=discord)](https://discord.gg/jaSXnDMv)
12
-
13
-
14
-
15
-
16
- [![Gridify](https://raw.githubusercontent.com/alirezanet/Gridify/master/docs/.vuepress/public/gridify-readme-logo.svg)](https://alirezanet.github.io/Gridify/)
17
-
18
- ## Introduction
19
- Gridify is a dynamic LINQ library that simplifies the process of converting strings to LINQ queries. With exceptional performance and ease-of-use, Gridify makes it effortless to apply filtering, sorting, and pagination using text-based data.
20
-
21
- ## Features
22
-
23
- - Fast and easy to use
24
- - Supports filtering, sorting, and pagination
25
- - Supports `string` to LINQ conversion
26
- - Supports nested queries and sub-collections
27
- - Supports `string` to `object` mapping
28
- - Supports query compilation
29
- - Supports collection indexes
30
- - Custom Operators
31
- - Compatible with ORMs, especially Entity Framework
32
- - Can be used on every collection that LINQ supports
33
- - Compatible with object-mappers like AutoMapper
34
- - Compatible with Elasticsearch 🔥🔥
35
-
36
- ## Documentation
37
-
38
- Check out our docs at [https://alirezanet.github.io/Gridify/](https://alirezanet.github.io/Gridify/).
39
-
40
- ## Articles / Examples
41
- - [Using Gridify in the api controllers](https://alirezanet.github.io/Gridify/example/api-controller.html#using-gridify-in-api-controllers)
42
- - [Trabajando con filtros dinámicos usando Gridify en .NET](https://henriquemauri.net/trabalhando-com-filtros-dinamicos-utilizando-o-gridify-no-net/) by [@Henrique Mauri](https://github.com/hgmauri) (Spanish)
43
- - [<span dir="rtl" align="right">آشنایی با Gridify</span>](https://www.dntips.ir/post/3345/%d8%a2%d8%b4%d9%86%d8%a7%db%8c%db%8c-%d8%a8%d8%a7-gridify) (Persian)
44
- - Comming soon
45
-
46
- ## Want to support us?
47
-
48
- - Don't forget to give a ⭐ to this repo on GitHub!
49
- - Share your feedback and ideas to improve the library!
50
- - Share the library on your favorite social media and with your friends!
51
- - Help us to improve the documentation!
52
-
53
- ## Contribution
54
-
55
- We welcome contributions! Feel free to send us a pull request. Check out our [Contribution Page](https://alirezanet.github.io/Gridify/contribution) for more information.
56
-
57
- ## License
58
-
59
- This project is licensed under the [MIT License](https://github.com/alirezanet/gridify/blob/master/LICENSE).
@@ -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 });