Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gridify TS library (GridifyClient) #136

Merged
merged 26 commits into from
Nov 17, 2023
Merged

Gridify TS library (GridifyClient) #136

merged 26 commits into from
Nov 17, 2023

Conversation

alirezanet
Copy link
Owner

@alirezanet alirezanet commented Nov 10, 2023

Description

Fixes #129 (issue)

available here:
https://www.npmjs.com/package/gridify-client

npm i gridify-client 

Usage example:

  import { GridifyQueryBuilder, ConditionalOperator as op } from "gridify-client";
  const query = new GridifyQueryBuilder()
         .setPage(2)
         .setPageSize(10)
         .addOrderBy("name", true)
         .startGroup()
             .addCondition("age", op.LessThan, 50)
             .or()
             .addCondition("name", op.StartsWith, "A")
         .endGroup()
         .and()
         .addCondition("isActive", op.Equal, true)
         .build();

console.log(query);
// output:  
     {
         page: 2,
         pageSize: 10,
         orderBy: "name desc",
         filter: "(age<50|name^A),isActive=true",
      }

Test html file:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Gridify Client Test</title>
    <script>
      function testLibrary() {
        const op = GridifyClient.ConditionalOperator

        const query = new GridifyClient.GridifyQueryBuilder()
          .setPage(2)
          .setPageSize(10)
          .addOrderBy('name', true)
          .startGroup()
          .addCondition('age', op.LessThan, 50)
          .or()
          .addCondition('name', op.StartsWith, 'A')
          .endGroup()
          .and()
          .addCondition('isActive', op.Equal, true)
          .build()
        
        document.writeln(JSON.stringify(query))

        console.log(query)
      }
    </script>
  </head>
  <body>
    <h1>Gridify Client Test Page</h1>
    <script
      src="https://unpkg.com/[email protected]/dist/index.umd.js"
      onload="testLibrary()"
    ></script>
  </body>
</html>

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • I have made corresponding changes to the documentation
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes

Copy link

what-the-diff bot commented Nov 10, 2023

PR Summary

  • Setup Enhanced Testing Infrastructure
    The new file jest.config.js has been added to the repository to improve the testing structure of the codebase. This will set up the testing environment and specify which file types to test, thus augmenting the efficiency and accuracy of the testing process.

  • Added Project Manifest File
    The new package.json file has been introduced to handle project metadata and dependencies for the "gridify-client" project. It lists essential information like the main entry point for the application (index.js), the repository URL, author details, and the project's license. It also defines critical command scripts for building the project and running tests, as well as the development dependencies required. This file serves as a guide for anyone trying to understand the project's structure and dependencies.

  • New Enumeration to Define Comparison and Logical Operators
    The GridifyOperator.ts script has been added. It defines a list of comparison operators (like equal, not equal, less than, etc.) and logical operators (such as AND, OR) for conditional expressions in the code. These enumerated lists will make the code clearer and less prone to human error.

  • New Module for Query Building
    A new module, GridifyQueryBuilder.ts, provides functionality for building queries used in the project. It uses the defined operators and an interface for the possible parameter structures, identified as IGridifyQuery. This file contains classes and functions that transform user-provided parameters into SQL-like queries understood by the system.

  • Added Interface for Gridify Queries
    The IGridifyQuery.ts file introduces an interface for what a gridify query may look like, including attributes like page number, page size, order by, and filter conditions. It provides a structure for the parameters passed to the gridify query builder.

  • Testing Module for Gridify Query Builder
    The GridifyQueryBuilder.test.ts file has been added to test the functionalities of the Gridify Query Builder. It does not only verify the correct execution of code but also helps catch any unanticipated erroneous responses or bugs, ensuring the final output is as expected.

@alirezanet alirezanet changed the title Gridify JS library (GridifyClient) Gridify TS library (GridifyClient) Nov 10, 2023
@alirezanet alirezanet marked this pull request as ready for review November 12, 2023 16:28
@alirezanet alirezanet merged commit b6b5186 into master Nov 17, 2023
3 checks passed
@alirezanet alirezanet deleted the JsLib branch November 18, 2023 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JavaScript client library
1 participant