@6thbridge/utils 1.9.0-1 → 1.9.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/lib/actions/database-session.action.d.ts +13 -0
- package/lib/actions/database-session.action.js +77 -0
- package/lib/actions/database-session.action.js.map +1 -0
- package/lib/actions/database-session.action.test.d.ts +1 -0
- package/lib/actions/database-session.action.test.js +137 -0
- package/lib/actions/database-session.action.test.js.map +1 -0
- package/lib/actions/index.d.ts +2 -0
- package/lib/actions/index.js +2 -0
- package/lib/actions/index.js.map +1 -1
- package/lib/actions/lock.action.d.ts +16 -0
- package/lib/actions/lock.action.js +171 -0
- package/lib/actions/lock.action.js.map +1 -0
- package/lib/actions/lock.action.test.d.ts +1 -0
- package/lib/actions/lock.action.test.js +63 -0
- package/lib/actions/lock.action.test.js.map +1 -0
- package/lib/data/rabbitmq/index.d.ts +3 -2
- package/lib/data/rabbitmq/index.js +3 -0
- package/lib/data/rabbitmq/index.js.map +1 -1
- package/lib/database/MongoDBRepository.d.ts +27 -120
- package/lib/database/MongoDBRepository.js +49 -41
- package/lib/database/MongoDBRepository.js.map +1 -1
- package/lib/database/MongoDBTypeRepository.d.ts +51 -0
- package/lib/database/MongoDBTypeRepository.js +90 -0
- package/lib/database/MongoDBTypeRepository.js.map +1 -0
- package/lib/database/index.d.ts +2 -0
- package/lib/database/index.js +4 -0
- package/lib/database/index.js.map +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +25 -16
- package/lib/index.js.map +1 -1
- package/lib/logger/batching.d.ts +7 -0
- package/lib/logger/batching.js +90 -0
- package/lib/logger/batching.js.map +1 -0
- package/lib/logger/batching.spec.d.ts +1 -0
- package/lib/logger/batching.spec.js +108 -0
- package/lib/logger/batching.spec.js.map +1 -0
- package/lib/logger/index.d.ts +1 -0
- package/lib/logger/index.js +5 -1
- package/lib/logger/index.js.map +1 -1
- package/lib/logger/logger-test.js +53 -24
- package/lib/logger/logger-test.js.map +1 -1
- package/lib/logger/logger.js +8 -23
- package/lib/logger/logger.js.map +1 -1
- package/lib/logger/redact.js +1 -1
- package/lib/logger/redact.js.map +1 -1
- package/lib/logger/test.spec.js +57 -0
- package/lib/logger/test.spec.js.map +1 -1
- package/lib/middlewares/common.js +7 -7
- package/lib/middlewares/common.js.map +1 -1
- package/lib/middlewares/error.middleware.d.ts +12 -0
- package/lib/middlewares/error.middleware.js +57 -0
- package/lib/middlewares/error.middleware.js.map +1 -0
- package/lib/middlewares/error.middleware.test.d.ts +1 -0
- package/lib/middlewares/error.middleware.test.js +45 -0
- package/lib/middlewares/error.middleware.test.js.map +1 -0
- package/lib/middlewares/express.js +19 -9
- package/lib/middlewares/express.js.map +1 -1
- package/lib/middlewares/index.js +17 -7
- package/lib/middlewares/index.js.map +1 -1
- package/lib/monitoring/index.js +3 -3
- package/lib/monitoring/index.js.map +1 -1
- package/lib/monitoring/rollbar.js +2 -2
- package/lib/monitoring/rollbar.js.map +1 -1
- package/lib/pipelines/index.d.ts +3 -0
- package/lib/pipelines/index.js +20 -0
- package/lib/pipelines/index.js.map +1 -0
- package/lib/pipelines/parallel-pipeline.d.ts +7 -0
- package/lib/pipelines/parallel-pipeline.js +49 -0
- package/lib/pipelines/parallel-pipeline.js.map +1 -0
- package/lib/pipelines/pipeline-step.d.ts +5 -0
- package/lib/pipelines/pipeline-step.js +3 -0
- package/lib/pipelines/pipeline-step.js.map +1 -0
- package/lib/pipelines/pipeline.example.d.ts +2 -0
- package/lib/pipelines/pipeline.example.js +96 -0
- package/lib/pipelines/pipeline.example.js.map +1 -0
- package/lib/pipelines/pipelines.test.d.ts +1 -0
- package/lib/pipelines/pipelines.test.js +204 -0
- package/lib/pipelines/pipelines.test.js.map +1 -0
- package/lib/pipelines/pipelines.typecheck.d.ts +1 -0
- package/lib/pipelines/pipelines.typecheck.js +68 -0
- package/lib/pipelines/pipelines.typecheck.js.map +1 -0
- package/lib/pipelines/serial-pipeline.d.ts +7 -0
- package/lib/pipelines/serial-pipeline.js +39 -0
- package/lib/pipelines/serial-pipeline.js.map +1 -0
- package/lib/responses/express.d.ts +1 -1
- package/lib/responses/express.js +4 -4
- package/lib/responses/express.js.map +1 -1
- package/lib/responses/index.js +17 -7
- package/lib/responses/index.js.map +1 -1
- package/lib/schemas/country.schema.d.ts +5 -0
- package/lib/schemas/country.schema.js +15 -0
- package/lib/schemas/country.schema.js.map +1 -0
- package/lib/schemas/index.d.ts +2 -0
- package/lib/schemas/index.js +21 -0
- package/lib/schemas/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/context.entity.js +17 -7
- package/lib/types/context.entity.js.map +1 -1
- package/lib/types/integrations/credential.entity.d.ts +1 -0
- package/lib/types/integrations/credential.entity.js +5 -0
- package/lib/types/integrations/credential.entity.js.map +1 -1
- package/lib/types/integrations/integration.entity.d.ts +5 -1
- package/lib/types/integrations/integration.entity.js +10 -1
- package/lib/types/integrations/integration.entity.js.map +1 -1
- package/lib/types/route.entity.d.ts +1 -1
- package/lib/utils/amount.js +0 -1
- package/lib/utils/amount.js.map +1 -1
- package/lib/utils/database.d.ts +2 -0
- package/lib/utils/database.js +35 -6
- package/lib/utils/database.js.map +1 -1
- package/lib/utils/database.spec.js +229 -185
- package/lib/utils/database.spec.js.map +1 -1
- package/lib/utils/file.d.ts +3 -2
- package/lib/utils/file.js.map +1 -1
- package/lib/utils/helper.d.ts +2 -0
- package/lib/utils/helper.js +20 -0
- package/lib/utils/helper.js.map +1 -1
- package/lib/utils/helper.spec.js +56 -0
- package/lib/utils/helper.spec.js.map +1 -1
- package/lib/utils/http.d.ts +3 -4
- package/lib/utils/http.js +68 -44
- package/lib/utils/http.js.map +1 -1
- package/lib/utils/http.spec.d.ts +1 -0
- package/lib/utils/http.spec.js +121 -0
- package/lib/utils/http.spec.js.map +1 -0
- package/lib/utils/phoneNumber.d.ts +2 -2
- package/lib/utils/phoneNumber.js +17 -7
- package/lib/utils/phoneNumber.js.map +1 -1
- package/lib/utils/phoneNumber.spec.js +20 -0
- package/lib/utils/phoneNumber.spec.js.map +1 -1
- package/lib/utils/validator.d.ts +3 -2
- package/lib/utils/validator.js +40 -14
- package/lib/utils/validator.js.map +1 -1
- package/lib/utils/validator.spec.js +130 -14
- package/lib/utils/validator.spec.js.map +1 -1
- package/package.json +30 -23
- package/readme.md +37 -2
|
@@ -1,126 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/// <reference types="mongoose/types/expressions" />
|
|
9
|
-
/// <reference types="mongoose/types/helpers" />
|
|
10
|
-
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
-
/// <reference types="mongoose/types/indexes" />
|
|
12
|
-
/// <reference types="mongoose/types/models" />
|
|
13
|
-
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
-
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
-
/// <reference types="mongoose/types/populate" />
|
|
16
|
-
/// <reference types="mongoose/types/query" />
|
|
17
|
-
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
-
/// <reference types="mongoose/types/session" />
|
|
19
|
-
/// <reference types="mongoose/types/types" />
|
|
20
|
-
/// <reference types="mongoose/types/utility" />
|
|
21
|
-
/// <reference types="mongoose/types/validation" />
|
|
22
|
-
/// <reference types="mongoose/types/virtuals" />
|
|
23
|
-
/// <reference types="mongoose/types/schematypes" />
|
|
24
|
-
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
/// <reference types="mongoose/types/inferhydrateddoctype" />
|
|
26
|
-
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
27
|
-
/// <reference types="mongoose-paginate-v2" />
|
|
28
|
-
import { CreateOptions, HydratedDocument, InsertManyOptions, Model, PaginateResult, ProjectionType, QueryFilter, QueryOptions, SortOrder, UpdateQuery, UpdateWithAggregationPipeline, Document } from 'mongoose';
|
|
29
|
-
type RepositoryDocument = Document;
|
|
30
|
-
type SortDefinition = Record<string, SortOrder>;
|
|
31
|
-
type FindOneAndUpdateOptions<TSchema extends RepositoryDocument> = NonNullable<Parameters<Model<TSchema>['findOneAndUpdate']>[2]> & {
|
|
32
|
-
new?: boolean;
|
|
33
|
-
};
|
|
34
|
-
type UpdateOneOptions<TSchema extends RepositoryDocument> = NonNullable<Parameters<Model<TSchema>['updateOne']>[2]>;
|
|
35
|
-
type UpdateManyOptions<TSchema extends RepositoryDocument> = NonNullable<Parameters<Model<TSchema>['updateMany']>[2]>;
|
|
36
|
-
type DeleteManyOptions<TSchema extends RepositoryDocument> = NonNullable<Parameters<Model<TSchema>['deleteMany']>[1]>;
|
|
37
|
-
type CountDocumentsOptions<TSchema extends RepositoryDocument> = NonNullable<Parameters<Model<TSchema>['countDocuments']>[1]>;
|
|
38
|
-
type BulkWritePayload<TSchema extends RepositoryDocument> = Parameters<Model<TSchema>['bulkWrite']>[0];
|
|
39
|
-
type BulkWriteOptions<TSchema extends RepositoryDocument> = Parameters<Model<TSchema>['bulkWrite']>[1];
|
|
40
|
-
export interface FindOptions<TSchema extends RepositoryDocument = RepositoryDocument> extends QueryOptions<TSchema> {
|
|
1
|
+
import { ClientSession, CreateOptions, InsertManyOptions, Model, PaginateModel, PaginateResult, ProjectionType, QueryOptions } from 'mongoose';
|
|
2
|
+
export declare class MongooseOptions {
|
|
3
|
+
session?: ClientSession | null;
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
}
|
|
6
|
+
export declare class FindOptions extends MongooseOptions {
|
|
7
|
+
[x: string]: any;
|
|
41
8
|
page?: number;
|
|
42
9
|
limit?: number;
|
|
43
10
|
lean?: boolean;
|
|
44
11
|
}
|
|
45
|
-
export type TypedModel<
|
|
46
|
-
export declare class MongoDBRepository
|
|
12
|
+
export type TypedModel<T> = PaginateModel<T> | Model<T>;
|
|
13
|
+
export declare class MongoDBRepository {
|
|
47
14
|
private readonly Model;
|
|
48
|
-
constructor(Model: TypedModel<
|
|
49
|
-
getModel(): TypedModel<
|
|
50
|
-
create(payload:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
} : never : never) | (import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
67
|
-
__v: number;
|
|
68
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>> extends infer T_1 ? T_1 extends import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
69
|
-
__v: number;
|
|
70
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>> ? T_1 extends null ? (T_1 extends infer T_2 ? T_2 extends T_1 ? T_2 extends any[] ? (import("mongoose").Require_id<TSchema> extends infer T_3 ? T_3 extends import("mongoose").Require_id<TSchema> ? T_3 extends {
|
|
71
|
-
__v?: infer U | undefined;
|
|
72
|
-
} ? T_3 : T_3 & {
|
|
73
|
-
__v: number;
|
|
74
|
-
} : never : never)[] : import("mongoose").Require_id<TSchema> extends infer T_4 ? T_4 extends import("mongoose").Require_id<TSchema> ? T_4 extends {
|
|
75
|
-
__v?: infer U | undefined;
|
|
76
|
-
} ? T_4 : T_4 & {
|
|
77
|
-
__v: number;
|
|
78
|
-
} : never : never : never : never) | null : T_1 extends any[] ? (import("mongoose").Require_id<TSchema> extends infer T_5 ? T_5 extends import("mongoose").Require_id<TSchema> ? T_5 extends {
|
|
79
|
-
__v?: infer U | undefined;
|
|
80
|
-
} ? T_5 : T_5 & {
|
|
81
|
-
__v: number;
|
|
82
|
-
} : never : never)[] : import("mongoose").Require_id<TSchema> extends infer T_6 ? T_6 extends import("mongoose").Require_id<TSchema> ? T_6 extends {
|
|
83
|
-
__v?: infer U | undefined;
|
|
84
|
-
} ? T_6 : T_6 & {
|
|
85
|
-
__v: number;
|
|
86
|
-
} : never : never : never : never) | null, import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
87
|
-
__v: number;
|
|
88
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>>, {}, TSchema, "findOne", {}>;
|
|
89
|
-
find(condition?: QueryFilter<TSchema>, sort?: SortDefinition, options?: FindOptions<TSchema>): import("mongoose").Query<import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
90
|
-
__v: number;
|
|
91
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>>[], import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
92
|
-
__v: number;
|
|
93
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>>, {}, TSchema, "find", {}> | import("mongoose").Query<(import("mongoose").Require_id<TSchema> extends infer T ? T extends import("mongoose").Require_id<TSchema> ? T extends {
|
|
94
|
-
__v?: infer U | undefined;
|
|
95
|
-
} ? T : T & {
|
|
96
|
-
__v: number;
|
|
97
|
-
} : never : never)[], import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
98
|
-
__v: number;
|
|
99
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>>, {}, TSchema, "find", {}>;
|
|
100
|
-
paginate(condition?: QueryFilter<TSchema>, sort?: SortDefinition, options?: FindOptions<TSchema>): Promise<PaginateResult<HydratedDocument<TSchema>>>;
|
|
101
|
-
deleteMany(condition?: QueryFilter<TSchema>, options?: DeleteManyOptions<TSchema>): import("mongoose").Query<import("mongodb").DeleteResult, import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
102
|
-
__v: number;
|
|
103
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>>, {}, TSchema, "deleteMany", {}>;
|
|
104
|
-
insertMany(data?: Array<TSchema>, options?: InsertManyOptions): Promise<import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
105
|
-
__v: number;
|
|
106
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>>[]>;
|
|
107
|
-
countDocuments(condition?: QueryFilter<TSchema>, options?: CountDocumentsOptions<TSchema>): import("mongoose").Query<number, import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
108
|
-
__v: number;
|
|
109
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>>, {}, TSchema, "countDocuments", {}>;
|
|
110
|
-
updateOne(query?: QueryFilter<TSchema>, update?: UpdateQuery<TSchema> | UpdateWithAggregationPipeline, options?: UpdateOneOptions<TSchema>): import("mongoose").Query<import("mongoose").UpdateWriteOpResult, import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
111
|
-
__v: number;
|
|
112
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>>, {}, TSchema, "updateOne", {}>;
|
|
113
|
-
updateMany(query?: QueryFilter<TSchema>, update?: UpdateQuery<TSchema> | UpdateWithAggregationPipeline, options?: UpdateManyOptions<TSchema>): import("mongoose").Query<import("mongoose").UpdateWriteOpResult, import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
114
|
-
__v: number;
|
|
115
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>>, {}, TSchema, "updateMany", {}>;
|
|
116
|
-
upsert(query?: QueryFilter<TSchema>, update?: UpdateQuery<TSchema> | UpdateWithAggregationPipeline, options?: UpdateOneOptions<TSchema>): import("mongoose").Query<import("mongoose").UpdateWriteOpResult, import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
117
|
-
__v: number;
|
|
118
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>>, {}, TSchema, "updateOne", {}>;
|
|
119
|
-
findOneAndUpdate(filter: QueryFilter<TSchema>, update: UpdateQuery<TSchema> | UpdateWithAggregationPipeline, options?: FindOneAndUpdateOptions<TSchema>): import("mongoose").Query<import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
120
|
-
__v: number;
|
|
121
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>> | null, import("mongoose").IfAny<TSchema, any, Document<unknown, {}, TSchema, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<TSchema> & {
|
|
122
|
-
__v: number;
|
|
123
|
-
} & import("mongoose").AddDefaultId<TSchema, {}, import("mongoose").DefaultSchemaOptions>>, {}, TSchema, "findOneAndUpdate", {}>;
|
|
124
|
-
bulkWrite(bulkWritePayload: BulkWritePayload<TSchema>, options?: BulkWriteOptions<TSchema>): Promise<import("mongodb").BulkWriteResult>;
|
|
15
|
+
constructor(Model: TypedModel<any>);
|
|
16
|
+
getModel(): TypedModel<any>;
|
|
17
|
+
create(payload: Record<string, any>, options?: CreateOptions): Promise<any>;
|
|
18
|
+
findById(id: string, projection?: ProjectionType<any>, options?: QueryOptions): import("mongoose").Query<any, any, {}, any, "findOne", {}>;
|
|
19
|
+
findOne(condition?: Record<string, any>, sort?: Record<string, number>, options?: FindOptions): import("mongoose").Query<any, any, {}, any, "findOne", {}>;
|
|
20
|
+
find(condition: Record<string, any>, sort?: Record<string, any>, options?: FindOptions): import("mongoose").Query<any[], any, {}, any, "find", {}>;
|
|
21
|
+
paginate(condition: Record<string, any>, sort?: Record<string, any>, options?: FindOptions): Promise<PaginateResult<any>>;
|
|
22
|
+
deleteMany(condition?: Record<string, any>, options?: MongooseOptions): import("mongoose").Query<import("mongodb").DeleteResult, any, {}, any, "deleteMany", {}>;
|
|
23
|
+
insertMany(data: any[] | undefined, options: InsertManyOptions & {
|
|
24
|
+
lean: true;
|
|
25
|
+
}): never[] | Promise<any[]>;
|
|
26
|
+
countDocuments(condition?: Record<string, any>, options?: MongooseOptions): import("mongoose").Query<number, any, {}, any, "countDocuments", {}>;
|
|
27
|
+
updateOne(query?: Record<string, any>, update?: Record<string, any>, options?: MongooseOptions): import("mongoose").Query<import("mongoose").UpdateWriteOpResult, any, {}, any, "updateOne", {}>;
|
|
28
|
+
updateMany(query?: Record<string, any>, update?: Record<string, any>, options?: MongooseOptions): import("mongoose").Query<import("mongoose").UpdateWriteOpResult, any, {}, any, "updateMany", {}>;
|
|
29
|
+
upsert(query?: Record<string, any>, update?: any, options?: MongooseOptions): import("mongoose").Query<import("mongoose").UpdateWriteOpResult, any, {}, any, "updateOne", {}>;
|
|
30
|
+
findOneAndUpdate(filter: any, update: any, options?: MongooseOptions): import("mongoose").Query<any, any, {}, any, "findOneAndUpdate", {}>;
|
|
31
|
+
bulkWrite(bulkWritePayload: any): any;
|
|
32
|
+
deleteOne(query: Record<string, any>): import("mongoose").Query<import("mongodb").DeleteResult, any, {}, any, "deleteOne", {}>;
|
|
125
33
|
}
|
|
126
|
-
export {};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.MongoDBRepository = void 0;
|
|
3
|
+
exports.MongoDBRepository = exports.FindOptions = exports.MongooseOptions = void 0;
|
|
4
|
+
class MongooseOptions {
|
|
5
|
+
}
|
|
6
|
+
exports.MongooseOptions = MongooseOptions;
|
|
7
|
+
class FindOptions extends MongooseOptions {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.limit = 100;
|
|
11
|
+
this.lean = false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.FindOptions = FindOptions;
|
|
15
15
|
class MongoDBRepository {
|
|
16
16
|
constructor(Model) {
|
|
17
17
|
this.Model = Model;
|
|
@@ -20,60 +20,68 @@ class MongoDBRepository {
|
|
|
20
20
|
return this.Model;
|
|
21
21
|
}
|
|
22
22
|
create(payload, options) {
|
|
23
|
-
return this.Model.create(payload);
|
|
23
|
+
return this.Model.create(payload, options);
|
|
24
24
|
}
|
|
25
25
|
findById(id, projection, options) {
|
|
26
|
-
return this.Model.
|
|
26
|
+
return this.Model.findOne({ _id: id }, projection, options);
|
|
27
27
|
}
|
|
28
28
|
findOne(condition = {}, sort, options) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
if (lean)
|
|
32
|
-
return result.lean();
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
find(condition = {}, sort, options) {
|
|
36
|
-
const _a = options !== null && options !== void 0 ? options : {}, { lean, page: _page, limit: _limit } = _a, queryOptions = __rest(_a, ["lean", "page", "limit"]);
|
|
37
|
-
const result = this.Model.find(condition, undefined, queryOptions).sort(sort);
|
|
38
|
-
if (lean)
|
|
29
|
+
const result = this.Model.findOne(condition).sort(sort);
|
|
30
|
+
if (options === null || options === void 0 ? void 0 : options.lean)
|
|
39
31
|
return result.lean();
|
|
40
32
|
return result;
|
|
41
33
|
}
|
|
42
|
-
|
|
43
|
-
return this.Model.
|
|
34
|
+
find(condition, sort, options) {
|
|
35
|
+
return this.Model.find(condition, options === null || options === void 0 ? void 0 : options.populate, {
|
|
36
|
+
lean: options === null || options === void 0 ? void 0 : options.lean,
|
|
44
37
|
sort,
|
|
45
|
-
page: options === null || options === void 0 ? void 0 : options.page,
|
|
46
|
-
limit: options === null || options === void 0 ? void 0 : options.limit,
|
|
47
38
|
});
|
|
48
39
|
}
|
|
40
|
+
paginate(condition, sort, options) {
|
|
41
|
+
return this.Model.paginate(condition, Object.assign(Object.assign({}, options), { sort }));
|
|
42
|
+
}
|
|
49
43
|
deleteMany(condition = {}, options) {
|
|
50
|
-
|
|
44
|
+
var _a;
|
|
45
|
+
return this.Model.deleteMany(condition).session((_a = options === null || options === void 0 ? void 0 : options.session) !== null && _a !== void 0 ? _a : null);
|
|
51
46
|
}
|
|
52
47
|
insertMany(data = [], options) {
|
|
53
48
|
if (data.length === 0)
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
return this.Model.insertMany(data, options);
|
|
57
|
-
return this.Model.insertMany(data);
|
|
49
|
+
return [];
|
|
50
|
+
return this.Model.insertMany(data, options);
|
|
58
51
|
}
|
|
59
52
|
countDocuments(condition = {}, options) {
|
|
60
|
-
|
|
53
|
+
var _a;
|
|
54
|
+
return this.Model.countDocuments(condition).session((_a = options === null || options === void 0 ? void 0 : options.session) !== null && _a !== void 0 ? _a : null);
|
|
61
55
|
}
|
|
62
56
|
updateOne(query = {}, update = {}, options) {
|
|
63
|
-
|
|
57
|
+
var _a;
|
|
58
|
+
return this.Model.updateOne(query, update).session((_a = options === null || options === void 0 ? void 0 : options.session) !== null && _a !== void 0 ? _a : null);
|
|
64
59
|
}
|
|
65
60
|
updateMany(query = {}, update = {}, options) {
|
|
66
|
-
|
|
61
|
+
var _a;
|
|
62
|
+
return this.Model.updateMany(query, update).session((_a = options === null || options === void 0 ? void 0 : options.session) !== null && _a !== void 0 ? _a : null);
|
|
67
63
|
}
|
|
68
64
|
upsert(query = {}, update = {}, options) {
|
|
69
|
-
|
|
65
|
+
var _a;
|
|
66
|
+
return this.Model.updateOne(query, update, {
|
|
67
|
+
upsert: true,
|
|
68
|
+
setDefaultsOnInsert: true,
|
|
69
|
+
}).session((_a = options === null || options === void 0 ? void 0 : options.session) !== null && _a !== void 0 ? _a : null);
|
|
70
70
|
}
|
|
71
71
|
findOneAndUpdate(filter, update, options) {
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
var _a;
|
|
73
|
+
if (options === null || options === void 0 ? void 0 : options.new) {
|
|
74
|
+
options.returnDocument = "after";
|
|
75
|
+
delete options.new;
|
|
76
|
+
}
|
|
77
|
+
return this.Model.findOneAndUpdate(filter, update, Object.assign({ returnDocument: "after" }, options)).session((_a = options === null || options === void 0 ? void 0 : options.session) !== null && _a !== void 0 ? _a : null);
|
|
78
|
+
}
|
|
79
|
+
bulkWrite(bulkWritePayload) {
|
|
80
|
+
//@ts-ignore
|
|
81
|
+
return this.Model.bulkWrite(bulkWritePayload);
|
|
74
82
|
}
|
|
75
|
-
|
|
76
|
-
return this.Model.
|
|
83
|
+
deleteOne(query) {
|
|
84
|
+
return this.Model.deleteOne(query);
|
|
77
85
|
}
|
|
78
86
|
}
|
|
79
87
|
exports.MongoDBRepository = MongoDBRepository;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongoDBRepository.js","sourceRoot":"","sources":["../../src/database/MongoDBRepository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MongoDBRepository.js","sourceRoot":"","sources":["../../src/database/MongoDBRepository.ts"],"names":[],"mappings":";;;AAWA,MAAa,eAAe;CAG3B;AAHD,0CAGC;AAGD,MAAa,WAAY,SAAQ,eAAe;IAAhD;;QAIE,UAAK,GAAY,GAAG,CAAC;QACrB,SAAI,GAAa,KAAK,CAAC;IACzB,CAAC;CAAA;AAND,kCAMC;AAKD,MAAa,iBAAiB;IAC5B,YAA6B,KAAsB;QAAtB,UAAK,GAAL,KAAK,CAAiB;IACnD,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,OAA4B,EAAE,OAAuB;QAC1D,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAc,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,QAAQ,CAAC,EAAU,EAAE,UAAgC,EAAE,OAAsB;QAC3E,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,CAAC,YAAiC,EAAE,EAAE,IAA6B,EAAE,OAAqB;QAC/F,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAW,CAAC,CAAC;QAC/D,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI;YAAE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;QAExC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,CAAC,SAA8B,EAAE,IAA0B,EAAE,OAAqB;QACpF,OAAO,IA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
import { ClientSession, CreateOptions, ProjectionType, QueryOptions, PaginateResult, PaginateModel, Document, Model, InsertManyOptions, QueryFilter, UpdateQuery, Query, SortOrder } from 'mongoose';
|
|
2
|
+
declare class MongooseOptions {
|
|
3
|
+
session?: ClientSession | null;
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
}
|
|
6
|
+
declare class FindOptions extends MongooseOptions {
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
page?: number;
|
|
9
|
+
limit?: number;
|
|
10
|
+
lean?: boolean;
|
|
11
|
+
}
|
|
12
|
+
type TypedModel<T> = PaginateModel<T> | Model<T>;
|
|
13
|
+
export type EntityDoc<T> = Omit<Document, 'toObject' | 'toJSON'> & T & {
|
|
14
|
+
toObject: () => T;
|
|
15
|
+
toJSON: () => T;
|
|
16
|
+
};
|
|
17
|
+
export declare class MongoDBTypedRepository<T = any> {
|
|
18
|
+
private readonly Model;
|
|
19
|
+
constructor(Model: TypedModel<T>);
|
|
20
|
+
getModel(): TypedModel<T>;
|
|
21
|
+
create(payload: Partial<T>, options?: CreateOptions): Promise<EntityDoc<T>>;
|
|
22
|
+
findById(id: string, projection?: ProjectionType<any>, options?: QueryOptions): Promise<EntityDoc<T> | null>;
|
|
23
|
+
findOne(condition?: QueryFilter<T>, sort?: Record<string, number>, options?: FindOptions): Promise<EntityDoc<T> | null>;
|
|
24
|
+
findOneLean(condition?: QueryFilter<T>, sort?: Record<string, number>, options?: FindOptions): Promise<T | null>;
|
|
25
|
+
find(condition: QueryFilter<T>, sort?: Record<string, SortOrder>, options?: FindOptions): Promise<EntityDoc<T>[]>;
|
|
26
|
+
findLean(condition: QueryFilter<T>, sort?: Record<string, SortOrder>, options?: FindOptions): Promise<T[]>;
|
|
27
|
+
paginate(condition: QueryFilter<T>, sort?: Record<string, SortOrder>, options?: FindOptions): Promise<PaginateResult<T>>;
|
|
28
|
+
deleteMany(condition?: QueryFilter<T>, options?: MongooseOptions): Query<import("mongodb").DeleteResult, import("mongoose").IfAny<T, any, Document<unknown, {}, T, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<T> & {
|
|
29
|
+
__v: number;
|
|
30
|
+
} & import("mongoose").AddDefaultId<T, {}, import("mongoose").DefaultSchemaOptions>>, {}, T, "deleteMany", {}>;
|
|
31
|
+
insertMany(data: any[] | undefined, options: InsertManyOptions & {
|
|
32
|
+
lean: true;
|
|
33
|
+
}): Promise<EntityDoc<T>[]>;
|
|
34
|
+
countDocuments(condition?: QueryFilter<T>, options?: MongooseOptions): Promise<number>;
|
|
35
|
+
updateOne(query?: QueryFilter<T>, update?: UpdateQuery<T>, options?: MongooseOptions): Query<import("mongoose").UpdateWriteOpResult, import("mongoose").IfAny<T, any, Document<unknown, {}, T, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<T> & {
|
|
36
|
+
__v: number;
|
|
37
|
+
} & import("mongoose").AddDefaultId<T, {}, import("mongoose").DefaultSchemaOptions>>, {}, T, "updateOne", {}>;
|
|
38
|
+
updateMany(query?: QueryFilter<T>, update?: UpdateQuery<T>, options?: MongooseOptions): Query<import("mongoose").UpdateWriteOpResult, import("mongoose").IfAny<T, any, Document<unknown, {}, T, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<T> & {
|
|
39
|
+
__v: number;
|
|
40
|
+
} & import("mongoose").AddDefaultId<T, {}, import("mongoose").DefaultSchemaOptions>>, {}, T, "updateMany", {}>;
|
|
41
|
+
upsert(query?: QueryFilter<T>, update?: UpdateQuery<T>, options?: MongooseOptions): Query<import("mongoose").UpdateWriteOpResult, import("mongoose").IfAny<T, any, Document<unknown, {}, T, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<T> & {
|
|
42
|
+
__v: number;
|
|
43
|
+
} & import("mongoose").AddDefaultId<T, {}, import("mongoose").DefaultSchemaOptions>>, {}, T, "updateOne", {}>;
|
|
44
|
+
findOneAndUpdate(filter: QueryFilter<T>, update: UpdateQuery<T>, options?: MongooseOptions): Query<import("mongoose").IfAny<T, any, Document<unknown, {}, T, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<T> & {
|
|
45
|
+
__v: number;
|
|
46
|
+
} & import("mongoose").AddDefaultId<T, {}, import("mongoose").DefaultSchemaOptions>> | null, import("mongoose").IfAny<T, any, Document<unknown, {}, T, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<T> & {
|
|
47
|
+
__v: number;
|
|
48
|
+
} & import("mongoose").AddDefaultId<T, {}, import("mongoose").DefaultSchemaOptions>>, {}, T, "findOneAndUpdate", {}>;
|
|
49
|
+
bulkWrite(bulkWritePayload: any): any;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongoDBTypedRepository = void 0;
|
|
4
|
+
class MongooseOptions {
|
|
5
|
+
}
|
|
6
|
+
class FindOptions extends MongooseOptions {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.limit = 100;
|
|
10
|
+
this.lean = false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
class MongoDBTypedRepository {
|
|
14
|
+
constructor(Model) {
|
|
15
|
+
this.Model = Model;
|
|
16
|
+
}
|
|
17
|
+
getModel() {
|
|
18
|
+
return this.Model;
|
|
19
|
+
}
|
|
20
|
+
create(payload, options) {
|
|
21
|
+
return this.Model.create(payload, options);
|
|
22
|
+
}
|
|
23
|
+
findById(id, projection, options) {
|
|
24
|
+
return this.Model.findOne({ _id: id }, projection, options);
|
|
25
|
+
}
|
|
26
|
+
findOne(condition = {}, sort, options) {
|
|
27
|
+
return this.Model.findOne(condition).sort(sort);
|
|
28
|
+
}
|
|
29
|
+
findOneLean(condition = {}, sort, options) {
|
|
30
|
+
return this.Model.findOne(condition).sort(sort).lean();
|
|
31
|
+
}
|
|
32
|
+
find(condition, sort, options) {
|
|
33
|
+
const query = this.Model.find(condition).sort(sort);
|
|
34
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) !== undefined) {
|
|
35
|
+
query.limit(options.limit);
|
|
36
|
+
}
|
|
37
|
+
if (options === null || options === void 0 ? void 0 : options.session) {
|
|
38
|
+
query.session(options.session);
|
|
39
|
+
}
|
|
40
|
+
return query;
|
|
41
|
+
}
|
|
42
|
+
findLean(condition, sort, options) {
|
|
43
|
+
return this.find(condition, sort, options).lean();
|
|
44
|
+
}
|
|
45
|
+
paginate(condition, sort, options) {
|
|
46
|
+
return this.Model.paginate(condition, Object.assign(Object.assign({}, options), { sort }));
|
|
47
|
+
}
|
|
48
|
+
deleteMany(condition = {}, options) {
|
|
49
|
+
var _a;
|
|
50
|
+
return this.Model.deleteMany(condition).session((_a = options === null || options === void 0 ? void 0 : options.session) !== null && _a !== void 0 ? _a : null);
|
|
51
|
+
}
|
|
52
|
+
insertMany(data = [], options) {
|
|
53
|
+
if (data.length === 0)
|
|
54
|
+
return Promise.resolve([]);
|
|
55
|
+
return this.Model.insertMany(data, options);
|
|
56
|
+
}
|
|
57
|
+
countDocuments(condition = {}, options) {
|
|
58
|
+
var _a;
|
|
59
|
+
return this.Model.countDocuments(condition).session((_a = options === null || options === void 0 ? void 0 : options.session) !== null && _a !== void 0 ? _a : null);
|
|
60
|
+
}
|
|
61
|
+
updateOne(query = {}, update = {}, options) {
|
|
62
|
+
var _a;
|
|
63
|
+
return this.Model.updateOne(query, update).session((_a = options === null || options === void 0 ? void 0 : options.session) !== null && _a !== void 0 ? _a : null);
|
|
64
|
+
}
|
|
65
|
+
updateMany(query = {}, update = {}, options) {
|
|
66
|
+
var _a;
|
|
67
|
+
return this.Model.updateMany(query, update).session((_a = options === null || options === void 0 ? void 0 : options.session) !== null && _a !== void 0 ? _a : null);
|
|
68
|
+
}
|
|
69
|
+
upsert(query = {}, update = {}, options) {
|
|
70
|
+
var _a;
|
|
71
|
+
return this.Model.updateOne(query, update, {
|
|
72
|
+
upsert: true,
|
|
73
|
+
setDefaultsOnInsert: true,
|
|
74
|
+
}).session((_a = options === null || options === void 0 ? void 0 : options.session) !== null && _a !== void 0 ? _a : null);
|
|
75
|
+
}
|
|
76
|
+
findOneAndUpdate(filter, update, options) {
|
|
77
|
+
var _a;
|
|
78
|
+
if (options === null || options === void 0 ? void 0 : options.new) {
|
|
79
|
+
options.returnDocument = "after";
|
|
80
|
+
delete options.new;
|
|
81
|
+
}
|
|
82
|
+
return this.Model.findOneAndUpdate(filter, update, Object.assign({ returnDocument: "after" }, options)).session((_a = options === null || options === void 0 ? void 0 : options.session) !== null && _a !== void 0 ? _a : null);
|
|
83
|
+
}
|
|
84
|
+
bulkWrite(bulkWritePayload) {
|
|
85
|
+
//@ts-ignore
|
|
86
|
+
return this.Model.bulkWrite(bulkWritePayload);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.MongoDBTypedRepository = MongoDBTypedRepository;
|
|
90
|
+
//# sourceMappingURL=MongoDBTypeRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MongoDBTypeRepository.js","sourceRoot":"","sources":["../../src/database/MongoDBTypeRepository.ts"],"names":[],"mappings":";;;AAWA,MAAM,eAAe;CAGpB;AAGD,MAAM,WAAY,SAAQ,eAAe;IAAzC;;QAIE,UAAK,GAAY,GAAG,CAAC;QACrB,SAAI,GAAa,KAAK,CAAC;IACzB,CAAC;CAAA;AASD,MAAa,sBAAsB;IACjC,YAA6B,KAAoB;QAApB,UAAK,GAAL,KAAK,CAAe;IACjD,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,OAAmB,EAAE,OAAuB;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAc,EAAE,OAAO,CAA2B,CAAC;IAC9E,CAAC;IAED,QAAQ,CAAC,EAAU,EAAE,UAAgC,EAAE,OAAsB;QAC3E,OAAO,IAAI,CAAC,KAAK,CAA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AO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE;YACzC,MAAM,EAAE,IAAI;YACZ,mBAAmB,EAAE,IAAI;SAC1B,CAAC,CAAC,OAAO,CAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,mCAAI,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,gBAAgB,CAAC,MAAsB,EAAE,MAAsB,EAAE,OAAyB;;QACxF,IAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,EAAC,CAAC;YACf,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC;YACjC,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,kBAC/C,cAAc,EAAE,OAAO,IACpB,OAAO,EACV,CAAC,OAAO,CAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,mCAAI,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,SAAS,CAAC,gBAAqB;QAC7B,YAAY;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAChD,CAAC;CACF;AA9FD,wDA8FC"}
|
package/lib/database/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import mongoosePaginate from 'mongoose-paginate-v2';
|
|
2
2
|
export { mongoosePaginate };
|
|
3
3
|
export * from "./MongoDBRepository";
|
|
4
|
+
export * from "./MongoDBTypeRepository";
|
|
4
5
|
export declare class MongoDB {
|
|
5
6
|
_id?: string;
|
|
6
7
|
id?: string;
|
|
7
8
|
updatedAt?: Date;
|
|
8
9
|
createdAt?: Date;
|
|
9
10
|
toJSON?: () => any;
|
|
11
|
+
static getId(entity: MongoDB): string | undefined;
|
|
10
12
|
}
|
package/lib/database/index.js
CHANGED
|
@@ -21,7 +21,11 @@ exports.MongoDB = exports.mongoosePaginate = void 0;
|
|
|
21
21
|
const mongoose_paginate_v2_1 = __importDefault(require("mongoose-paginate-v2"));
|
|
22
22
|
exports.mongoosePaginate = mongoose_paginate_v2_1.default;
|
|
23
23
|
__exportStar(require("./MongoDBRepository"), exports);
|
|
24
|
+
__exportStar(require("./MongoDBTypeRepository"), exports);
|
|
24
25
|
class MongoDB {
|
|
26
|
+
static getId(entity) {
|
|
27
|
+
return entity._id || entity.id;
|
|
28
|
+
}
|
|
25
29
|
}
|
|
26
30
|
exports.MongoDB = MongoDB;
|
|
27
31
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,gFAAoD;AAC3C,2BADF,8BAAgB,CACE;AACzB,sDAAoC;AACpC,MAAa,OAAO;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,gFAAoD;AAC3C,2BADF,8BAAgB,CACE;AACzB,sDAAoC;AACpC,0DAAwC;AACxC,MAAa,OAAO;IAQT,MAAM,CAAC,KAAK,CAAC,MAAe;QAC/B,OAAO,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC;IACnC,CAAC;CACJ;AAXD,0BAWC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
1
2
|
import { logger, LoggerInterface } from './logger';
|
|
2
3
|
import * as middlewares from './middlewares';
|
|
3
4
|
export * as responses from './responses';
|
|
@@ -7,8 +8,10 @@ export * from './types/custom.exception';
|
|
|
7
8
|
export * from './types';
|
|
8
9
|
export * from './data';
|
|
9
10
|
export * from './database';
|
|
11
|
+
export * from './schemas';
|
|
10
12
|
export * from './utils';
|
|
11
13
|
export * from './actions';
|
|
14
|
+
export * from './pipelines';
|
|
12
15
|
export * from './logger';
|
|
13
16
|
declare module "axios" {
|
|
14
17
|
interface AxiosRequestConfig {
|
|
@@ -16,4 +19,4 @@ declare module "axios" {
|
|
|
16
19
|
logger?: LoggerInterface;
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
|
-
export { logger, middlewares, };
|
|
22
|
+
export { logger, middlewares, BigNumber };
|
package/lib/index.js
CHANGED
|
@@ -15,18 +15,33 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
37
|
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
28
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.middlewares = exports.logger = exports.responses = void 0;
|
|
42
|
+
exports.BigNumber = exports.middlewares = exports.logger = exports.responses = void 0;
|
|
43
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
44
|
+
exports.BigNumber = bignumber_js_1.default;
|
|
30
45
|
const logger_1 = require("./logger");
|
|
31
46
|
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.logger; } });
|
|
32
47
|
const middlewares = __importStar(require("./middlewares"));
|
|
@@ -38,8 +53,10 @@ __exportStar(require("./types/custom.exception"), exports);
|
|
|
38
53
|
__exportStar(require("./types"), exports);
|
|
39
54
|
__exportStar(require("./data"), exports);
|
|
40
55
|
__exportStar(require("./database"), exports);
|
|
56
|
+
__exportStar(require("./schemas"), exports);
|
|
41
57
|
__exportStar(require("./utils"), exports);
|
|
42
58
|
__exportStar(require("./actions"), exports);
|
|
59
|
+
__exportStar(require("./pipelines"), exports);
|
|
43
60
|
__exportStar(require("./logger"), exports);
|
|
44
61
|
process.on('uncaughtException', (err) => {
|
|
45
62
|
logger_1.logger.critical('uncaughtException: ' + err.message, {}, err.stack);
|
|
@@ -78,12 +95,4 @@ process.on('warning', (warning) => {
|
|
|
78
95
|
name: warning.name, stack: warning.stack,
|
|
79
96
|
});
|
|
80
97
|
});
|
|
81
|
-
process.on('SIGTERM', (signal) => {
|
|
82
|
-
logger_1.logger.warn(`SIGTERM: ${process.env.APP_NAME || signal} is shutting down`, {
|
|
83
|
-
name: signal.name,
|
|
84
|
-
});
|
|
85
|
-
setTimeout(() => {
|
|
86
|
-
process.exit(1); //mandatory (as per the Node.js docs)
|
|
87
|
-
}, 5000);
|
|
88
|
-
});
|
|
89
98
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":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AAE,OAAO,CAAC,KAAK;KACzC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function configureLogBatching(options: {
|
|
2
|
+
batchSize?: number;
|
|
3
|
+
flushIntervalMs?: number;
|
|
4
|
+
}): void;
|
|
5
|
+
export declare function enqueueLog(payload: Record<string, any>): void;
|
|
6
|
+
export declare function flushLogs(): Promise<void>;
|
|
7
|
+
export declare function registerLoggingShutdown(): void;
|