@gblikas/querykit 0.0.0
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/.cursor/BUGBOT.md +21 -0
- package/.cursor/rules/01-project-structure.mdc +77 -0
- package/.cursor/rules/02-typescript-standards.mdc +105 -0
- package/.cursor/rules/03-testing-standards.mdc +78 -0
- package/.cursor/rules/04-query-language.mdc +79 -0
- package/.cursor/rules/05-solid-principles.mdc +118 -0
- package/.cursor/rules/liqe-readme-docs.mdc +438 -0
- package/.devcontainer/devcontainer.json +25 -0
- package/.eslintignore +1 -0
- package/.eslintrc.js +39 -0
- package/.github/dependabot.yml +12 -0
- package/.github/workflows/ci.yml +114 -0
- package/.github/workflows/publish.yml +61 -0
- package/.husky/pre-commit +30 -0
- package/.prettierrc +10 -0
- package/CONTRIBUTING.md +187 -0
- package/LICENSE +674 -0
- package/README.md +237 -0
- package/dist/adapters/drizzle/index.d.ts +122 -0
- package/dist/adapters/drizzle/index.js +166 -0
- package/dist/adapters/index.d.ts +7 -0
- package/dist/adapters/index.js +25 -0
- package/dist/adapters/types.d.ts +60 -0
- package/dist/adapters/types.js +8 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.js +118 -0
- package/dist/parser/index.d.ts +2 -0
- package/dist/parser/index.js +18 -0
- package/dist/parser/parser.d.ts +51 -0
- package/dist/parser/parser.js +201 -0
- package/dist/parser/types.d.ts +68 -0
- package/dist/parser/types.js +5 -0
- package/dist/query/builder.d.ts +61 -0
- package/dist/query/builder.js +188 -0
- package/dist/query/index.d.ts +2 -0
- package/dist/query/index.js +18 -0
- package/dist/query/types.d.ts +79 -0
- package/dist/query/types.js +2 -0
- package/dist/security/index.d.ts +2 -0
- package/dist/security/index.js +18 -0
- package/dist/security/types.d.ts +181 -0
- package/dist/security/types.js +43 -0
- package/dist/security/validator.d.ts +191 -0
- package/dist/security/validator.js +344 -0
- package/dist/translators/drizzle/index.d.ts +73 -0
- package/dist/translators/drizzle/index.js +260 -0
- package/dist/translators/index.d.ts +8 -0
- package/dist/translators/index.js +27 -0
- package/dist/translators/sql/index.d.ts +108 -0
- package/dist/translators/sql/index.js +252 -0
- package/dist/translators/types.d.ts +39 -0
- package/dist/translators/types.js +8 -0
- package/examples/qk-next/README.md +35 -0
- package/examples/qk-next/app/favicon.ico +0 -0
- package/examples/qk-next/app/globals.css +122 -0
- package/examples/qk-next/app/layout.tsx +121 -0
- package/examples/qk-next/app/page.tsx +813 -0
- package/examples/qk-next/app/providers.tsx +80 -0
- package/examples/qk-next/components/aurora-background.tsx +12 -0
- package/examples/qk-next/components/github-stars.tsx +51 -0
- package/examples/qk-next/components/mode-toggle.tsx +27 -0
- package/examples/qk-next/components/reactbits/blocks/Backgrounds/Aurora/Aurora.tsx +217 -0
- package/examples/qk-next/components/reactbits/blocks/Backgrounds/LightRays/LightRays.tsx +474 -0
- package/examples/qk-next/components/theme-provider.tsx +11 -0
- package/examples/qk-next/components/ui/card.tsx +92 -0
- package/examples/qk-next/components/ui/command.tsx +184 -0
- package/examples/qk-next/components/ui/dialog.tsx +143 -0
- package/examples/qk-next/components/ui/drawer.tsx +135 -0
- package/examples/qk-next/components/ui/hover-card.tsx +44 -0
- package/examples/qk-next/components/ui/icons.tsx +148 -0
- package/examples/qk-next/components/ui/sonner.tsx +26 -0
- package/examples/qk-next/components/ui/table.tsx +117 -0
- package/examples/qk-next/components.json +21 -0
- package/examples/qk-next/eslint.config.mjs +21 -0
- package/examples/qk-next/jsrepo.json +13 -0
- package/examples/qk-next/lib/utils.ts +6 -0
- package/examples/qk-next/next.config.ts +8 -0
- package/examples/qk-next/package.json +48 -0
- package/examples/qk-next/pnpm-lock.yaml +5558 -0
- package/examples/qk-next/postcss.config.mjs +5 -0
- package/examples/qk-next/public/file.svg +1 -0
- package/examples/qk-next/public/globe.svg +1 -0
- package/examples/qk-next/public/next.svg +1 -0
- package/examples/qk-next/public/vercel.svg +1 -0
- package/examples/qk-next/public/window.svg +1 -0
- package/examples/qk-next/tsconfig.json +42 -0
- package/examples/qk-next/types/sonner.d.ts +3 -0
- package/jest.config.js +26 -0
- package/package.json +51 -0
- package/src/adapters/drizzle/drizzle-adapter.test.ts +115 -0
- package/src/adapters/drizzle/index.ts +299 -0
- package/src/adapters/index.ts +11 -0
- package/src/adapters/types.ts +72 -0
- package/src/index.ts +194 -0
- package/src/integration.test.ts +202 -0
- package/src/parser/index.ts +2 -0
- package/src/parser/parser.test.ts +1056 -0
- package/src/parser/parser.ts +268 -0
- package/src/parser/types.ts +97 -0
- package/src/query/builder.test.ts +272 -0
- package/src/query/builder.ts +274 -0
- package/src/query/index.ts +2 -0
- package/src/query/types.ts +107 -0
- package/src/security/index.ts +2 -0
- package/src/security/types.ts +210 -0
- package/src/security/validator.test.ts +459 -0
- package/src/security/validator.ts +395 -0
- package/src/security.test.ts +366 -0
- package/src/translators/drizzle/drizzle-translator.test.ts +128 -0
- package/src/translators/drizzle/index.test.ts +45 -0
- package/src/translators/drizzle/index.ts +346 -0
- package/src/translators/index.ts +14 -0
- package/src/translators/sql/index.test.ts +45 -0
- package/src/translators/sql/index.ts +331 -0
- package/src/translators/sql/sql-translator.test.ts +419 -0
- package/src/translators/types.ts +44 -0
- package/src/types/sonner.d.ts +3 -0
- package/tsconfig.json +34 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
. "$(dirname -- "$0")/_/husky.sh"
|
|
3
|
+
|
|
4
|
+
# Check if SKIP_TESTS is set to true
|
|
5
|
+
if [ "$SKIP_TESTS" = "true" ]; then
|
|
6
|
+
echo "⚠️ Skipping tests due to SKIP_TESTS=true"
|
|
7
|
+
echo "⚠️ This should only be used for emergency fixes!"
|
|
8
|
+
RUN_TESTS=false
|
|
9
|
+
else
|
|
10
|
+
RUN_TESTS=true
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
echo "Running pre-commit checks..."
|
|
14
|
+
|
|
15
|
+
# Run lint-staged to process only changed files
|
|
16
|
+
echo "🔍 Running lint-staged..."
|
|
17
|
+
pnpm lint-staged || { echo "❌ Linting failed"; exit 1; }
|
|
18
|
+
|
|
19
|
+
# Check TypeScript compilation
|
|
20
|
+
echo "🔍 Checking TypeScript compilation..."
|
|
21
|
+
pnpm exec tsc --noEmit || { echo "❌ TypeScript check failed"; exit 1; }
|
|
22
|
+
|
|
23
|
+
# Run tests
|
|
24
|
+
if [ "$RUN_TESTS" = "true" ]; then
|
|
25
|
+
echo "🧪 Running tests..."
|
|
26
|
+
pnpm test || { echo "❌ Tests failed"; exit 1; }
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
# If everything passes, allow the commit
|
|
30
|
+
echo "✅ Pre-commit checks passed!"
|
package/.prettierrc
ADDED
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Contributing to QueryKit
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to QueryKit! This document provides guidelines and instructions for contributing to the project.
|
|
4
|
+
|
|
5
|
+
## Code of Conduct
|
|
6
|
+
|
|
7
|
+
Please read and follow our [Code of Conduct](CODE_OF_CONDUCT.md) to maintain a respectful and inclusive environment for everyone.
|
|
8
|
+
|
|
9
|
+
## Getting Started
|
|
10
|
+
|
|
11
|
+
1. **Fork the repository** and clone it locally
|
|
12
|
+
2. **Install dependencies** with `npm install`
|
|
13
|
+
3. **Create a branch** for your contribution
|
|
14
|
+
4. **Make your changes**
|
|
15
|
+
5. **Run tests** to ensure everything works
|
|
16
|
+
6. **Submit a pull request**
|
|
17
|
+
|
|
18
|
+
## Project Structure
|
|
19
|
+
|
|
20
|
+
QueryKit is organized into several key components:
|
|
21
|
+
|
|
22
|
+
- **Parser** (`src/parser`): Core query parsing engine that converts DSL expressions into structured internal format (AST)
|
|
23
|
+
- Lexical analyzer
|
|
24
|
+
- Syntax parser
|
|
25
|
+
- AST type definitions
|
|
26
|
+
- Validation logic
|
|
27
|
+
- Integrates with [Liqe](https://github.com/gajus/liqe) for Lucene-like query parsing
|
|
28
|
+
|
|
29
|
+
- **Translators** (`src/translators`): Convert parsed queries into target-specific formats
|
|
30
|
+
- SQL translator (for Drizzle)
|
|
31
|
+
- JavaScript translator (for in-memory filtering)
|
|
32
|
+
- Each translator implements the standard translator interface
|
|
33
|
+
|
|
34
|
+
- **Adapters** (`src/adapters`): Connect QueryKit to external systems
|
|
35
|
+
- Drizzle ORM adapter
|
|
36
|
+
- In-memory filtering adapter
|
|
37
|
+
- Each adapter implements the standard adapter interface
|
|
38
|
+
|
|
39
|
+
- **CLI** (`src/cli`): Command-line interface for testing and debugging
|
|
40
|
+
- Query parsing/testing tools
|
|
41
|
+
- Query translation debugging
|
|
42
|
+
- Code generation utilities
|
|
43
|
+
|
|
44
|
+
- **Frontend Utilities** (`src/frontend`): Browser-specific implementations
|
|
45
|
+
- Query builder components
|
|
46
|
+
- Client-side filtering utilities
|
|
47
|
+
- Browser-optimized parsing
|
|
48
|
+
|
|
49
|
+
- **Server Helpers** (`src/server`): Server-side integration utilities
|
|
50
|
+
- Middleware for Express/Fastify
|
|
51
|
+
- Request parsing helpers
|
|
52
|
+
- Database integration utilities
|
|
53
|
+
|
|
54
|
+
- **Common** (`src/common`): Shared utilities and types
|
|
55
|
+
|
|
56
|
+
## Key Dependencies
|
|
57
|
+
|
|
58
|
+
When contributing to QueryKit, you should be familiar with these key dependencies:
|
|
59
|
+
|
|
60
|
+
- **[Liqe](https://github.com/gajus/liqe)**: A Lucene-like parser that we use for parsing the query syntax. Rather than implementing our own parser from scratch, we'll leverage Liqe's capabilities to parse queries into an abstract syntax tree (AST) that our translators can then work with.
|
|
61
|
+
|
|
62
|
+
- **[Drizzle ORM](https://github.com/drizzle-team/drizzle-orm)**: The TypeScript ORM we integrate with for SQL database operations. Contributions to the Drizzle adapter should be familiar with how Drizzle ORM works.
|
|
63
|
+
|
|
64
|
+
## Development Workflow
|
|
65
|
+
|
|
66
|
+
1. **Choose an issue** from the issue tracker or propose a new feature
|
|
67
|
+
2. **Discuss** major changes in issues before implementation
|
|
68
|
+
3. **Follow coding standards** as outlined below
|
|
69
|
+
4. **Write tests** for your changes
|
|
70
|
+
5. **Update documentation** if necessary
|
|
71
|
+
6. **Submit a PR** with a clear description of changes
|
|
72
|
+
|
|
73
|
+
## Coding Standards
|
|
74
|
+
|
|
75
|
+
### TypeScript Guidelines
|
|
76
|
+
|
|
77
|
+
1. Use English for all code and documentation
|
|
78
|
+
2. Always declare explicit types
|
|
79
|
+
3. Document public APIs with JSDoc
|
|
80
|
+
4. One export per file when possible
|
|
81
|
+
5. Follow SOLID principles
|
|
82
|
+
|
|
83
|
+
### Naming Conventions
|
|
84
|
+
|
|
85
|
+
- `PascalCase` for classes, interfaces, type aliases, and enums
|
|
86
|
+
- `camelCase` for variables, functions, methods, and properties
|
|
87
|
+
- `kebab-case` for file names and directory names
|
|
88
|
+
- `UPPERCASE` for constants and environment variables
|
|
89
|
+
- `I` prefix for interfaces (e.g., `ITranslator`)
|
|
90
|
+
|
|
91
|
+
### Function Guidelines
|
|
92
|
+
|
|
93
|
+
1. Keep functions short (< 20 instructions)
|
|
94
|
+
2. Follow single responsibility principle
|
|
95
|
+
3. Use early returns to avoid nesting
|
|
96
|
+
4. Prefer higher-order functions
|
|
97
|
+
5. Use default parameters instead of null checks
|
|
98
|
+
|
|
99
|
+
## Testing
|
|
100
|
+
|
|
101
|
+
### Test Organization
|
|
102
|
+
|
|
103
|
+
1. Co-locate tests with source files
|
|
104
|
+
2. Use descriptive test file names: `[feature].test.ts` or `[feature].spec.ts`
|
|
105
|
+
3. Group related tests in describe blocks
|
|
106
|
+
4. Use clear test case descriptions
|
|
107
|
+
|
|
108
|
+
### Test Coverage Requirements
|
|
109
|
+
|
|
110
|
+
- Public APIs: 100% coverage
|
|
111
|
+
- Internal implementation: 80% coverage
|
|
112
|
+
- Test both success and failure cases
|
|
113
|
+
- Include edge cases
|
|
114
|
+
|
|
115
|
+
## Pull Request Process
|
|
116
|
+
|
|
117
|
+
1. Ensure all tests pass
|
|
118
|
+
2. Update documentation if needed
|
|
119
|
+
3. Link related issues
|
|
120
|
+
4. Wait for code review
|
|
121
|
+
5. Address feedback and requested changes
|
|
122
|
+
6. Once approved, a maintainer will merge your PR
|
|
123
|
+
|
|
124
|
+
## Query Language Design
|
|
125
|
+
|
|
126
|
+
When working on query language features, follow these principles:
|
|
127
|
+
|
|
128
|
+
1. Syntax should be readable and intuitive (OData/Lucene-inspired)
|
|
129
|
+
2. Support basic comparison operators: `==`, `!=`, `>`, `>=`, `<`, `<=`
|
|
130
|
+
3. Support logical operators: `&&`, `||`, `!`
|
|
131
|
+
4. Support complex operations: string matching, array operations, nested property access
|
|
132
|
+
5. Ensure consistent behavior across environments
|
|
133
|
+
6. Prioritize type safety
|
|
134
|
+
7. Design for extensibility
|
|
135
|
+
|
|
136
|
+
## Using Liqe for Query Parsing
|
|
137
|
+
|
|
138
|
+
For the query parsing capabilities of QueryKit, we're using [Liqe](https://github.com/gajus/liqe) as our foundation. When working with this aspect of the codebase:
|
|
139
|
+
|
|
140
|
+
1. Learn the Liqe API and AST structure before making changes
|
|
141
|
+
2. When extending the parser, ensure compatibility with Liqe's existing functionality
|
|
142
|
+
3. Write comprehensive tests for any modifications to the parsing logic
|
|
143
|
+
4. Consider the performance implications of your changes, as parsing is a critical path
|
|
144
|
+
5. Document any extensions or modifications to the standard Liqe syntax
|
|
145
|
+
|
|
146
|
+
Example of using Liqe in QueryKit:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { parse, filter } from 'liqe';
|
|
150
|
+
|
|
151
|
+
// Parse a query string into an AST
|
|
152
|
+
const ast = parse('title:"Meeting notes" AND priority:>2');
|
|
153
|
+
|
|
154
|
+
// Use the AST with our translator or directly with Liqe's filter
|
|
155
|
+
const results = filter(ast, dataCollection);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Roadmap and Future Goals
|
|
159
|
+
|
|
160
|
+
We're currently focusing on:
|
|
161
|
+
|
|
162
|
+
### Core Parsing Engine and DSL
|
|
163
|
+
- [ ] Implementing Lucene-style query syntax parser using Liqe
|
|
164
|
+
- [ ] Creating an internal AST representation
|
|
165
|
+
- [ ] Developing a type-safe query building API
|
|
166
|
+
- [ ] Adding comprehensive validation
|
|
167
|
+
|
|
168
|
+
### First Adapters
|
|
169
|
+
- [ ] Drizzle ORM integration
|
|
170
|
+
- [ ] In-memory JavaScript filtering
|
|
171
|
+
- [ ] Error handling and validation
|
|
172
|
+
|
|
173
|
+
### Advanced Features
|
|
174
|
+
- [ ] CLI tools for testing and debugging queries
|
|
175
|
+
- [ ] Performance optimizations for large queries
|
|
176
|
+
- [ ] Support for complex operators and functions
|
|
177
|
+
- [ ] Query composition utilities
|
|
178
|
+
|
|
179
|
+
### Ecosystem Expansion
|
|
180
|
+
- [ ] Frontend query builder components
|
|
181
|
+
- [ ] Additional ORM adapters
|
|
182
|
+
- [ ] Server middleware for Express/Fastify
|
|
183
|
+
- [ ] Documentation and examples
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
By contributing to QueryKit, you agree that your contributions will be licensed under the same [MIT License](LICENSE) that covers the project.
|