tsledge 0.1.30 → 0.1.31

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/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "email": "wockenfussnik@gmail.com",
5
5
  "homepage": "https://github.com/NiklasDerEchte/TSledge/",
6
6
  "name": "tsledge",
7
- "version": "0.1.30",
7
+ "version": "0.1.31",
8
8
  "license": "MIT",
9
9
  "funding": [
10
10
  {
@@ -1,15 +0,0 @@
1
- import { HTTPRequestConfig } from './types';
2
- /**
3
- * Converts an object to a URL-encoded string for form submission.
4
- * With content type application/x-www-form-urlencoded, the body should be a string in the format of key=value&key2=value2.
5
- * @param obj
6
- * @returns
7
- */
8
- export declare function formDataParser(obj: Record<string, any>): string;
9
- /**
10
- * Executes the HTTP request using axios or fetch as fallback
11
- * @param config RequestConfig
12
- * @returns Promise<T> The response data
13
- */
14
- export declare function httpRequest<T = any>(config: HTTPRequestConfig): Promise<T>;
15
- //# sourceMappingURL=http.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/core/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAE/D;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAgEhF"}
@@ -1,4 +0,0 @@
1
- export * from './query-builder';
2
- export * from './types';
3
- export * from './http';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
@@ -1,96 +0,0 @@
1
- import { JoinRelation, PromiseDefaultCodec, QueryBuilderConfig } from './types';
2
- export declare class QueryBuilder {
3
- private _config;
4
- private _matchConditions;
5
- private _stages;
6
- private _relations;
7
- private _unsetFields;
8
- constructor(config: QueryBuilderConfig);
9
- /**
10
- * Generates the aggregation pipeline based on the current configuration of the QueryBuilder.
11
- * @returns
12
- */
13
- getAggregationPipeline(): any[];
14
- /**
15
- * Returns the current configuration of the QueryBuilder, including model, select fields, and any applied options.
16
- * @returns
17
- */
18
- getConfig(): QueryBuilderConfig;
19
- /**
20
- * Applies schema-based options such as joins and unset fields.
21
- */
22
- private _applyPathOptions;
23
- /**
24
- * Adds match conditions to the query builder.
25
- * @param match - The match conditions to add.
26
- * @param conjunction - The logical conjunction ('and' or 'or').
27
- * @param append - Whether to append to existing conditions or replace them.
28
- */
29
- match(match: Record<string, any> | Record<string, any>[], conjunction?: string, append?: boolean): void;
30
- /**
31
- * Adds aggregation stages to the query builder.
32
- * @param stages
33
- * @returns
34
- */
35
- stage(stages: any[] | {} | any): void;
36
- /**
37
- * Adds join relations to the query builder.
38
- * @param rels
39
- * @returns
40
- */
41
- join(rels: JoinRelation | JoinRelation[] | null): void;
42
- /**
43
- * Calculates the $lookup stage for a given JoinRelation.
44
- * @param relation
45
- * @returns
46
- */
47
- private _calculateJoin;
48
- /**
49
- * Automatically generates JoinRelation objects from schema refs.
50
- * @param model The Mongoose model to scan.
51
- * @param prefix Optional prefix for nested paths (e.g., 'alias.field').
52
- * @returns Array of JoinRelation objects.
53
- */
54
- private _generateSchemaJoins;
55
- /**
56
- * Generates the list of fields to unset based on schema select options.
57
- * @param config - The query request configuration.
58
- */
59
- private _generateSchemaUnsetList;
60
- /**
61
- * Collects paths from the schema where select is set to false.
62
- * @param schema - The Mongoose schema to scan.
63
- * @param prefix - Optional prefix for nested paths.
64
- * @param select - Optional array of fields to select.
65
- * @returns Array of paths to unset.
66
- */
67
- private _collectSelectFalse;
68
- /**
69
- * Generates the aggregation pipeline based on joins, stages, match conditions, and unset fields.
70
- * @returns The aggregation pipeline array.
71
- */
72
- private _generatePipeline;
73
- /**
74
- * Executes the aggregation pipeline and returns the results.
75
- * @param config - Parameters for the query execution.
76
- * @returns The collection response wrapped in a Codec.
77
- */
78
- exec<T = any>(config?: {
79
- isOne?: boolean;
80
- limit?: number;
81
- skip?: number;
82
- }): PromiseDefaultCodec;
83
- /**
84
- * Processes a single document from the aggregation result.
85
- * @param res - The aggregation result array.
86
- * @returns The processed document or null if none.
87
- */
88
- private _processSingleDocument;
89
- /**
90
- * Processes multiple documents from the aggregation result.
91
- * @param res - The aggregation result array.
92
- * @returns The array of processed documents.
93
- */
94
- private _processMultipleDocuments;
95
- }
96
- //# sourceMappingURL=query-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query-builder.d.ts","sourceRoot":"","sources":["../../src/core/query-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE5G,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,gBAAgB,CAA2B;IACnD,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,YAAY,CAAgB;gBAExB,MAAM,EAAE,kBAAkB;IAKtC;;;OAGG;IACI,sBAAsB,IAAI,GAAG,EAAE;IAItC;;;OAGG;IACI,SAAS,IAAI,kBAAkB;IAItC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAKzB;;;;;OAKG;IACH,KAAK,CACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAClD,WAAW,GAAE,MAAc,EAC3B,MAAM,GAAE,OAAc;IAiBxB;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG;IAS9B;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,EAAE,GAAG,IAAI;IAM/C;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAYtB;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAuC5B;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAWhC;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAuB3B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAmBzB;;;;OAIG;IACG,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,EAAE;QAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,mBAAmB;IA6BvB;;;;OAIG;YACW,sBAAsB;IAapC;;;;OAIG;YACW,yBAAyB;CAcxC"}
@@ -1,58 +0,0 @@
1
- import mongoose from 'mongoose';
2
- export interface DefaultResponseBody extends Record<string, any> {
3
- data?: any[] | any;
4
- meta?: {
5
- total?: number;
6
- };
7
- error?: string;
8
- }
9
- export declare class Codec<T = any> {
10
- content: T;
11
- returnCode: number;
12
- constructor(content: T, code?: number);
13
- sendToClient(res: any): void;
14
- is1xx(): boolean;
15
- is2xx(): boolean;
16
- is3xx(): boolean;
17
- is4xx(): boolean;
18
- }
19
- export type DefaultCodec = Codec<DefaultResponseBody>;
20
- export type PromiseDefaultCodec = Promise<Codec<DefaultResponseBody>>;
21
- export declare class JoinRelation<T = any> {
22
- ref: mongoose.Model<T>;
23
- localField: string;
24
- alias: string;
25
- constructor(localField: string, ref: mongoose.Model<T>, alias?: string | undefined);
26
- }
27
- export interface QueryBuilderConfig<T = any> {
28
- model: mongoose.Model<T>;
29
- select?: string[] | undefined;
30
- eachFunc?: (doc: any) => any;
31
- asyncEachFunc?: (doc: any) => Promise<any>;
32
- }
33
- export declare enum HttpMethod {
34
- POST = "post",
35
- GET = "get",
36
- DELETE = "delete",
37
- PUT = "put"
38
- }
39
- export interface HTTPRequestConfig {
40
- url: string;
41
- method?: HttpMethod;
42
- /**
43
- * Optional query parameters to be appended to the URL. They will be automatically URL-encoded. For example, { search: 'test', page: '1' } will result in ?search=test&page=1 being appended to the URL.
44
- */
45
- urlSearchParams?: Record<string, string>;
46
- /**
47
- * The body can be an object or a string. If it's an object, it will be automatically stringified as JSON and the Content-Type header will be set to application/json. If it's a string, it will be sent as-is and the Content-Type header will default to application/x-www-form-urlencoded unless explicitly set in the headers.
48
- */
49
- body?: any;
50
- /**
51
- * Optional headers to include in the request. If the body is an object and Content-Type is not explicitly set, it will default to application/json. If the body is a string and Content-Type is not explicitly set, it will default to application/x-www-form-urlencoded. You can override these defaults by providing your own Content-Type header.
52
- */
53
- headers?: Record<string, string>;
54
- }
55
- export type KeysEnum<T> = {
56
- [P in keyof Required<T>]: any;
57
- };
58
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,MAAM,WAAW,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAC9D,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IACnB,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,KAAK,CAAC,CAAC,GAAG,GAAG;IACxB,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,CAAC,EAAE,IAAI,GAAE,MAAY;IAK1C,YAAY,CAAC,GAAG,EAAE,GAAG;IAOrB,KAAK;IAGL,KAAK;IAGL,KAAK;IAGL,KAAK;CAGN;AA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AAC,CAAC,CAAC,GAAG,GAAG;CAAE,CAAC"}
@@ -1,4 +0,0 @@
1
- export declare const EXIT_CODE_SUCCESS = 0;
2
- export declare const EXIT_CODE_GENERAL_ERROR = 1;
3
- export declare const EXIT_CODE_INVALID_CONFIG = 2;
4
- //# sourceMappingURL=exitCodes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exitCodes.d.ts","sourceRoot":"","sources":["../src/exitCodes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,wBAAwB,IAAI,CAAC"}