tsledge 0.1.8 → 0.1.9
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/LICENSE +1 -1
- package/dist/fluent-interface/fluent-pattern-handler.d.ts +7 -8
- package/dist/fluent-interface/fluent-pattern-handler.d.ts.map +1 -1
- package/dist/fluent-interface/types.d.ts +7 -2
- package/dist/fluent-interface/types.d.ts.map +1 -1
- package/dist/index.js +8 -9
- package/dist/src/index.js +8 -9
- package/dist/tests/main.js +13 -10
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PromiseDefaultCodec
|
|
1
|
+
import { FluentAPIOption, FluentMiddleware, FluentExecParams } from './types';
|
|
2
|
+
import { PromiseDefaultCodec } from '../core/index';
|
|
3
3
|
export declare class FluentPatternHandler {
|
|
4
4
|
private static _singleton;
|
|
5
5
|
private _options;
|
|
@@ -8,13 +8,13 @@ export declare class FluentPatternHandler {
|
|
|
8
8
|
* Constructor for QueryPatternExecutor.
|
|
9
9
|
* @param options - Array of query pattern options for filtering.
|
|
10
10
|
*/
|
|
11
|
-
constructor(options?:
|
|
11
|
+
constructor(options?: FluentAPIOption[], execMiddleware?: FluentMiddleware[]);
|
|
12
12
|
/**
|
|
13
13
|
* Initializes the singleton instance of FluentPatternHandler with the provided options.
|
|
14
14
|
* @param options - Array of query pattern options for filtering.
|
|
15
15
|
* @returns Singleton instance of FluentPatternHandler.
|
|
16
16
|
*/
|
|
17
|
-
static init(options?:
|
|
17
|
+
static init(options?: FluentAPIOption[], execMiddleware?: FluentMiddleware[]): FluentPatternHandler;
|
|
18
18
|
/**
|
|
19
19
|
* Returns the singleton instance of FluentPatternHandler.
|
|
20
20
|
* @returns Singleton instance of FluentPatternHandler.
|
|
@@ -46,11 +46,10 @@ export declare class FluentPatternHandler {
|
|
|
46
46
|
*/
|
|
47
47
|
private _buildExecutionConfig;
|
|
48
48
|
/**
|
|
49
|
-
* Executes the query builder with
|
|
50
|
-
* @param
|
|
51
|
-
* @param queryBuilder
|
|
49
|
+
* Executes the query builder with applied filters and returns the result.
|
|
50
|
+
* @param params Execution parameters including the query builder and request query.
|
|
52
51
|
* @returns
|
|
53
52
|
*/
|
|
54
|
-
exec<T = any>(
|
|
53
|
+
exec<T = any>(params: FluentExecParams): PromiseDefaultCodec;
|
|
55
54
|
}
|
|
56
55
|
//# sourceMappingURL=fluent-pattern-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluent-pattern-handler.d.ts","sourceRoot":"","sources":["../../src/fluent-interface/fluent-pattern-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,
|
|
1
|
+
{"version":3,"file":"fluent-pattern-handler.d.ts","sourceRoot":"","sources":["../../src/fluent-interface/fluent-pattern-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,EAEf,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAA8B,mBAAmB,EAAgB,MAAM,eAAe,CAAC;AAY9F,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAuB;IAChD,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,wBAAwB,CAA0B;IAE1D;;;OAGG;gBACS,OAAO,GAAE,eAAe,EAAO,EAAE,cAAc,GAAE,gBAAgB,EAAO;IAWpF;;;;OAIG;WACW,IAAI,CAChB,OAAO,GAAE,eAAe,EAAO,EAC/B,cAAc,GAAE,gBAAgB,EAAO,GACtC,oBAAoB;IAQvB;;;OAGG;WACW,WAAW,IAAI,oBAAoB;IASjD;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAsChC;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAoCxB;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAYhC;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAa/B;;;;OAIG;IACY,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,gBAAgB,GAAG,mBAAmB;CAgB1E"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { DefaultResponseBody, KeysEnum, QueryBuilder } from '../core/index';
|
|
4
|
-
export type FluentMiddleware = (queryBuilder: QueryBuilder) => void;
|
|
5
4
|
export interface FluentRequestParams extends Record<string, string> {
|
|
6
5
|
collection: string;
|
|
7
6
|
}
|
|
@@ -20,10 +19,16 @@ export interface FluentRequestQuery {
|
|
|
20
19
|
* Attributes of FluentRequestQuery used for validation and parsing.
|
|
21
20
|
*/
|
|
22
21
|
export declare const fluentRequestQueryAttributes: KeysEnum<FluentRequestQuery>;
|
|
23
|
-
export interface
|
|
22
|
+
export interface FluentAPIOption<T = any> {
|
|
24
23
|
model: mongoose.Model<T>;
|
|
25
24
|
filters?: string[];
|
|
26
25
|
}
|
|
27
26
|
export type FluentExpressRequest = Request<FluentRequestParams, DefaultResponseBody, FluentRequestBody, FluentRequestQuery>;
|
|
28
27
|
export type FluentExpressResponse = Response<DefaultResponseBody>;
|
|
28
|
+
export type FluentExecParams = {
|
|
29
|
+
req: FluentExpressRequest;
|
|
30
|
+
res: FluentExpressResponse;
|
|
31
|
+
queryBuilder: QueryBuilder;
|
|
32
|
+
};
|
|
33
|
+
export type FluentMiddleware = (params: FluentExecParams) => void;
|
|
29
34
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/fluent-interface/types.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE5E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C5B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -950,22 +950,21 @@ var FluentPatternHandler = class _FluentPatternHandler {
|
|
|
950
950
|
};
|
|
951
951
|
}
|
|
952
952
|
/**
|
|
953
|
-
* Executes the query builder with
|
|
954
|
-
* @param
|
|
955
|
-
* @
|
|
956
|
-
* @returns
|
|
953
|
+
* Executes the query builder with applied filters and returns the result.
|
|
954
|
+
* @param params Execution parameters including the query builder and request query.
|
|
955
|
+
* @returns
|
|
957
956
|
*/
|
|
958
|
-
async exec(
|
|
957
|
+
async exec(params) {
|
|
959
958
|
try {
|
|
960
959
|
if (this._execMiddlewareFunctions && this._execMiddlewareFunctions.length > 0) {
|
|
961
960
|
this._execMiddlewareFunctions.forEach((func) => {
|
|
962
|
-
func(
|
|
961
|
+
func(params);
|
|
963
962
|
});
|
|
964
963
|
}
|
|
965
|
-
const queryParams = this._parseFluentRequestQuery(req.query);
|
|
966
|
-
this._applyParameters(queryBuilder, queryParams);
|
|
964
|
+
const queryParams = this._parseFluentRequestQuery(params.req.query);
|
|
965
|
+
this._applyParameters(params.queryBuilder, queryParams);
|
|
967
966
|
const execConfig = this._buildExecutionConfig(queryParams);
|
|
968
|
-
return await queryBuilder.exec(execConfig);
|
|
967
|
+
return await params.queryBuilder.exec(execConfig);
|
|
969
968
|
} catch (err) {
|
|
970
969
|
console.error("[ERROR - QueryPatternExecutor]", err);
|
|
971
970
|
return new Codec({ data: [], meta: { total: 0 } }, 500);
|
package/dist/src/index.js
CHANGED
|
@@ -950,22 +950,21 @@ var FluentPatternHandler = class _FluentPatternHandler {
|
|
|
950
950
|
};
|
|
951
951
|
}
|
|
952
952
|
/**
|
|
953
|
-
* Executes the query builder with
|
|
954
|
-
* @param
|
|
955
|
-
* @
|
|
956
|
-
* @returns
|
|
953
|
+
* Executes the query builder with applied filters and returns the result.
|
|
954
|
+
* @param params Execution parameters including the query builder and request query.
|
|
955
|
+
* @returns
|
|
957
956
|
*/
|
|
958
|
-
async exec(
|
|
957
|
+
async exec(params) {
|
|
959
958
|
try {
|
|
960
959
|
if (this._execMiddlewareFunctions && this._execMiddlewareFunctions.length > 0) {
|
|
961
960
|
this._execMiddlewareFunctions.forEach((func) => {
|
|
962
|
-
func(
|
|
961
|
+
func(params);
|
|
963
962
|
});
|
|
964
963
|
}
|
|
965
|
-
const queryParams = this._parseFluentRequestQuery(req.query);
|
|
966
|
-
this._applyParameters(queryBuilder, queryParams);
|
|
964
|
+
const queryParams = this._parseFluentRequestQuery(params.req.query);
|
|
965
|
+
this._applyParameters(params.queryBuilder, queryParams);
|
|
967
966
|
const execConfig = this._buildExecutionConfig(queryParams);
|
|
968
|
-
return await queryBuilder.exec(execConfig);
|
|
967
|
+
return await params.queryBuilder.exec(execConfig);
|
|
969
968
|
} catch (err) {
|
|
970
969
|
console.error("[ERROR - QueryPatternExecutor]", err);
|
|
971
970
|
return new Codec({ data: [], meta: { total: 0 } }, 500);
|
package/dist/tests/main.js
CHANGED
|
@@ -786,22 +786,21 @@ var FluentPatternHandler = class _FluentPatternHandler {
|
|
|
786
786
|
};
|
|
787
787
|
}
|
|
788
788
|
/**
|
|
789
|
-
* Executes the query builder with
|
|
790
|
-
* @param
|
|
791
|
-
* @
|
|
792
|
-
* @returns
|
|
789
|
+
* Executes the query builder with applied filters and returns the result.
|
|
790
|
+
* @param params Execution parameters including the query builder and request query.
|
|
791
|
+
* @returns
|
|
793
792
|
*/
|
|
794
|
-
async exec(
|
|
793
|
+
async exec(params) {
|
|
795
794
|
try {
|
|
796
795
|
if (this._execMiddlewareFunctions && this._execMiddlewareFunctions.length > 0) {
|
|
797
796
|
this._execMiddlewareFunctions.forEach((func) => {
|
|
798
|
-
func(
|
|
797
|
+
func(params);
|
|
799
798
|
});
|
|
800
799
|
}
|
|
801
|
-
const queryParams = this._parseFluentRequestQuery(req.query);
|
|
802
|
-
this._applyParameters(queryBuilder, queryParams);
|
|
800
|
+
const queryParams = this._parseFluentRequestQuery(params.req.query);
|
|
801
|
+
this._applyParameters(params.queryBuilder, queryParams);
|
|
803
802
|
const execConfig = this._buildExecutionConfig(queryParams);
|
|
804
|
-
return await queryBuilder.exec(execConfig);
|
|
803
|
+
return await params.queryBuilder.exec(execConfig);
|
|
805
804
|
} catch (err) {
|
|
806
805
|
console.error("[ERROR - QueryPatternExecutor]", err);
|
|
807
806
|
return new Codec({ data: [], meta: { total: 0 } }, 500);
|
|
@@ -882,7 +881,11 @@ router2.get(
|
|
|
882
881
|
let queryBuilder = new QueryBuilder({
|
|
883
882
|
model
|
|
884
883
|
});
|
|
885
|
-
let codec = await FluentPatternHandler.getInstance().exec(
|
|
884
|
+
let codec = await FluentPatternHandler.getInstance().exec({
|
|
885
|
+
req,
|
|
886
|
+
res,
|
|
887
|
+
queryBuilder
|
|
888
|
+
});
|
|
886
889
|
codec.sendToClient(res);
|
|
887
890
|
} catch (e) {
|
|
888
891
|
console.log(e);
|
package/package.json
CHANGED