crud-query-parser 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,31 @@
1
+ import { c as CrudRequest } from './crud-request-CvDKp6Iy.mjs';
2
+
3
+ interface OpenAPIParameter {
4
+ name: string;
5
+ description?: string;
6
+ required?: boolean;
7
+ schema?: OpenAPISchema;
8
+ style?: string;
9
+ explode?: boolean;
10
+ }
11
+ interface OpenAPISchema {
12
+ type: string;
13
+ default?: string;
14
+ items?: OpenAPISchema;
15
+ }
16
+
17
+ type RequestParamValue = string | string[] | undefined;
18
+ interface RequestParser {
19
+ /**
20
+ * Parses a query string into a parsed request object
21
+ *
22
+ * @param query The query string map
23
+ */
24
+ parse(query: Record<string, RequestParamValue>): CrudRequest;
25
+ /**
26
+ * Gets the OpenAPI query parameters documentation
27
+ */
28
+ getOpenAPIParameters(): OpenAPIParameter[];
29
+ }
30
+
31
+ export type { OpenAPIParameter as O, RequestParamValue as R, RequestParser as a };
package/package.json CHANGED
@@ -1,18 +1,33 @@
1
1
  {
2
2
  "name": "crud-query-parser",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Parses HTTP requests and converts them into database queries",
5
+ "keywords": [
6
+ "crud",
7
+ "http",
8
+ "query",
9
+ "request",
10
+ "parser",
11
+ "typeorm",
12
+ "nestjs"
13
+ ],
5
14
  "license": "MIT",
6
15
  "author": "Guilherme Chaguri",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/Guichaguri/crud-query-parser.git"
19
+ },
7
20
  "scripts": {
8
21
  "build": "tsup",
9
- "prepublishOnly": "npm run build"
22
+ "prepublishOnly": "npm run build",
23
+ "sample:typeorm": "ts-node ./samples/typeorm/index.ts"
10
24
  },
11
25
  "tsup": {
12
26
  "entry": [
13
27
  "src/index.ts",
14
28
  "src/adapters/typeorm/index.ts",
15
29
  "src/parsers/crud/index.ts",
30
+ "src/helpers/nestjs/index.ts",
16
31
  "src/filters/index.ts"
17
32
  ],
18
33
  "target": "es2022",
@@ -67,6 +82,16 @@
67
82
  "types": "./dist/parsers/crud/index.d.ts"
68
83
  }
69
84
  },
85
+ "./helpers/nestjs": {
86
+ "import": {
87
+ "default": "./dist/helpers/nestjs/index.mjs",
88
+ "types": "./dist/helpers/nestjs/index.d.mts"
89
+ },
90
+ "require": {
91
+ "default": "./dist/helpers/nestjs/index.js",
92
+ "types": "./dist/helpers/nestjs/index.d.ts"
93
+ }
94
+ },
70
95
  "./filters": {
71
96
  "import": {
72
97
  "default": "./dist/filters/index.mjs",
@@ -100,6 +125,7 @@
100
125
  "@types/node": "^17.0.23",
101
126
  "reflect-metadata": "^0.2.2",
102
127
  "sqlite3": "^5.1.7",
128
+ "ts-node": "^10.9.2",
103
129
  "tsup": "^8.1.0",
104
130
  "typeorm": "^0.3.20",
105
131
  "typescript": "^5.5.2"
@@ -1,42 +0,0 @@
1
- import { c as CrudRequest, e as CrudRequestWhereAND, f as CrudRequestWhereOR, i as CrudRequestWhereOperator, h as CrudRequestWhereValueType, d as CrudRequestWhere } from './crud-request-CvDKp6Iy.js';
2
-
3
- type RequestParamValue = string | string[] | undefined;
4
- interface RequestParser {
5
- /**
6
- * Parses a query string into a parsed request object
7
- *
8
- * @param query The query string map
9
- */
10
- parse(query: Record<string, RequestParamValue>): CrudRequest;
11
- }
12
-
13
- /**
14
- * A helper class that makes it easier to create a CrudRequestWhere
15
- */
16
- declare class ParsedRequestWhereBuilder {
17
- private readonly where;
18
- private readonly parent?;
19
- constructor(where?: CrudRequestWhereAND | CrudRequestWhereOR, parent?: ParsedRequestWhereBuilder | undefined);
20
- /**
21
- * Adds an AND bracket
22
- */
23
- addAnd(): ParsedRequestWhereBuilder;
24
- /**
25
- * Adds an OR bracket
26
- */
27
- addOr(): ParsedRequestWhereBuilder;
28
- /**
29
- * Adds a field comparison
30
- *
31
- * @param field The field path
32
- * @param operator The comparison operator
33
- * @param value The value to compare
34
- */
35
- addField(field: string[], operator: CrudRequestWhereOperator, value: CrudRequestWhereValueType): ParsedRequestWhereBuilder;
36
- /**
37
- * Constructs the final where condition
38
- */
39
- build(): CrudRequestWhere;
40
- }
41
-
42
- export { ParsedRequestWhereBuilder as P, type RequestParamValue as R, type RequestParser as a };
@@ -1,42 +0,0 @@
1
- import { c as CrudRequest, e as CrudRequestWhereAND, f as CrudRequestWhereOR, i as CrudRequestWhereOperator, h as CrudRequestWhereValueType, d as CrudRequestWhere } from './crud-request-CvDKp6Iy.mjs';
2
-
3
- type RequestParamValue = string | string[] | undefined;
4
- interface RequestParser {
5
- /**
6
- * Parses a query string into a parsed request object
7
- *
8
- * @param query The query string map
9
- */
10
- parse(query: Record<string, RequestParamValue>): CrudRequest;
11
- }
12
-
13
- /**
14
- * A helper class that makes it easier to create a CrudRequestWhere
15
- */
16
- declare class ParsedRequestWhereBuilder {
17
- private readonly where;
18
- private readonly parent?;
19
- constructor(where?: CrudRequestWhereAND | CrudRequestWhereOR, parent?: ParsedRequestWhereBuilder | undefined);
20
- /**
21
- * Adds an AND bracket
22
- */
23
- addAnd(): ParsedRequestWhereBuilder;
24
- /**
25
- * Adds an OR bracket
26
- */
27
- addOr(): ParsedRequestWhereBuilder;
28
- /**
29
- * Adds a field comparison
30
- *
31
- * @param field The field path
32
- * @param operator The comparison operator
33
- * @param value The value to compare
34
- */
35
- addField(field: string[], operator: CrudRequestWhereOperator, value: CrudRequestWhereValueType): ParsedRequestWhereBuilder;
36
- /**
37
- * Constructs the final where condition
38
- */
39
- build(): CrudRequestWhere;
40
- }
41
-
42
- export { ParsedRequestWhereBuilder as P, type RequestParamValue as R, type RequestParser as a };