Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added applyQueryParseOutput function + issue templates
- Loading branch information
Showing
12 changed files
with
143 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
name: 🚨 Bug report | ||
about: Report a bug report, to improve this project. | ||
title: 'Bug: ' | ||
labels: 'bug-report' | ||
assignees: '' | ||
|
||
--- | ||
|
||
<!-- 💚 Thanks for your time to make this project better with your feedback 💚 | ||
**IMPORTANT** Before reporting a bug: | ||
👍 A properly detailed bug report can save a LOT of time and help fixing issues as soon as possible. | ||
--> | ||
|
||
### Versions | ||
- Node: <!-- e.g. Node 16 --> | ||
- OS: <!-- e.g. Windows 99> --> | ||
|
||
### Reproduction | ||
|
||
<details open> | ||
<summary>Additional Details</summary> | ||
</details> | ||
|
||
### Steps to reproduce | ||
|
||
|
||
### What is Expected? | ||
|
||
|
||
### What is actually happening? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
blank_issues_enabled: false | ||
contact_links: | ||
- name: ❗️ All other issues | ||
url: https://github.com/PHT-Medic/central-ui/discussions | ||
about: | | ||
Please use GitHub Discussions for other issues and asking questions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
name: 🧠 Feature request | ||
about: Suggest an idea or enhancement for this project | ||
title: 'Feature: ' | ||
labels: 'feature-request' | ||
assignees: '' | ||
|
||
--- | ||
|
||
<!-- 💚 Thanks for your time to make this project better with your feedback 💚 --> | ||
|
||
### Is your feature request related to a problem? Please describe. | ||
|
||
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] --> | ||
|
||
### Describe the solution you'd like | ||
|
||
<!-- A clear and concise description of what you want to happen. Adding some code examples would be neat! --> | ||
|
||
### Describe alternatives you've considered | ||
|
||
<!-- A clear and concise description of any alternative solutions or features you've considered. --> | ||
|
||
### Additional context | ||
|
||
<!-- Add any other context or screenshots about the feature request here. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Security Policy | ||
## Reporting a Vulnerability | ||
|
||
If you discover a security vulnerability regarding this project, please e-mail me to contact@tada5hi.net! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './parameter'; | ||
export * from './utils'; | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {Parameter, ParameterType, ParseOutput} from "@trapi/query"; | ||
|
||
import { | ||
applyQueryFieldsParseOutput, | ||
applyQueryPaginationParseOutput, | ||
applyQueryRelationsParseOutput, | ||
applyQueryFiltersParseOutput | ||
} from "./parameter"; | ||
|
||
import {SelectQueryBuilder} from "typeorm"; | ||
|
||
export function applyQueryParseOutput<T>( | ||
query: SelectQueryBuilder<T>, | ||
context: ParseOutput | ||
) : ParseOutput { | ||
for(const key in context) { | ||
switch (key as ParameterType) { | ||
case Parameter.FIELDS: | ||
applyQueryFieldsParseOutput(query, context.fields); | ||
break; | ||
case Parameter.FILTERS: | ||
applyQueryFiltersParseOutput(query, context.filters); | ||
break; | ||
case Parameter.PAGINATION: | ||
applyQueryPaginationParseOutput(query, context.pagination); | ||
break; | ||
case Parameter.RELATIONS: | ||
applyQueryRelationsParseOutput(query, context.relations); | ||
break; | ||
case Parameter.SORT: | ||
applyQueryRelationsParseOutput(query, context.sort); | ||
break; | ||
} | ||
} | ||
|
||
return context; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {FakeSelectQueryBuilder} from "../../data/typeorm/FakeSelectQueryBuilder"; | ||
import {applyQueryParseOutput} from "../../../src"; | ||
|
||
describe('src/api/sort.ts', () => { | ||
const query = new FakeSelectQueryBuilder(); | ||
|
||
it('should apply query output', () => { | ||
const data = applyQueryParseOutput(query, { | ||
relations: [], | ||
fields: [], | ||
filters: [], | ||
pagination: {}, | ||
sort: [] | ||
}); | ||
|
||
expect(data).toEqual({ | ||
relations: [], | ||
fields: [], | ||
filters: [], | ||
pagination: {}, | ||
sort: [] | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters